Struct zksync_dal::storage_logs_dal::StorageLogsDal
source · pub struct StorageLogsDal<'a, 'c> { /* private fields */ }
Implementations§
source§impl StorageLogsDal<'_, '_>
impl StorageLogsDal<'_, '_>
sourcepub async fn insert_storage_logs(
&mut self,
block_number: L2BlockNumber,
logs: &[StorageLog],
) -> DalResult<()>
pub async fn insert_storage_logs( &mut self, block_number: L2BlockNumber, logs: &[StorageLog], ) -> DalResult<()>
Inserts storage logs grouped by transaction for an L2 block. The ordering of transactions must be the same as their ordering in the L2 block.
pub async fn insert_storage_logs_with_preimages_from_snapshot( &mut self, l2_block_number: L2BlockNumber, snapshot_storage_logs: &[SnapshotStorageLog<StorageKey>], ) -> DalResult<()>
insert_storage_logs_from_snapshot()
pub async fn insert_storage_logs_from_snapshot( &mut self, l2_block_number: L2BlockNumber, snapshot_storage_logs: &[SnapshotStorageLog], ) -> DalResult<()>
pub async fn append_storage_logs( &mut self, block_number: L2BlockNumber, logs: &[StorageLog], ) -> DalResult<()>
sourcepub async fn modified_keys_in_l2_blocks(
&mut self,
l2_block_numbers: RangeInclusive<L2BlockNumber>,
) -> DalResult<Vec<H256>>
pub async fn modified_keys_in_l2_blocks( &mut self, l2_block_numbers: RangeInclusive<L2BlockNumber>, ) -> DalResult<Vec<H256>>
Returns distinct hashed storage keys that were modified in the specified L2 block range.
sourcepub async fn roll_back_storage_logs(
&mut self,
block_number: L2BlockNumber,
) -> DalResult<()>
pub async fn roll_back_storage_logs( &mut self, block_number: L2BlockNumber, ) -> DalResult<()>
Removes all storage logs with a L2 block number strictly greater than the specified block_number
.
pub async fn is_contract_deployed_at_address( &mut self, address: Address, ) -> bool
sourcepub async fn filter_deployed_contracts(
&mut self,
addresses: impl Iterator<Item = Address>,
at_l2_block: Option<L2BlockNumber>,
) -> DalResult<HashMap<Address, L2BlockNumber>>
pub async fn filter_deployed_contracts( &mut self, addresses: impl Iterator<Item = Address>, at_l2_block: Option<L2BlockNumber>, ) -> DalResult<HashMap<Address, L2BlockNumber>>
Returns addresses and the corresponding deployment L2 block numbers among the specified contract
addresses
. at_l2_block
allows filtering deployment by L2 blocks.
sourcepub async fn get_touched_slots_for_l1_batch(
&mut self,
l1_batch_number: L1BatchNumber,
) -> DalResult<HashMap<H256, H256>>
pub async fn get_touched_slots_for_l1_batch( &mut self, l1_batch_number: L1BatchNumber, ) -> DalResult<HashMap<H256, H256>>
Returns latest values for all slots written to in the specified L1 batch judging by storage logs (i.e., not taking deduplication logic into account).
sourcepub async fn get_touched_slots_for_executed_l1_batch(
&mut self,
l1_batch_number: L1BatchNumber,
) -> DalResult<HashMap<StorageKey, H256>>
pub async fn get_touched_slots_for_executed_l1_batch( &mut self, l1_batch_number: L1BatchNumber, ) -> DalResult<HashMap<StorageKey, H256>>
Same as Self::get_touched_slots_for_l1_batch()
, but loads key preimages instead of hashed keys.
Correspondingly, this method is safe to call for locally executed L1 batches, for which key preimages
are known; otherwise, it will error.
sourcepub async fn get_storage_logs_for_revert(
&mut self,
l1_batch_number: L1BatchNumber,
) -> DalResult<HashMap<H256, Option<(H256, u64)>>>
pub async fn get_storage_logs_for_revert( &mut self, l1_batch_number: L1BatchNumber, ) -> DalResult<HashMap<H256, Option<(H256, u64)>>>
Returns (hashed) storage keys and the corresponding values that need to be applied to a storage in order to revert it to the specified L1 batch. Deduplication is taken into account.
pub async fn get_l1_batches_and_indices_for_initial_writes( &mut self, hashed_keys: &[H256], ) -> DalResult<HashMap<H256, (L1BatchNumber, u64)>>
sourcepub async fn get_previous_storage_values(
&mut self,
hashed_keys: &[H256],
next_l1_batch: L1BatchNumber,
) -> DalResult<HashMap<H256, Option<H256>>>
pub async fn get_previous_storage_values( &mut self, hashed_keys: &[H256], next_l1_batch: L1BatchNumber, ) -> DalResult<HashMap<H256, Option<H256>>>
Gets previous values for the specified storage keys before the specified L1 batch number.
§Return value
The returned map is guaranteed to contain all unique keys from hashed_keys
.
§Performance
This DB query is slow, especially when used with large hashed_keys
slices. Prefer using alternatives
wherever possible.
sourcepub async fn get_storage_values(
&mut self,
hashed_keys: &[H256],
l2_block_number: L2BlockNumber,
) -> DalResult<HashMap<H256, Option<H256>>>
pub async fn get_storage_values( &mut self, hashed_keys: &[H256], l2_block_number: L2BlockNumber, ) -> DalResult<HashMap<H256, Option<H256>>>
Returns current values for the specified keys at the specified l2_block_number
.
sourcepub async fn dump_all_storage_logs_for_tests(&mut self) -> Vec<DbStorageLog>
pub async fn dump_all_storage_logs_for_tests(&mut self) -> Vec<DbStorageLog>
Retrieves all storage log entries for testing purposes.
sourcepub async fn get_storage_logs_row_count(
&mut self,
at_l2_block: L2BlockNumber,
) -> DalResult<u64>
pub async fn get_storage_logs_row_count( &mut self, at_l2_block: L2BlockNumber, ) -> DalResult<u64>
Returns the total number of rows in the storage_logs
table before and at the specified L2 block.
Warning. This method is slow (requires a full table scan).
sourcepub async fn get_chunk_starts_for_l2_block(
&mut self,
l2_block_number: L2BlockNumber,
key_ranges: &[RangeInclusive<H256>],
) -> DalResult<Vec<Option<StorageRecoveryLogEntry>>>
pub async fn get_chunk_starts_for_l2_block( &mut self, l2_block_number: L2BlockNumber, key_ranges: &[RangeInclusive<H256>], ) -> DalResult<Vec<Option<StorageRecoveryLogEntry>>>
Gets a starting tree entry for each of the supplied key_ranges
for the specified
l2_block_number
. This method is used during Merkle tree recovery.
sourcepub async fn get_tree_entries_for_l2_block(
&mut self,
l2_block_number: L2BlockNumber,
key_range: RangeInclusive<H256>,
) -> DalResult<Vec<StorageRecoveryLogEntry>>
pub async fn get_tree_entries_for_l2_block( &mut self, l2_block_number: L2BlockNumber, key_range: RangeInclusive<H256>, ) -> DalResult<Vec<StorageRecoveryLogEntry>>
Fetches tree entries for the specified l2_block_number
and key_range
. This is used during
Merkle tree recovery.
Trait Implementations§
Auto Trait Implementations§
impl<'a, 'c> Freeze for StorageLogsDal<'a, 'c>
impl<'a, 'c> !RefUnwindSafe for StorageLogsDal<'a, 'c>
impl<'a, 'c> Send for StorageLogsDal<'a, 'c>
impl<'a, 'c> Sync for StorageLogsDal<'a, 'c>
impl<'a, 'c> Unpin for StorageLogsDal<'a, 'c>
impl<'a, 'c> !UnwindSafe for StorageLogsDal<'a, 'c>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request