pub struct ZkStorage<S: MerkleProofSpec> { /* private fields */ }Implementations§
Trait Implementations§
source§impl<S: MerkleProofSpec> Clone for ZkStorage<S>
impl<S: MerkleProofSpec> Clone for ZkStorage<S>
source§impl<S: MerkleProofSpec> Storage for ZkStorage<S>
impl<S: MerkleProofSpec> Storage for ZkStorage<S>
§type Witness = <S as MerkleProofSpec>::Witness
type Witness = <S as MerkleProofSpec>::Witness
The witness type for this storage instance.
§type RuntimeConfig = ()
type RuntimeConfig = ()
The runtime config for this storage instance.
§type Proof = SparseMerkleProof<<S as MerkleProofSpec>::Hasher>
type Proof = SparseMerkleProof<<S as MerkleProofSpec>::Hasher>
A cryptographic proof that a particular key has a particular value, or is absent.
§type StateUpdate = NodeBatch
type StateUpdate = NodeBatch
State update that will be committed to the database.
fn with_config(_config: Self::RuntimeConfig) -> Result<Self, Error>
source§fn get(
&self,
_key: &StorageKey,
witness: &Self::Witness
) -> Option<StorageValue>
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]>
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>
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
)
fn commit( &self, _node_batch: &Self::StateUpdate, _accessory_writes: &OrderedReadsAndWrites )
Commits state changes to the database.
source§fn open_proof(
&self,
state_root: [u8; 32],
state_proof: StorageProof<Self::Proof>
) -> Result<(StorageKey, Option<StorageValue>), Error>
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>
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>
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.commitsource§fn validate_and_commit_with_accessory_update(
&self,
state_accesses: OrderedReadsAndWrites,
witness: &Self::Witness,
accessory_update: &OrderedReadsAndWrites
) -> Result<[u8; 32], Error>
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.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> 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
Mutably borrows from an owned value. Read more