Skip to content

Commit b3772ac

Browse files
authored
Merge pull request #2850 from input-output-hk/damrobi/msnark/simplify-code
Moving mithril-stm errors into corresponding module
2 parents 0b49f0a + c0cbd4b commit b3772ac

File tree

35 files changed

+279
-237
lines changed

35 files changed

+279
-237
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

mithril-common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-common"
3-
version = "0.6.35"
3+
version = "0.6.37"
44
description = "Common types, interfaces, and utilities for Mithril nodes."
55
authors = { workspace = true }
66
edition = { workspace = true }

mithril-common/src/protocol/multi_signer.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl MultiSigner {
9191

9292
#[cfg(test)]
9393
mod test {
94-
use mithril_stm::MultiSignatureError;
94+
use mithril_stm::BlsSignatureError;
9595

9696
use crate::{
9797
crypto_helper::ProtocolAggregationError,
@@ -195,8 +195,8 @@ mod test {
195195
"Verify single signature should fail if the signer isn't in the registered parties",
196196
);
197197

198-
match error.downcast_ref::<MultiSignatureError>() {
199-
Some(MultiSignatureError::SignatureInvalid(_)) => (),
198+
match error.downcast_ref::<BlsSignatureError>() {
199+
Some(BlsSignatureError::SignatureInvalid(_)) => (),
200200
_ => panic!("Expected an SignatureInvalid error, got: {error:?}"),
201201
}
202202
}
@@ -221,8 +221,8 @@ mod test {
221221
.verify_single_signature(&ProtocolMessage::default(), &single_signature)
222222
.expect_err("Verify single signature should fail");
223223

224-
match error.downcast_ref::<MultiSignatureError>() {
225-
Some(MultiSignatureError::SignatureInvalid(_)) => (),
224+
match error.downcast_ref::<BlsSignatureError>() {
225+
Some(BlsSignatureError::SignatureInvalid(_)) => (),
226226
_ => panic!("Expected an SignatureInvalid error, got: {error:?}"),
227227
}
228228
}

mithril-stm/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## 0.6.4 (12-12-2025)
9+
10+
### Changed
11+
12+
- Error types in the Stm library moved to corresponding sub-modules.
13+
814
## 0.6.2 (11-27-2025)
915

1016
### Changed

mithril-stm/Cargo.toml

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mithril-stm"
3-
version = "0.6.3"
3+
version = "0.6.4"
44
edition = { workspace = true }
55
authors = { workspace = true }
66
homepage = { workspace = true }
@@ -17,8 +17,7 @@ crate-type = ["lib", "cdylib", "staticlib"]
1717
default = ["rug-backend"]
1818
rug-backend = ["rug/default"]
1919
num-integer-backend = ["dep:num-bigint", "dep:num-rational", "dep:num-traits"]
20-
benchmark-internals = [] # For benchmarking multi_sig
21-
future_proof_system = [] # For activating future proof systems
20+
benchmark-internals = [] # For benchmarking
2221
future_snark = [
2322
"dep:ff",
2423
"dep:group",
@@ -73,7 +72,7 @@ required-features = ["benchmark-internals"]
7372
[[bench]]
7473
name = "schnorr_sig"
7574
harness = false
76-
required-features = ["future_snark"]
75+
required-features = ["future_snark", "benchmark-internals"]
7776

7877
[[bench]]
7978
name = "stm"

mithril-stm/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ mod protocol;
117117
mod signature_scheme;
118118

119119
pub use protocol::*;
120+
pub use signature_scheme::BlsSignatureError;
120121

121122
#[cfg(feature = "benchmark-internals")]
122123
pub use signature_scheme::{

mithril-stm/src/membership_commitment/merkle_tree/commitment.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
use std::marker::PhantomData;
2+
13
use anyhow::{Context, anyhow};
24
use blake2::digest::{Digest, FixedOutput};
35
use serde::{Deserialize, Serialize};
4-
use std::marker::PhantomData;
56

6-
use super::{MerkleBatchPath, MerklePath, MerkleTreeLeaf, parent, sibling};
7-
use crate::{MerkleTreeError, StmResult};
7+
use crate::StmResult;
8+
9+
use super::{MerkleBatchPath, MerklePath, MerkleTreeError, MerkleTreeLeaf, parent, sibling};
810

911
/// `MerkleTree` commitment.
1012
/// This structure differs from `MerkleTree` in that it does not contain all elements, which are not always necessary.
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/// Error types related to merkle trees.
2+
#[derive(Debug, Clone, thiserror::Error)]
3+
pub enum MerkleTreeError {
4+
/// Serialization error
5+
#[error("Serialization of a merkle tree failed")]
6+
SerializationError,
7+
8+
/// Invalid merkle path
9+
#[error("Path does not verify against root")]
10+
PathInvalid(Vec<u8>),
11+
12+
/// Invalid merkle batch path
13+
#[error("Batch path does not verify against root")]
14+
BatchPathInvalid(Vec<u8>),
15+
}

mithril-stm/src/membership_commitment/merkle_tree/leaf.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ use std::cmp::Ordering;
22

33
use serde::{Deserialize, Serialize};
44

5-
use crate::{
6-
MerkleTreeError, Stake, StmResult, VerificationKey, signature_scheme::BlsVerificationKey,
7-
};
5+
use crate::{Stake, StmResult, VerificationKey, signature_scheme::BlsVerificationKey};
6+
7+
use super::MerkleTreeError;
88

99
/// The values that are committed in the Merkle Tree.
1010
/// Namely, a verified `VerificationKey` and its corresponding stake.

mithril-stm/src/membership_commitment/merkle_tree/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
//! Merkle tree implementation for STM
22
33
mod commitment;
4+
mod error;
45
mod leaf;
56
mod path;
67
mod tree;
78

89
pub use commitment::*;
10+
pub use error::*;
911
pub use leaf::*;
1012
pub use path::*;
1113
pub use tree::*;

0 commit comments

Comments
 (0)