Skip to content

Commit

Permalink
Skip processing needless block in the bundle validator
Browse files Browse the repository at this point in the history
We only keep track of the state of the last K blocks, if there are more than
K blocks left to process we can skip some blocks as their result will simply
be dumpped after processing, this also help to prevent the bundle validator
from stuck on some pruned blocks because these block will be skip as the chain
grows.

Signed-off-by: linning <linningde25@gmail.com>
  • Loading branch information
NingLin-P committed Jun 21, 2023
1 parent 068353d commit 3e928cb
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions crates/subspace-transaction-pool/src/bundle_validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,12 @@ where
}
}

// Add bundles from the new block of the best fork
for enacted_block in enacted {
// Add bundles from the new block of the best fork, only need to process at most the last K
// blocks as the result of other blocks will be dumpped immediately, this also help to prevent
// the bundle validator from stuck on some pruned blocks because these blocks will be skip as
// the chain grows.
let needless_block = enacted.len().saturating_sub(self.confirm_depth_k);
for enacted_block in enacted.iter().skip(needless_block) {
let bundles = self.successfully_submitted_bundles_at(enacted_block.hash)?;
bundle_stored_in_last_k.push_front(BlockBundle::new(
enacted_block.hash,
Expand Down

0 comments on commit 3e928cb

Please sign in to comment.