diff --git a/Cargo.lock b/Cargo.lock index 6bdecdf269..54fd7138ad 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1157,6 +1157,7 @@ dependencies = [ "commonware-macros", "commonware-math", "commonware-p2p", + "commonware-parallel", "commonware-runtime", "commonware-utils", "futures", diff --git a/consensus/fuzz/Cargo.toml b/consensus/fuzz/Cargo.toml index 21638b7dd3..ddb506016f 100644 --- a/consensus/fuzz/Cargo.toml +++ b/consensus/fuzz/Cargo.toml @@ -17,6 +17,7 @@ commonware-cryptography.workspace = true commonware-macros.workspace = true commonware-math.workspace = true commonware-p2p.workspace = true +commonware-parallel.workspace = true commonware-runtime.workspace = true commonware-utils.workspace = true futures.workspace = true diff --git a/consensus/fuzz/fuzz_targets/simplex_bls12381_threshold_minpk.rs b/consensus/fuzz/fuzz_targets/simplex_bls12381_threshold_minpk.rs index f723b843b2..0e09ab98ba 100644 --- a/consensus/fuzz/fuzz_targets/simplex_bls12381_threshold_minpk.rs +++ b/consensus/fuzz/fuzz_targets/simplex_bls12381_threshold_minpk.rs @@ -6,13 +6,14 @@ use commonware_cryptography::{ bls12381::primitives::variant::MinPk, certificate::mocks::Fixture, ed25519::PublicKey as Ed25519PublicKey, }; +use commonware_parallel::Sequential; use commonware_runtime::deterministic; use libfuzzer_sys::fuzz_target; struct SimplexBls12381MinPk; impl Simplex for SimplexBls12381MinPk { - type Scheme = bls12381_threshold::Scheme; + type Scheme = bls12381_threshold::Scheme; type Elector = Random; fn fixture( diff --git a/consensus/fuzz/fuzz_targets/simplex_bls12381_threshold_minsig.rs b/consensus/fuzz/fuzz_targets/simplex_bls12381_threshold_minsig.rs index 81f066ee40..7b19f93cf7 100644 --- a/consensus/fuzz/fuzz_targets/simplex_bls12381_threshold_minsig.rs +++ b/consensus/fuzz/fuzz_targets/simplex_bls12381_threshold_minsig.rs @@ -6,13 +6,14 @@ use commonware_cryptography::{ bls12381::primitives::variant::MinSig, certificate::mocks::Fixture, ed25519::PublicKey as Ed25519PublicKey, }; +use commonware_parallel::Sequential; use commonware_runtime::deterministic; use libfuzzer_sys::fuzz_target; struct SimplexBls12381MinSig; impl Simplex for SimplexBls12381MinSig { - type Scheme = bls12381_threshold::Scheme; + type Scheme = bls12381_threshold::Scheme; type Elector = Random; fn fixture( diff --git a/consensus/fuzz/fuzz_targets/simplex_elector.rs b/consensus/fuzz/fuzz_targets/simplex_elector.rs index a4ba1fb0e1..51a2e0b5b1 100644 --- a/consensus/fuzz/fuzz_targets/simplex_elector.rs +++ b/consensus/fuzz/fuzz_targets/simplex_elector.rs @@ -15,6 +15,7 @@ use commonware_cryptography::{ Sha256, Signer, }; use commonware_math::algebra::Random as _; +use commonware_parallel::Sequential; use commonware_utils::{ordered::Set, TryCollect}; use libfuzzer_sys::fuzz_target; use rand::{rngs::StdRng, SeedableRng}; @@ -76,10 +77,18 @@ fuzz_target!(|input: FuzzInput| { fuzz::(&input, RoundRobin::::shuffled(seed), None); } FuzzElector::RandomMinPk(certificate) => { - fuzz::, _>(&input, Random, Some(certificate)); + fuzz::, _>( + &input, + Random, + Some(certificate), + ); } FuzzElector::RandomMinSig(certificate) => { - fuzz::, _>(&input, Random, Some(certificate)); + fuzz::, _>( + &input, + Random, + Some(certificate), + ); } } }); diff --git a/consensus/fuzz/fuzz_targets/simplex_messages.rs b/consensus/fuzz/fuzz_targets/simplex_messages.rs index 327bd6c9cd..2b362b1435 100644 --- a/consensus/fuzz/fuzz_targets/simplex_messages.rs +++ b/consensus/fuzz/fuzz_targets/simplex_messages.rs @@ -15,13 +15,14 @@ use commonware_cryptography::{ ed25519::PublicKey, sha256, }; +use commonware_parallel::Sequential; use libfuzzer_sys::fuzz_target; type Ed25519Scheme = ed25519::Scheme; type Bls12381MultisigMinPk = bls12381_multisig::Scheme; type Bls12381MultisigMinSig = bls12381_multisig::Scheme; -type ThresholdSchemeMinPk = bls12381_threshold::Scheme; -type ThresholdSchemeMinSig = bls12381_threshold::Scheme; +type ThresholdSchemeMinPk = bls12381_threshold::Scheme; +type ThresholdSchemeMinSig = bls12381_threshold::Scheme; #[derive(Arbitrary, Debug)] enum FuzzInput { diff --git a/consensus/src/marshal/mod.rs b/consensus/src/marshal/mod.rs index 4fe0f4dcf7..938ff9aadf 100644 --- a/consensus/src/marshal/mod.rs +++ b/consensus/src/marshal/mod.rs @@ -128,6 +128,7 @@ mod tests { simulated::{self, Link, Network, Oracle}, Manager, }; + use commonware_parallel::Sequential; use commonware_runtime::{buffer::PoolRef, deterministic, Clock, Metrics, Quota, Runner}; use commonware_storage::archive::immutable; use commonware_utils::{vec::NonEmptyVec, NZUsize, NZU16, NZU64}; @@ -147,7 +148,7 @@ mod tests { type B = Block; type K = PublicKey; type V = MinPk; - type S = bls12381_threshold::Scheme; + type S = bls12381_threshold::Scheme; type P = ConstantProvider; const PAGE_SIZE: NonZeroU16 = NZU16!(1024); diff --git a/consensus/src/simplex/elector.rs b/consensus/src/simplex/elector.rs index dfa998ede6..014f0d87fc 100644 --- a/consensus/src/simplex/elector.rs +++ b/consensus/src/simplex/elector.rs @@ -233,13 +233,14 @@ mod tests { bls12381::primitives::variant::MinPk, certificate::mocks::Fixture, sha256::Digest as Sha256Digest, Sha256, }; + use commonware_parallel::Sequential; use commonware_utils::{quorum_from_slice, TryFromIterator}; use rand::{rngs::StdRng, SeedableRng}; const NAMESPACE: &[u8] = b"test"; type ThresholdScheme = - bls12381_threshold::Scheme; + bls12381_threshold::Scheme; #[test] fn round_robin_rotates_through_participants() { diff --git a/consensus/src/simplex/mod.rs b/consensus/src/simplex/mod.rs index bec8ef5928..adc8f439a2 100644 --- a/consensus/src/simplex/mod.rs +++ b/consensus/src/simplex/mod.rs @@ -317,6 +317,7 @@ mod tests { simulated::{Config, Link, Network, Oracle, Receiver, Sender, SplitOrigin, SplitTarget}, Recipients, Sender as _, }; + use commonware_parallel::Sequential; use commonware_runtime::{ buffer::PoolRef, count_running_tasks, deterministic, Clock, Metrics, Quota, Runner, Spawner, }; @@ -4763,7 +4764,7 @@ mod tests { fn tle() where V: Variant, - L: Elector>, + L: Elector>, { // Create context let n = 4; diff --git a/consensus/src/simplex/scheme/bls12381_threshold.rs b/consensus/src/simplex/scheme/bls12381_threshold.rs index f0746da487..36284c9a85 100644 --- a/consensus/src/simplex/scheme/bls12381_threshold.rs +++ b/consensus/src/simplex/scheme/bls12381_threshold.rs @@ -75,7 +75,7 @@ enum Role { /// The scheme is generic over a [`Strategy`] which determines whether cryptographic /// operations such as signature recovery and batch verification run sequentially or in parallel. #[derive(Clone, Debug)] -pub struct Scheme { +pub struct Scheme { role: Role, strategy: S, } @@ -274,7 +274,7 @@ pub fn fixture( namespace: &[u8], n: u32, ) -> commonware_cryptography::certificate::mocks::Fixture< - Scheme, + Scheme, > where V: Variant, @@ -356,7 +356,7 @@ impl Seed { } /// Verifies the threshold signature on this [Seed]. - pub fn verify(&self, scheme: &Scheme) -> bool { + pub fn verify(&self, scheme: &Scheme) -> bool { let seed_message = self.round.encode(); ops::verify_message::( @@ -446,13 +446,17 @@ pub trait Seedable { fn seed(&self) -> Seed; } -impl Seedable for Notarization, D> { +impl Seedable + for Notarization, D> +{ fn seed(&self) -> Seed { Seed::new(self.proposal.round, self.certificate.seed_signature) } } -impl Seedable for Finalization, D> { +impl Seedable + for Finalization, D> +{ fn seed(&self) -> Seed { Seed::new(self.proposal.round, self.certificate.seed_signature) } @@ -773,7 +777,7 @@ mod tests { const NAMESPACE: &[u8] = b"bls-threshold-signing-scheme"; - type Scheme = super::Scheme; + type Scheme = super::Scheme; type Signature = super::Signature; fn setup_signers(n: u32, seed: u64) -> (Vec>, Scheme) { diff --git a/consensus/src/simplex/scheme/reporter.rs b/consensus/src/simplex/scheme/reporter.rs index 427f2a1227..1bb3321488 100644 --- a/consensus/src/simplex/scheme/reporter.rs +++ b/consensus/src/simplex/scheme/reporter.rs @@ -123,6 +123,7 @@ mod tests { sha256::Digest as Sha256Digest, Hasher, Sha256, }; + use commonware_parallel::Sequential; use futures::executor::block_on; use rand::{rngs::StdRng, SeedableRng}; use std::sync::{Arc, Mutex}; @@ -260,7 +261,7 @@ mod tests { } = bls12381_threshold::fixture::(&mut rng, NAMESPACE, 4); assert!( - !bls12381_threshold::Scheme::::is_attributable(), + !bls12381_threshold::Scheme::::is_attributable(), "BLS threshold must be non-attributable" ); @@ -307,7 +308,7 @@ mod tests { } = bls12381_threshold::fixture::(&mut rng, NAMESPACE, 4); assert!( - !bls12381_threshold::Scheme::::is_attributable(), + !bls12381_threshold::Scheme::::is_attributable(), "BLS threshold must be non-attributable" ); diff --git a/consensus/src/simplex/types.rs b/consensus/src/simplex/types.rs index 2872beab7d..063783b7d7 100644 --- a/consensus/src/simplex/types.rs +++ b/consensus/src/simplex/types.rs @@ -3241,8 +3241,9 @@ mod tests { use crate::simplex::scheme::bls12381_threshold; use commonware_codec::conformance::CodecConformance; use commonware_cryptography::{ed25519::PublicKey, sha256::Digest as Sha256Digest}; + use commonware_parallel::Sequential; - type Scheme = bls12381_threshold::Scheme; + type Scheme = bls12381_threshold::Scheme; commonware_conformance::conformance_tests! { CodecConformance>,