Skip to content

Commit

Permalink
Consensus: fix history sync while processing received BatchSetInfo
Browse files Browse the repository at this point in the history
Fixes #3206
  • Loading branch information
Eligioo authored and jsdanielh committed Jan 10, 2025
1 parent 0c6d859 commit 7c82820
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions consensus/src/sync/history/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -366,9 +366,15 @@ impl<TNetwork: Network + 'static> SyncCluster<TNetwork> {
let current_epoch_number = blockchain.epoch_number();
let num_known_txs = if epoch_number == current_epoch_number {
let last_macro_block = Policy::last_macro_block(current_block_number);
blockchain
.history_store
.num_epoch_transactions_before(last_macro_block, None) as u64
// Check if the last_macro_block crosses an epoch boundary. This could happen if locally the node is in the first batch of an epoch.
// In this case, the number of known transactions must be 0 to avoid fetching the number of epoch transactions from the previous epoch.
if Policy::is_election_block_at(last_macro_block) {
0
} else {
blockchain
.history_store
.num_epoch_transactions_before(last_macro_block, None) as u64
}
} else {
0
};
Expand Down

0 comments on commit 7c82820

Please sign in to comment.