diff --git a/graph/src/components/store/mod.rs b/graph/src/components/store/mod.rs index 40a46531c75..eb4aebe90be 100644 --- a/graph/src/components/store/mod.rs +++ b/graph/src/components/store/mod.rs @@ -1059,9 +1059,16 @@ impl PruneRequest { )); } - // We need to add + 1 to `earliset_block` because the lower bound is inclusive - // and otherwise we would end up with `history_blocks + 1` blocks of history instead of `history_blocks` - let earliest_block = latest_block - history_blocks + 1; + // Note: this intentionally keeps `history_blocks + 1` blocks on disk. + // The range [earliest_block, latest_block] is inclusive on both ends, + // so it contains `history_blocks + 1` entries. The extra block is a + // required buffer: `revert_block_ptr` requires at least + // `reorg_threshold + 2` actual blocks on disk to allow even a + // single-block reorg after pruning, and `strategy` requires + // `earliest_block < final_block`. Both conditions are satisfied when + // `history_blocks >= reorg_threshold + 1`, which gives + // `reorg_threshold + 2` blocks on disk. + let earliest_block = latest_block - history_blocks; let final_block = latest_block - reorg_threshold; Ok(Self {