Struct snarkvm_console_program::state_path::StatePath
source · pub struct StatePath<N: Network> { /* private fields */ }
Expand description
The state path proves existence of the transition leaf to either a global or local state root.
Implementations§
source§impl<N: Network> StatePath<N>
impl<N: Network> StatePath<N>
sourcepub fn verify(&self, is_global: bool, local_state_root: Field<N>) -> Result<()>
pub fn verify(&self, is_global: bool, local_state_root: Field<N>) -> Result<()>
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
source§impl<N: Network> StatePath<N>
impl<N: Network> StatePath<N>
sourcepub fn new_local(
global_state_root: N::StateRoot,
local_state_root: N::TransactionID,
transaction_path: TransactionPath<N>,
transaction_leaf: TransactionLeaf<N>,
transition_path: TransitionPath<N>,
transition_leaf: TransitionLeaf<N>
) -> Result<Self>
pub fn new_local( global_state_root: N::StateRoot, local_state_root: N::TransactionID, transaction_path: TransactionPath<N>, transaction_leaf: TransactionLeaf<N>, transition_path: TransitionPath<N>, transition_leaf: TransitionLeaf<N> ) -> Result<Self>
Initializes a new instance of StatePath
.
sourcepub fn from(
global_state_root: N::StateRoot,
block_path: BlockPath<N>,
block_hash: N::BlockHash,
previous_block_hash: N::BlockHash,
header_root: Field<N>,
header_path: HeaderPath<N>,
header_leaf: HeaderLeaf<N>,
transactions_path: TransactionsPath<N>,
transaction_id: N::TransactionID,
transaction_path: TransactionPath<N>,
transaction_leaf: TransactionLeaf<N>,
transition_path: TransitionPath<N>,
transition_leaf: TransitionLeaf<N>
) -> Self
pub fn from( global_state_root: N::StateRoot, block_path: BlockPath<N>, block_hash: N::BlockHash, previous_block_hash: N::BlockHash, header_root: Field<N>, header_path: HeaderPath<N>, header_leaf: HeaderLeaf<N>, transactions_path: TransactionsPath<N>, transaction_id: N::TransactionID, transaction_path: TransactionPath<N>, transaction_leaf: TransactionLeaf<N>, transition_path: TransitionPath<N>, transition_leaf: TransitionLeaf<N> ) -> Self
Initializes a new instance of StatePath
.
sourcepub const fn global_state_root(&self) -> N::StateRoot
pub const fn global_state_root(&self) -> N::StateRoot
Returns the global state root.
sourcepub const fn block_path(&self) -> &BlockPath<N>
pub const fn block_path(&self) -> &BlockPath<N>
Returns the block path.
sourcepub const fn block_hash(&self) -> N::BlockHash
pub const fn block_hash(&self) -> N::BlockHash
Returns the block hash.
sourcepub const fn previous_block_hash(&self) -> N::BlockHash
pub const fn previous_block_hash(&self) -> N::BlockHash
Returns the previous block hash.
sourcepub const fn header_root(&self) -> &Field<N>
pub const fn header_root(&self) -> &Field<N>
Returns the block header root.
sourcepub const fn header_path(&self) -> &HeaderPath<N>
pub const fn header_path(&self) -> &HeaderPath<N>
Returns the header path.
sourcepub const fn header_leaf(&self) -> &HeaderLeaf<N>
pub const fn header_leaf(&self) -> &HeaderLeaf<N>
Returns the header leaf.
sourcepub const fn transactions_path(&self) -> &TransactionsPath<N>
pub const fn transactions_path(&self) -> &TransactionsPath<N>
Returns the transactions path.
sourcepub const fn transaction_id(&self) -> &N::TransactionID
pub const fn transaction_id(&self) -> &N::TransactionID
Returns the transaction ID.
sourcepub const fn transaction_path(&self) -> &TransactionPath<N>
pub const fn transaction_path(&self) -> &TransactionPath<N>
Returns the Merkle path for the transaction leaf.
sourcepub const fn transaction_leaf(&self) -> &TransactionLeaf<N>
pub const fn transaction_leaf(&self) -> &TransactionLeaf<N>
Returns the transaction leaf.
sourcepub const fn transition_path(&self) -> &TransitionPath<N>
pub const fn transition_path(&self) -> &TransitionPath<N>
Returns the Merkle path for the transition leaf.
sourcepub const fn transition_leaf(&self) -> &TransitionLeaf<N>
pub const fn transition_leaf(&self) -> &TransitionLeaf<N>
Returns the transition leaf.
Trait Implementations§
source§impl<N: Clone + Network> Clone for StatePath<N>where
N::StateRoot: Clone,
N::BlockHash: Clone,
N::TransactionID: Clone,
impl<N: Clone + Network> Clone for StatePath<N>where N::StateRoot: Clone, N::BlockHash: Clone, N::TransactionID: Clone,
source§impl<'de, N: Network> Deserialize<'de> for StatePath<N>
impl<'de, N: Network> Deserialize<'de> for StatePath<N>
source§fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>
Deserializes the state path from a string or bytes.
source§impl<N: Network> Parser for StatePath<N>
impl<N: Network> Parser for StatePath<N>
source§fn parse(string: &str) -> ParserResult<'_, Self>
fn parse(string: &str) -> ParserResult<'_, Self>
Parses a string into the state path.
source§impl<N: PartialEq + Network> PartialEq<StatePath<N>> for StatePath<N>where
N::StateRoot: PartialEq,
N::BlockHash: PartialEq,
N::TransactionID: PartialEq,
impl<N: PartialEq + Network> PartialEq<StatePath<N>> for StatePath<N>where N::StateRoot: PartialEq, N::BlockHash: PartialEq, N::TransactionID: PartialEq,
impl<N: Eq + Network> Eq for StatePath<N>where N::StateRoot: Eq, N::BlockHash: Eq, N::TransactionID: Eq,
impl<N: Network> StructuralEq for StatePath<N>
impl<N: Network> StructuralPartialEq for StatePath<N>
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§
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<'de, T> DeserializeExt<'de> for Twhere
T: DeserializeOwned,
impl<'de, T> DeserializeExt<'de> for Twhere T: DeserializeOwned,
fn take_from_value<D>( value: &mut Value, field: &str ) -> Result<T, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,
§impl<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,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<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,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.