pub struct ZkStorage<S: MerkleProofSpec> { /* private fields */ }
Expand description
A Storage
implementation designed to be used inside the zkVM.
Implementations§
Source§impl<S: MerkleProofSpec> ZkStorage<S>
impl<S: MerkleProofSpec> ZkStorage<S>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new ZkStorage
instance. Identical to Default::default
.
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>
Source§type Witness = <S as MerkleProofSpec>::Witness
type Witness = <S as MerkleProofSpec>::Witness
The witness type for this storage instance.
Source§type RuntimeConfig = ()
type RuntimeConfig = ()
The runtime config for this storage instance.
Source§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.
Source§type StateUpdate = ()
type StateUpdate = ()
State update that will be committed to the database.
Source§fn with_config(_config: Self::RuntimeConfig) -> Result<Self, Error>
fn with_config(_config: Self::RuntimeConfig) -> Result<Self, Error>
Creates a new instance of this
Storage
type, with some configuration
options.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 compute_state_update(
&self,
state_accesses: OrderedReadsAndWrites,
witness: &Self::Witness,
) -> Result<(Self::Root, Self::StateUpdate), Error>
fn compute_state_update( &self, state_accesses: OrderedReadsAndWrites, witness: &Self::Witness, ) -> Result<(Self::Root, 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 is_empty(&self) -> bool
fn is_empty(&self) -> bool
Indicates if storage is empty or not.
Useful during initialization.
Source§fn open_proof(
state_root: Self::Root,
state_proof: StorageProof<Self::Proof>,
) -> Result<(StorageKey, Option<StorageValue>), Error>
fn open_proof( state_root: Self::Root, 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. Read more
Source§fn validate_and_commit(
&self,
state_accesses: OrderedReadsAndWrites,
witness: &Self::Witness,
) -> Result<Self::Root, Error>
fn validate_and_commit( &self, state_accesses: OrderedReadsAndWrites, witness: &Self::Witness, ) -> Result<Self::Root, 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<Self::Root, Error>
fn validate_and_commit_with_accessory_update( &self, state_accesses: OrderedReadsAndWrites, witness: &Self::Witness, accessory_update: &OrderedReadsAndWrites, ) -> Result<Self::Root, 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.Auto Trait Implementations§
impl<S> Freeze for ZkStorage<S>
impl<S> RefUnwindSafe for ZkStorage<S>
impl<S> Send for ZkStorage<S>
impl<S> Sync for ZkStorage<S>
impl<S> Unpin for ZkStorage<S>
impl<S> UnwindSafe for ZkStorage<S>
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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 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>
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