Browse Source

Merge branch 'main' into next

next
Bobbin Threadbare 2 months ago
committed by GitHub
parent
commit
a424652ba7
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 5 deletions
  1. +5
    -0
      CHANGELOG.md
  2. +2
    -2
      src/merkle/mod.rs
  3. +15
    -3
      src/merkle/smt/mod.rs

+ 5
- 0
CHANGELOG.md

@ -2,6 +2,11 @@
- [BREAKING] Increment minimum supported Rust version to 1.84. - [BREAKING] Increment minimum supported Rust version to 1.84.
## 0.13.2 (2025-01-24)
- Made `InnerNode` and `NodeMutation` public. Implemented (de)serialization of `LeafIndex` (#367).
## 0.13.1 (2024-12-26) ## 0.13.1 (2024-12-26)
- Generate reverse mutations set on applying of mutations set, implemented serialization of `MutationsSet` (#355). - Generate reverse mutations set on applying of mutations set, implemented serialization of `MutationsSet` (#355).

+ 2
- 2
src/merkle/mod.rs

@ -24,8 +24,8 @@ mod smt;
#[cfg(feature = "internal")] #[cfg(feature = "internal")]
pub use smt::build_subtree_for_bench; pub use smt::build_subtree_for_bench;
pub use smt::{ pub use smt::{
LeafIndex, MutationSet, SimpleSmt, Smt, SmtLeaf, SmtLeafError, SmtProof, SmtProofError,
SubtreeLeaf, SMT_DEPTH, SMT_MAX_DEPTH, SMT_MIN_DEPTH,
InnerNode, LeafIndex, MutationSet, NodeMutation, SimpleSmt, Smt, SmtLeaf, SmtLeafError,
SmtProof, SmtProofError, SubtreeLeaf, SMT_DEPTH, SMT_MAX_DEPTH, SMT_MIN_DEPTH,
}; };
mod mmr; mod mmr;

+ 15
- 3
src/merkle/smt/mod.rs

@ -643,17 +643,29 @@ impl TryFrom for LeafIndex {
} }
} }
impl<const DEPTH: u8> Serializable for LeafIndex<DEPTH> {
fn write_into<W: ByteWriter>(&self, target: &mut W) {
self.index.write_into(target);
}
}
impl<const DEPTH: u8> Deserializable for LeafIndex<DEPTH> {
fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
Ok(Self { index: source.read()? })
}
}
// MUTATIONS // MUTATIONS
// ================================================================================================ // ================================================================================================
/// A change to an inner node of a [`SparseMerkleTree`] that hasn't yet been applied.
/// A change to an inner node of a sparse Merkle tree that hasn't yet been applied.
/// [`MutationSet`] stores this type in relation to a [`NodeIndex`] to keep track of what changes /// [`MutationSet`] stores this type in relation to a [`NodeIndex`] to keep track of what changes
/// need to occur at which node indices. /// need to occur at which node indices.
#[derive(Debug, Clone, PartialEq, Eq)] #[derive(Debug, Clone, PartialEq, Eq)]
pub enum NodeMutation { pub enum NodeMutation {
/// Corresponds to [`SparseMerkleTree::remove_inner_node()`].
/// Node needs to be removed.
Removal, Removal,
/// Corresponds to [`SparseMerkleTree::insert_inner_node()`].
/// Node needs to be inserted.
Addition(InnerNode), Addition(InnerNode),
} }

Loading…
Cancel
Save