diff --git a/.circleci/config.yml b/.circleci/config.yml index 2402f7faa9..0c7567f0d6 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -134,7 +134,7 @@ commands: jobs: snarkvm: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - checkout @@ -144,7 +144,7 @@ jobs: algorithms: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -153,7 +153,7 @@ jobs: algorithms-profiler: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: # This runs a single test with profiler enabled @@ -163,7 +163,7 @@ jobs: circuit: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -172,7 +172,7 @@ jobs: circuit-account: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -182,7 +182,7 @@ jobs: # This checks that no `console` structs are used in core circuit logic. circuit-account-noconsole: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -192,7 +192,7 @@ jobs: circuit-algorithms: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -201,7 +201,7 @@ jobs: circuit-collections: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -211,7 +211,7 @@ jobs: # This checks that no `console` structs are used in core circuit logic. circuit-collections-noconsole: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -221,7 +221,7 @@ jobs: circuit-environment: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -230,7 +230,7 @@ jobs: circuit-network: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -239,7 +239,7 @@ jobs: circuit-program: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -248,7 +248,7 @@ jobs: circuit-types: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -257,7 +257,7 @@ jobs: circuit-types-address: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -266,7 +266,7 @@ jobs: circuit-types-boolean: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -275,7 +275,7 @@ jobs: circuit-types-field: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -284,7 +284,7 @@ jobs: circuit-types-group: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -293,7 +293,7 @@ jobs: circuit-types-integers: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -303,7 +303,7 @@ jobs: circuit-types-scalar: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -312,7 +312,7 @@ jobs: circuit-types-string: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -320,7 +320,7 @@ jobs: cache_key: snarkvm-circuit-types-string-cache console: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -329,7 +329,7 @@ jobs: console-account: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -338,7 +338,7 @@ jobs: console-algorithms: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -347,7 +347,7 @@ jobs: console-collections: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -356,7 +356,7 @@ jobs: console-network: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -365,7 +365,7 @@ jobs: console-network-environment: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -374,7 +374,7 @@ jobs: console-program: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -383,7 +383,7 @@ jobs: console-types: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -392,7 +392,7 @@ jobs: console-types-address: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -401,7 +401,7 @@ jobs: console-types-boolean: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -410,7 +410,7 @@ jobs: console-types-field: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -419,7 +419,7 @@ jobs: console-types-group: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -428,7 +428,7 @@ jobs: console-types-integers: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -437,7 +437,7 @@ jobs: console-types-scalar: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -446,7 +446,7 @@ jobs: console-types-string: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -455,7 +455,7 @@ jobs: curves: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -464,7 +464,7 @@ jobs: fields: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -473,7 +473,7 @@ jobs: ledger: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -482,7 +482,7 @@ jobs: ledger-with-rocksdb: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -492,7 +492,7 @@ jobs: ledger-authority: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -501,7 +501,7 @@ jobs: ledger-block: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -510,7 +510,7 @@ jobs: ledger-coinbase: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -519,7 +519,7 @@ jobs: ledger-committee: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -528,7 +528,7 @@ jobs: ledger-narwhal: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -537,7 +537,7 @@ jobs: ledger-narwhal-batch-certificate: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -546,7 +546,7 @@ jobs: ledger-narwhal-batch-header: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -555,7 +555,7 @@ jobs: ledger-narwhal-data: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -564,7 +564,7 @@ jobs: ledger-narwhal-subdag: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -573,7 +573,7 @@ jobs: ledger-narwhal-transmission: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -582,7 +582,7 @@ jobs: ledger-narwhal-transmission-id: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -591,7 +591,7 @@ jobs: ledger-query: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -600,7 +600,7 @@ jobs: ledger-store: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -610,7 +610,7 @@ jobs: ledger-test-helpers: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -619,7 +619,7 @@ jobs: parameters: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -628,7 +628,7 @@ jobs: synthesizer: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -638,7 +638,7 @@ jobs: synthesizer-integration: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -648,7 +648,7 @@ jobs: synthesizer-process: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -657,7 +657,7 @@ jobs: synthesizer-process-with-rocksdb: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -667,7 +667,7 @@ jobs: synthesizer-program: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -677,7 +677,7 @@ jobs: synthesizer-program-integration-keccak: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -687,7 +687,7 @@ jobs: synthesizer-program-integration-psd: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -697,7 +697,7 @@ jobs: synthesizer-program-integration-sha: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -707,7 +707,7 @@ jobs: synthesizer-program-integration-rest: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -717,7 +717,7 @@ jobs: synthesizer-snark: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - run_serial: @@ -726,7 +726,7 @@ jobs: utilities: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -735,7 +735,7 @@ jobs: utilities-derives: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - run_serial: @@ -744,7 +744,7 @@ jobs: wasm: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - checkout @@ -762,7 +762,7 @@ jobs: check-fmt: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - checkout @@ -778,7 +778,7 @@ jobs: check-clippy: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: 2xlarge steps: - checkout @@ -795,7 +795,7 @@ jobs: check-all-targets: docker: - - image: cimg/rust:1.71.1 + - image: cimg/rust:1.72.1 resource_class: xlarge steps: - checkout diff --git a/.rusty-hook.toml b/.rusty-hook.toml index c8bbf1f690..210316b294 100644 --- a/.rusty-hook.toml +++ b/.rusty-hook.toml @@ -1,5 +1,5 @@ [hooks] -pre-commit = "cargo clippy --workspace --all-targets --all-features && cargo +nightly fmt --all -- --check" +pre-commit = "cargo +nightly fmt --all -- --check && cargo clippy --workspace --all-targets --all-features" [logging] verbose = true diff --git a/Cargo.lock b/Cargo.lock index 535855bb94..fb64c0e982 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -738,17 +738,6 @@ dependencies = [ "powerfmt", ] -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote 1.0.33", - "syn 1.0.109", -] - [[package]] name = "digest" version = "0.10.7" @@ -3091,7 +3080,6 @@ version = "0.16.16" dependencies = [ "aleo-std", "anyhow", - "derivative", "itertools 0.11.0", "num-traits", "rand", diff --git a/Cargo.toml b/Cargo.toml index 650a738747..ea85c06b0d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -22,7 +22,7 @@ categories = [ include = [ "Cargo.toml", "vm", "README.md", "LICENSE.md" ] license = "Apache-2.0" edition = "2021" -rust-version = "1.70" +rust-version = "1.72.1" [workspace] members = [ diff --git a/algorithms/src/fft/polynomial/sparse.rs b/algorithms/src/fft/polynomial/sparse.rs index f38967f99f..16e397e357 100644 --- a/algorithms/src/fft/polynomial/sparse.rs +++ b/algorithms/src/fft/polynomial/sparse.rs @@ -105,7 +105,7 @@ impl SparsePolynomial { *cur_coeff += *self_coeff * other_coeff; } } - SparsePolynomial::from_coefficients(result.into_iter()) + SparsePolynomial::from_coefficients(result) } } } diff --git a/algorithms/src/polycommit/test_templates.rs b/algorithms/src/polycommit/test_templates.rs index 5664111254..60f73f027f 100644 --- a/algorithms/src/polycommit/test_templates.rs +++ b/algorithms/src/polycommit/test_templates.rs @@ -263,7 +263,7 @@ where let max_degree = max_degree.unwrap_or_else(|| distributions::Uniform::from(8..=64).sample(rng)); let pp = SonicKZG10::::load_srs(max_degree)?; let universal_prover = &pp.to_universal_prover().unwrap(); - let supported_degree_bounds = vec![1 << 10, 1 << 15, 1 << 20, 1 << 25, 1 << 30]; + let supported_degree_bounds = [1 << 10, 1 << 15, 1 << 20, 1 << 25, 1 << 30]; for _ in 0..num_iters { let supported_degree = @@ -391,7 +391,7 @@ fn equation_test_template>( let max_degree = max_degree.unwrap_or_else(|| distributions::Uniform::from(8..=64).sample(rng)); let pp = SonicKZG10::::load_srs(max_degree)?; let universal_prover = &pp.to_universal_prover().unwrap(); - let supported_degree_bounds = vec![1 << 10, 1 << 15, 1 << 20, 1 << 25, 1 << 30]; + let supported_degree_bounds = [1 << 10, 1 << 15, 1 << 20, 1 << 25, 1 << 30]; for _ in 0..num_iters { let supported_degree = diff --git a/algorithms/src/snark/varuna/ahp/prover/mod.rs b/algorithms/src/snark/varuna/ahp/prover/mod.rs index 9cb0f042bb..68adb3038c 100644 --- a/algorithms/src/snark/varuna/ahp/prover/mod.rs +++ b/algorithms/src/snark/varuna/ahp/prover/mod.rs @@ -26,4 +26,4 @@ pub(crate) use oracles::*; mod round_functions; mod state; -pub(self) use state::*; +use state::*; diff --git a/algorithms/src/snark/varuna/ahp/prover/oracles.rs b/algorithms/src/snark/varuna/ahp/prover/oracles.rs index 725b6a291d..37b1c94728 100644 --- a/algorithms/src/snark/varuna/ahp/prover/oracles.rs +++ b/algorithms/src/snark/varuna/ahp/prover/oracles.rs @@ -37,7 +37,7 @@ impl FirstOracles { /// Iterate over the polynomials output by the prover in the first round. pub fn into_iter(self) -> impl Iterator> { - self.batches.into_values().flat_map(|b| b.into_iter()).map(|b| b.0).chain(self.mask_poly.into_iter()) + self.batches.into_values().flat_map(|b| b.into_iter()).map(|b| b.0).chain(self.mask_poly) } pub fn matches_info(&self, info: &BTreeMap) -> bool { diff --git a/algorithms/src/snark/varuna/ahp/verifier/messages.rs b/algorithms/src/snark/varuna/ahp/verifier/messages.rs index b939a86c74..1abd254d6d 100644 --- a/algorithms/src/snark/varuna/ahp/verifier/messages.rs +++ b/algorithms/src/snark/varuna/ahp/verifier/messages.rs @@ -62,11 +62,7 @@ pub struct FourthMessage { impl FourthMessage { pub fn into_iter(self) -> impl Iterator { - self.delta_a - .into_iter() - .zip_eq(self.delta_b.into_iter()) - .zip_eq(self.delta_c.into_iter()) - .flat_map(|((r_a, r_b), r_c)| [r_a, r_b, r_c]) + self.delta_a.into_iter().zip_eq(self.delta_b).zip_eq(self.delta_c).flat_map(|((r_a, r_b), r_c)| [r_a, r_b, r_c]) } } diff --git a/algorithms/src/snark/varuna/varuna.rs b/algorithms/src/snark/varuna/varuna.rs index df01ee4425..b4fb57a534 100644 --- a/algorithms/src/snark/varuna/varuna.rs +++ b/algorithms/src/snark/varuna/varuna.rs @@ -302,7 +302,7 @@ where // (since the first coeff is 1), and so we squeeze out `num_polynomials` points. let mut challenges = sponge.squeeze_nonnative_field_elements(verifying_key.circuit_commitments.len()); let point = challenges.pop().ok_or(anyhow!("Failed to squeeze random element"))?; - let combiners = core::iter::once(E::Fr::one()).chain(challenges.into_iter()); + let combiners = core::iter::once(E::Fr::one()).chain(challenges); // We will construct a linear combination and provide a proof of evaluation of the lc at `point`. let (lc, evaluation) = diff --git a/circuit/program/src/data/plaintext/mod.rs b/circuit/program/src/data/plaintext/mod.rs index efe8c8eaca..8f717c34ea 100644 --- a/circuit/program/src/data/plaintext/mod.rs +++ b/circuit/program/src/data/plaintext/mod.rs @@ -132,144 +132,117 @@ mod tests { // Test a random struct with literal members. run_test(Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::new(Mode::Private, "a".try_into()?), - Plaintext::::Literal( - Literal::Boolean(Boolean::new(Mode::Private, true)), - OnceCell::new(), - ), - ), - ( - Identifier::new(Mode::Private, "b".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + IndexMap::from_iter(vec![ + ( + Identifier::new(Mode::Private, "a".try_into()?), + Plaintext::::Literal(Literal::Boolean(Boolean::new(Mode::Private, true)), OnceCell::new()), + ), + ( + Identifier::new(Mode::Private, "b".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ] - .into_iter(), - ), + ), + ]), OnceCell::new(), )); // Test a random struct with array members. run_test(Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::new(Mode::Private, "a".try_into()?), - Plaintext::::Literal( - Literal::Boolean(Boolean::new(Mode::Private, true)), - OnceCell::new(), - ), + IndexMap::from_iter(vec![ + ( + Identifier::new(Mode::Private, "a".try_into()?), + Plaintext::::Literal(Literal::Boolean(Boolean::new(Mode::Private, true)), OnceCell::new()), + ), + ( + Identifier::new(Mode::Private, "b".try_into()?), + Plaintext::::Array( + vec![ + Plaintext::::Literal( + Literal::Boolean(Boolean::new(Mode::Private, true)), + OnceCell::new(), + ), + Plaintext::::Literal( + Literal::Boolean(Boolean::new(Mode::Private, false)), + OnceCell::new(), + ), + ], + OnceCell::new(), ), - ( - Identifier::new(Mode::Private, "b".try_into()?), - Plaintext::::Array( - vec![ + ), + ]), + OnceCell::new(), + )); + + // Test random deeply-nested struct. + run_test(Plaintext::::Struct( + IndexMap::from_iter(vec![ + ( + Identifier::new(Mode::Private, "a".try_into()?), + Plaintext::::Literal(Literal::Boolean(Boolean::new(Mode::Private, true)), OnceCell::new()), + ), + ( + Identifier::new(Mode::Private, "b".try_into()?), + Plaintext::::Struct( + IndexMap::from_iter(vec![ + ( + Identifier::new(Mode::Private, "c".try_into()?), Plaintext::::Literal( Literal::Boolean(Boolean::new(Mode::Private, true)), OnceCell::new(), ), - Plaintext::::Literal( - Literal::Boolean(Boolean::new(Mode::Private, false)), + ), + ( + Identifier::new(Mode::Private, "d".try_into()?), + Plaintext::::Struct( + IndexMap::from_iter(vec![ + ( + Identifier::new(Mode::Private, "e".try_into()?), + Plaintext::::Literal( + Literal::Boolean(Boolean::new(Mode::Private, true)), + OnceCell::new(), + ), + ), + ( + Identifier::new(Mode::Private, "f".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), + ), + ), + ]), OnceCell::new(), ), - ], - OnceCell::new(), - ), - ), - ] - .into_iter(), - ), - OnceCell::new(), - )); - - // Test random deeply-nested struct. - run_test(Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::new(Mode::Private, "a".try_into()?), - Plaintext::::Literal( - Literal::Boolean(Boolean::new(Mode::Private, true)), - OnceCell::new(), - ), - ), - ( - Identifier::new(Mode::Private, "b".try_into()?), - Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::new(Mode::Private, "c".try_into()?), + ), + ( + Identifier::new(Mode::Private, "g".try_into()?), + Plaintext::::Array( + vec![ Plaintext::::Literal( Literal::Boolean(Boolean::new(Mode::Private, true)), OnceCell::new(), ), - ), - ( - Identifier::new(Mode::Private, "d".try_into()?), - Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::new(Mode::Private, "e".try_into()?), - Plaintext::::Literal( - Literal::Boolean(Boolean::new(Mode::Private, true)), - OnceCell::new(), - ), - ), - ( - Identifier::new(Mode::Private, "f".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new( - Mode::Private, - Uniform::rand(&mut rng), - )), - OnceCell::new(), - ), - ), - ] - .into_iter(), - ), - OnceCell::new(), - ), - ), - ( - Identifier::new(Mode::Private, "g".try_into()?), - Plaintext::::Array( - vec![ - Plaintext::::Literal( - Literal::Boolean(Boolean::new(Mode::Private, true)), - OnceCell::new(), - ), - Plaintext::::Literal( - Literal::Boolean(Boolean::new(Mode::Private, false)), - OnceCell::new(), - ), - ], + Plaintext::::Literal( + Literal::Boolean(Boolean::new(Mode::Private, false)), OnceCell::new(), ), - ), - ] - .into_iter(), + ], + OnceCell::new(), + ), ), - OnceCell::new(), - ), + ]), + OnceCell::new(), ), - ( - Identifier::new(Mode::Private, "h".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + ), + ( + Identifier::new(Mode::Private, "h".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ] - .into_iter(), - ), + ), + ]), OnceCell::new(), )); @@ -304,69 +277,60 @@ mod tests { run_test(Plaintext::::Array( vec![ Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::new(Mode::Private, "x".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + IndexMap::from_iter(vec![ + ( + Identifier::new(Mode::Private, "x".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ( - Identifier::new(Mode::Private, "y".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + ), + ( + Identifier::new(Mode::Private, "y".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ] - .into_iter(), - ), + ), + ]), OnceCell::new(), ), Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::new(Mode::Private, "x".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + IndexMap::from_iter(vec![ + ( + Identifier::new(Mode::Private, "x".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ( - Identifier::new(Mode::Private, "y".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + ), + ( + Identifier::new(Mode::Private, "y".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ] - .into_iter(), - ), + ), + ]), OnceCell::new(), ), Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::new(Mode::Private, "x".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + IndexMap::from_iter(vec![ + ( + Identifier::new(Mode::Private, "x".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ( - Identifier::new(Mode::Private, "y".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + ), + ( + Identifier::new(Mode::Private, "y".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ] - .into_iter(), - ), + ), + ]), OnceCell::new(), ), ], @@ -382,25 +346,22 @@ mod tests { OnceCell::new(), ), Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::new(Mode::Private, "x".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + IndexMap::from_iter(vec![ + ( + Identifier::new(Mode::Private, "x".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ( - Identifier::new(Mode::Private, "y".try_into()?), - Plaintext::::Literal( - Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), - OnceCell::new(), - ), + ), + ( + Identifier::new(Mode::Private, "y".try_into()?), + Plaintext::::Literal( + Literal::Field(Field::new(Mode::Private, Uniform::rand(&mut rng))), + OnceCell::new(), ), - ] - .into_iter(), - ), + ), + ]), OnceCell::new(), ), ], diff --git a/circuit/program/src/data/record/decrypt.rs b/circuit/program/src/data/record/decrypt.rs index 4be3944a2f..b7f9d1a0bd 100644 --- a/circuit/program/src/data/record/decrypt.rs +++ b/circuit/program/src/data/record/decrypt.rs @@ -102,22 +102,16 @@ mod tests { let randomizer = Scalar::new(Mode::Private, Uniform::rand(rng)); let record = Record { owner, - data: IndexMap::from_iter( - vec![ - ( - Identifier::from_str("a")?, - Entry::Private(Plaintext::from(Literal::Field(Field::new(Mode::Private, Uniform::rand(rng))))), - ), - ( - Identifier::from_str("b")?, - Entry::Private(Plaintext::from(Literal::Scalar(Scalar::new( - Mode::Private, - Uniform::rand(rng), - )))), - ), - ] - .into_iter(), - ), + data: IndexMap::from_iter(vec![ + ( + Identifier::from_str("a")?, + Entry::Private(Plaintext::from(Literal::Field(Field::new(Mode::Private, Uniform::rand(rng))))), + ), + ( + Identifier::from_str("b")?, + Entry::Private(Plaintext::from(Literal::Scalar(Scalar::new(Mode::Private, Uniform::rand(rng))))), + ), + ]), nonce: A::g_scalar_multiply(&randomizer), }; diff --git a/circuit/types/field/src/helpers/from_bits.rs b/circuit/types/field/src/helpers/from_bits.rs index d1f7abfda2..3376cfa199 100644 --- a/circuit/types/field/src/helpers/from_bits.rs +++ b/circuit/types/field/src/helpers/from_bits.rs @@ -126,7 +126,7 @@ mod tests { }); // Add excess zero bits. - let candidate = vec![given_bits, vec![Boolean::new(mode, false); i as usize]].concat(); + let candidate = [given_bits, vec![Boolean::new(mode, false); i as usize]].concat(); Circuit::scope(&format!("Excess {mode} {i}"), || { let candidate = Field::::from_bits_le(&candidate); @@ -171,7 +171,7 @@ mod tests { }); // Add excess zero bits. - let candidate = vec![vec![Boolean::new(mode, false); i as usize], given_bits].concat(); + let candidate = [vec![Boolean::new(mode, false); i as usize], given_bits].concat(); Circuit::scope(&format!("Excess {mode} {i}"), || { let candidate = Field::::from_bits_be(&candidate); diff --git a/circuit/types/integers/src/helpers/from_bits.rs b/circuit/types/integers/src/helpers/from_bits.rs index ffcdb0ff89..8919575dd8 100644 --- a/circuit/types/integers/src/helpers/from_bits.rs +++ b/circuit/types/integers/src/helpers/from_bits.rs @@ -74,7 +74,7 @@ mod tests { }); // Add excess zero bits. - let candidate = vec![given_bits, vec![Boolean::new(mode, false); i as usize]].concat(); + let candidate = [given_bits, vec![Boolean::new(mode, false); i as usize]].concat(); Circuit::scope(&format!("Excess {mode} {i}"), || { let candidate = Integer::::from_bits_le(&candidate); @@ -114,7 +114,7 @@ mod tests { }); // Add excess zero bits. - let candidate = vec![vec![Boolean::new(mode, false); i as usize], given_bits].concat(); + let candidate = [vec![Boolean::new(mode, false); i as usize], given_bits].concat(); Circuit::scope(&format!("Excess {mode} {i}"), || { let candidate = Integer::::from_bits_be(&candidate); diff --git a/circuit/types/scalar/src/helpers/from_bits.rs b/circuit/types/scalar/src/helpers/from_bits.rs index 2b0522c70b..2422607938 100644 --- a/circuit/types/scalar/src/helpers/from_bits.rs +++ b/circuit/types/scalar/src/helpers/from_bits.rs @@ -116,7 +116,7 @@ mod tests { }); // Add excess zero bits. - let candidate = vec![given_bits, vec![Boolean::new(mode, false); i as usize]].concat(); + let candidate = [given_bits, vec![Boolean::new(mode, false); i as usize]].concat(); Circuit::scope(&format!("Excess {mode} {i}"), || { let candidate = Scalar::::from_bits_le(&candidate); @@ -157,7 +157,7 @@ mod tests { }); // Add excess zero bits. - let candidate = vec![vec![Boolean::new(mode, false); i as usize], given_bits].concat(); + let candidate = [vec![Boolean::new(mode, false); i as usize], given_bits].concat(); Circuit::scope(&format!("Excess {mode} {i}"), || { let candidate = Scalar::::from_bits_be(&candidate); diff --git a/console/account/src/compute_key/from_bits.rs b/console/account/src/compute_key/from_bits.rs index b26d7e0ddb..fa1f73e576 100644 --- a/console/account/src/compute_key/from_bits.rs +++ b/console/account/src/compute_key/from_bits.rs @@ -73,7 +73,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); let candidate = ComputeKey::::from_bits_le(&candidate)?; assert_eq!(expected, candidate); @@ -96,7 +96,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); let candidate = ComputeKey::::from_bits_be(&candidate)?; assert_eq!(expected, candidate); diff --git a/console/account/src/signature/from_bits.rs b/console/account/src/signature/from_bits.rs index 95c30b02be..5892bbfc7c 100644 --- a/console/account/src/signature/from_bits.rs +++ b/console/account/src/signature/from_bits.rs @@ -91,7 +91,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); let candidate = Signature::::from_bits_le(&candidate)?; assert_eq!(expected, candidate); @@ -114,7 +114,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); let candidate = Signature::::from_bits_be(&candidate)?; assert_eq!(expected, candidate); diff --git a/console/network/environment/src/lib.rs b/console/network/environment/src/lib.rs index bfd495d509..c7c54316ac 100644 --- a/console/network/environment/src/lib.rs +++ b/console/network/environment/src/lib.rs @@ -25,7 +25,37 @@ pub mod traits; pub use traits::*; pub mod prelude { - pub use crate::{environment::*, helpers::*, traits::*}; + pub use crate::{ + environment::*, + helpers::*, + traits::{ + algorithms::*, + arithmetic::*, + bitwise::*, + from_bits::*, + from_field::*, + parse::*, + parse_string::*, + to_bits_le, + to_field::*, + type_name::*, + types::{ + integer_magnitude::Magnitude, + integer_type::{ + CheckedPow, + CheckedShl, + IntegerProperties, + IntegerType, + WrappingDiv, + WrappingPow, + WrappingRem, + }, + *, + }, + visibility::*, + ToBits, + }, + }; pub use snarkvm_curves::{AffineCurve, MontgomeryParameters, ProjectiveCurve, TwistedEdwardsParameters}; pub use snarkvm_fields::{Field as _, PrimeField as _, SquareRootField as _, Zero as _}; diff --git a/console/network/environment/src/traits/mod.rs b/console/network/environment/src/traits/mod.rs index 7e03615c0d..aaeb41611f 100644 --- a/console/network/environment/src/traits/mod.rs +++ b/console/network/environment/src/traits/mod.rs @@ -12,6 +12,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub use snarkvm_utilities::{to_bits_le, ToBits}; + pub mod algorithms; pub use algorithms::*; @@ -33,8 +35,6 @@ pub use parse::*; pub mod parse_string; pub use parse_string::string_parser; -pub use snarkvm_utilities::{to_bits_le, ToBits}; - pub mod to_field; pub use to_field::*; diff --git a/console/program/src/data/plaintext/mod.rs b/console/program/src/data/plaintext/mod.rs index be300e0a8c..aea42f16b9 100644 --- a/console/program/src/data/plaintext/mod.rs +++ b/console/program/src/data/plaintext/mod.rs @@ -93,102 +93,84 @@ mod tests { // Test a random struct with literal members. run_test(Plaintext::::Struct( - IndexMap::from_iter( - vec![ - (Identifier::from_str("a")?, Plaintext::::from_str("true")?), - ( - Identifier::from_str("b")?, - Plaintext::::Literal( - Literal::Field(Field::new(Uniform::rand(&mut rng))), - OnceCell::new(), - ), + IndexMap::from_iter(vec![ + (Identifier::from_str("a")?, Plaintext::::from_str("true")?), + ( + Identifier::from_str("b")?, + Plaintext::::Literal( + Literal::Field(Field::new(Uniform::rand(&mut rng))), + OnceCell::new(), ), - ] - .into_iter(), - ), + ), + ]), OnceCell::new(), )); // Test a random struct with array members. run_test(Plaintext::::Struct( - IndexMap::from_iter( - vec![ - (Identifier::from_str("a")?, Plaintext::::from_str("true")?), - ( - Identifier::from_str("b")?, - Plaintext::::Array( - vec![ - Plaintext::::from_str("true")?, - Plaintext::::from_str("false")?, - ], - OnceCell::new(), - ), + IndexMap::from_iter(vec![ + (Identifier::from_str("a")?, Plaintext::::from_str("true")?), + ( + Identifier::from_str("b")?, + Plaintext::::Array( + vec![ + Plaintext::::from_str("true")?, + Plaintext::::from_str("false")?, + ], + OnceCell::new(), ), - ] - .into_iter(), - ), + ), + ]), OnceCell::new(), )); // Test random deeply-nested struct. run_test(Plaintext::::Struct( - IndexMap::from_iter( - vec![ - (Identifier::from_str("a")?, Plaintext::::from_str("true")?), - ( - Identifier::from_str("b")?, - Plaintext::::Struct( - IndexMap::from_iter( - vec![ - (Identifier::from_str("c")?, Plaintext::::from_str("true")?), - ( - Identifier::from_str("d")?, - Plaintext::::Struct( - IndexMap::from_iter( - vec![ - ( - Identifier::from_str("e")?, - Plaintext::::from_str("true")?, - ), - ( - Identifier::from_str("f")?, - Plaintext::::Literal( - Literal::Field(Field::new(Uniform::rand(&mut rng))), - OnceCell::new(), - ), - ), - ] - .into_iter(), + IndexMap::from_iter(vec![ + (Identifier::from_str("a")?, Plaintext::::from_str("true")?), + ( + Identifier::from_str("b")?, + Plaintext::::Struct( + IndexMap::from_iter(vec![ + (Identifier::from_str("c")?, Plaintext::::from_str("true")?), + ( + Identifier::from_str("d")?, + Plaintext::::Struct( + IndexMap::from_iter(vec![ + (Identifier::from_str("e")?, Plaintext::::from_str("true")?), + ( + Identifier::from_str("f")?, + Plaintext::::Literal( + Literal::Field(Field::new(Uniform::rand(&mut rng))), + OnceCell::new(), ), - OnceCell::new(), ), - ), - ( - Identifier::from_str("g")?, - Plaintext::Array( - vec![ - Plaintext::::from_str("true")?, - Plaintext::::from_str("false")?, - ], - OnceCell::new(), - ), - ), - ] - .into_iter(), + ]), + OnceCell::new(), + ), + ), + ( + Identifier::from_str("g")?, + Plaintext::Array( + vec![ + Plaintext::::from_str("true")?, + Plaintext::::from_str("false")?, + ], + OnceCell::new(), + ), ), - OnceCell::new(), - ), + ]), + OnceCell::new(), ), - ( - Identifier::from_str("h")?, - Plaintext::::Literal( - Literal::Field(Field::new(Uniform::rand(&mut rng))), - OnceCell::new(), - ), + ), + ( + Identifier::from_str("h")?, + Plaintext::::Literal( + Literal::Field(Field::new(Uniform::rand(&mut rng))), + OnceCell::new(), ), - ] - .into_iter(), - ), + ), + ]), OnceCell::new(), )); diff --git a/console/program/src/data/plaintext/parse.rs b/console/program/src/data/plaintext/parse.rs index 01fb453595..7a395f4291 100644 --- a/console/program/src/data/plaintext/parse.rs +++ b/console/program/src/data/plaintext/parse.rs @@ -59,7 +59,7 @@ impl Parser for Plaintext { // Parse the '}' from the string. let (string, _) = tag("}")(string)?; // Output the plaintext. - Ok((string, Plaintext::Struct(IndexMap::from_iter(members.into_iter()), Default::default()))) + Ok((string, Plaintext::Struct(IndexMap::from_iter(members), Default::default()))) } /// Parses a plaintext as an array: `[plaintext_0, ..., plaintext_n]`. diff --git a/console/program/src/data/record/decrypt.rs b/console/program/src/data/record/decrypt.rs index 4e9d5d15b2..31fb963db2 100644 --- a/console/program/src/data/record/decrypt.rs +++ b/console/program/src/data/record/decrypt.rs @@ -112,13 +112,10 @@ mod tests { let randomizer = Scalar::rand(rng); let record = Record { owner, - data: IndexMap::from_iter( - vec![ - (Identifier::from_str("a")?, Entry::Private(Plaintext::from(Literal::Field(Field::rand(rng))))), - (Identifier::from_str("b")?, Entry::Private(Plaintext::from(Literal::Scalar(Scalar::rand(rng))))), - ] - .into_iter(), - ), + data: IndexMap::from_iter(vec![ + (Identifier::from_str("a")?, Entry::Private(Plaintext::from(Literal::Field(Field::rand(rng))))), + (Identifier::from_str("b")?, Entry::Private(Plaintext::from(Literal::Scalar(Scalar::rand(rng))))), + ]), nonce: N::g_scalar_multiply(&randomizer), }; // Encrypt the record. diff --git a/console/program/src/data/record/entry/parse.rs b/console/program/src/data/record/entry/parse.rs index af5c9491db..ec7a125da3 100644 --- a/console/program/src/data/record/entry/parse.rs +++ b/console/program/src/data/record/entry/parse.rs @@ -95,7 +95,7 @@ impl Parser for Entry> { // Parse the '}' from the string. let (string, _) = tag("}")(string)?; // Output the plaintext and visibility. - Ok((string, (Plaintext::Struct(IndexMap::from_iter(members.into_iter()), Default::default()), mode))) + Ok((string, (Plaintext::Struct(IndexMap::from_iter(members), Default::default()), mode))) } /// Parses an entry as an array: `[plaintext_0.visibility, ..., plaintext_n.visibility]`. diff --git a/console/program/src/data/record/is_owner.rs b/console/program/src/data/record/is_owner.rs index 6ef8ef6dd2..54df9c6958 100644 --- a/console/program/src/data/record/is_owner.rs +++ b/console/program/src/data/record/is_owner.rs @@ -78,13 +78,10 @@ mod tests { let randomizer = Scalar::rand(rng); let record = Record { owner, - data: IndexMap::from_iter( - vec![ - (Identifier::from_str("a")?, Entry::Private(Plaintext::from(Literal::Field(Field::rand(rng))))), - (Identifier::from_str("b")?, Entry::Private(Plaintext::from(Literal::Scalar(Scalar::rand(rng))))), - ] - .into_iter(), - ), + data: IndexMap::from_iter(vec![ + (Identifier::from_str("a")?, Entry::Private(Plaintext::from(Literal::Field(Field::rand(rng))))), + (Identifier::from_str("b")?, Entry::Private(Plaintext::from(Literal::Scalar(Scalar::rand(rng))))), + ]), nonce: N::g_scalar_multiply(&randomizer), }; diff --git a/console/program/src/data/record/parse_plaintext.rs b/console/program/src/data/record/parse_plaintext.rs index c04a190d85..0dfcdc4aa1 100644 --- a/console/program/src/data/record/parse_plaintext.rs +++ b/console/program/src/data/record/parse_plaintext.rs @@ -102,7 +102,7 @@ impl Parser for Record> { // Parse the '}' from the string. let (string, _) = tag("}")(string)?; // Output the record. - Ok((string, Record { owner, data: IndexMap::from_iter(entries.into_iter()), nonce })) + Ok((string, Record { owner, data: IndexMap::from_iter(entries), nonce })) } } diff --git a/console/program/src/data_types/record_type/parse.rs b/console/program/src/data_types/record_type/parse.rs index d6e78933ff..fae51218c2 100644 --- a/console/program/src/data_types/record_type/parse.rs +++ b/console/program/src/data_types/record_type/parse.rs @@ -94,7 +94,7 @@ impl Parser for RecordType { })(string)?; // Return the record type. - Ok((string, Self { name, owner, entries: IndexMap::from_iter(entries.into_iter()) })) + Ok((string, Self { name, owner, entries: IndexMap::from_iter(entries) })) } } @@ -143,9 +143,10 @@ mod tests { let expected = RecordType:: { name: Identifier::from_str("message")?, owner: PublicOrPrivate::Private, - entries: IndexMap::from_iter( - vec![(Identifier::from_str("first")?, EntryType::from_str("field.constant")?)].into_iter(), - ), + entries: IndexMap::from_iter(vec![( + Identifier::from_str("first")?, + EntryType::from_str("field.constant")?, + )]), }; let (remainder, candidate) = RecordType::::parse( diff --git a/console/program/src/data_types/struct_type/parse.rs b/console/program/src/data_types/struct_type/parse.rs index 648203697f..1b606a749f 100644 --- a/console/program/src/data_types/struct_type/parse.rs +++ b/console/program/src/data_types/struct_type/parse.rs @@ -70,7 +70,7 @@ impl Parser for StructType { Ok(members) })(string)?; // Return the struct. - Ok((string, Self { name, members: IndexMap::from_iter(members.into_iter()) })) + Ok((string, Self { name, members: IndexMap::from_iter(members) })) } } @@ -122,13 +122,10 @@ mod tests { fn test_parse() -> Result<()> { let expected = StructType:: { name: Identifier::from_str("message")?, - members: IndexMap::from_iter( - vec![ - (Identifier::from_str("sender")?, PlaintextType::from_str("address")?), - (Identifier::from_str("amount")?, PlaintextType::from_str("u64")?), - ] - .into_iter(), - ), + members: IndexMap::from_iter(vec![ + (Identifier::from_str("sender")?, PlaintextType::from_str("address")?), + (Identifier::from_str("amount")?, PlaintextType::from_str("u64")?), + ]), }; let (remainder, candidate) = StructType::::parse( diff --git a/console/program/src/state_path/mod.rs b/console/program/src/state_path/mod.rs index 2ff02b04b4..ce3b719d88 100644 --- a/console/program/src/state_path/mod.rs +++ b/console/program/src/state_path/mod.rs @@ -280,7 +280,7 @@ pub mod test_helpers { let header_path = header_tree.prove(1, &header_leaf.to_bits_le())?; let previous_block_hash: N::BlockHash = Field::::rand(rng).into(); - let preimage = (*previous_block_hash).to_bits_le().into_iter().chain(header_root.to_bits_le().into_iter()); + let preimage = (*previous_block_hash).to_bits_le().into_iter().chain(header_root.to_bits_le()); let block_hash = N::hash_bhp1024(&preimage.collect::>())?; // Construct the global state root and block path. diff --git a/console/types/address/src/from_bits.rs b/console/types/address/src/from_bits.rs index 6b7df16c23..f344d1252c 100644 --- a/console/types/address/src/from_bits.rs +++ b/console/types/address/src/from_bits.rs @@ -49,7 +49,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); let candidate = Address::::from_bits_le(&candidate)?; assert_eq!(expected, candidate); @@ -72,7 +72,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![vec![false; i], given_bits].concat(); + let candidate = [vec![false; i], given_bits].concat(); let candidate = Address::::from_bits_be(&candidate)?; assert_eq!(expected, candidate); diff --git a/console/types/boolean/src/from_bits.rs b/console/types/boolean/src/from_bits.rs index 3cf131b005..173572f188 100644 --- a/console/types/boolean/src/from_bits.rs +++ b/console/types/boolean/src/from_bits.rs @@ -54,7 +54,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); assert!(Boolean::::from_bits_le(&candidate).is_err()); } Ok(()) @@ -73,7 +73,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![vec![false; i], given_bits].concat(); + let candidate = [vec![false; i], given_bits].concat(); assert!(Boolean::::from_bits_be(&candidate).is_err()); } Ok(()) diff --git a/console/types/field/src/from_bits.rs b/console/types/field/src/from_bits.rs index 2b283272f7..ad79a3685e 100644 --- a/console/types/field/src/from_bits.rs +++ b/console/types/field/src/from_bits.rs @@ -93,7 +93,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); let candidate = Field::::from_bits_le(&candidate)?; assert_eq!(expected, candidate); @@ -115,7 +115,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![vec![false; i], given_bits].concat(); + let candidate = [vec![false; i], given_bits].concat(); let candidate = Field::::from_bits_be(&candidate)?; assert_eq!(expected, candidate); diff --git a/console/types/group/src/from_bits.rs b/console/types/group/src/from_bits.rs index c8eafc873a..d5c9188d54 100644 --- a/console/types/group/src/from_bits.rs +++ b/console/types/group/src/from_bits.rs @@ -48,7 +48,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); let candidate = Group::::from_bits_le(&candidate)?; assert_eq!(expected, candidate); @@ -70,7 +70,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![vec![false; i], given_bits].concat(); + let candidate = [vec![false; i], given_bits].concat(); let candidate = Group::::from_bits_be(&candidate)?; assert_eq!(expected, candidate); diff --git a/console/types/integers/src/from_bits.rs b/console/types/integers/src/from_bits.rs index 98381be72b..87290176de 100644 --- a/console/types/integers/src/from_bits.rs +++ b/console/types/integers/src/from_bits.rs @@ -48,7 +48,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); let candidate = Integer::::from_bits_le(&candidate)?; assert_eq!(expected, candidate); @@ -70,7 +70,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![vec![false; i], given_bits].concat(); + let candidate = [vec![false; i], given_bits].concat(); let candidate = Integer::::from_bits_be(&candidate)?; assert_eq!(expected, candidate); diff --git a/console/types/integers/src/lib.rs b/console/types/integers/src/lib.rs index 2142ae50de..bfc0d0b2b7 100644 --- a/console/types/integers/src/lib.rs +++ b/console/types/integers/src/lib.rs @@ -38,9 +38,7 @@ mod zero; pub use snarkvm_console_network_environment::prelude::*; pub use snarkvm_console_types_boolean::Boolean; pub use snarkvm_console_types_field::Field; - -use snarkvm_console_network_environment::traits::types::{integer_magnitude::Magnitude, integer_type::IntegerType}; -use snarkvm_console_types_scalar::Scalar; +pub use snarkvm_console_types_scalar::Scalar; use core::marker::PhantomData; diff --git a/console/types/scalar/src/from_bits.rs b/console/types/scalar/src/from_bits.rs index fbe3e4a3b9..4f9a123bfb 100644 --- a/console/types/scalar/src/from_bits.rs +++ b/console/types/scalar/src/from_bits.rs @@ -96,7 +96,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![given_bits, vec![false; i]].concat(); + let candidate = [given_bits, vec![false; i]].concat(); let candidate = Scalar::::from_bits_le(&candidate)?; assert_eq!(expected, candidate); @@ -118,7 +118,7 @@ mod tests { assert_eq!(expected, candidate); // Add excess zero bits. - let candidate = vec![vec![false; i], given_bits].concat(); + let candidate = [vec![false; i], given_bits].concat(); let candidate = Scalar::::from_bits_be(&candidate)?; assert_eq!(expected, candidate); diff --git a/curves/src/bls12_377/fq.rs b/curves/src/bls12_377/fq.rs index fa333b8217..1bcd522597 100644 --- a/curves/src/bls12_377/fq.rs +++ b/curves/src/bls12_377/fq.rs @@ -24,6 +24,7 @@ use snarkvm_utilities::biginteger::BigInteger384 as BigInteger; pub type Fq = Fp384; +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct FqParameters; impl Fp384Parameters for FqParameters {} diff --git a/curves/src/bls12_377/fq12.rs b/curves/src/bls12_377/fq12.rs index a94da8470f..165599a37f 100644 --- a/curves/src/bls12_377/fq12.rs +++ b/curves/src/bls12_377/fq12.rs @@ -19,7 +19,7 @@ use crate::bls12_377::{Fq, Fq2, Fq6Parameters}; pub type Fq12 = Fp12; -#[derive(Clone, Copy)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct Fq12Parameters; impl Fp12Parameters for Fq12Parameters { diff --git a/curves/src/bls12_377/fq2.rs b/curves/src/bls12_377/fq2.rs index 649cf6d33b..fbaffb2c7e 100644 --- a/curves/src/bls12_377/fq2.rs +++ b/curves/src/bls12_377/fq2.rs @@ -21,7 +21,7 @@ use crate::bls12_377::Fq; pub type Fq2 = Fp2; -#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Fq2Parameters; impl Fp2Parameters for Fq2Parameters { diff --git a/curves/src/bls12_377/fq6.rs b/curves/src/bls12_377/fq6.rs index 35a420d298..841c81dabc 100644 --- a/curves/src/bls12_377/fq6.rs +++ b/curves/src/bls12_377/fq6.rs @@ -23,7 +23,7 @@ use crate::bls12_377::{Fq, Fq2, Fq2Parameters}; pub type Fq6 = Fp6; -#[derive(Clone, Copy)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct Fq6Parameters; impl Fp6Parameters for Fq6Parameters { diff --git a/curves/src/bls12_377/fr.rs b/curves/src/bls12_377/fr.rs index 9756f51950..67de1ab1ad 100644 --- a/curves/src/bls12_377/fr.rs +++ b/curves/src/bls12_377/fr.rs @@ -47,6 +47,7 @@ use snarkvm_utilities::biginteger::BigInteger256 as BigInteger; /// ``` pub type Fr = Fp256; +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct FrParameters; impl Fp256Parameters for FrParameters {} diff --git a/curves/src/edwards_bls12/fr.rs b/curves/src/edwards_bls12/fr.rs index 1e8f9c1b85..0ed9d8e233 100644 --- a/curves/src/edwards_bls12/fr.rs +++ b/curves/src/edwards_bls12/fr.rs @@ -24,6 +24,7 @@ use snarkvm_utilities::biginteger::BigInteger256 as BigInteger; pub type Fr = Fp256; +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)] pub struct FrParameters; impl Fp256Parameters for FrParameters {} diff --git a/curves/src/traits/tests_projective.rs b/curves/src/traits/tests_projective.rs index 6b8da06408..b48d55d9a3 100644 --- a/curves/src/traits/tests_projective.rs +++ b/curves/src/traits/tests_projective.rs @@ -44,7 +44,7 @@ fn random_addition_test(rng: &mut TestRng) { assert_eq!(aplusa, aplusamixed); } - let mut tmp = vec![G::zero(); 6]; + let mut tmp = [G::zero(); 6]; // (a + b) + c tmp[0] = (a + b) + c; diff --git a/fields/Cargo.toml b/fields/Cargo.toml index 036a436cb1..d610be066d 100644 --- a/fields/Cargo.toml +++ b/fields/Cargo.toml @@ -35,9 +35,6 @@ default-features = false [dependencies.anyhow] version = "1.0" -[dependencies.derivative] -version = "2" - [dependencies.itertools] version = "0.11.0" diff --git a/fields/src/fp12_2over3over2.rs b/fields/src/fp12_2over3over2.rs index 7659c781a1..e7da3be7cd 100644 --- a/fields/src/fp12_2over3over2.rs +++ b/fields/src/fp12_2over3over2.rs @@ -22,48 +22,38 @@ use rand::{ use serde::{Deserialize, Serialize}; use std::{ cmp::Ordering, + fmt::Debug, + hash::Hash, io::{Read, Result as IoResult, Write}, ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}, }; -pub trait Fp12Parameters: 'static + Send + Sync + Copy { +pub trait Fp12Parameters: 'static + Copy + Clone + Debug + Default + PartialEq + Eq + Hash + Send + Sync { type Fp6Params: Fp6Parameters; /// Coefficients for the Frobenius automorphism. const FROBENIUS_COEFF_FP12_C1: [Fp2>; 12]; } +type Fp2Params

= <

::Fp6Params as Fp6Parameters>::Fp2Params; + /// An element of Fp12, represented by c0 + c1 * v -#[derive(Derivative, Serialize, Deserialize)] -#[derivative( - Default(bound = "P: Fp12Parameters"), - Hash(bound = "P: Fp12Parameters"), - Clone(bound = "P: Fp12Parameters"), - Copy(bound = "P: Fp12Parameters"), - Debug(bound = "P: Fp12Parameters"), - PartialEq(bound = "P: Fp12Parameters"), - Eq(bound = "P: Fp12Parameters") -)] -#[must_use] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Fp12 { pub c0: Fp6, pub c1: Fp6, } -type Fp2Params

= <

::Fp6Params as Fp6Parameters>::Fp2Params; - impl Fp12

{ - /// Multiply by quadratic nonresidue v. - #[inline(always)] - pub(crate) fn mul_fp6_by_nonresidue(fe: &Fp6) -> Fp6 { - let new_c0 = P::Fp6Params::mul_fp2_by_nonresidue(&fe.c2); - let new_c1 = fe.c0; - let new_c2 = fe.c1; - Fp6::new(new_c0, new_c1, new_c2) + /// Initializes an element of `Fp12` from two `Fp6` elements. + pub const fn new(c0: Fp6, c1: Fp6) -> Self { + Self { c0, c1 } } +} - pub fn new(c0: Fp6, c1: Fp6) -> Self { - Self { c0, c1 } +impl Fp12

{ + pub fn conjugate(&mut self) { + self.c1 = self.c1.neg(); } pub fn mul_by_fp(&mut self, element: &<::Fp2Params as Fp2Parameters>::Fp) { @@ -71,8 +61,13 @@ impl Fp12

{ self.c1.mul_by_fp(element); } - pub fn conjugate(&mut self) { - self.c1 = self.c1.neg(); + /// Multiply by quadratic nonresidue v. + #[inline(always)] + pub(crate) fn mul_fp6_by_nonresidue(fe: &Fp6) -> Fp6 { + let new_c0 = P::Fp6Params::mul_fp2_by_nonresidue(&fe.c2); + let new_c1 = fe.c0; + let new_c2 = fe.c1; + Fp6::new(new_c0, new_c1, new_c2) } pub fn mul_by_034(&mut self, c0: &Fp2>, c3: &Fp2>, c4: &Fp2>) { diff --git a/fields/src/fp2.rs b/fields/src/fp2.rs index 19841a359e..528e5c3be7 100644 --- a/fields/src/fp2.rs +++ b/fields/src/fp2.rs @@ -28,11 +28,15 @@ use rand::{ use serde::{Deserialize, Serialize}; use std::{ cmp::{Ord, Ordering, PartialOrd}, + fmt::Debug, + hash::Hash, io::{Read, Result as IoResult, Write}, ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}, }; -pub trait Fp2Parameters: 'static + Send + Sync + Serialize + for<'a> Deserialize<'a> { +pub trait Fp2Parameters: + 'static + Copy + Clone + Default + Debug + PartialEq + Eq + Hash + Serialize + for<'a> Deserialize<'a> + Send + Sync +{ type Fp: PrimeField; /// Coefficients for the Frobenius automorphism. @@ -48,26 +52,20 @@ pub trait Fp2Parameters: 'static + Send + Sync + Serialize + for<'a> Deserialize } } -#[derive(Derivative, Serialize, Deserialize)] -#[derivative( - Default(bound = "P: Fp2Parameters"), - Hash(bound = "P: Fp2Parameters"), - Clone(bound = "P: Fp2Parameters"), - Copy(bound = "P: Fp2Parameters"), - Debug(bound = "P: Fp2Parameters"), - PartialEq(bound = "P: Fp2Parameters"), - Eq(bound = "P: Fp2Parameters") -)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Fp2 { pub c0: P::Fp, pub c1: P::Fp, } impl Fp2

{ - pub fn new(c0: P::Fp, c1: P::Fp) -> Self { + /// Initializes a `Fp2` element from two `Fp` elements. + pub const fn new(c0: P::Fp, c1: P::Fp) -> Self { Fp2 { c0, c1 } } +} +impl Fp2

{ /// Norm of Fp2 over Fp: Norm(a) = a.x^2 - beta * a.y^2 pub fn norm(&self) -> P::Fp { let t0 = self.c0.square(); diff --git a/fields/src/fp6_3over2.rs b/fields/src/fp6_3over2.rs index 859e5a6613..5699630195 100644 --- a/fields/src/fp6_3over2.rs +++ b/fields/src/fp6_3over2.rs @@ -28,11 +28,13 @@ use rand::{ use serde::{Deserialize, Serialize}; use std::{ cmp::Ordering, + fmt::Debug, + hash::Hash, io::{Read, Result as IoResult, Write}, ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}, }; -pub trait Fp6Parameters: 'static + Send + Sync + Copy { +pub trait Fp6Parameters: 'static + Copy + Clone + Default + Debug + PartialEq + Eq + Hash + Send + Sync { type Fp2Params: Fp2Parameters; /// Coefficients for the Frobenius automorphism. @@ -48,16 +50,7 @@ pub trait Fp6Parameters: 'static + Send + Sync + Copy { } /// An element of Fp6, represented by c0 + c1 * v + c2 * v^(2). -#[derive(Derivative, Serialize, Deserialize)] -#[derivative( - Default(bound = "P: Fp6Parameters"), - Hash(bound = "P: Fp6Parameters"), - Clone(bound = "P: Fp6Parameters"), - Copy(bound = "P: Fp6Parameters"), - Debug(bound = "P: Fp6Parameters"), - PartialEq(bound = "P: Fp6Parameters"), - Eq(bound = "P: Fp6Parameters") -)] +#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash, Serialize, Deserialize)] pub struct Fp6 { pub c0: Fp2, pub c1: Fp2, @@ -65,7 +58,8 @@ pub struct Fp6 { } impl Fp6

{ - pub fn new(c0: Fp2, c1: Fp2, c2: Fp2) -> Self { + /// Initializes an element of `Fp6` from 3 `Fp2` elements. + pub const fn new(c0: Fp2, c1: Fp2, c2: Fp2) -> Self { Self { c0, c1, c2 } } diff --git a/fields/src/fp_256.rs b/fields/src/fp_256.rs index 15af78a1e1..641a5d0f20 100644 --- a/fields/src/fp_256.rs +++ b/fields/src/fp_256.rs @@ -47,21 +47,8 @@ use zeroize::Zeroize; pub trait Fp256Parameters: FieldParameters {} -#[derive(Derivative, Zeroize)] -#[derivative( - Default(bound = ""), - Hash(bound = ""), - Clone(bound = ""), - Copy(bound = ""), - PartialEq(bound = ""), - Eq(bound = "") -)] -pub struct Fp256

( - pub BigInteger, - #[derivative(Debug = "ignore")] - #[doc(hidden)] - pub PhantomData

, -); +#[derive(Copy, Clone, Default, PartialEq, Eq, Hash, Zeroize)] +pub struct Fp256(pub BigInteger, #[doc(hidden)] pub PhantomData

); impl Fp256

{ #[inline] diff --git a/fields/src/fp_384.rs b/fields/src/fp_384.rs index 596ef055c2..9c74c0e336 100644 --- a/fields/src/fp_384.rs +++ b/fields/src/fp_384.rs @@ -47,21 +47,8 @@ use zeroize::Zeroize; pub trait Fp384Parameters: FieldParameters {} -#[derive(Derivative, Zeroize)] -#[derivative( - Default(bound = "P: Fp384Parameters"), - Hash(bound = "P: Fp384Parameters"), - Clone(bound = "P: Fp384Parameters"), - Copy(bound = "P: Fp384Parameters"), - PartialEq(bound = "P: Fp384Parameters"), - Eq(bound = "P: Fp384Parameters") -)] -pub struct Fp384( - pub BigInteger, - #[derivative(Debug = "ignore")] - #[doc(hidden)] - pub PhantomData

, -); +#[derive(Copy, Clone, Default, PartialEq, Eq, Hash, Zeroize)] +pub struct Fp384(pub BigInteger, #[doc(hidden)] pub PhantomData

); impl Fp384

{ #[inline] diff --git a/fields/src/lib.rs b/fields/src/lib.rs index 1a5e5be332..f2037076c9 100644 --- a/fields/src/lib.rs +++ b/fields/src/lib.rs @@ -15,9 +15,6 @@ #![allow(clippy::module_inception)] #![forbid(unsafe_code)] -#[macro_use] -extern crate derivative; - #[macro_use] extern crate thiserror; diff --git a/fields/src/traits/field_parameters.rs b/fields/src/traits/field_parameters.rs index 280b72f124..ba0c4a186a 100644 --- a/fields/src/traits/field_parameters.rs +++ b/fields/src/traits/field_parameters.rs @@ -14,8 +14,12 @@ use crate::traits::{FftParameters, PoseidonDefaultParameters}; +use core::{fmt::Debug, hash::Hash}; + /// A trait that defines parameters for a prime field. -pub trait FieldParameters: 'static + FftParameters + PoseidonDefaultParameters { +pub trait FieldParameters: + 'static + FftParameters + PoseidonDefaultParameters + Copy + Clone + Debug + Default + PartialEq + Eq + Hash +{ /// The modulus of the field. const MODULUS: Self::BigInteger; diff --git a/ledger/block/src/lib.rs b/ledger/block/src/lib.rs index eccf37af50..fd9dae34ce 100644 --- a/ledger/block/src/lib.rs +++ b/ledger/block/src/lib.rs @@ -636,7 +636,7 @@ pub mod test_helpers { // Prepare the confirmed transaction. let confirmed = ConfirmedTransaction::accepted_execute(0, transaction.clone(), vec![]).unwrap(); // Prepare the transactions. - let transactions = Transactions::from_iter([confirmed].into_iter()); + let transactions = Transactions::from_iter([confirmed]); // Construct the ratifications. let ratifications = Ratifications::try_from(vec![]).unwrap(); diff --git a/ledger/block/src/ratifications/mod.rs b/ledger/block/src/ratifications/mod.rs index 884c09d6f6..bb11fe0951 100644 --- a/ledger/block/src/ratifications/mod.rs +++ b/ledger/block/src/ratifications/mod.rs @@ -51,7 +51,7 @@ impl TryFrom>> for Ratifications { /// Initializes from a given ratifications list. fn try_from(ratifications: Vec>) -> Result { - Self::try_from_iter(ratifications.into_iter()) + Self::try_from_iter(ratifications) } } diff --git a/ledger/narwhal/batch-certificate/src/lib.rs b/ledger/narwhal/batch-certificate/src/lib.rs index 64ddc93470..9356b7dcf6 100644 --- a/ledger/narwhal/batch-certificate/src/lib.rs +++ b/ledger/narwhal/batch-certificate/src/lib.rs @@ -206,8 +206,7 @@ impl BatchCertificate { match self { Self::V1 { batch_header, signatures, .. } => { // Return the median timestamp. - let mut timestamps = - signatures.values().copied().chain([batch_header.timestamp()].into_iter()).collect::>(); + let mut timestamps = signatures.values().copied().chain([batch_header.timestamp()]).collect::>(); timestamps.sort_unstable(); timestamps[timestamps.len() / 2] } diff --git a/ledger/src/lib.rs b/ledger/src/lib.rs index ecb5c9c59d..175151bb46 100644 --- a/ledger/src/lib.rs +++ b/ledger/src/lib.rs @@ -52,7 +52,6 @@ use console::{ types::{Field, Group}, }; use ledger_authority::Authority; -use ledger_block::{Block, ConfirmedTransaction, Header, Metadata, Ratify, Transaction, Transactions}; use ledger_coinbase::{CoinbasePuzzle, CoinbaseSolution, EpochChallenge, ProverSolution, PuzzleCommitment}; use ledger_committee::Committee; use ledger_narwhal::{BatchCertificate, Subdag, Transmission, TransmissionID}; diff --git a/ledger/src/tests.rs b/ledger/src/tests.rs index b8ff45e39e..8e2feda956 100644 --- a/ledger/src/tests.rs +++ b/ledger/src/tests.rs @@ -111,8 +111,7 @@ fn test_insufficient_private_fees() { { // Prepare a `split` execution without a fee. let inputs = [Value::Record(record_1.clone()), Value::from_str("100u64").unwrap()]; - let authorization = - ledger.vm.authorize(&private_key, "credits.aleo", "split", inputs.into_iter(), rng).unwrap(); + let authorization = ledger.vm.authorize(&private_key, "credits.aleo", "split", inputs, rng).unwrap(); let split_transaction_without_fee = ledger.vm.execute_authorization(authorization, None, None, rng).unwrap(); assert!(ledger.check_transaction_basic(&split_transaction_without_fee, None, rng).is_ok()); } @@ -125,8 +124,7 @@ fn test_insufficient_private_fees() { Value::from_str(&format!("{address}")).unwrap(), Value::from_str("100u64").unwrap(), ]; - let authorization = - ledger.vm.authorize(&private_key, "credits.aleo", "transfer_private", inputs.into_iter(), rng).unwrap(); + let authorization = ledger.vm.authorize(&private_key, "credits.aleo", "transfer_private", inputs, rng).unwrap(); let transaction_without_fee = ledger.vm.execute_authorization(authorization, None, None, rng).unwrap(); let execution = transaction_without_fee.execution().unwrap(); diff --git a/ledger/store/src/helpers/memory/internal/map.rs b/ledger/store/src/helpers/memory/internal/map.rs index 6c0e838db0..211d7e11a1 100644 --- a/ledger/store/src/helpers/memory/internal/map.rs +++ b/ledger/store/src/helpers/memory/internal/map.rs @@ -194,7 +194,7 @@ impl< let operations = core::mem::take(&mut *self.atomic_batch.lock()); // Insert the operations into an index map to remove any operations that would have been overwritten anyways. - let operations: IndexMap<_, _> = IndexMap::from_iter(operations.into_iter()); + let operations: IndexMap<_, _> = IndexMap::from_iter(operations); if !operations.is_empty() { // Acquire a write lock on the map. @@ -321,7 +321,7 @@ impl< /// Returns an iterator visiting each key-value pair in the atomic batch. /// fn iter_pending(&'a self) -> Self::PendingIterator { - let filtered_atomic_batch: IndexMap<_, _> = IndexMap::from_iter(self.atomic_batch.lock().clone().into_iter()); + let filtered_atomic_batch: IndexMap<_, _> = IndexMap::from_iter(self.atomic_batch.lock().clone()); filtered_atomic_batch.into_iter().map(|(k, v)| (Cow::Owned(k), v.map(|v| Cow::Owned(v)))) } diff --git a/ledger/store/src/helpers/mod.rs b/ledger/store/src/helpers/mod.rs index 994fe0638f..deb8926700 100644 --- a/ledger/store/src/helpers/mod.rs +++ b/ledger/store/src/helpers/mod.rs @@ -85,6 +85,7 @@ macro_rules! atomic_finalize { // // Wrap the operations that should be batched in a closure to be able to abort the entire // write batch if any of them fails. + #[allow(clippy::redundant_closure_call)] match ($finalize_mode, || -> Result<_, String> { $ops }()) { // If this is a successful real run, commit the atomic batch. (FinalizeMode::RealRun, Ok(result)) => { diff --git a/ledger/store/src/helpers/rocksdb/internal/map.rs b/ledger/store/src/helpers/rocksdb/internal/map.rs index 2dc677ad07..105d220121 100644 --- a/ledger/store/src/helpers/rocksdb/internal/map.rs +++ b/ledger/store/src/helpers/rocksdb/internal/map.rs @@ -177,7 +177,7 @@ impl< if !operations.is_empty() { // Insert the operations into an index map to remove any operations that would have been overwritten anyways. - let operations: IndexMap<_, _> = IndexMap::from_iter(operations.into_iter()); + let operations: IndexMap<_, _> = IndexMap::from_iter(operations); // Prepare the key and value for each queued operation. // @@ -346,7 +346,7 @@ impl< /// Returns an iterator visiting each key-value pair in the atomic batch. /// fn iter_pending(&'a self) -> Self::PendingIterator { - let filtered_atomic_batch: IndexMap<_, _> = IndexMap::from_iter(self.atomic_batch.lock().clone().into_iter()); + let filtered_atomic_batch: IndexMap<_, _> = IndexMap::from_iter(self.atomic_batch.lock().clone()); filtered_atomic_batch.into_iter().map(|(k, v)| (Cow::Owned(k), v.map(|v| Cow::Owned(v)))) } diff --git a/ledger/test-helpers/src/lib.rs b/ledger/test-helpers/src/lib.rs index 813fb8cb0b..eac0196063 100644 --- a/ledger/test-helpers/src/lib.rs +++ b/ledger/test-helpers/src/lib.rs @@ -413,7 +413,7 @@ fn sample_genesis_block_and_components_raw( // Prepare the confirmed transaction. let confirmed = ConfirmedTransaction::accepted_execute(0, transaction.clone(), vec![]).unwrap(); // Prepare the transactions. - let transactions = Transactions::from_iter([confirmed].into_iter()); + let transactions = Transactions::from_iter([confirmed]); // Construct the ratifications. let ratifications = Ratifications::try_from(vec![]).unwrap(); diff --git a/rust-toolchain b/rust-toolchain index 883bde3070..22d6771a47 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -1.71.1 \ No newline at end of file +1.72.1