Skip to content

Commit 49cd84d

Browse files
authored
fix(provider): historical provider doesn't respect pinned block number (#360)
The fork version of the `HistoricalStateProvider` should falls back to requesting data from the forked network ONLY when the pinned block number (i.e., the block number the `HistoricalStateProvider` is created for - the `block_id` given to `<ForkedProvider as StateFactoryProvider>::historical`) is less than or equal to the block number which katana is forked at. Currently, `HistoricalStateProvider` would immediately falls back to the forked network. The request is then handled by the `Backend` and `Backend` is pinned to the forked block number and not the block number the state provider is for.
1 parent 92196ed commit 49cd84d

File tree

5 files changed

+207
-124
lines changed

5 files changed

+207
-124
lines changed

crates/core/src/backend/storage.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl Blockchain {
141141

142142
// TODO: convert this to block number instead of BlockHashOrNumber so that it is easier to
143143
// check if the requested block is within the supported range or not.
144-
let database = ForkedProvider::new(db, block_id, provider.clone());
144+
let database = ForkedProvider::new(db, block_num, provider.clone());
145145

146146
// initialize parent fork block
147147
//

crates/primitives/src/block.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub enum ConfirmedBlockIdOrTag {
5252
L1Accepted,
5353
}
5454

55-
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
55+
#[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
5656
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
5757
pub enum BlockHashOrNumber {
5858
Hash(BlockHash),

0 commit comments

Comments
 (0)