Skip to content

Commit

Permalink
fix: unwind_to should be exclusive (paradigmxyz#10738)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Seitz <[email protected]>
  • Loading branch information
alexgao001 and mattsse authored Sep 6, 2024
1 parent a89de21 commit dbf5d48
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion crates/stages/stages/src/stages/headers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,9 @@ where

// First unwind the db tables, until the unwind_to block number. use the walker to unwind
// HeaderNumbers based on the index in CanonicalHeaders
// unwind from the next block number since the unwind_to block is exclusive
provider.unwind_table_by_walker::<tables::CanonicalHeaders, tables::HeaderNumbers>(
input.unwind_to..,
(input.unwind_to + 1)..,
)?;
provider.unwind_table_by_num::<tables::CanonicalHeaders>(input.unwind_to)?;
provider.unwind_table_by_num::<tables::HeaderTerminalDifficulties>(input.unwind_to)?;
Expand Down
4 changes: 3 additions & 1 deletion crates/storage/provider/src/providers/database/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,9 @@ impl<TX: DbTxMut + DbTx> DatabaseProvider<TX> {
Ok(deleted)
}

/// Unwind a table forward by a [`Walker`][reth_db_api::cursor::Walker] on another table
/// Unwind a table forward by a [`Walker`][reth_db_api::cursor::Walker] on another table.
///
/// Note: Range is inclusive and first key in the range is removed.
pub fn unwind_table_by_walker<T1, T2>(
&self,
range: impl RangeBounds<T1::Key>,
Expand Down

0 comments on commit dbf5d48

Please sign in to comment.