Skip to content

Commit 4b5000e

Browse files
committed
refactor!: Remove feature mock
The so-called “MockMMR” is a historic artifact that is unused in direct dependencies. Turn it into a type that is accessible only from unit tests and remove the feature `mock` to slim down the public API. Replace `hashbrown::HashSet` with `std::collections::HashSet`, which amounts to the same thing but allows removing the direct dependency on `hashbrown`. Other changes, only relevant for developers of twenty-first: - rename the “MockMMR” to the more canonical “ArchivalMMR”. - reflect the internals more accurately by renaming the collection of all nodes from “leafs” to “nodes” - remove helper struct `MyVec<_>` - replace some helper functions with sane initialize functions - reduce visibility of some internal helper functions - rework documentation in some places
1 parent c1d8b94 commit 4b5000e

9 files changed

Lines changed: 440 additions & 615 deletions

File tree

twenty-first/Cargo.toml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ readme.workspace = true
1515
keywords = ["polynomial", "merkle-tree", "post-quantum", "algebra", "tip5"]
1616
categories = ["cryptography", "mathematics"]
1717

18-
[features]
19-
# include mock module
20-
mock = []
21-
2218
[dev-dependencies]
2319
blake3 = "1.5.5"
2420
bincode = "1.3.3"
@@ -38,7 +34,6 @@ features = ["user-hooks"]
3834
arbitrary = { version = "1", features = ["derive"] }
3935
bfieldcodec_derive = "0.7"
4036
get-size2 = { version = "0.3", features = ["derive"] }
41-
hashbrown = "0.15"
4237
hex = "0.4.3"
4338
itertools = "0.14"
4439
num-bigint = { version = "0.4", features = ["serde"] }

twenty-first/src/lib.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ pub mod math;
66
pub mod prelude;
77
pub mod util_types;
88

9-
#[cfg(any(test, feature = "mock"))]
10-
pub mod mock;
11-
129
// This is needed for `#[derive(BFieldCodec)]` macro to work consistently across crates.
1310
// Specifically:
1411
// From inside the `twenty-first` crate, we need to refer to `twenty-first` by `crate`.
@@ -64,7 +61,6 @@ pub(crate) mod tests {
6461
implements_usual_auto_traits::<math::lattice::kem::SecretKey>();
6562
implements_usual_auto_traits::<math::lattice::kem::PublicKey>();
6663
implements_usual_auto_traits::<math::lattice::kem::Ciphertext>();
67-
implements_usual_auto_traits::<mock::mmr::MockMmr>();
6864
implements_usual_auto_traits::<util_types::sponge::Domain>();
6965
implements_usual_auto_traits::<util_types::mmr::mmr_accumulator::MmrAccumulator>();
7066
implements_usual_auto_traits::<math::zerofier_tree::Branch<BFieldElement>>();

twenty-first/src/mock/mmr/mod.rs

Lines changed: 0 additions & 138 deletions
This file was deleted.

twenty-first/src/mock/mod.rs

Lines changed: 0 additions & 1 deletion
This file was deleted.

twenty-first/src/util_types/mmr.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ pub mod mmr_trait;
55
pub mod shared_advanced;
66
pub mod shared_basic;
77

8+
#[cfg(test)]
9+
pub(crate) mod archival_mmr;
10+
811
const TOO_MANY_LEAFS_ERR: &str =
912
"internal error: Merkle Mountain Ranges should have at most 2^63 leafs";

0 commit comments

Comments
 (0)