Struct snarkvm_wasm::program::StatePath
pub struct StatePath<N>where
N: Network,{ /* private fields */ }
Expand description
The state path proves existence of the transition leaf to either a global or local state root.
Implementations
impl<N> StatePath<N>where
N: Network,
impl<N> StatePath<N>where
N: Network,
pub fn verify(
&self,
is_global: bool,
local_state_root: Field<N>
) -> Result<(), Error>
pub fn verify(
&self,
is_global: bool,
local_state_root: Field<N>
) -> Result<(), Error>
Checks if the state path is valid.
Parameters
local_state_root
is the local transaction root for the current execution.is_global
is a boolean indicating whether this is a global or local state root.
Diagram
The [[ ]]
notation is used to denote public inputs.
[[ global_state_root ]]
|
block_path
|
block_hash := Hash( previous_block_hash || header_root )
|
header_path
|
header_leaf
|
transactions_path [[ local_state_root ]]
| |
(true) ------ is_global ------ (false)
|
transaction_id
|
transaction_path
|
transaction_leaf
|
transition_path
|
transition_leaf
impl<N> StatePath<N>where
N: Network,
impl<N> StatePath<N>where
N: Network,
pub fn new_local(
global_state_root: <N as Network>::StateRoot,
local_state_root: <N as Network>::TransactionID,
transaction_path: MerklePath<N, _>,
transaction_leaf: TransactionLeaf<N>,
transition_path: MerklePath<N, _>,
transition_leaf: TransitionLeaf<N>
) -> Result<StatePath<N>, Error>
pub fn new_local(
global_state_root: <N as Network>::StateRoot,
local_state_root: <N as Network>::TransactionID,
transaction_path: MerklePath<N, _>,
transaction_leaf: TransactionLeaf<N>,
transition_path: MerklePath<N, _>,
transition_leaf: TransitionLeaf<N>
) -> Result<StatePath<N>, Error>
Initializes a new instance of StatePath
.
pub fn from(
global_state_root: <N as Network>::StateRoot,
block_path: MerklePath<N, _>,
block_hash: <N as Network>::BlockHash,
previous_block_hash: <N as Network>::BlockHash,
header_root: Field<N>,
header_path: MerklePath<N, _>,
header_leaf: HeaderLeaf<N>,
transactions_path: MerklePath<N, _>,
transaction_id: <N as Network>::TransactionID,
transaction_path: MerklePath<N, _>,
transaction_leaf: TransactionLeaf<N>,
transition_path: MerklePath<N, _>,
transition_leaf: TransitionLeaf<N>
) -> StatePath<N>
pub fn from(
global_state_root: <N as Network>::StateRoot,
block_path: MerklePath<N, _>,
block_hash: <N as Network>::BlockHash,
previous_block_hash: <N as Network>::BlockHash,
header_root: Field<N>,
header_path: MerklePath<N, _>,
header_leaf: HeaderLeaf<N>,
transactions_path: MerklePath<N, _>,
transaction_id: <N as Network>::TransactionID,
transaction_path: MerklePath<N, _>,
transaction_leaf: TransactionLeaf<N>,
transition_path: MerklePath<N, _>,
transition_leaf: TransitionLeaf<N>
) -> StatePath<N>
Initializes a new instance of StatePath
.
pub const fn global_state_root(&self) -> <N as Network>::StateRoot
pub const fn global_state_root(&self) -> <N as Network>::StateRoot
Returns the global state root.
pub const fn block_path(&self) -> &MerklePath<N, _>
pub const fn block_path(&self) -> &MerklePath<N, _>
Returns the block path.
pub const fn block_hash(&self) -> <N as Network>::BlockHash
pub const fn block_hash(&self) -> <N as Network>::BlockHash
Returns the block hash.
pub const fn previous_block_hash(&self) -> <N as Network>::BlockHash
pub const fn previous_block_hash(&self) -> <N as Network>::BlockHash
Returns the previous block hash.
pub const fn header_root(&self) -> &Field<N>
pub const fn header_root(&self) -> &Field<N>
Returns the block header root.
pub const fn header_path(&self) -> &MerklePath<N, _>
pub const fn header_path(&self) -> &MerklePath<N, _>
Returns the header path.
pub const fn header_leaf(&self) -> &HeaderLeaf<N>
pub const fn header_leaf(&self) -> &HeaderLeaf<N>
Returns the header leaf.
pub const fn transactions_path(&self) -> &MerklePath<N, _>
pub const fn transactions_path(&self) -> &MerklePath<N, _>
Returns the transactions path.
pub const fn transaction_id(&self) -> &<N as Network>::TransactionID
pub const fn transaction_id(&self) -> &<N as Network>::TransactionID
Returns the transaction ID.
pub const fn transaction_path(&self) -> &MerklePath<N, _>
pub const fn transaction_path(&self) -> &MerklePath<N, _>
Returns the Merkle path for the transaction leaf.
pub const fn transaction_leaf(&self) -> &TransactionLeaf<N>
pub const fn transaction_leaf(&self) -> &TransactionLeaf<N>
Returns the transaction leaf.
pub const fn transition_path(&self) -> &MerklePath<N, _>
pub const fn transition_path(&self) -> &MerklePath<N, _>
Returns the Merkle path for the transition leaf.
pub const fn transition_leaf(&self) -> &TransitionLeaf<N>
pub const fn transition_leaf(&self) -> &TransitionLeaf<N>
Returns the transition leaf.
Trait Implementations
impl<N> Clone for StatePath<N>where
N: Clone + Network,
<N as Network>::StateRoot: Clone,
<N as Network>::BlockHash: Clone,
<N as Network>::TransactionID: Clone,
impl<N> Clone for StatePath<N>where
N: Clone + Network,
<N as Network>::StateRoot: Clone,
<N as Network>::BlockHash: Clone,
<N as Network>::TransactionID: Clone,
impl<'de, N> Deserialize<'de> for StatePath<N>where
N: Network,
impl<'de, N> Deserialize<'de> for StatePath<N>where
N: Network,
fn deserialize<D>(
deserializer: D
) -> Result<StatePath<N>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D
) -> Result<StatePath<N>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserializes the state path from a string or bytes.
impl<N> PartialEq<StatePath<N>> for StatePath<N>where
N: PartialEq<N> + Network,
<N as Network>::StateRoot: PartialEq<<N as Network>::StateRoot>,
<N as Network>::BlockHash: PartialEq<<N as Network>::BlockHash>,
<N as Network>::TransactionID: PartialEq<<N as Network>::TransactionID>,
impl<N> PartialEq<StatePath<N>> for StatePath<N>where
N: PartialEq<N> + Network,
<N as Network>::StateRoot: PartialEq<<N as Network>::StateRoot>,
<N as Network>::BlockHash: PartialEq<<N as Network>::BlockHash>,
<N as Network>::TransactionID: PartialEq<<N as Network>::TransactionID>,
impl<N> Serialize for StatePath<N>where
N: Network,
impl<N> Serialize for StatePath<N>where
N: Network,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serializes the state path into string or bytes.
impl<N> Eq for StatePath<N>where
N: Eq + Network,
<N as Network>::StateRoot: Eq,
<N as Network>::BlockHash: Eq,
<N as Network>::TransactionID: Eq,
impl<N> StructuralEq for StatePath<N>where
N: Network,
impl<N> StructuralPartialEq for StatePath<N>where
N: Network,
Auto Trait Implementations
impl<N> RefUnwindSafe for StatePath<N>where
N: RefUnwindSafe,
<N as Network>::BlockHash: RefUnwindSafe,
<N as Environment>::Field: RefUnwindSafe,
<N as Network>::StateRoot: RefUnwindSafe,
<N as Network>::TransactionID: RefUnwindSafe,
impl<N> Send for StatePath<N>
impl<N> Sync for StatePath<N>
impl<N> Unpin for StatePath<N>where
N: Unpin,
<N as Network>::BlockHash: Unpin,
<N as Environment>::Field: Unpin,
<N as Network>::StateRoot: Unpin,
<N as Network>::TransactionID: Unpin,
impl<N> UnwindSafe for StatePath<N>where
N: UnwindSafe,
<N as Network>::BlockHash: UnwindSafe,
<N as Environment>::Field: UnwindSafe,
<N as Network>::StateRoot: UnwindSafe,
<N as Network>::TransactionID: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
sourceimpl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn instrument(self, span: Span) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
sourcefn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
fn in_current_span(self) -> Instrumented<Self>ⓘNotable traits for Instrumented<T>impl<T> Future for Instrumented<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;
impl<T> Pointable for T
impl<T> Pointable for T
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
where
S: Into<Dispatch>,
T: Future, type Output = <T as Future>::Output;
sourcefn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
fn with_current_subscriber(self) -> WithDispatch<Self>ⓘNotable traits for WithDispatch<T>impl<T> Future for WithDispatch<T>where
T: Future, type Output = <T as Future>::Output;
T: Future, type Output = <T as Future>::Output;