Struct zksync_dal::storage_logs_dal::StorageLogsDal

source ·
pub struct StorageLogsDal<'a, 'c> { /* private fields */ }

Implementations§

source§

impl StorageLogsDal<'_, '_>

source

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.

source

pub async fn insert_storage_logs_with_preimages_from_snapshot( &mut self, l2_block_number: L2BlockNumber, snapshot_storage_logs: &[SnapshotStorageLog<StorageKey>], ) -> DalResult<()>

👎Deprecated: Will be removed in favor of insert_storage_logs_from_snapshot()
source

pub async fn insert_storage_logs_from_snapshot( &mut self, l2_block_number: L2BlockNumber, snapshot_storage_logs: &[SnapshotStorageLog], ) -> DalResult<()>

source

pub async fn append_storage_logs( &mut self, block_number: L2BlockNumber, logs: &[StorageLog], ) -> DalResult<()>

source

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.

source

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.

source

pub async fn is_contract_deployed_at_address( &mut self, address: Address, ) -> bool

source

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.

source

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).

source

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.

source

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.

source

pub async fn get_l1_batches_and_indices_for_initial_writes( &mut self, hashed_keys: &[H256], ) -> DalResult<HashMap<H256, (L1BatchNumber, u64)>>

source

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.

source

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.

source

pub async fn dump_all_storage_logs_for_tests(&mut self) -> Vec<DbStorageLog>

Retrieves all storage log entries for testing purposes.

source

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).

source

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.

source

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§

source§

impl<'a, 'c> Debug for StorageLogsDal<'a, 'c>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FutureExt for T

source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
source§

impl<T> IntoRequest<T> for T

source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more