diff --git a/.circleci/config.yml b/.circleci/config.yml index 2d2cae77f8..21a7909252 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -134,7 +134,7 @@ commands: jobs: snarkvm: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - checkout @@ -144,7 +144,7 @@ jobs: algorithms: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -153,7 +153,7 @@ jobs: circuit: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -162,7 +162,7 @@ jobs: circuit-account: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -172,7 +172,7 @@ jobs: # This checks that no `console` structs are used in core circuit logic. circuit-account-noconsole: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -182,7 +182,7 @@ jobs: circuit-algorithms: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -191,7 +191,7 @@ jobs: circuit-collections: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -201,7 +201,7 @@ jobs: # This checks that no `console` structs are used in core circuit logic. circuit-collections-noconsole: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -211,7 +211,7 @@ jobs: circuit-environment: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -220,7 +220,7 @@ jobs: circuit-network: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -229,7 +229,7 @@ jobs: circuit-program: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -238,7 +238,7 @@ jobs: circuit-types: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -247,7 +247,7 @@ jobs: circuit-types-address: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -256,7 +256,7 @@ jobs: circuit-types-boolean: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -265,7 +265,7 @@ jobs: circuit-types-field: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -274,7 +274,7 @@ jobs: circuit-types-group: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -283,7 +283,7 @@ jobs: circuit-types-integers: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -293,7 +293,7 @@ jobs: circuit-types-scalar: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -302,7 +302,7 @@ jobs: circuit-types-string: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -310,7 +310,7 @@ jobs: cache_key: snarkvm-circuit-types-string-cache console: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -319,7 +319,7 @@ jobs: console-account: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -328,7 +328,7 @@ jobs: console-algorithms: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -337,7 +337,7 @@ jobs: console-collections: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -346,7 +346,7 @@ jobs: console-network: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -355,7 +355,7 @@ jobs: console-network-environment: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -364,7 +364,7 @@ jobs: console-program: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -373,7 +373,7 @@ jobs: console-types: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -382,7 +382,7 @@ jobs: console-types-address: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -391,7 +391,7 @@ jobs: console-types-boolean: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -400,7 +400,7 @@ jobs: console-types-field: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -409,7 +409,7 @@ jobs: console-types-group: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -418,7 +418,7 @@ jobs: console-types-integers: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -427,7 +427,7 @@ jobs: console-types-scalar: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -436,7 +436,7 @@ jobs: console-types-string: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -445,7 +445,7 @@ jobs: curves: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -454,7 +454,7 @@ jobs: fields: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -463,7 +463,7 @@ jobs: ledger: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -472,7 +472,7 @@ jobs: ledger-authority: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -481,7 +481,7 @@ jobs: ledger-block: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -490,7 +490,7 @@ jobs: ledger-coinbase: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -499,7 +499,7 @@ jobs: ledger-committee: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -508,7 +508,7 @@ jobs: ledger-narwhal: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -517,7 +517,7 @@ jobs: ledger-narwhal-batch-certificate: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -526,7 +526,7 @@ jobs: ledger-narwhal-batch-header: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -535,7 +535,7 @@ jobs: ledger-narwhal-subdag: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -544,7 +544,7 @@ jobs: ledger-narwhal-transmission: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -553,7 +553,7 @@ jobs: ledger-narwhal-transmission-id: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -562,7 +562,7 @@ jobs: ledger-query: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -571,7 +571,7 @@ jobs: ledger-store: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -581,7 +581,7 @@ jobs: ledger-test-helpers: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -590,7 +590,7 @@ jobs: parameters: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -599,7 +599,7 @@ jobs: synthesizer: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -609,7 +609,7 @@ jobs: synthesizer-integration: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -619,7 +619,7 @@ jobs: synthesizer-process: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -628,7 +628,7 @@ jobs: synthesizer-program: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -637,7 +637,7 @@ jobs: synthesizer-snark: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - run_serial: @@ -646,7 +646,7 @@ jobs: utilities: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -655,7 +655,7 @@ jobs: utilities-derives: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - run_serial: @@ -664,7 +664,7 @@ jobs: wasm: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - checkout @@ -682,7 +682,7 @@ jobs: check-fmt: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - checkout @@ -698,7 +698,7 @@ jobs: check-clippy: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: 2xlarge steps: - checkout @@ -715,7 +715,7 @@ jobs: check-all-targets: docker: - - image: cimg/rust:1.69 + - image: cimg/rust:1.71.1 resource_class: xlarge steps: - checkout diff --git a/circuit/algorithms/src/bhp/hasher/mod.rs b/circuit/algorithms/src/bhp/hasher/mod.rs index 014bce94e6..63bee114d3 100644 --- a/circuit/algorithms/src/bhp/hasher/mod.rs +++ b/circuit/algorithms/src/bhp/hasher/mod.rs @@ -102,7 +102,7 @@ impl Inject for BH #[cfg(all(test, console))] mod tests { use super::*; - use snarkvm_circuit_types::{environment::Circuit, Eject}; + use snarkvm_circuit_types::environment::{Circuit, Eject}; use anyhow::Result; diff --git a/circuit/algorithms/src/bhp/mod.rs b/circuit/algorithms/src/bhp/mod.rs index 91e9d7964e..6845dd343b 100644 --- a/circuit/algorithms/src/bhp/mod.rs +++ b/circuit/algorithms/src/bhp/mod.rs @@ -87,7 +87,7 @@ impl Inject for BH #[cfg(all(test, console))] mod tests { use super::*; - use snarkvm_circuit_types::{environment::Circuit, Eject}; + use snarkvm_circuit_types::environment::{Circuit, Eject}; use anyhow::Result; diff --git a/circuit/algorithms/src/traits.rs b/circuit/algorithms/src/traits.rs index ca978d39be..c30f3a9825 100644 --- a/circuit/algorithms/src/traits.rs +++ b/circuit/algorithms/src/traits.rs @@ -12,10 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -use snarkvm_circuit_types::{ - environment::{Eject, Inject, ScalarTrait, Ternary, ToBits}, - GroupTrait, -}; +use snarkvm_circuit_types::environment::{Eject, GroupTrait, Inject, ScalarTrait, Ternary, ToBits}; /// A trait for a commitment scheme. pub trait Commit { diff --git a/circuit/environment/benches/linear_combination.rs b/circuit/environment/benches/linear_combination.rs index 9904c6fb4a..ca8f7df1d1 100644 --- a/circuit/environment/benches/linear_combination.rs +++ b/circuit/environment/benches/linear_combination.rs @@ -15,7 +15,10 @@ #[macro_use] extern crate criterion; -use snarkvm_circuit::prelude::*; +use snarkvm_circuit::{ + environment::{prelude::num_traits::One as _, Circuit, Eject, Environment, Inject, LinearCombination, Mode, One}, + types::Field, +}; use criterion::Criterion; diff --git a/circuit/environment/src/helpers/circuit_type.rs b/circuit/environment/src/helpers/circuit_type.rs index 22544d24df..7f66a26514 100644 --- a/circuit/environment/src/helpers/circuit_type.rs +++ b/circuit/environment/src/helpers/circuit_type.rs @@ -14,35 +14,11 @@ use crate::{Eject, Mode}; -/// Wrapper struct for circuits whose mode is constant. -#[derive(Debug, Clone)] -pub struct Constant(T); - -impl Constant { - /// Initializes a new `Constant`. Ensures that `Constant` cannot be initialized if the input circuit is not constant. - pub fn new(circuit: T) -> Self { - assert!(circuit.eject_mode().is_constant()); - Self(circuit) - } -} - -impl Eject for Constant { - type Primitive = T::Primitive; - - fn eject_mode(&self) -> Mode { - self.0.eject_mode() - } - - fn eject_value(&self) -> Self::Primitive { - self.0.eject_value() - } -} - /// Helper enum used in the case where a circuit's output mode or counts are determined by /// its mode and the actual value of the circuit. #[derive(Debug, Clone)] pub enum CircuitType { - Constant(Constant), + Constant(T), Public, Private, } @@ -63,7 +39,7 @@ impl CircuitType { impl From for CircuitType { fn from(circuit: T) -> Self { match circuit.eject_mode() { - Mode::Constant => CircuitType::Constant(Constant(circuit)), + Mode::Constant => CircuitType::Constant(circuit), Mode::Public => CircuitType::Public, Mode::Private => CircuitType::Private, } @@ -76,7 +52,7 @@ impl From for CircuitType { impl From<&T> for CircuitType { fn from(circuit: &T) -> Self { match circuit.eject_mode() { - Mode::Constant => CircuitType::Constant(Constant(circuit.clone())), + Mode::Constant => CircuitType::Constant(circuit.clone()), Mode::Public => CircuitType::Public, Mode::Private => CircuitType::Private, } diff --git a/circuit/environment/src/lib.rs b/circuit/environment/src/lib.rs index 5ee03d339d..3fbef9790e 100644 --- a/circuit/environment/src/lib.rs +++ b/circuit/environment/src/lib.rs @@ -66,8 +66,11 @@ pub mod prelude { Zero as _, }, traits::{ - integers::{CheckedPow, IntegerProperties, IntegerType, Magnitude, WrappingDiv, WrappingPow, WrappingRem}, string_parser, + types::{ + integer_magnitude::Magnitude, + integer_type::{CheckedPow, IntegerProperties, IntegerType, WrappingDiv, WrappingPow, WrappingRem}, + }, Double as _, FromBits as _, Inverse as _, @@ -79,8 +82,7 @@ pub mod prelude { ParserResult, TypeName, }; - pub use snarkvm_fields::{Field as _, PrimeField, Zero as _}; - pub use snarkvm_utilities::ToBits as _; + pub use snarkvm_fields::{self, Field as _, PrimeField, Zero as _}; #[cfg(debug_assertions)] pub use snarkvm_curves::AffineCurve as _; @@ -120,6 +122,6 @@ pub mod prelude { multi::{many0, many1}, sequence::{pair, terminated}, }; - pub use num_traits::{Inv, One as NumOne, Pow, Unsigned}; + pub use num_traits::{self, Inv, One as NumOne, Pow, Unsigned}; pub use once_cell::unsync::OnceCell; } diff --git a/circuit/environment/src/macros/mod.rs b/circuit/environment/src/macros/mod.rs index 13cdd1e495..2aa1051a4a 100644 --- a/circuit/environment/src/macros/mod.rs +++ b/circuit/environment/src/macros/mod.rs @@ -12,11 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -pub mod metrics; +mod metrics; pub use metrics::*; -pub mod scope; +mod scope; pub use scope::*; -pub mod witness; +mod witness; pub use witness::*; diff --git a/circuit/environment/src/traits/mod.rs b/circuit/environment/src/traits/mod.rs index 46b1075ac4..f1cfa96d20 100644 --- a/circuit/environment/src/traits/mod.rs +++ b/circuit/environment/src/traits/mod.rs @@ -12,26 +12,26 @@ // See the License for the specific language governing permissions and // limitations under the License. -pub mod eject; +mod eject; pub use eject::*; -pub mod from; +mod from; pub use from::*; -pub mod inject; +mod inject; pub use inject::*; -pub mod metrics; +mod metrics; pub use metrics::*; -pub mod operators; +mod operators; pub use operators::*; -pub mod to; +mod to; pub use to::*; -pub mod to_bits; +mod to_bits; pub use to_bits::*; -pub mod types; +mod types; pub use types::*; diff --git a/circuit/environment/src/traits/operators.rs b/circuit/environment/src/traits/operators.rs index 7644fe27fc..39d8eac78b 100644 --- a/circuit/environment/src/traits/operators.rs +++ b/circuit/environment/src/traits/operators.rs @@ -12,6 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. +pub use crate::prelude::num_traits::Pow; pub use console::traits::{ arithmetic::*, bitwise::*, diff --git a/circuit/environment/src/traits/types/mod.rs b/circuit/environment/src/traits/types/mod.rs index cd0ea766ee..f57ced5233 100644 --- a/circuit/environment/src/traits/types/mod.rs +++ b/circuit/environment/src/traits/types/mod.rs @@ -12,23 +12,23 @@ // See the License for the specific language governing permissions and // limitations under the License. -pub mod address; +mod address; pub use address::*; -pub mod boolean; +mod boolean; pub use boolean::*; -pub mod field; +mod field; pub use field::*; -pub mod group; +mod group; pub use group::*; -pub mod integers; +mod integers; pub use integers::{IntegerCore, IntegerTrait}; -pub mod scalar; +mod scalar; pub use scalar::*; -pub mod string; +mod string; pub use string::*; diff --git a/circuit/program/src/request/mod.rs b/circuit/program/src/request/mod.rs index d3917341aa..7ae6f49b2b 100644 --- a/circuit/program/src/request/mod.rs +++ b/circuit/program/src/request/mod.rs @@ -21,7 +21,7 @@ mod verify; use crate::{Identifier, Plaintext, ProgramID, Record, Value}; use snarkvm_circuit_account::Signature; use snarkvm_circuit_network::Aleo; -use snarkvm_circuit_types::{environment::prelude::*, Address, Boolean, Equal, Field, Group, Scalar, U16}; +use snarkvm_circuit_types::{environment::prelude::*, Address, Boolean, Field, Group, Scalar, U16}; pub enum InputID { /// The hash of the constant input. diff --git a/circuit/src/lib.rs b/circuit/src/lib.rs index 6ae9e23836..785026670e 100644 --- a/circuit/src/lib.rs +++ b/circuit/src/lib.rs @@ -14,28 +14,37 @@ #![forbid(unsafe_code)] -pub use snarkvm_circuit_account as account; -pub use snarkvm_circuit_account::*; +pub use modules::*; -pub use snarkvm_circuit_algorithms as algorithms; -pub use snarkvm_circuit_algorithms::*; +pub mod modules { + pub use snarkvm_circuit_account as account; + pub use snarkvm_circuit_account::*; -pub use snarkvm_circuit_collections as collections; -pub use snarkvm_circuit_collections::*; + pub use snarkvm_circuit_algorithms as algorithms; + pub use snarkvm_circuit_algorithms::*; -pub use snarkvm_circuit_environment as environment; -pub use snarkvm_circuit_environment::*; + pub use snarkvm_circuit_collections as collections; + pub use snarkvm_circuit_collections::*; -pub use snarkvm_circuit_network as network; -pub use snarkvm_circuit_network::*; + pub use snarkvm_circuit_environment as environment; + pub use snarkvm_circuit_environment::{Assignment, Circuit, Eject, Environment, Inject, Mode}; -pub use snarkvm_circuit_program as program; -pub use snarkvm_circuit_program::*; + pub use snarkvm_circuit_network as network; + pub use snarkvm_circuit_network::*; -pub use snarkvm_circuit_types as types; -pub use snarkvm_circuit_types::*; + pub use snarkvm_circuit_program as program; + pub use snarkvm_circuit_program::*; + + pub use snarkvm_circuit_types as types; + pub use snarkvm_circuit_types::*; +} + +pub mod traits { + pub use snarkvm_circuit_algorithms::traits::*; + pub use snarkvm_circuit_environment::traits::*; +} pub mod prelude { - pub use super::*; - pub use snarkvm_circuit_environment::*; + pub use crate::modules::*; + pub use snarkvm_circuit_environment::prelude::*; } diff --git a/circuit/types/src/lib.rs b/circuit/types/src/lib.rs index affba2a442..d5af6980e3 100644 --- a/circuit/types/src/lib.rs +++ b/circuit/types/src/lib.rs @@ -14,25 +14,34 @@ #![forbid(unsafe_code)] -pub use snarkvm_circuit_environment as environment; -pub use snarkvm_circuit_types_address as address; -pub use snarkvm_circuit_types_boolean as boolean; -pub use snarkvm_circuit_types_field as field; -pub use snarkvm_circuit_types_group as group; -pub use snarkvm_circuit_types_integers as integers; -pub use snarkvm_circuit_types_scalar as scalar; -pub use snarkvm_circuit_types_string as string; - -pub use address::Address; -pub use boolean::Boolean; -pub use environment::prelude::*; -pub use field::Field; -pub use group::Group; -pub use integers::{I128, I16, I32, I64, I8, U128, U16, U32, U64, U8}; -pub use scalar::Scalar; -pub use string::StringType; +pub use modules::*; + +pub mod modules { + pub use snarkvm_circuit_environment as environment; + + pub use snarkvm_circuit_types_address as address; + pub use snarkvm_circuit_types_address::Address; + + pub use snarkvm_circuit_types_boolean as boolean; + pub use snarkvm_circuit_types_boolean::Boolean; + + pub use snarkvm_circuit_types_field as field; + pub use snarkvm_circuit_types_field::Field; + + pub use snarkvm_circuit_types_group as group; + pub use snarkvm_circuit_types_group::Group; + + pub use snarkvm_circuit_types_integers as integers; + pub use snarkvm_circuit_types_integers::{I128, I16, I32, I64, I8, U128, U16, U32, U64, U8}; + + pub use snarkvm_circuit_types_scalar as scalar; + pub use snarkvm_circuit_types_scalar::Scalar; + + pub use snarkvm_circuit_types_string as string; + pub use snarkvm_circuit_types_string::StringType; +} pub mod prelude { - pub use super::*; - pub use environment::prelude::*; + pub use crate::modules::*; + pub use snarkvm_circuit_environment::prelude::*; } diff --git a/console/account/src/lib.rs b/console/account/src/lib.rs index 7881794ea8..77e5874bbf 100644 --- a/console/account/src/lib.rs +++ b/console/account/src/lib.rs @@ -19,7 +19,7 @@ pub use snarkvm_console_types::{environment::prelude::*, Address, Field, Group, Scalar}; -pub mod address; +mod address; #[cfg(feature = "compute_key")] pub mod compute_key; diff --git a/console/algorithms/src/blake2xs/mod.rs b/console/algorithms/src/blake2xs/mod.rs index 1359261f59..8ebc5bf1c6 100644 --- a/console/algorithms/src/blake2xs/mod.rs +++ b/console/algorithms/src/blake2xs/mod.rs @@ -12,12 +12,10 @@ // See the License for the specific language governing permissions and // limitations under the License. -///! -///! Blake2Xs function -///! -///! This implementation is based on the BLAKE2Xs specification in Section 2 of -///! -///! +/// Blake2Xs function +/// +/// This implementation is based on the BLAKE2Xs specification in Section 2 of +/// mod hash_to_curve; pub struct Blake2Xs; diff --git a/console/network/environment/src/lib.rs b/console/network/environment/src/lib.rs index ee0693959f..92c88ec1a0 100644 --- a/console/network/environment/src/lib.rs +++ b/console/network/environment/src/lib.rs @@ -24,4 +24,90 @@ pub use helpers::*; pub mod traits; pub use traits::*; -pub mod prelude; +pub mod prelude { + pub use crate::{environment::*, helpers::*, traits::*}; + + pub use snarkvm_curves::{AffineCurve, MontgomeryParameters, ProjectiveCurve, TwistedEdwardsParameters}; + pub use snarkvm_fields::{Field as _, PrimeField as _, SquareRootField as _, Zero as _}; + pub use snarkvm_utilities::{ + cfg_find, + cfg_find_map, + cfg_into_iter, + cfg_iter, + cfg_iter_mut, + cfg_values, + error, + has_duplicates, + io::{Read, Result as IoResult, Write}, + DeserializeExt, + FromBits as _, + FromBytes, + FromBytesDeserializer, + TestRng, + ToBits as _, + ToBytes, + ToBytesSerializer, + Uniform, + }; + + pub use core::{ + cmp::Ordering, + fmt::{self, Debug, Display, Formatter}, + hash::Hash as _, + iter::{Product, Sum}, + ops::{ + Add, + AddAssign, + BitAnd, + BitAndAssign, + BitOr, + BitOrAssign, + BitXor, + BitXorAssign, + Deref, + DerefMut, + Div, + DivAssign, + Mul, + MulAssign, + Neg, + Not, + Rem, + RemAssign, + Shl, + ShlAssign, + Shr, + ShrAssign, + Sub, + SubAssign, + }, + str::{self, FromStr}, + }; + + pub use anyhow::{anyhow, bail, ensure, Error, Result}; + pub use bech32::{self, FromBase32, ToBase32}; + pub use itertools::Itertools; + pub use nom::{ + branch::alt, + bytes::{complete::tag, streaming::take}, + character::complete::{alpha1, alphanumeric1, char, one_of}, + combinator::{complete, fail, map, map_res, opt, recognize}, + multi::{many0, many1, separated_list0, separated_list1}, + sequence::{pair, terminated}, + }; + pub use num_traits::{One, Pow, Zero}; + pub use rand::{ + distributions::{Alphanumeric, Distribution, Standard}, + CryptoRng, + Rng, + }; + pub use serde::{ + de, + de::{DeserializeOwned, SeqAccess, Visitor}, + ser::{self, SerializeSeq, SerializeStruct}, + Deserialize, + Deserializer, + Serialize, + Serializer, + }; +} diff --git a/console/network/environment/src/prelude.rs b/console/network/environment/src/prelude.rs deleted file mode 100644 index 947208152b..0000000000 --- a/console/network/environment/src/prelude.rs +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright (C) 2019-2023 Aleo Systems Inc. -// This file is part of the snarkVM library. - -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at: -// http://www.apache.org/licenses/LICENSE-2.0 - -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -pub use super::*; - -pub use snarkvm_curves::{AffineCurve, MontgomeryParameters, ProjectiveCurve, TwistedEdwardsParameters}; -pub use snarkvm_fields::{Field as _, PrimeField as _, SquareRootField as _, Zero as _}; -pub use snarkvm_utilities::{ - cfg_find, - cfg_find_map, - cfg_into_iter, - cfg_iter, - cfg_iter_mut, - cfg_values, - error, - has_duplicates, - io::{Read, Result as IoResult, Write}, - DeserializeExt, - FromBits as _, - FromBytes, - FromBytesDeserializer, - TestRng, - ToBits as _, - ToBytes, - ToBytesSerializer, - Uniform, -}; - -pub use core::{ - cmp::Ordering, - fmt::{self, Debug, Display, Formatter}, - hash::Hash as _, - iter::{Product, Sum}, - ops::{ - Add, - AddAssign, - BitAnd, - BitAndAssign, - BitOr, - BitOrAssign, - BitXor, - BitXorAssign, - Deref, - DerefMut, - Div, - DivAssign, - Mul, - MulAssign, - Neg, - Not, - Rem, - RemAssign, - Shl, - ShlAssign, - Shr, - ShrAssign, - Sub, - SubAssign, - }, - str::{self, FromStr}, -}; - -pub use anyhow::{anyhow, bail, ensure, Error, Result}; -pub use bech32::{self, FromBase32, ToBase32}; -pub use itertools::Itertools; -pub use nom::{ - branch::alt, - bytes::{complete::tag, streaming::take}, - character::complete::{alpha1, alphanumeric1, char, one_of}, - combinator::{complete, fail, map, map_res, opt, recognize}, - multi::{many0, many1, separated_list0, separated_list1}, - sequence::{pair, terminated}, -}; -pub use num_traits::{One, Pow, Zero}; -pub use rand::{ - distributions::{Alphanumeric, Distribution, Standard}, - CryptoRng, - Rng, -}; -pub use serde::{ - de, - de::{DeserializeOwned, SeqAccess, Visitor}, - ser::{self, SerializeSeq, SerializeStruct}, - Deserialize, - Deserializer, - Serialize, - Serializer, -}; diff --git a/console/network/environment/src/traits/mod.rs b/console/network/environment/src/traits/mod.rs index a4d183a2fd..7e03615c0d 100644 --- a/console/network/environment/src/traits/mod.rs +++ b/console/network/environment/src/traits/mod.rs @@ -30,8 +30,8 @@ pub use from_field::*; pub mod parse; pub use parse::*; -pub mod string; -pub use string::string_parser; +pub mod parse_string; +pub use parse_string::string_parser; pub use snarkvm_utilities::{to_bits_le, ToBits}; @@ -42,14 +42,11 @@ pub mod type_name; pub use type_name::*; pub mod types; -pub use types::*; +pub use types::{ + integer_magnitude::Magnitude, + integer_type::{CheckedPow, CheckedShl, IntegerProperties, IntegerType, WrappingDiv, WrappingPow, WrappingRem}, + *, +}; pub mod visibility; pub use visibility::*; - -pub mod integers { - pub use super::{ - integer_type::{CheckedPow, CheckedShl, IntegerProperties, IntegerType, WrappingDiv, WrappingPow, WrappingRem}, - magnitude::Magnitude, - }; -} diff --git a/console/network/environment/src/traits/string.rs b/console/network/environment/src/traits/parse_string.rs similarity index 100% rename from console/network/environment/src/traits/string.rs rename to console/network/environment/src/traits/parse_string.rs diff --git a/console/network/environment/src/traits/types.rs b/console/network/environment/src/traits/types.rs index 7fb18df9e3..a57bc0aa84 100644 --- a/console/network/environment/src/traits/types.rs +++ b/console/network/environment/src/traits/types.rs @@ -302,7 +302,7 @@ pub trait IntegerCore: { } -pub(super) mod integer_type { +pub mod integer_type { use snarkvm_utilities::{FromBits, FromBytes, ToBits, ToBytes, Uniform}; use core::{ @@ -596,8 +596,8 @@ pub(super) mod integer_type { integer_properties_impl!(i128, u128, true); } -/// Sealed trait pattern to prevent abuse of Magnitude. -pub(super) mod magnitude { +/// Trait pattern to prevent abuse of Magnitude. +pub mod integer_magnitude { use super::integer_type::IntegerType; use num_traits::{ToPrimitive, Unsigned}; diff --git a/console/types/integers/src/lib.rs b/console/types/integers/src/lib.rs index f35e03485e..2f86e9e335 100644 --- a/console/types/integers/src/lib.rs +++ b/console/types/integers/src/lib.rs @@ -38,7 +38,7 @@ 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::integers::*; +use snarkvm_console_network_environment::traits::types::{integer_magnitude::Magnitude, integer_type::IntegerType}; use core::marker::PhantomData; diff --git a/console/types/src/lib.rs b/console/types/src/lib.rs index 6856e14ec0..4563a32655 100644 --- a/console/types/src/lib.rs +++ b/console/types/src/lib.rs @@ -16,44 +16,47 @@ #![allow(clippy::too_many_arguments)] #![warn(clippy::cast_possible_truncation)] -pub use snarkvm_console_network_environment as environment; - -#[cfg(feature = "address")] -pub use snarkvm_console_types_address as address; -#[cfg(feature = "address")] -pub use snarkvm_console_types_address::Address; - -#[cfg(feature = "boolean")] -pub use snarkvm_console_types_boolean as boolean; -#[cfg(feature = "boolean")] -pub use snarkvm_console_types_boolean::Boolean; - -#[cfg(feature = "field")] -pub use snarkvm_console_types_field as field; -#[cfg(feature = "field")] -pub use snarkvm_console_types_field::Field; - -#[cfg(feature = "group")] -pub use snarkvm_console_types_group as group; -#[cfg(feature = "group")] -pub use snarkvm_console_types_group::Group; - -#[cfg(feature = "integers")] -pub use snarkvm_console_types_integers as integers; -#[cfg(feature = "integers")] -pub use snarkvm_console_types_integers::{I128, I16, I32, I64, I8, U128, U16, U32, U64, U8}; - -#[cfg(feature = "scalar")] -pub use snarkvm_console_types_scalar as scalar; -#[cfg(feature = "scalar")] -pub use snarkvm_console_types_scalar::Scalar; - -#[cfg(feature = "string")] -pub use snarkvm_console_types_string as string; -#[cfg(feature = "string")] -pub use snarkvm_console_types_string::StringType; - +pub use modules::*; pub mod prelude { - pub use super::*; + pub use crate::modules::*; pub use snarkvm_console_network_environment::prelude::*; } + +pub mod modules { + pub use snarkvm_console_network_environment as environment; + + #[cfg(feature = "address")] + pub use snarkvm_console_types_address as address; + #[cfg(feature = "address")] + pub use snarkvm_console_types_address::Address; + + #[cfg(feature = "boolean")] + pub use snarkvm_console_types_boolean as boolean; + #[cfg(feature = "boolean")] + pub use snarkvm_console_types_boolean::Boolean; + + #[cfg(feature = "field")] + pub use snarkvm_console_types_field as field; + #[cfg(feature = "field")] + pub use snarkvm_console_types_field::Field; + + #[cfg(feature = "group")] + pub use snarkvm_console_types_group as group; + #[cfg(feature = "group")] + pub use snarkvm_console_types_group::Group; + + #[cfg(feature = "integers")] + pub use snarkvm_console_types_integers as integers; + #[cfg(feature = "integers")] + pub use snarkvm_console_types_integers::{I128, I16, I32, I64, I8, U128, U16, U32, U64, U8}; + + #[cfg(feature = "scalar")] + pub use snarkvm_console_types_scalar as scalar; + #[cfg(feature = "scalar")] + pub use snarkvm_console_types_scalar::Scalar; + + #[cfg(feature = "string")] + pub use snarkvm_console_types_string as string; + #[cfg(feature = "string")] + pub use snarkvm_console_types_string::StringType; +} diff --git a/fields/src/traits/poseidon_grain_lfsr.rs b/fields/src/traits/poseidon_grain_lfsr.rs index 2d28dd6454..f6c0b7ad63 100644 --- a/fields/src/traits/poseidon_grain_lfsr.rs +++ b/fields/src/traits/poseidon_grain_lfsr.rs @@ -39,11 +39,7 @@ impl PoseidonGrainLFSR { state[1] = true; // b2, ..., b5 describes the S-BOX - if is_sbox_an_inverse { - state[5] = true; - } else { - state[5] = false; - } + state[5] = is_sbox_an_inverse; // b6, ..., b17 are the binary representation of n (prime_num_bits) { diff --git a/ledger/src/check_next_block.rs b/ledger/src/check_next_block.rs index 28dcc2b283..edbd50b725 100644 --- a/ledger/src/check_next_block.rs +++ b/ledger/src/check_next_block.rs @@ -311,7 +311,7 @@ impl> Ledger { ConfirmedTransaction::RejectedExecute(_, _, rejected) => Some(rejected.to_id()?), }; - self.check_transaction_basic(transaction.deref(), rejected_id) + self.check_transaction_basic(*transaction, rejected_id) .map_err(|e| anyhow!("Invalid transaction found in the transactions list: {e}")) })?; diff --git a/ledger/src/lib.rs b/ledger/src/lib.rs index 2a5635d051..ebf5437394 100644 --- a/ledger/src/lib.rs +++ b/ledger/src/lib.rs @@ -134,8 +134,8 @@ impl> Ledger { // Safety check the existence of `NUM_BLOCKS` random blocks. const NUM_BLOCKS: usize = 1000; - let block_heights: Vec = (0..=latest_height) - .choose_multiple(&mut OsRng::default(), core::cmp::min(NUM_BLOCKS, latest_height as usize)); + let block_heights: Vec = + (0..=latest_height).choose_multiple(&mut OsRng, core::cmp::min(NUM_BLOCKS, latest_height as usize)); cfg_into_iter!(block_heights).try_for_each(|height| { ledger.get_block(height)?; Ok::<_, Error>(()) diff --git a/synthesizer/process/src/stack/execute.rs b/synthesizer/process/src/stack/execute.rs index c1982da95b..8ba0dedc62 100644 --- a/synthesizer/process/src/stack/execute.rs +++ b/synthesizer/process/src/stack/execute.rs @@ -337,7 +337,7 @@ impl StackExecute for Stack { { // If this function has the finalize command, then construct the finalize inputs. if let Some(command) = function.finalize_command() { - use circuit::ToBits; + use circuit::traits::ToBits; // Ensure the number of inputs is within bounds. ensure!( diff --git a/synthesizer/program/src/lib.rs b/synthesizer/program/src/lib.rs index 90b2499e08..19e3b92425 100644 --- a/synthesizer/program/src/lib.rs +++ b/synthesizer/program/src/lib.rs @@ -33,7 +33,7 @@ pub use function::*; mod import; pub use import::*; -mod logic; +pub mod logic; pub use logic::*; mod mapping; diff --git a/synthesizer/program/src/logic/instruction/operation/commit.rs b/synthesizer/program/src/logic/instruction/operation/commit.rs index bbd63d65fe..3b9c1569c5 100644 --- a/synthesizer/program/src/logic/instruction/operation/commit.rs +++ b/synthesizer/program/src/logic/instruction/operation/commit.rs @@ -154,7 +154,7 @@ impl CommitInstruction { stack: &(impl StackMatches + StackProgram), registers: &mut (impl RegistersLoadCircuit + RegistersStoreCircuit), ) -> Result<()> { - use circuit::ToBits; + use circuit::traits::ToBits; // Ensure the number of operands is correct. if self.operands.len() != 2 { diff --git a/synthesizer/program/src/logic/instruction/operation/hash.rs b/synthesizer/program/src/logic/instruction/operation/hash.rs index 6d099a2eff..43f8511675 100644 --- a/synthesizer/program/src/logic/instruction/operation/hash.rs +++ b/synthesizer/program/src/logic/instruction/operation/hash.rs @@ -212,7 +212,7 @@ impl HashInstruction { stack: &(impl StackMatches + StackProgram), registers: &mut (impl RegistersLoadCircuit + RegistersStoreCircuit), ) -> Result<()> { - use circuit::{ToBits, ToFields}; + use circuit::traits::{ToBits, ToFields}; // Ensure the number of operands is correct. check_number_of_operands(VARIANT, Self::opcode(), self.operands.len())?; diff --git a/synthesizer/program/src/logic/instruction/operation/macros.rs b/synthesizer/program/src/logic/instruction/operation/macros.rs index e5f1197b55..51f5cbd90b 100644 --- a/synthesizer/program/src/logic/instruction/operation/macros.rs +++ b/synthesizer/program/src/logic/instruction/operation/macros.rs @@ -767,7 +767,7 @@ mod tests { ("ensure shifting past boundary halts") => { match *<$operation as $crate::Operation<_, _, _, 2>>::OPCODE { // Note that this case needs special handling, since the desired behavior of `checked_shl` deviates from Rust semantics. - "shl" => should_succeed &= console::prelude::traits::integers::CheckedShl::checked_shl(&*a, &(*b as u32)).is_some(), + "shl" => should_succeed &= console::prelude::CheckedShl::checked_shl(&*a, &(*b as u32)).is_some(), "shr" => should_succeed &= (*a).checked_shr(*b as u32).is_some(), _ => panic!("Unsupported test enforcement for '{}'", <$operation as $crate::Operation<_, _, _, 2>>::OPCODE), } diff --git a/synthesizer/program/src/logic/instruction/operation/mod.rs b/synthesizer/program/src/logic/instruction/operation/mod.rs index fcc587cd3f..7a86303564 100644 --- a/synthesizer/program/src/logic/instruction/operation/mod.rs +++ b/synthesizer/program/src/logic/instruction/operation/mod.rs @@ -61,7 +61,7 @@ pub trait Operation = UnaryLiteral>; crate::operation!( - pub struct AbsOperation { + pub struct AbsOperation { I8 => I8 ("ensure overflows halt"), I16 => I16 ("ensure overflows halt"), I32 => I32 ("ensure overflows halt"), @@ -74,7 +74,7 @@ crate::operation!( pub type AbsWrapped = UnaryLiteral>; crate::operation!( - pub struct AbsWrappedOperation { + pub struct AbsWrappedOperation { I8 => I8, I16 => I16, I32 => I32, @@ -108,7 +108,7 @@ crate::operation!( pub type AddWrapped = BinaryLiteral>; crate::operation!( - pub struct AddWrappedOperation { + pub struct AddWrappedOperation { (I8, I8) => I8, (I16, I16) => I16, (I32, I32) => I32, @@ -165,7 +165,7 @@ crate::operation!( pub type DivWrapped = BinaryLiteral>; crate::operation!( - pub struct DivWrappedOperation { + pub struct DivWrappedOperation { (I8, I8) => I8 ("ensure divide by zero halts"), (I16, I16) => I16 ("ensure divide by zero halts"), (I32, I32) => I32 ("ensure divide by zero halts"), @@ -183,7 +183,7 @@ crate::operation!( pub type Double = UnaryLiteral>; crate::operation!( - pub struct DoubleOperation { + pub struct DoubleOperation { Field => Field, Group => Group, } @@ -193,7 +193,7 @@ crate::operation!( pub type GreaterThan = BinaryLiteral>; crate::operation!( - pub struct GreaterThanOperation { + pub struct GreaterThanOperation { // (Address, Address) => Boolean, (Field, Field) => Boolean, (I8, I8) => Boolean, @@ -214,7 +214,7 @@ crate::operation!( pub type GreaterThanOrEqual = BinaryLiteral>; crate::operation!( - pub struct GreaterThanOrEqualOperation { + pub struct GreaterThanOrEqualOperation { // (Address, Address) => Boolean, (Field, Field) => Boolean, (I8, I8) => Boolean, @@ -235,7 +235,7 @@ crate::operation!( pub type Inv = UnaryLiteral>; crate::operation!( - pub struct InvOperation { + pub struct InvOperation { Field => Field ("ensure inverse of zero halts"), } ); @@ -244,7 +244,7 @@ crate::operation!( pub type LessThan = BinaryLiteral>; crate::operation!( - pub struct LessThanOperation { + pub struct LessThanOperation { // (Address, Address) => Boolean, (Field, Field) => Boolean, (I8, I8) => Boolean, @@ -265,7 +265,7 @@ crate::operation!( pub type LessThanOrEqual = BinaryLiteral>; crate::operation!( - pub struct LessThanOrEqualOperation { + pub struct LessThanOrEqualOperation { // (Address, Address) => Boolean, (Field, Field) => Boolean, (I8, I8) => Boolean, @@ -286,7 +286,7 @@ crate::operation!( pub type Modulo = BinaryLiteral>; crate::operation!( - pub struct ModuloOperation { + pub struct ModuloOperation { (U8, U8) => U8("ensure divide by zero halts"), (U16, U16) => U16("ensure divide by zero halts"), (U32, U32) => U32("ensure divide by zero halts"), @@ -321,7 +321,7 @@ crate::operation!( pub type MulWrapped = BinaryLiteral>; crate::operation!( - pub struct MulWrappedOperation { + pub struct MulWrappedOperation { (I8, I8) => I8, (I16, I16) => I16, (I32, I32) => I32, @@ -339,7 +339,7 @@ crate::operation!( pub type Nand = BinaryLiteral>; crate::operation!( - pub struct NandOperation { + pub struct NandOperation { (Boolean, Boolean) => Boolean, } ); @@ -363,7 +363,7 @@ crate::operation!( pub type Nor = BinaryLiteral>; crate::operation!( - pub struct NorOperation { + pub struct NorOperation { (Boolean, Boolean) => Boolean, } ); @@ -410,7 +410,7 @@ crate::operation!( pub type Pow = BinaryLiteral>; crate::operation!( - pub struct PowOperation { + pub struct PowOperation { (Field, Field) => Field, (I8, U8) => I8 ("ensure exponentiation overflows halt"), (I8, U16) => I8 ("ensure exponentiation overflows halt"), @@ -449,7 +449,7 @@ crate::operation!( pub type PowWrapped = BinaryLiteral>; crate::operation!( - pub struct PowWrappedOperation { + pub struct PowWrappedOperation { (I8, U8) => I8, (I8, U16) => I8, (I8, U32) => I8, @@ -505,7 +505,7 @@ crate::operation!( pub type RemWrapped = BinaryLiteral>; crate::operation!( - pub struct RemWrappedOperation { + pub struct RemWrappedOperation { (I8, I8) => I8 ("ensure divide by zero halts"), (I16, I16) => I16 ("ensure divide by zero halts"), (I32, I32) => I32 ("ensure divide by zero halts"), @@ -523,7 +523,7 @@ crate::operation!( pub type Shl = BinaryLiteral>; crate::operation!( - pub struct ShlOperation { + pub struct ShlOperation { (I8, U8) => I8 ("ensure shifting past boundary halts"), (I8, U16) => I8 ("ensure shifting past boundary halts"), (I8, U32) => I8 ("ensure shifting past boundary halts"), @@ -561,7 +561,7 @@ crate::operation!( pub type ShlWrapped = BinaryLiteral>; crate::operation!( - pub struct ShlWrappedOperation { + pub struct ShlWrappedOperation { (I8, U8) => I8, (I8, U16) => I8, (I8, U32) => I8, @@ -599,7 +599,7 @@ crate::operation!( pub type Shr = BinaryLiteral>; crate::operation!( - pub struct ShrOperation { + pub struct ShrOperation { (I8, U8) => I8 ("ensure shifting past boundary halts"), (I8, U16) => I8 ("ensure shifting past boundary halts"), (I8, U32) => I8 ("ensure shifting past boundary halts"), @@ -637,7 +637,7 @@ crate::operation!( pub type ShrWrapped = BinaryLiteral>; crate::operation!( - pub struct ShrWrappedOperation { + pub struct ShrWrappedOperation { (I8, U8) => I8, (I8, U16) => I8, (I8, U32) => I8, @@ -675,7 +675,7 @@ crate::operation!( pub type Square = UnaryLiteral>; crate::operation!( - pub struct SquareOperation { + pub struct SquareOperation { Field => Field, } ); @@ -684,7 +684,7 @@ crate::operation!( pub type SquareRoot = UnaryLiteral>; crate::operation!( - pub struct SquareRootOperation { + pub struct SquareRootOperation { Field => Field ("ensure quadratic nonresidues halt"), } ); @@ -714,7 +714,7 @@ crate::operation!( pub type SubWrapped = BinaryLiteral>; crate::operation!( - pub struct SubWrappedOperation { + pub struct SubWrappedOperation { (I8, I8) => I8, (I16, I16) => I16, (I32, I32) => I32, @@ -732,7 +732,7 @@ crate::operation!( pub type Ternary = TernaryLiteral>; crate::operation!( - pub struct TernaryOperation { + pub struct TernaryOperation { (Boolean, Address, Address) => Address, (Boolean, Boolean, Boolean) => Boolean, (Boolean, Field, Field) => Field, diff --git a/synthesizer/program/src/traits/command.rs b/synthesizer/program/src/traits/command.rs index c6f55a7077..eb4d2438cd 100644 --- a/synthesizer/program/src/traits/command.rs +++ b/synthesizer/program/src/traits/command.rs @@ -13,7 +13,8 @@ // limitations under the License. use console::{ - prelude::*, + network::Network, + prelude::{FromBytes, Parser, ToBytes}, program::{Identifier, Register}, }; diff --git a/synthesizer/program/src/traits/instruction.rs b/synthesizer/program/src/traits/instruction.rs index 176bfe1343..e65e96694c 100644 --- a/synthesizer/program/src/traits/instruction.rs +++ b/synthesizer/program/src/traits/instruction.rs @@ -12,7 +12,11 @@ // See the License for the specific language governing permissions and // limitations under the License. -use console::{prelude::*, program::Register}; +use console::{ + network::Network, + prelude::{FromBytes, Parser, ToBytes}, + program::Register, +}; pub trait InstructionTrait: Clone + Parser + FromBytes + ToBytes { /// Returns the destination registers of the instruction. diff --git a/synthesizer/snark/src/lib.rs b/synthesizer/snark/src/lib.rs index 9e9c632890..c8aeeccba7 100644 --- a/synthesizer/snark/src/lib.rs +++ b/synthesizer/snark/src/lib.rs @@ -46,8 +46,11 @@ pub use verifying_key::VerifyingKey; #[cfg(test)] pub(crate) mod test_helpers { use super::*; - use circuit::prelude::{Assignment, Circuit, Eject, Environment, Field, Inject, Mode, NumOne, One}; - use console::network::Testnet3; + use circuit::{ + environment::{Assignment, Circuit, Eject, Environment, Inject, Mode, One}, + types::Field, + }; + use console::{network::Testnet3, prelude::One as _}; use once_cell::sync::OnceCell; @@ -134,7 +137,7 @@ pub(crate) mod test_helpers { #[cfg(test)] mod test { use super::*; - use circuit::prelude::{Circuit, Environment, NumOne}; + use circuit::environment::{Circuit, Environment}; use console::network::Testnet3; type CurrentNetwork = Testnet3; diff --git a/synthesizer/src/lib.rs b/synthesizer/src/lib.rs index 9f53430baf..febf14df98 100644 --- a/synthesizer/src/lib.rs +++ b/synthesizer/src/lib.rs @@ -41,9 +41,9 @@ pub mod prelude { #[cfg(feature = "process")] pub use crate::process::*; #[cfg(feature = "program")] - pub use crate::program::*; + pub use crate::program::{Closure, Finalize, Function, Instruction, Mapping, Program}; #[cfg(feature = "snark")] - pub use crate::snark::*; + pub use crate::snark::{Certificate, Proof, ProvingKey, UniversalSRS, VerifyingKey}; #[cfg(all(feature = "process", feature = "program", feature = "snark"))] pub use crate::vm::*; } diff --git a/synthesizer/src/vm/finalize.rs b/synthesizer/src/vm/finalize.rs index 54a711377a..f4932ff9e0 100644 --- a/synthesizer/src/vm/finalize.rs +++ b/synthesizer/src/vm/finalize.rs @@ -244,7 +244,7 @@ impl> VM { // TODO (howardwu): Ensure this fee corresponds to the deployment. // Attempt to finalize the deployment, which should fail. #[cfg(debug_assertions)] - if let Ok(..) = process.finalize_deployment(store, deployment) { + if process.finalize_deployment(store, deployment).is_ok() { // Note: This will abort the entire atomic batch. return Err("Failed to reject a rejected deploy transaction".to_string()); } @@ -260,7 +260,7 @@ impl> VM { // TODO (howardwu): Ensure this fee corresponds to the execution. // Attempt to finalize the execution, which should fail. #[cfg(debug_assertions)] - if let Ok(..) = process.finalize_execution(state, store, execution) { + if process.finalize_execution(state, store, execution).is_ok() { // Note: This will abort the entire atomic batch. return Err("Failed to reject a rejected execute transaction".to_string()); } diff --git a/vm/cli/commands/execute.rs b/vm/cli/commands/execute.rs index 3d07c1808c..6fd0f50164 100644 --- a/vm/cli/commands/execute.rs +++ b/vm/cli/commands/execute.rs @@ -14,8 +14,6 @@ use super::*; -pub const LOCALE: &num_format::Locale = &num_format::Locale::en; - /// Executes an Aleo program function locally #[derive(Debug, Parser)] pub struct Execute { diff --git a/vm/cli/commands/mod.rs b/vm/cli/commands/mod.rs index 865542c637..68f71186e3 100644 --- a/vm/cli/commands/mod.rs +++ b/vm/cli/commands/mod.rs @@ -42,5 +42,7 @@ use colored::Colorize; use core::str::FromStr; use std::collections::HashMap; +pub const LOCALE: &num_format::Locale = &num_format::Locale::en; + pub(crate) type CurrentNetwork = crate::prelude::Testnet3; pub(crate) type Aleo = crate::circuit::AleoV0; diff --git a/vm/cli/commands/run.rs b/vm/cli/commands/run.rs index 4070e3c4b1..db13d5e741 100644 --- a/vm/cli/commands/run.rs +++ b/vm/cli/commands/run.rs @@ -14,8 +14,6 @@ use super::*; -pub const LOCALE: &num_format::Locale = &num_format::Locale::en; - /// Runs an Aleo program function #[derive(Debug, Parser)] pub struct Run { diff --git a/vm/lib.rs b/vm/lib.rs index 31b5691d34..cc5d1cfdaa 100644 --- a/vm/lib.rs +++ b/vm/lib.rs @@ -46,41 +46,11 @@ pub use snarkvm_utilities as utilities; #[cfg(feature = "wasm")] pub use snarkvm_wasm as wasm; -pub mod errors { - #[cfg(feature = "algorithms")] - pub use crate::algorithms::errors::*; - #[cfg(feature = "curves")] - pub use crate::curves::errors::*; - #[cfg(feature = "fields")] - pub use crate::fields::errors::*; - #[cfg(feature = "parameters")] - pub use crate::parameters::errors::*; - #[cfg(feature = "r1cs")] - pub use crate::r1cs::errors::*; -} - -pub mod traits { - #[cfg(feature = "algorithms")] - pub use crate::algorithms::traits::*; - #[cfg(feature = "curves")] - pub use crate::curves::traits::*; - #[cfg(feature = "fields")] - pub use crate::fields::traits::*; -} - pub mod prelude { - pub use crate::{errors::*, traits::*}; - - #[cfg(feature = "algorithms")] - pub use crate::algorithms::prelude::*; #[cfg(feature = "console")] - pub use crate::console::{account::*, network::*, prelude::*, program::*}; + pub use crate::console::{account::*, network::*, program::*}; #[cfg(feature = "ledger")] pub use crate::ledger::*; - #[cfg(feature = "parameters")] - pub use crate::parameters::prelude::*; #[cfg(feature = "synthesizer")] pub use crate::synthesizer::prelude::*; - #[cfg(feature = "utilities")] - pub use crate::utilities::*; } diff --git a/wasm/src/lib.rs b/wasm/src/lib.rs index 878a80bddc..6105b7c352 100644 --- a/wasm/src/lib.rs +++ b/wasm/src/lib.rs @@ -13,15 +13,15 @@ // limitations under the License. #[cfg(feature = "console")] -pub use snarkvm_console::*; +pub use snarkvm_console as console; #[cfg(feature = "curves")] -pub use snarkvm_curves::{bls12_377::*, edwards_bls12::*}; +pub use snarkvm_curves as curves; #[cfg(feature = "fields")] -pub use snarkvm_fields::*; +pub use snarkvm_fields as fields; #[cfg(feature = "synthesizer")] -pub use snarkvm_synthesizer::*; +pub use snarkvm_synthesizer as synthesizer; #[cfg(feature = "utilities")] -pub use snarkvm_utilities::*; +pub use snarkvm_utilities as utilities; #[cfg(test)] mod tests;