Skip to content

Commit

Permalink
Merge pull request #1770 from skalenetwork/bug/1640-slow-catchup
Browse files Browse the repository at this point in the history
Bug/1640 slow catchup
  • Loading branch information
olehnikolaiev authored Jan 11, 2024
2 parents 026d174 + 89fb0a0 commit bba2a8a
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
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;
};

0 comments on commit bba2a8a

Please sign in to comment.