Skip to main content

Step

Enum Step 

Source
pub enum Step {
    Branch {
        skip: usize,
        neighbors: [Hash; 4],
    },
    Fork {
        skip: usize,
        neighbor: Neighbor,
    },
    Leaf {
        skip: usize,
        key: Hash,
        value: Hash,
    },
}
Expand description

A single step in a Merkle-Patricia Trie proof.

Steps represent the different node types encountered while traversing the trie:

  • Branch: An internal node with multiple children, optimized using a mini Sparse-Merkle Tree
  • Fork: A special case of branch with exactly one neighbor
  • Leaf: A terminal node containing the actual key-value pair

Each step includes a skip value indicating the number of nibbles shared in the common prefix at that level, optimizing storage by avoiding redundant prefix storage.

§Branch Node Structure

Branch nodes use a 4-level binary Sparse-Merkle Tree to represent up to 16 children:

       ┌───────┴───────┐
   ┌───┴───┐       ┌───┴───┐
 ┌─┴─┐   ┌─┴─┐   ┌─┴─┐   ┌─┴─┐
┌┴┐ ┌┴┐ ┌┴┐ ┌┴┐ ┌┴┐ ┌┴┐ ┌┴┐ ┌┴┐
0 1 2 3 4 5 6 7 8 9 a b c d e f

This structure reduces the proof size from 1532=480 bytes to just 432=130 bytes per branch step while maintaining security through the Merkle Tree structure.

Variants§

§

Branch

A branch node with multiple children, using an optimized 4-level Sparse-Merkle Tree representation requiring only 4 hashes instead of up to 15.

The skip value indicates the length of the common prefix at this level. The neighbors array contains exactly 4 hashes representing the authentication path in the mini Sparse-Merkle Tree of the branch’s children.

Fields

§skip: usize
§neighbors: [Hash; 4]
§

Fork

A fork node with exactly one neighbor, requiring complete neighbor information for proper proof verification.

The skip value indicates the length of the common prefix at this level. The neighbor contains the complete information about the single adjacent node.

Fields

§skip: usize
§neighbor: Neighbor
§

Leaf

A leaf node containing the actual key-value pair.

The skip value indicates the length of the common prefix at this level. The key and value are the hashes of the original key-value pair.

Fields

§skip: usize
§key: Hash
§value: Hash

Implementations§

Source§

impl Step

Source

pub fn is_leaf(&self) -> bool

Source

pub fn is_branch(&self) -> bool

Source

pub fn is_fork(&self) -> bool

Trait Implementations§

Source§

impl Arbitrary for Step

Source§

type Parameters = ()

The type of parameters that arbitrary_with accepts for configuration of the generated Strategy. Parameters must implement Default.
Source§

type Strategy = BoxedStrategy<Step>

The type of Strategy used to generate values of type Self.
Source§

fn arbitrary_with(_args: Self::Parameters) -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). The strategy is passed the arguments given in args. Read more
Source§

fn arbitrary() -> Self::Strategy

Generates a Strategy for producing arbitrary values of type the implementing type (Self). Read more
Source§

impl Clone for Step

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Step

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Step

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Step

Source§

impl FromBytes for Step

Source§

fn from_bytes(bytes: &[u8]) -> Result<Self>

Source§

impl FromHex for Step

Source§

fn from_hex(input: &str) -> Result<Self>

Source§

impl Hash for Step

Source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl LowerHex for Step

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Step

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl PartialOrd for Step

Source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 (const: unstable) · Source§

fn lt(&self, other: &Rhs) -> bool

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 (const: unstable) · Source§

fn le(&self, other: &Rhs) -> bool

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 (const: unstable) · Source§

fn gt(&self, other: &Rhs) -> bool

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 (const: unstable) · Source§

fn ge(&self, other: &Rhs) -> bool

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl StructuralPartialEq for Step

Source§

impl ToBytes for Step

Source§

type Output = Vec<u8>

Source§

fn to_bytes(&self) -> Self::Output

Converts the value to a representation in bytes.
Source§

fn to_bytes_vec(&self) -> Vec<u8> ⓘ

Converts the value to a representation in bytes, as a vector. Read more
Source§

fn hash_bytes<D: Digest>(&self) -> Hash

This is a convenience method, and automatically derived from to_bytes.
Source§

fn is_zero(&self) -> bool

This is useful for checking if a value is empty.
Source§

fn to_bytes_mut(&mut self) -> &mut [u8] ⓘ

Provides mutable access to the bytes representation. Read more
Source§

impl ToHex for Step

Source§

fn to_hex(&self) -> String

Source§

impl UpperHex for Step

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Step

§

impl RefUnwindSafe for Step

§

impl Send for Step

§

impl Sync for Step

§

impl Unpin for Step

§

impl UnsafeUnpin for Step

§

impl UnwindSafe for Step

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V