From f76245e2986eee889b1cdb117a64d7cd32a44768 Mon Sep 17 00:00:00 2001 From: Robin Salen <30937548+Nashtare@users.noreply.github.com> Date: Thu, 1 Feb 2024 07:16:28 -0500 Subject: [PATCH] Cleanup imports (#1492) --- evm/src/all_stark.rs | 2 +- evm/src/arithmetic/arithmetic_stark.rs | 4 ++-- evm/src/arithmetic/byte.rs | 2 +- evm/src/arithmetic/columns.rs | 2 +- evm/src/arithmetic/divmod.rs | 2 +- evm/src/arithmetic/modular.rs | 2 +- evm/src/arithmetic/utils.rs | 2 +- evm/src/byte_packing/byte_packing_stark.rs | 2 +- evm/src/constraint_consumer.rs | 2 +- evm/src/cpu/columns/general.rs | 6 +++--- evm/src/cpu/columns/mod.rs | 8 ++++---- evm/src/cpu/columns/ops.rs | 6 +++--- evm/src/cpu/cpu_stark.rs | 6 +++--- evm/src/cpu/kernel/assembler.rs | 6 +----- evm/src/cpu/kernel/constants/exc_bitfields.rs | 2 +- evm/src/cpu/kernel/constants/trie_type.rs | 2 +- evm/src/cpu/kernel/interpreter.rs | 11 ++--------- evm/src/cpu/kernel/stack/permutations.rs | 2 +- evm/src/cpu/kernel/stack/stack_manipulation.rs | 4 ++-- evm/src/cpu/kernel/tests/bignum/mod.rs | 2 +- evm/src/cpu/kernel/utils.rs | 2 +- evm/src/cpu/membus.rs | 2 +- evm/src/cpu/stack.rs | 2 +- evm/src/cross_table_lookup.rs | 8 ++++---- evm/src/curve_pairings.rs | 2 +- evm/src/extension_tower.rs | 4 ++-- evm/src/fixed_recursive_verifier.rs | 2 +- evm/src/generation/mpt.rs | 2 +- evm/src/generation/prover_input.rs | 4 ++-- evm/src/keccak/keccak_stark.rs | 12 ++++-------- evm/src/keccak_sponge/columns.rs | 6 +++--- evm/src/keccak_sponge/keccak_sponge_stark.rs | 15 +++++---------- evm/src/logic.rs | 6 +++--- evm/src/memory/memory_stark.rs | 2 +- evm/src/recursive_verifier.rs | 4 ++-- evm/src/util.rs | 2 +- evm/src/verifier.rs | 2 +- evm/src/witness/traces.rs | 2 +- evm/tests/empty_txn_list.rs | 2 +- 39 files changed, 68 insertions(+), 88 deletions(-) diff --git a/evm/src/all_stark.rs b/evm/src/all_stark.rs index cf03a600..fadb9d16 100644 --- a/evm/src/all_stark.rs +++ b/evm/src/all_stark.rs @@ -1,4 +1,4 @@ -use std::iter; +use core::iter; use itertools::Itertools; use plonky2::field::extension::Extendable; diff --git a/evm/src/arithmetic/arithmetic_stark.rs b/evm/src/arithmetic/arithmetic_stark.rs index 1d3af2b9..0165542e 100644 --- a/evm/src/arithmetic/arithmetic_stark.rs +++ b/evm/src/arithmetic/arithmetic_stark.rs @@ -1,5 +1,5 @@ -use std::marker::PhantomData; -use std::ops::Range; +use core::marker::PhantomData; +use core::ops::Range; use plonky2::field::extension::{Extendable, FieldExtension}; use plonky2::field::packed::PackedField; diff --git a/evm/src/arithmetic/byte.rs b/evm/src/arithmetic/byte.rs index b7381ae0..f7581efa 100644 --- a/evm/src/arithmetic/byte.rs +++ b/evm/src/arithmetic/byte.rs @@ -60,7 +60,7 @@ //! y * 256 ∈ {0, 256, 512, ..., 2^16 - 256} //! 8. Hence y ∈ {0, 1, ..., 255} -use std::ops::Range; +use core::ops::Range; use ethereum_types::U256; use plonky2::field::extension::Extendable; diff --git a/evm/src/arithmetic/columns.rs b/evm/src/arithmetic/columns.rs index dc535492..e4172bc0 100644 --- a/evm/src/arithmetic/columns.rs +++ b/evm/src/arithmetic/columns.rs @@ -1,6 +1,6 @@ //! Arithmetic unit -use std::ops::Range; +use core::ops::Range; pub(crate) const LIMB_BITS: usize = 16; const EVM_REGISTER_BITS: usize = 256; diff --git a/evm/src/arithmetic/divmod.rs b/evm/src/arithmetic/divmod.rs index b284c829..a4599dc7 100644 --- a/evm/src/arithmetic/divmod.rs +++ b/evm/src/arithmetic/divmod.rs @@ -2,7 +2,7 @@ //! //! The logic for verifying them is detailed in the `modular` submodule. -use std::ops::Range; +use core::ops::Range; use ethereum_types::U256; use plonky2::field::extension::Extendable; diff --git a/evm/src/arithmetic/modular.rs b/evm/src/arithmetic/modular.rs index 05f9cf0d..5a1df5c7 100644 --- a/evm/src/arithmetic/modular.rs +++ b/evm/src/arithmetic/modular.rs @@ -108,7 +108,7 @@ //! only require 96 columns, or 80 if the output doesn't need to be //! reduced. -use std::ops::Range; +use core::ops::Range; use ethereum_types::U256; use num::bigint::Sign; diff --git a/evm/src/arithmetic/utils.rs b/evm/src/arithmetic/utils.rs index 7fadb8f1..7350dd32 100644 --- a/evm/src/arithmetic/utils.rs +++ b/evm/src/arithmetic/utils.rs @@ -1,4 +1,4 @@ -use std::ops::{Add, AddAssign, Mul, Neg, Range, Shr, Sub, SubAssign}; +use core::ops::{Add, AddAssign, Mul, Neg, Range, Shr, Sub, SubAssign}; use ethereum_types::U256; use plonky2::field::extension::Extendable; diff --git a/evm/src/byte_packing/byte_packing_stark.rs b/evm/src/byte_packing/byte_packing_stark.rs index 0de8968a..03449d0d 100644 --- a/evm/src/byte_packing/byte_packing_stark.rs +++ b/evm/src/byte_packing/byte_packing_stark.rs @@ -25,7 +25,7 @@ //! This means that the higher-order bytes will be thrown away during the process, if the value //! is greater than 256^length, and as a result a different value will be stored in memory. -use std::marker::PhantomData; +use core::marker::PhantomData; use itertools::Itertools; use plonky2::field::extension::{Extendable, FieldExtension}; diff --git a/evm/src/constraint_consumer.rs b/evm/src/constraint_consumer.rs index 470e2db2..919b5163 100644 --- a/evm/src/constraint_consumer.rs +++ b/evm/src/constraint_consumer.rs @@ -1,4 +1,4 @@ -use std::marker::PhantomData; +use core::marker::PhantomData; use plonky2::field::extension::Extendable; use plonky2::field::packed::PackedField; diff --git a/evm/src/cpu/columns/general.rs b/evm/src/cpu/columns/general.rs index 08b6c82d..f565acc6 100644 --- a/evm/src/cpu/columns/general.rs +++ b/evm/src/cpu/columns/general.rs @@ -1,6 +1,6 @@ -use std::borrow::{Borrow, BorrowMut}; -use std::fmt::{Debug, Formatter}; -use std::mem::{size_of, transmute}; +use core::borrow::{Borrow, BorrowMut}; +use core::fmt::{Debug, Formatter}; +use core::mem::{size_of, transmute}; /// General purpose columns, which can have different meanings depending on what CTL or other /// operation is occurring at this row. diff --git a/evm/src/cpu/columns/mod.rs b/evm/src/cpu/columns/mod.rs index 8a0ad0a5..92da4e99 100644 --- a/evm/src/cpu/columns/mod.rs +++ b/evm/src/cpu/columns/mod.rs @@ -1,7 +1,7 @@ -use std::borrow::{Borrow, BorrowMut}; -use std::fmt::Debug; -use std::mem::{size_of, transmute}; -use std::ops::{Index, IndexMut}; +use core::borrow::{Borrow, BorrowMut}; +use core::fmt::Debug; +use core::mem::{size_of, transmute}; +use core::ops::{Index, IndexMut}; use plonky2::field::types::Field; diff --git a/evm/src/cpu/columns/ops.rs b/evm/src/cpu/columns/ops.rs index 0c5be6ef..c15d6572 100644 --- a/evm/src/cpu/columns/ops.rs +++ b/evm/src/cpu/columns/ops.rs @@ -1,6 +1,6 @@ -use std::borrow::{Borrow, BorrowMut}; -use std::mem::{size_of, transmute}; -use std::ops::{Deref, DerefMut}; +use core::borrow::{Borrow, BorrowMut}; +use core::mem::{size_of, transmute}; +use core::ops::{Deref, DerefMut}; use crate::util::transmute_no_compile_time_size_checks; diff --git a/evm/src/cpu/cpu_stark.rs b/evm/src/cpu/cpu_stark.rs index 1212e7a7..91e1f3ef 100644 --- a/evm/src/cpu/cpu_stark.rs +++ b/evm/src/cpu/cpu_stark.rs @@ -1,6 +1,6 @@ -use std::borrow::Borrow; -use std::iter::repeat; -use std::marker::PhantomData; +use core::borrow::Borrow; +use core::iter::repeat; +use core::marker::PhantomData; use itertools::Itertools; use plonky2::field::extension::{Extendable, FieldExtension}; diff --git a/evm/src/cpu/kernel/assembler.rs b/evm/src/cpu/kernel/assembler.rs index 29c46ce1..7a546e77 100644 --- a/evm/src/cpu/kernel/assembler.rs +++ b/evm/src/cpu/kernel/assembler.rs @@ -430,12 +430,8 @@ fn push_target_size(target: &PushTarget) -> u8 { #[cfg(test)] mod tests { - use std::collections::HashMap; - - use itertools::Itertools; - + use super::*; use crate::cpu::kernel::assembler::*; - use crate::cpu::kernel::ast::*; use crate::cpu::kernel::parser::parse; #[test] diff --git a/evm/src/cpu/kernel/constants/exc_bitfields.rs b/evm/src/cpu/kernel/constants/exc_bitfields.rs index 6054bf9b..59dec8b1 100644 --- a/evm/src/cpu/kernel/constants/exc_bitfields.rs +++ b/evm/src/cpu/kernel/constants/exc_bitfields.rs @@ -1,4 +1,4 @@ -use std::ops::RangeInclusive; +use core::ops::RangeInclusive; use ethereum_types::U256; diff --git a/evm/src/cpu/kernel/constants/trie_type.rs b/evm/src/cpu/kernel/constants/trie_type.rs index 5120c163..fd89f410 100644 --- a/evm/src/cpu/kernel/constants/trie_type.rs +++ b/evm/src/cpu/kernel/constants/trie_type.rs @@ -1,4 +1,4 @@ -use std::ops::Deref; +use core::ops::Deref; use eth_trie_utils::partial_trie::HashedPartialTrie; diff --git a/evm/src/cpu/kernel/interpreter.rs b/evm/src/cpu/kernel/interpreter.rs index be66d2e9..7ba5809f 100644 --- a/evm/src/cpu/kernel/interpreter.rs +++ b/evm/src/cpu/kernel/interpreter.rs @@ -1,8 +1,8 @@ //! An EVM interpreter for testing and debugging purposes. use core::cmp::Ordering; +use core::ops::Range; use std::collections::{BTreeSet, HashMap, HashSet}; -use std::ops::Range; use anyhow::bail; use eth_trie_utils::partial_trie::PartialTrie; @@ -1664,15 +1664,8 @@ pub(crate) use unpack_address; #[cfg(test)] mod tests { - use std::collections::HashMap; - - use ethereum_types::U256; - - use crate::cpu::kernel::constants::context_metadata::ContextMetadata; - use crate::cpu::kernel::interpreter::{run, Interpreter}; + use super::*; use crate::memory::segments::Segment; - use crate::witness::memory::MemoryAddress; - use crate::witness::operation::CONTEXT_SCALING_FACTOR; #[test] fn test_run() -> anyhow::Result<()> { diff --git a/evm/src/cpu/kernel/stack/permutations.rs b/evm/src/cpu/kernel/stack/permutations.rs index 69d5f2e6..71304edd 100644 --- a/evm/src/cpu/kernel/stack/permutations.rs +++ b/evm/src/cpu/kernel/stack/permutations.rs @@ -19,8 +19,8 @@ //! //! We typically represent a `(0 i)` transposition as a single scalar `i`. +use core::hash::Hash; use std::collections::{HashMap, HashSet}; -use std::hash::Hash; use crate::cpu::kernel::stack::stack_manipulation::{StackItem, StackOp}; diff --git a/evm/src/cpu/kernel/stack/stack_manipulation.rs b/evm/src/cpu/kernel/stack/stack_manipulation.rs index 5214351c..a7b376c5 100644 --- a/evm/src/cpu/kernel/stack/stack_manipulation.rs +++ b/evm/src/cpu/kernel/stack/stack_manipulation.rs @@ -1,7 +1,7 @@ -use std::cmp::Ordering; +use core::cmp::Ordering; +use core::hash::Hash; use std::collections::hash_map::Entry::{Occupied, Vacant}; use std::collections::{BinaryHeap, HashMap}; -use std::hash::Hash; use itertools::Itertools; diff --git a/evm/src/cpu/kernel/tests/bignum/mod.rs b/evm/src/cpu/kernel/tests/bignum/mod.rs index 9e15d96f..0cc6f0dc 100644 --- a/evm/src/cpu/kernel/tests/bignum/mod.rs +++ b/evm/src/cpu/kernel/tests/bignum/mod.rs @@ -1,4 +1,4 @@ -use std::cmp::Ordering; +use core::cmp::Ordering; use std::fs::File; use std::io::{BufRead, BufReader}; use std::path::PathBuf; diff --git a/evm/src/cpu/kernel/utils.rs b/evm/src/cpu/kernel/utils.rs index eea033d4..18b5f548 100644 --- a/evm/src/cpu/kernel/utils.rs +++ b/evm/src/cpu/kernel/utils.rs @@ -1,4 +1,4 @@ -use std::fmt::Debug; +use core::fmt::Debug; use ethereum_types::U256; use plonky2_util::ceil_div_usize; diff --git a/evm/src/cpu/membus.rs b/evm/src/cpu/membus.rs index fb6c5301..6ce84561 100644 --- a/evm/src/cpu/membus.rs +++ b/evm/src/cpu/membus.rs @@ -11,7 +11,7 @@ pub(crate) const NUM_GP_CHANNELS: usize = 3; /// Indices for code and general purpose memory channels. pub mod channel_indices { - use std::ops::Range; + use core::ops::Range; pub(crate) const CODE: usize = 0; pub(crate) const GP: Range = CODE + 1..(CODE + 1) + super::NUM_GP_CHANNELS; diff --git a/evm/src/cpu/stack.rs b/evm/src/cpu/stack.rs index 9acf1f3a..87ca7ee1 100644 --- a/evm/src/cpu/stack.rs +++ b/evm/src/cpu/stack.rs @@ -1,4 +1,4 @@ -use std::cmp::max; +use core::cmp::max; use itertools::izip; use plonky2::field::extension::Extendable; diff --git a/evm/src/cross_table_lookup.rs b/evm/src/cross_table_lookup.rs index 428279ba..c3110ee8 100644 --- a/evm/src/cross_table_lookup.rs +++ b/evm/src/cross_table_lookup.rs @@ -27,10 +27,10 @@ //! is similar, but we provide not only `local_values` but also `next_values` -- corresponding to //! the current and next row values -- when computing the linear combinations. -use std::borrow::Borrow; -use std::cmp::min; -use std::fmt::Debug; -use std::iter::repeat; +use core::borrow::Borrow; +use core::cmp::min; +use core::fmt::Debug; +use core::iter::repeat; use anyhow::{ensure, Result}; use hashbrown::HashMap; diff --git a/evm/src/curve_pairings.rs b/evm/src/curve_pairings.rs index 71188a21..af155cc5 100644 --- a/evm/src/curve_pairings.rs +++ b/evm/src/curve_pairings.rs @@ -1,4 +1,4 @@ -use std::ops::{Add, Mul, Neg}; +use core::ops::{Add, Mul, Neg}; use ethereum_types::U256; use rand::distributions::Standard; diff --git a/evm/src/extension_tower.rs b/evm/src/extension_tower.rs index da7cca55..ea4e3176 100644 --- a/evm/src/extension_tower.rs +++ b/evm/src/extension_tower.rs @@ -1,5 +1,5 @@ -use std::fmt::Debug; -use std::ops::{Add, Div, Mul, Neg, Sub}; +use core::fmt::Debug; +use core::ops::{Add, Div, Mul, Neg, Sub}; use ethereum_types::{U256, U512}; use rand::distributions::{Distribution, Standard}; diff --git a/evm/src/fixed_recursive_verifier.rs b/evm/src/fixed_recursive_verifier.rs index 58db9987..c7a705c3 100644 --- a/evm/src/fixed_recursive_verifier.rs +++ b/evm/src/fixed_recursive_verifier.rs @@ -1,6 +1,6 @@ use core::mem::{self, MaybeUninit}; +use core::ops::Range; use std::collections::BTreeMap; -use std::ops::Range; use std::path::Path; use std::sync::atomic::AtomicBool; use std::sync::Arc; diff --git a/evm/src/generation/mpt.rs b/evm/src/generation/mpt.rs index a2abe1b2..71976bc0 100644 --- a/evm/src/generation/mpt.rs +++ b/evm/src/generation/mpt.rs @@ -1,5 +1,5 @@ +use core::ops::Deref; use std::collections::HashMap; -use std::ops::Deref; use bytes::Bytes; use eth_trie_utils::nibbles::Nibbles; diff --git a/evm/src/generation/prover_input.rs b/evm/src/generation/prover_input.rs index 0214b847..5c0aba1a 100644 --- a/evm/src/generation/prover_input.rs +++ b/evm/src/generation/prover_input.rs @@ -1,6 +1,6 @@ -use std::cmp::min; +use core::cmp::min; +use core::mem::transmute; use std::collections::{BTreeSet, HashMap}; -use std::mem::transmute; use std::str::FromStr; use anyhow::{bail, Error}; diff --git a/evm/src/keccak/keccak_stark.rs b/evm/src/keccak/keccak_stark.rs index 63098e79..26edc40a 100644 --- a/evm/src/keccak/keccak_stark.rs +++ b/evm/src/keccak/keccak_stark.rs @@ -1,4 +1,4 @@ -use std::marker::PhantomData; +use core::marker::PhantomData; use itertools::Itertools; use plonky2::field::extension::{Extendable, FieldExtension}; @@ -622,21 +622,17 @@ impl, const D: usize> Stark for KeccakStark, const D: usize> Stark for KeccakSpongeS #[cfg(test)] mod tests { - use std::borrow::Borrow; - use anyhow::Result; - use itertools::Itertools; use keccak_hash::keccak; use plonky2::field::goldilocks_field::GoldilocksField; use plonky2::field::types::PrimeField64; use plonky2::plonk::config::{GenericConfig, PoseidonGoldilocksConfig}; - use crate::keccak_sponge::columns::KeccakSpongeColumnsView; - use crate::keccak_sponge::keccak_sponge_stark::{KeccakSpongeOp, KeccakSpongeStark}; + use super::*; use crate::memory::segments::Segment; use crate::stark_testing::{test_stark_circuit_constraints, test_stark_low_degree}; - use crate::witness::memory::MemoryAddress; #[test] fn test_stark_degree() -> Result<()> { diff --git a/evm/src/logic.rs b/evm/src/logic.rs index 43ea2342..c03991af 100644 --- a/evm/src/logic.rs +++ b/evm/src/logic.rs @@ -1,4 +1,4 @@ -use std::marker::PhantomData; +use core::marker::PhantomData; use ethereum_types::U256; use itertools::izip; @@ -28,8 +28,8 @@ const PACKED_LEN: usize = ceil_div_usize(VAL_BITS, PACKED_LIMB_BITS); /// `LogicStark` columns. pub(crate) mod columns { - use std::cmp::min; - use std::ops::Range; + use core::cmp::min; + use core::ops::Range; use super::{PACKED_LEN, PACKED_LIMB_BITS, VAL_BITS}; diff --git a/evm/src/memory/memory_stark.rs b/evm/src/memory/memory_stark.rs index 13ea1166..5adf46c7 100644 --- a/evm/src/memory/memory_stark.rs +++ b/evm/src/memory/memory_stark.rs @@ -1,4 +1,4 @@ -use std::marker::PhantomData; +use core::marker::PhantomData; use ethereum_types::U256; use itertools::Itertools; diff --git a/evm/src/recursive_verifier.rs b/evm/src/recursive_verifier.rs index 8d10b498..f3065e10 100644 --- a/evm/src/recursive_verifier.rs +++ b/evm/src/recursive_verifier.rs @@ -1,5 +1,5 @@ -use std::array::from_fn; -use std::fmt::Debug; +use core::array::from_fn; +use core::fmt::Debug; use anyhow::Result; use ethereum_types::{BigEndianHash, H256, U256}; diff --git a/evm/src/util.rs b/evm/src/util.rs index f4d80859..aec2e63e 100644 --- a/evm/src/util.rs +++ b/evm/src/util.rs @@ -1,4 +1,4 @@ -use std::mem::{size_of, transmute_copy, ManuallyDrop}; +use core::mem::{size_of, transmute_copy, ManuallyDrop}; use ethereum_types::{H160, H256, U256}; use itertools::Itertools; diff --git a/evm/src/verifier.rs b/evm/src/verifier.rs index 9eb12100..a173be5b 100644 --- a/evm/src/verifier.rs +++ b/evm/src/verifier.rs @@ -1,4 +1,4 @@ -use std::any::type_name; +use core::any::type_name; use anyhow::{ensure, Result}; use ethereum_types::{BigEndianHash, U256}; diff --git a/evm/src/witness/traces.rs b/evm/src/witness/traces.rs index d767aa7f..f7f5c9d3 100644 --- a/evm/src/witness/traces.rs +++ b/evm/src/witness/traces.rs @@ -1,4 +1,4 @@ -use std::mem::size_of; +use core::mem::size_of; use itertools::Itertools; use plonky2::field::extension::Extendable; diff --git a/evm/tests/empty_txn_list.rs b/evm/tests/empty_txn_list.rs index 2130e51b..15416c8c 100644 --- a/evm/tests/empty_txn_list.rs +++ b/evm/tests/empty_txn_list.rs @@ -1,5 +1,5 @@ +use core::marker::PhantomData; use std::collections::HashMap; -use std::marker::PhantomData; use std::time::Duration; use env_logger::{try_init_from_env, Env, DEFAULT_FILTER_ENV};