Struct sov_state::ZkStorage

source ·
pub struct ZkStorage<S: MerkleProofSpec> { /* private fields */ }

Implementations§

source§

impl<S: MerkleProofSpec> ZkStorage<S>

source

pub fn new() -> Self

Trait Implementations§

source§

impl<S: MerkleProofSpec> Clone for ZkStorage<S>

source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<S: Default + MerkleProofSpec> Default for ZkStorage<S>where S::Hasher: Default,

source§

fn default() -> ZkStorage<S>

Returns the “default value” for a type. Read more
source§

impl<S: MerkleProofSpec> Storage for ZkStorage<S>

§

type Witness = <S as MerkleProofSpec>::Witness

The witness type for this storage instance.
§

type RuntimeConfig = ()

The runtime config for this storage instance.
§

type Proof = SparseMerkleProof<<S as MerkleProofSpec>::Hasher>

A cryptographic proof that a particular key has a particular value, or is absent.
§

type StateUpdate = NodeBatch

State update that will be committed to the database.
source§

fn with_config(_config: Self::RuntimeConfig) -> Result<Self, Error>

source§

fn get( &self, _key: &StorageKey, witness: &Self::Witness ) -> Option<StorageValue>

Returns the value corresponding to the key or None if key is absent.
source§

fn get_state_root(&self, witness: &Self::Witness) -> Result<[u8; 32]>

Returns the latest state root hash from the storage.
source§

fn compute_state_update( &self, state_accesses: OrderedReadsAndWrites, witness: &Self::Witness ) -> Result<([u8; 32], Self::StateUpdate), Error>

Calculates new state root but does not commit any changes to the database.
source§

fn commit( &self, _node_batch: &Self::StateUpdate, _accessory_writes: &OrderedReadsAndWrites )

Commits state changes to the database.
source§

fn is_empty(&self) -> bool

Indicates if storage is empty or not. Useful during initialization
source§

fn open_proof( &self, state_root: [u8; 32], state_proof: StorageProof<Self::Proof> ) -> Result<(StorageKey, Option<StorageValue>), Error>

Opens a storage access proof and validates it against a state root. It returns a result with the opened leaf (key, value) pair in case of success.
source§

fn get_accessory(&self, _key: &StorageKey) -> Option<StorageValue>

Returns the value corresponding to the key or None if key is absent.
source§

fn validate_and_commit( &self, state_accesses: OrderedReadsAndWrites, witness: &Self::Witness ) -> Result<[u8; 32], Error>

Validate all of the storage accesses in a particular cache log, returning the new state root after applying all writes. This function is equivalent to calling: self.compute_state_update & self.commit
source§

fn validate_and_commit_with_accessory_update( &self, state_accesses: OrderedReadsAndWrites, witness: &Self::Witness, accessory_update: &OrderedReadsAndWrites ) -> Result<[u8; 32], Error>

A version of Storage::validate_and_commit that allows for “accessory” non-JMT updates. See sov_db::NativeDB for more information about accessory state.
source§

fn verify_proof<K, V, Codec>( &self, state_root: [u8; 32], proof: StorageProof<Self::Proof>, expected_key: &K, storage_map: &StateMap<K, V, Codec> ) -> Result<Option<StorageValue>, Error>where Codec: StateKeyCodec<K>,

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for ZkStorage<S>where <S as MerkleProofSpec>::Hasher: RefUnwindSafe,

§

impl<S> Send for ZkStorage<S>where <S as MerkleProofSpec>::Hasher: Send,

§

impl<S> Sync for ZkStorage<S>where <S as MerkleProofSpec>::Hasher: Sync,

§

impl<S> Unpin for ZkStorage<S>where <S as MerkleProofSpec>::Hasher: Unpin,

§

impl<S> UnwindSafe for ZkStorage<S>where <S as MerkleProofSpec>::Hasher: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> 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 Twhere 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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<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