Skip to content

Commit

Permalink
fix: seek_by_key_subkey usage on HistoricalStateProvider (#1584)
Browse files Browse the repository at this point in the history
  • Loading branch information
joshieDo committed Feb 28, 2023
1 parent 530a4a0 commit 6cdf0a3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/storage/db/src/abstraction/cursor.rs
Expand Up @@ -73,7 +73,7 @@ pub trait DbDupCursorRO<'tx, T: DupSort> {
/// Returns the next `value` of a duplicate `key`.
fn next_dup_val(&mut self) -> ValueOnlyResult<T>;

/// Seek by key and subkey
/// Seek by key and subkey. Make sure that the returned value subkey matches the queried one.
fn seek_by_key_subkey(&mut self, key: T::Key, subkey: T::SubKey) -> ValueOnlyResult<T>;

/// Returns an iterator starting at a key greater or equal than `start_key` of a DupSort
Expand Down
7 changes: 5 additions & 2 deletions crates/storage/provider/src/providers/state/historical.rs
Expand Up @@ -56,6 +56,7 @@ impl<'a, 'b, TX: DbTx<'a>> AccountProvider for HistoricalStateProviderRef<'a, 'b
.tx
.cursor_dup_read::<tables::AccountChangeSet>()?
.seek_by_key_subkey(changeset_transition_id, address)?
.filter(|acc| acc.address == address)
.ok_or(ProviderError::AccountChangeset {
transition_id: changeset_transition_id,
address,
Expand Down Expand Up @@ -95,6 +96,7 @@ impl<'a, 'b, TX: DbTx<'a>> StateProvider for HistoricalStateProviderRef<'a, 'b,
.tx
.cursor_dup_read::<tables::StorageChangeSet>()?
.seek_by_key_subkey((changeset_transition_id, address).into(), storage_key)?
.filter(|entry| entry.key == storage_key)
.ok_or(ProviderError::StorageChangeset {
transition_id: changeset_transition_id,
address,
Expand All @@ -107,8 +109,9 @@ impl<'a, 'b, TX: DbTx<'a>> StateProvider for HistoricalStateProviderRef<'a, 'b,
Ok(self
.tx
.cursor_dup_read::<tables::PlainStorageState>()?
.seek_by_key_subkey(address, storage_key)
.map(|r| r.map(|entry| entry.value))?)
.seek_by_key_subkey(address, storage_key)?
.filter(|entry| entry.key == storage_key)
.map(|entry| entry.value))
}
}

Expand Down

0 comments on commit 6cdf0a3

Please sign in to comment.