Skip to content

Commit

Permalink
Ensure transactions in past election blocks can be proven
Browse files Browse the repository at this point in the history
Before this change, transactions in election blocks where tried to be proven with the block number of the following election block, because `Policy::election_block_after()` returns the following election block if given an election block number.
  • Loading branch information
sisou committed Dec 17, 2024
1 parent 15586d0 commit f0a7c85
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions consensus/src/consensus/consensus_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,20 +277,26 @@ impl<N: Network> ConsensusProxy<N> {
// - Finalized epochs: we use the election block number that finalized the respective epoch
// - Finalized batch in the current epoch: We use the latest checkpoint block number
// - Current batch: We use the current head to prove those transactions
if block_number <= &election_head.block_number() {
// First Case: Transactions from finalized epochs
if Policy::is_election_block_at(*block_number) {
// 1st Case: Transactions in election blocks
hashes_by_block
.entry(Some(*block_number))
.or_insert(vec![])
.push(hash.clone());
} else if block_number < &election_head.block_number() {
// 2nd Case: Transactions from finalized epochs (but not in election blocks)
hashes_by_block
.entry(Some(Policy::election_block_after(*block_number)))
.or_insert(vec![])
.push(hash.clone());
} else if block_number <= &checkpoint_head.block_number() {
// Second Case: Transactions from a finalized batch in the current epoch
// 3rd Case: Transactions from a finalized batch in the current epoch
hashes_by_block
.entry(Some(checkpoint_head.block_number()))
.or_insert(vec![])
.push(hash.clone());
} else {
// Third Case: Transactions from the current batch
// 4th Case: Transactions from the current batch
hashes_by_block
.entry(Some(current_block_number))
.or_insert(vec![])
Expand Down

0 comments on commit f0a7c85

Please sign in to comment.