diff --git a/consensus/src/sync/history/cluster.rs b/consensus/src/sync/history/cluster.rs index cf0c99a6f8..0e02e52520 100644 --- a/consensus/src/sync/history/cluster.rs +++ b/consensus/src/sync/history/cluster.rs @@ -366,9 +366,15 @@ impl SyncCluster { 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 };