Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug/1640 slow catchup #1770

Merged
merged 10 commits into from
Jan 11, 2024
9 changes: 9 additions & 0 deletions libethereum/SkaleHost.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ using namespace dev::eth;
#define CONSENSUS 1
#endif

const int SkaleHost::REJECT_OLD_TRANSACTION_THROUGH_BROADCAST_INTERVAL_SEC = 600;

std::unique_ptr< ConsensusInterface > DefaultConsensusFactory::create(
ConsensusExtFace& _extFace ) const {
#if CONSENSUS
Expand Down Expand Up @@ -325,6 +327,13 @@ void SkaleHost::logState() {
}

h256 SkaleHost::receiveTransaction( std::string _rlp ) {
// drop incoming transactions if skaled has an outdated state
if ( m_client.bc().info().timestamp() + REJECT_OLD_TRANSACTION_THROUGH_BROADCAST_INTERVAL_SEC <
std::time( NULL ) ) {
LOG( m_debugLogger ) << "Dropped the transaction received through broadcast";
return h256();
}

Transaction transaction( jsToBytes( _rlp, OnFailed::Throw ), CheckTransaction::None );

h256 sha = transaction.sha3();
Expand Down
4 changes: 4 additions & 0 deletions libethereum/SkaleHost.h
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,8 @@ class SkaleHost {
std::atomic_int total_sent, total_arrived;

boost::chrono::high_resolution_clock::time_point latestBlockTime;

// reject old transactions that come through broadcast
// if current ts is much bigger than currentBlock.ts
static const int REJECT_OLD_TRANSACTION_THROUGH_BROADCAST_INTERVAL_SEC;
};
Loading