Compare commits

...

1 Commits

Author SHA1 Message Date
Georgios Konstantopoulos
9f43952b4c fix(engine): persist blocks immediately when persistence_threshold=0
Fixes #21093

The `should_persist()` function was using `>` instead of `>=` when
comparing the block count against the persistence threshold. This meant
that with `--engine.persistence-threshold=0`, blocks would not persist
until there was at least 1 block difference (i.e., 2 blocks in memory).

With the corrected `>=` comparison, setting persistence_threshold=0 now
correctly means "persist immediately" (0 blocks allowed in memory without
triggering persistence).
2026-01-16 11:48:11 +00:00
2 changed files with 3 additions and 3 deletions

View File

@@ -1761,7 +1761,7 @@ where
}
let min_block = self.persistence_state.last_persisted_block.number;
self.state.tree_state.canonical_block_number().saturating_sub(min_block) >
self.state.tree_state.canonical_block_number().saturating_sub(min_block) >=
self.config.persistence_threshold()
}

View File

@@ -491,7 +491,7 @@ fn test_tree_persist_block_batch() {
let chain_spec = MAINNET.clone();
let mut test_block_builder = TestBlockBuilder::eth().with_chain_spec((*chain_spec).clone());
// we need more than tree_config.persistence_threshold() +1 blocks to
// we need at least tree_config.persistence_threshold() + 1 blocks to
// trigger the persistence task.
let blocks: Vec<_> = test_block_builder
.get_executed_blocks(1..tree_config.persistence_threshold() + 2)
@@ -531,7 +531,7 @@ async fn test_tree_persist_blocks() {
let chain_spec = MAINNET.clone();
let mut test_block_builder = TestBlockBuilder::eth().with_chain_spec((*chain_spec).clone());
// we need more than tree_config.persistence_threshold() +1 blocks to
// we need at least tree_config.persistence_threshold() + 1 blocks to
// trigger the persistence task.
let blocks: Vec<_> = test_block_builder
.get_executed_blocks(1..tree_config.persistence_threshold() + 2)