Struct snarkvm_debug::prelude::state_path::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_rootis the local transaction root for the current execution.is_globalis 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_id := Hash( transition_root || tcm )
|
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, snarkvm_console_program::::state_path::configuration::TransactionPath::{constant#0}>,
transaction_leaf: TransactionLeaf<N>,
transition_root: Field<N>,
tcm: Field<N>,
transition_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::TransitionPath::{constant#0}>,
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, snarkvm_console_program::::state_path::configuration::TransactionPath::{constant#0}>, transaction_leaf: TransactionLeaf<N>, transition_root: Field<N>, tcm: Field<N>, transition_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::TransitionPath::{constant#0}>, 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, snarkvm_console_program::::state_path::configuration::BlockPath::{constant#0}>,
block_hash: <N as Network>::BlockHash,
previous_block_hash: <N as Network>::BlockHash,
header_root: Field<N>,
header_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::HeaderPath::{constant#0}>,
header_leaf: HeaderLeaf<N>,
transactions_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::TransactionsPath::{constant#0}>,
transaction_id: <N as Network>::TransactionID,
transaction_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::TransactionPath::{constant#0}>,
transaction_leaf: TransactionLeaf<N>,
transition_root: Field<N>,
tcm: Field<N>,
transition_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::TransitionPath::{constant#0}>,
transition_leaf: TransitionLeaf<N>
) -> StatePath<N>
pub fn from( global_state_root: <N as Network>::StateRoot, block_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::BlockPath::{constant#0}>, block_hash: <N as Network>::BlockHash, previous_block_hash: <N as Network>::BlockHash, header_root: Field<N>, header_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::HeaderPath::{constant#0}>, header_leaf: HeaderLeaf<N>, transactions_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::TransactionsPath::{constant#0}>, transaction_id: <N as Network>::TransactionID, transaction_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::TransactionPath::{constant#0}>, transaction_leaf: TransactionLeaf<N>, transition_root: Field<N>, tcm: Field<N>, transition_path: MerklePath<N, snarkvm_console_program::::state_path::configuration::TransitionPath::{constant#0}>, 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, snarkvm_console_program::::state_path::configuration::BlockPath::{constant#0}>
pub const fn block_path( &self ) -> &MerklePath<N, snarkvm_console_program::::state_path::configuration::BlockPath::{constant#0}>
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, snarkvm_console_program::::state_path::configuration::HeaderPath::{constant#0}>
pub const fn header_path( &self ) -> &MerklePath<N, snarkvm_console_program::::state_path::configuration::HeaderPath::{constant#0}>
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, snarkvm_console_program::::state_path::configuration::TransactionsPath::{constant#0}>
pub const fn transactions_path( &self ) -> &MerklePath<N, snarkvm_console_program::::state_path::configuration::TransactionsPath::{constant#0}>
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, snarkvm_console_program::::state_path::configuration::TransactionPath::{constant#0}>
pub const fn transaction_path( &self ) -> &MerklePath<N, snarkvm_console_program::::state_path::configuration::TransactionPath::{constant#0}>
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_root(&self) -> &Field<N>
pub const fn transition_root(&self) -> &Field<N>
Returns the transition root.
pub const fn transition_path(
&self
) -> &MerklePath<N, snarkvm_console_program::::state_path::configuration::TransitionPath::{constant#0}>
pub const fn transition_path( &self ) -> &MerklePath<N, snarkvm_console_program::::state_path::configuration::TransitionPath::{constant#0}>
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<'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 for StatePath<N>
impl<N> PartialEq for StatePath<N>
§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>
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>
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
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>,
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.