diff --git a/Cargo.lock b/Cargo.lock index 872ed5757d..1428b50c55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1392,7 +1392,6 @@ dependencies = [ "base64 0.13.1", "ethers-core", "ethers-signers", - "halo2-base", "halo2_proofs", "hex", "itertools 0.11.0", diff --git a/circuit-benchmarks/src/bytecode_circuit.rs b/circuit-benchmarks/src/bytecode_circuit.rs index b408853913..6664f0908c 100644 --- a/circuit-benchmarks/src/bytecode_circuit.rs +++ b/circuit-benchmarks/src/bytecode_circuit.rs @@ -4,7 +4,7 @@ mod tests { use ark_std::{end_timer, start_timer}; use bus_mapping::evm::OpcodeId; - use eth_types::{evm_types::MAX_CODE_SIZE, Field}; + use eth_types::evm_types::MAX_CODE_SIZE; use halo2_proofs::{ halo2curves::bn256::{Bn256, Fr, G1Affine}, plonk::{create_proof, keygen_pk, keygen_vk, verify_proof}, @@ -28,7 +28,7 @@ mod tests { bytecode_unroller::{unroll, UnrolledBytecode}, TestBytecodeCircuit, }, - util::SubCircuit, + util::{Field, SubCircuit}, }; #[cfg_attr(not(feature = "benches"), ignore)] diff --git a/eth-types/Cargo.toml b/eth-types/Cargo.toml index f95ea5b794..25d7eef52f 100644 --- a/eth-types/Cargo.toml +++ b/eth-types/Cargo.toml @@ -9,7 +9,6 @@ ethers-core.workspace = true ethers-signers.workspace = true hex.workspace = true halo2_proofs.workspace = true -halo2-base.workspace = true log.workspace = true regex.workspace = true serde.workspace = true diff --git a/eth-types/src/lib.rs b/eth-types/src/lib.rs index 3534b473ab..74d1e07437 100644 --- a/eth-types/src/lib.rs +++ b/eth-types/src/lib.rs @@ -45,7 +45,6 @@ pub use ethers_core::{ Address, Block, Bytes, Signature, H160, H256, H64, U256, U64, }, }; -use halo2_base::utils::ScalarField; use halo2_proofs::halo2curves::{bn256::Fr, group::ff::PrimeField}; use serde::{de, Deserialize, Deserializer, Serialize}; use std::{ @@ -89,7 +88,7 @@ pub mod base64 { /// Trait used to reduce verbosity with the declaration of the [`Field`] /// trait and its repr. pub trait Field: - PrimeField + hash_circuit::hash::Hashable + std::convert::From + ScalarField + PrimeField + hash_circuit::hash::Hashable + std::convert::From { /// Re-expose zero element as a function fn zero() -> Self { diff --git a/zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs b/zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs index 8e10a9f362..6946d7ae4e 100644 --- a/zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs +++ b/zkevm-circuits/src/bytecode_circuit/bytecode_unroller.rs @@ -1,5 +1,8 @@ -use crate::{table::BytecodeFieldTag, util::get_push_size}; -use eth_types::{state_db::CodeDB, Field, ToWord, Word, U256}; +use crate::{ + table::BytecodeFieldTag, + util::{get_push_size, Field}, +}; +use eth_types::{state_db::CodeDB, ToWord, Word, U256}; use std::vec; /// Public data for the bytecode diff --git a/zkevm-circuits/src/bytecode_circuit/circuit.rs b/zkevm-circuits/src/bytecode_circuit/circuit.rs index f19de695c7..99e1797586 100644 --- a/zkevm-circuits/src/bytecode_circuit/circuit.rs +++ b/zkevm-circuits/src/bytecode_circuit/circuit.rs @@ -5,11 +5,11 @@ use crate::{ not, or, rlc, select, }, table::{BytecodeFieldTag, BytecodeTable, KeccakTable, LookupTable}, - util::{get_push_size, Challenges, Expr, SubCircuit, SubCircuitConfig}, + util::{get_push_size, Challenges, Expr, Field, SubCircuit, SubCircuitConfig}, witness, }; use eth_types::{ - state_db::EMPTY_CODE_HASH_LE, Field, ToLittleEndian, ToScalar, ToWord, POSEIDON_CODE_HASH_EMPTY, + state_db::EMPTY_CODE_HASH_LE, ToLittleEndian, ToScalar, ToWord, POSEIDON_CODE_HASH_EMPTY, }; use gadgets::is_zero::{IsZeroChip, IsZeroConfig, IsZeroInstruction}; use halo2_proofs::{ diff --git a/zkevm-circuits/src/bytecode_circuit/circuit/to_poseidon_hash.rs b/zkevm-circuits/src/bytecode_circuit/circuit/to_poseidon_hash.rs index 374d20193e..f614afe5e3 100644 --- a/zkevm-circuits/src/bytecode_circuit/circuit/to_poseidon_hash.rs +++ b/zkevm-circuits/src/bytecode_circuit/circuit/to_poseidon_hash.rs @@ -5,10 +5,10 @@ use crate::{ not, or, select, }, table::{BytecodeFieldTag, KeccakTable, PoseidonTable}, - util::{Challenges, Expr, SubCircuitConfig}, + util::{Challenges, Expr, Field, SubCircuitConfig}, }; use bus_mapping::util::POSEIDON_CODE_HASH_EMPTY; -use eth_types::{Field, ToScalar, ToWord}; +use eth_types::{ToScalar, ToWord}; use gadgets::is_zero::IsZeroChip; use halo2_proofs::{ circuit::{Layouter, Region, Value}, diff --git a/zkevm-circuits/src/bytecode_circuit/dev.rs b/zkevm-circuits/src/bytecode_circuit/dev.rs index e5c8a74ebe..9f2ac61f05 100644 --- a/zkevm-circuits/src/bytecode_circuit/dev.rs +++ b/zkevm-circuits/src/bytecode_circuit/dev.rs @@ -3,9 +3,8 @@ pub use super::circuit::BytecodeCircuit; use crate::{ bytecode_circuit::circuit::BytecodeCircuitConfigArgs, table::{BytecodeTable, KeccakTable}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, }; -use eth_types::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, plonk::{Circuit, ConstraintSystem, Error}, diff --git a/zkevm-circuits/src/bytecode_circuit/test.rs b/zkevm-circuits/src/bytecode_circuit/test.rs index c0538f431e..a2c1cfe17f 100644 --- a/zkevm-circuits/src/bytecode_circuit/test.rs +++ b/zkevm-circuits/src/bytecode_circuit/test.rs @@ -2,10 +2,10 @@ use crate::{ bytecode_circuit::{bytecode_unroller::*, circuit::BytecodeCircuit}, table::BytecodeFieldTag, - util::{is_push_with_data, keccak, unusable_rows, Challenges, SubCircuit}, + util::{is_push_with_data, keccak, unusable_rows, Challenges, Field, SubCircuit}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{state_db::CodeDB, Bytecode, Field, ToWord, Word}; +use eth_types::{state_db::CodeDB, Bytecode, ToWord, Word}; use halo2_proofs::{dev::MockProver, halo2curves::bn256::Fr}; use log::error; diff --git a/zkevm-circuits/src/copy_circuit.rs b/zkevm-circuits/src/copy_circuit.rs index adf299e58e..65d73c72ac 100644 --- a/zkevm-circuits/src/copy_circuit.rs +++ b/zkevm-circuits/src/copy_circuit.rs @@ -11,9 +11,10 @@ mod test; #[cfg(any(feature = "test", test, feature = "test-circuits"))] pub use dev::CopyCircuit as TestCopyCircuit; +use crate::util::Field; use array_init::array_init; use bus_mapping::circuit_input_builder::{CopyDataType, CopyEvent}; -use eth_types::{Field, Word}; +use eth_types::Word; use gadgets::{ binary_number::BinaryNumberChip, is_equal::{IsEqualChip, IsEqualConfig, IsEqualInstruction}, diff --git a/zkevm-circuits/src/copy_circuit/copy_gadgets.rs b/zkevm-circuits/src/copy_circuit/copy_gadgets.rs index f9e3040b7e..2dee65f004 100644 --- a/zkevm-circuits/src/copy_circuit/copy_gadgets.rs +++ b/zkevm-circuits/src/copy_circuit/copy_gadgets.rs @@ -1,6 +1,6 @@ use super::{CURRENT, NEXT_ROW, NEXT_STEP}; +use crate::util::Field; use bus_mapping::circuit_input_builder::CopyDataType; -use eth_types::Field; use gadgets::{ binary_number::BinaryNumberConfig, is_equal::IsEqualConfig, diff --git a/zkevm-circuits/src/copy_circuit/dev.rs b/zkevm-circuits/src/copy_circuit/dev.rs index 4aa744640d..71f94ff6d2 100644 --- a/zkevm-circuits/src/copy_circuit/dev.rs +++ b/zkevm-circuits/src/copy_circuit/dev.rs @@ -3,9 +3,8 @@ pub use super::CopyCircuit; use crate::{ copy_circuit::{CopyCircuitConfig, CopyCircuitConfigArgs}, table::{BytecodeTable, CopyTable, RwTable, TxTable}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, }; -use eth_types::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, plonk::{Challenge, Circuit, ConstraintSystem, Error}, diff --git a/zkevm-circuits/src/copy_circuit/util.rs b/zkevm-circuits/src/copy_circuit/util.rs index 9bb2b152ed..ef57f62843 100644 --- a/zkevm-circuits/src/copy_circuit/util.rs +++ b/zkevm-circuits/src/copy_circuit/util.rs @@ -1,6 +1,5 @@ -use crate::evm_circuit::util::rlc; +use crate::{evm_circuit::util::rlc, util::Field}; use bus_mapping::circuit_input_builder::NumberOrHash; -use eth_types::Field; use halo2_proofs::circuit::Value; /// Encode the type `NumberOrHash` into a field element diff --git a/zkevm-circuits/src/ecc_circuit.rs b/zkevm-circuits/src/ecc_circuit.rs index 16be9af4f9..e9d56f4b69 100644 --- a/zkevm-circuits/src/ecc_circuit.rs +++ b/zkevm-circuits/src/ecc_circuit.rs @@ -3,11 +3,12 @@ use std::{iter, marker::PhantomData}; +use crate::util::Field; use bus_mapping::{ circuit_input_builder::{EcAddOp, EcMulOp, EcPairingOp, N_BYTES_PER_PAIR, N_PAIRING_PER_OP}, precompile::PrecompileCalls, }; -use eth_types::{Field, ToLittleEndian, ToScalar, U256}; +use eth_types::{ToLittleEndian, ToScalar, U256}; use halo2_base::{ gates::{GateInstructions, RangeInstructions}, utils::{decompose_bigint_option, fe_to_biguint, modulus}, diff --git a/zkevm-circuits/src/ecc_circuit/dev.rs b/zkevm-circuits/src/ecc_circuit/dev.rs index 21147349bd..6e74489861 100644 --- a/zkevm-circuits/src/ecc_circuit/dev.rs +++ b/zkevm-circuits/src/ecc_circuit/dev.rs @@ -1,4 +1,4 @@ -use eth_types::Field; +use crate::util::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, plonk::{Challenge, Circuit, ConstraintSystem, Error}, diff --git a/zkevm-circuits/src/ecc_circuit/test.rs b/zkevm-circuits/src/ecc_circuit/test.rs index 4de6e9fc3b..a077b9e235 100644 --- a/zkevm-circuits/src/ecc_circuit/test.rs +++ b/zkevm-circuits/src/ecc_circuit/test.rs @@ -3,10 +3,11 @@ use std::{ ops::{Add, Mul, Neg}, }; +use crate::util::Field; use bus_mapping::circuit_input_builder::{ EcAddOp, EcMulOp, EcPairingOp, EcPairingPair, PrecompileEcParams, }; -use eth_types::{Field, U256}; +use eth_types::U256; use halo2_proofs::{ arithmetic::Field as ArithmeticField, dev::MockProver, diff --git a/zkevm-circuits/src/ecc_circuit/util.rs b/zkevm-circuits/src/ecc_circuit/util.rs index 92c49c35d3..903e5d637a 100644 --- a/zkevm-circuits/src/ecc_circuit/util.rs +++ b/zkevm-circuits/src/ecc_circuit/util.rs @@ -1,4 +1,4 @@ -use eth_types::Field; +use crate::util::Field; use halo2_base::{AssignedValue, QuantumCell}; use halo2_ecc::{bigint::CRTInteger, ecc::EcPoint, fields::FieldExtPoint}; diff --git a/zkevm-circuits/src/evm_circuit.rs b/zkevm-circuits/src/evm_circuit.rs index ea6619c845..338684cd64 100644 --- a/zkevm-circuits/src/evm_circuit.rs +++ b/zkevm-circuits/src/evm_circuit.rs @@ -25,10 +25,9 @@ use crate::{ BlockTable, BytecodeTable, CopyTable, EccTable, ExpTable, KeccakTable, LookupTable, ModExpTable, PowOfRandTable, RwTable, SHA256Table, SigTable, TxTable, }, - util::{SubCircuit, SubCircuitConfig}, + util::{Field, SubCircuit, SubCircuitConfig}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use execution::ExecutionConfig; use itertools::Itertools; use strum::IntoEnumIterator; diff --git a/zkevm-circuits/src/evm_circuit/execution.rs b/zkevm-circuits/src/evm_circuit/execution.rs index 97f38187a0..1fbc7ab9c8 100644 --- a/zkevm-circuits/src/evm_circuit/execution.rs +++ b/zkevm-circuits/src/evm_circuit/execution.rs @@ -22,10 +22,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{LookupTable, RwTableTag, TxReceiptFieldTag}, - util::{query_expression, Challenges, Expr}, + util::{query_expression, Challenges, Expr, Field}, }; use bus_mapping::util::read_env_var; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use gadgets::util::not; use halo2_proofs::{ circuit::{Layouter, Region, Value}, diff --git a/zkevm-circuits/src/evm_circuit/execution/add_sub.rs b/zkevm-circuits/src/evm_circuit/execution/add_sub.rs index fb6e457e27..789783d11e 100644 --- a/zkevm-circuits/src/evm_circuit/execution/add_sub.rs +++ b/zkevm-circuits/src/evm_circuit/execution/add_sub.rs @@ -10,10 +10,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::plonk::Error; // AddGadget verifies ADD and SUB at the same time by an extra swap flag, diff --git a/zkevm-circuits/src/evm_circuit/execution/addmod.rs b/zkevm-circuits/src/evm_circuit/execution/addmod.rs index 105b37c98f..b88124c96b 100644 --- a/zkevm-circuits/src/evm_circuit/execution/addmod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/addmod.rs @@ -19,8 +19,9 @@ use crate::{ util::Expr, }; +use crate::util::Field; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian, U256, U512}; +use eth_types::{ToLittleEndian, U256, U512}; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/address.rs b/zkevm-circuits/src/evm_circuit/execution/address.rs index 508cabcd61..e492a5fba5 100644 --- a/zkevm-circuits/src/evm_circuit/execution/address.rs +++ b/zkevm-circuits/src/evm_circuit/execution/address.rs @@ -11,10 +11,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToAddress, ToLittleEndian}; +use eth_types::{ToAddress, ToLittleEndian}; use halo2_proofs::plonk::Error; use std::convert::TryInto; diff --git a/zkevm-circuits/src/evm_circuit/execution/balance.rs b/zkevm-circuits/src/evm_circuit/execution/balance.rs index 3a1995d664..1163aeb5a7 100644 --- a/zkevm-circuits/src/evm_circuit/execution/balance.rs +++ b/zkevm-circuits/src/evm_circuit/execution/balance.rs @@ -16,9 +16,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{AccountFieldTag, CallContextFieldTag}, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::GasCost, Field, ToLittleEndian}; +use eth_types::{evm_types::GasCost, ToLittleEndian}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs index eade282470..e77b2d2d22 100644 --- a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs +++ b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs @@ -27,10 +27,11 @@ use crate::{ AccountFieldTag, BlockContextFieldTag, CallContextFieldTag, RwTableTag, TxFieldTag as TxContextFieldTag, }, + util::Field, }; use array_init::array_init; use bus_mapping::{circuit_input_builder::CopyDataType, precompile::PrecompileCalls}; -use eth_types::{utils::is_precompiled, Address, Field, ToLittleEndian, ToScalar, U256}; +use eth_types::{utils::is_precompiled, Address, ToLittleEndian, ToScalar, U256}; use ethers_core::utils::{get_contract_address, keccak256, rlp::RlpStream}; use gadgets::util::{expr_from_bytes, not, select, Expr}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/bitwise.rs b/zkevm-circuits/src/evm_circuit/execution/bitwise.rs index 9a8addaa1b..e8562a21a5 100644 --- a/zkevm-circuits/src/evm_circuit/execution/bitwise.rs +++ b/zkevm-circuits/src/evm_circuit/execution/bitwise.rs @@ -11,9 +11,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian}; +use eth_types::{evm_types::OpcodeId, ToLittleEndian}; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/block_ctx.rs b/zkevm-circuits/src/evm_circuit/execution/block_ctx.rs index a349d5e256..1b16c74c6f 100644 --- a/zkevm-circuits/src/evm_circuit/execution/block_ctx.rs +++ b/zkevm-circuits/src/evm_circuit/execution/block_ctx.rs @@ -11,10 +11,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::BlockContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/blockhash.rs b/zkevm-circuits/src/evm_circuit/execution/blockhash.rs index 392b1770f5..114b20d999 100644 --- a/zkevm-circuits/src/evm_circuit/execution/blockhash.rs +++ b/zkevm-circuits/src/evm_circuit/execution/blockhash.rs @@ -17,12 +17,12 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::BlockContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; use eth_types::{ evm_types::block_utils::{is_valid_block_number, NUM_PREV_BLOCK_ALLOWED}, - Field, ToScalar, + ToScalar, }; use gadgets::util::not; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/byte.rs b/zkevm-circuits/src/evm_circuit/execution/byte.rs index dd4b4317d7..a6349d3c14 100644 --- a/zkevm-circuits/src/evm_circuit/execution/byte.rs +++ b/zkevm-circuits/src/evm_circuit/execution/byte.rs @@ -10,11 +10,11 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use array_init::array_init; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/calldatacopy.rs b/zkevm-circuits/src/evm_circuit/execution/calldatacopy.rs index 4cabced4ab..b5ea046ddd 100644 --- a/zkevm-circuits/src/evm_circuit/execution/calldatacopy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/calldatacopy.rs @@ -18,10 +18,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::{circuit_input_builder::CopyDataType, evm::OpcodeId}; -use eth_types::{evm_types::GasCost, Field, ToScalar}; +use eth_types::{evm_types::GasCost, ToScalar}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/calldataload.rs b/zkevm-circuits/src/evm_circuit/execution/calldataload.rs index 03778170c2..7a73590c38 100644 --- a/zkevm-circuits/src/evm_circuit/execution/calldataload.rs +++ b/zkevm-circuits/src/evm_circuit/execution/calldataload.rs @@ -1,6 +1,7 @@ +use crate::util::Field; use array_init::array_init; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, diff --git a/zkevm-circuits/src/evm_circuit/execution/calldatasize.rs b/zkevm-circuits/src/evm_circuit/execution/calldatasize.rs index c9b5029c26..5e9e3307db 100644 --- a/zkevm-circuits/src/evm_circuit/execution/calldatasize.rs +++ b/zkevm-circuits/src/evm_circuit/execution/calldatasize.rs @@ -11,10 +11,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/caller.rs b/zkevm-circuits/src/evm_circuit/execution/caller.rs index 19bc8f79ae..55303729e9 100644 --- a/zkevm-circuits/src/evm_circuit/execution/caller.rs +++ b/zkevm-circuits/src/evm_circuit/execution/caller.rs @@ -11,10 +11,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/callop.rs b/zkevm-circuits/src/evm_circuit/execution/callop.rs index 34a28ae776..05c843e0f3 100644 --- a/zkevm-circuits/src/evm_circuit/execution/callop.rs +++ b/zkevm-circuits/src/evm_circuit/execution/callop.rs @@ -21,7 +21,7 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{AccountFieldTag, CallContextFieldTag}, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::{ circuit_input_builder::CopyDataType, evm::OpcodeId, precompile::PrecompileCalls, @@ -29,7 +29,7 @@ use bus_mapping::{ use eth_types::{ evm_types::{memory::MemoryWordRange, GAS_STIPEND_CALL_WITH_VALUE}, utils::is_precompiled, - Field, ToAddress, ToBigEndian, ToLittleEndian, ToScalar, U256, + ToAddress, ToBigEndian, ToLittleEndian, ToScalar, U256, }; use halo2_proofs::{circuit::Value, plonk::Error}; use log::trace; diff --git a/zkevm-circuits/src/evm_circuit/execution/callvalue.rs b/zkevm-circuits/src/evm_circuit/execution/callvalue.rs index 12a9e95f2c..1cdc2bc8f2 100644 --- a/zkevm-circuits/src/evm_circuit/execution/callvalue.rs +++ b/zkevm-circuits/src/evm_circuit/execution/callvalue.rs @@ -10,10 +10,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/chainid.rs b/zkevm-circuits/src/evm_circuit/execution/chainid.rs index 0c368d8bbf..87a8f206a4 100644 --- a/zkevm-circuits/src/evm_circuit/execution/chainid.rs +++ b/zkevm-circuits/src/evm_circuit/execution/chainid.rs @@ -10,10 +10,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::BlockContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/codecopy.rs b/zkevm-circuits/src/evm_circuit/execution/codecopy.rs index d55435f17a..c4fac1920e 100644 --- a/zkevm-circuits/src/evm_circuit/execution/codecopy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/codecopy.rs @@ -1,5 +1,6 @@ +use crate::util::Field; use bus_mapping::{circuit_input_builder::CopyDataType, evm::OpcodeId}; -use eth_types::{evm_types::GasCost, Field, ToScalar}; +use eth_types::{evm_types::GasCost, ToScalar}; use halo2_proofs::{circuit::Value, plonk::Error}; use crate::{ diff --git a/zkevm-circuits/src/evm_circuit/execution/codesize.rs b/zkevm-circuits/src/evm_circuit/execution/codesize.rs index bd98f3ea76..2a8fe1e757 100644 --- a/zkevm-circuits/src/evm_circuit/execution/codesize.rs +++ b/zkevm-circuits/src/evm_circuit/execution/codesize.rs @@ -1,6 +1,6 @@ +use crate::util::Field; use array_init::array_init; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::{circuit::Value, plonk::Error}; use crate::{ diff --git a/zkevm-circuits/src/evm_circuit/execution/comparator.rs b/zkevm-circuits/src/evm_circuit/execution/comparator.rs index c11803c352..8ad2b0b021 100644 --- a/zkevm-circuits/src/evm_circuit/execution/comparator.rs +++ b/zkevm-circuits/src/evm_circuit/execution/comparator.rs @@ -11,9 +11,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian}; +use eth_types::{evm_types::OpcodeId, ToLittleEndian}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/create.rs b/zkevm-circuits/src/evm_circuit/execution/create.rs index 4f77e08b15..82f01c79bc 100644 --- a/zkevm-circuits/src/evm_circuit/execution/create.rs +++ b/zkevm-circuits/src/evm_circuit/execution/create.rs @@ -23,13 +23,13 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{AccountFieldTag, CallContextFieldTag, RwTableTag}, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::{circuit_input_builder::CopyDataType, evm::OpcodeId}; use eth_types::{ evm_types::{GasCost, CREATE2_GAS_PER_CODE_WORD, CREATE_GAS_PER_CODE_WORD, MAX_INIT_CODE_SIZE}, state_db::CodeDB, - Field, ToBigEndian, ToLittleEndian, ToScalar, ToWord, H256, KECCAK_CODE_HASH_EMPTY, U256, + ToBigEndian, ToLittleEndian, ToScalar, ToWord, H256, KECCAK_CODE_HASH_EMPTY, U256, }; use ethers_core::utils::keccak256; use gadgets::util::{and, expr_from_bytes}; diff --git a/zkevm-circuits/src/evm_circuit/execution/dummy.rs b/zkevm-circuits/src/evm_circuit/execution/dummy.rs index 653a9acf7d..426981f7c2 100644 --- a/zkevm-circuits/src/evm_circuit/execution/dummy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/dummy.rs @@ -7,7 +7,8 @@ use crate::evm_circuit::{ witness::{Block, Call, ExecStep, Transaction}, }; -use eth_types::{Field, ToLittleEndian}; +use crate::util::Field; +use eth_types::ToLittleEndian; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/dup.rs b/zkevm-circuits/src/evm_circuit/execution/dup.rs index 51c808b978..44ea76511a 100644 --- a/zkevm-circuits/src/evm_circuit/execution/dup.rs +++ b/zkevm-circuits/src/evm_circuit/execution/dup.rs @@ -9,9 +9,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field}; +use eth_types::evm_types::OpcodeId; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/end_block.rs b/zkevm-circuits/src/evm_circuit/execution/end_block.rs index dc32fd1333..f6df74ff44 100644 --- a/zkevm-circuits/src/evm_circuit/execution/end_block.rs +++ b/zkevm-circuits/src/evm_circuit/execution/end_block.rs @@ -14,12 +14,12 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{CallContextFieldTag, TxContextFieldTag}, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::l2_predeployed::message_queue::{ ADDRESS as MESSAGE_QUEUE, WITHDRAW_TRIE_ROOT_SLOT, }; -use eth_types::{Field, ToScalar}; +use eth_types::ToScalar; use halo2_proofs::{ circuit::{Cell as AssignedCell, Value}, plonk::{Error, Expression}, diff --git a/zkevm-circuits/src/evm_circuit/execution/end_inner_block.rs b/zkevm-circuits/src/evm_circuit/execution/end_inner_block.rs index b073d84b0e..03bd1ccc44 100644 --- a/zkevm-circuits/src/evm_circuit/execution/end_inner_block.rs +++ b/zkevm-circuits/src/evm_circuit/execution/end_inner_block.rs @@ -12,8 +12,8 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{BlockContextFieldTag, TxFieldTag::BlockNumber}, + util::Field, }; -use eth_types::Field; use gadgets::util::{not, Expr}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/end_tx.rs b/zkevm-circuits/src/evm_circuit/execution/end_tx.rs index 2a56554a32..c60d3cd816 100644 --- a/zkevm-circuits/src/evm_circuit/execution/end_tx.rs +++ b/zkevm-circuits/src/evm_circuit/execution/end_tx.rs @@ -22,10 +22,10 @@ use crate::{ AccountFieldTag, BlockContextFieldTag, CallContextFieldTag, RwTableTag, TxContextFieldTag, TxReceiptFieldTag, }, - util::Expr, + util::{Expr, Field}, }; use eth_types::{ - evm_types::MAX_REFUND_QUOTIENT_OF_GAS_USED, geth_types::TxType, Field, ToLittleEndian, ToScalar, + evm_types::MAX_REFUND_QUOTIENT_OF_GAS_USED, geth_types::TxType, ToLittleEndian, ToScalar, }; use gadgets::util::{not, select}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_code_store.rs b/zkevm-circuits/src/evm_circuit/execution/error_code_store.rs index 9f3f0bcf13..1c406a15c8 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_code_store.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_code_store.rs @@ -12,14 +12,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; - -use eth_types::{ - evm_types::{GasCost, OpcodeId}, - Field, -}; - +use eth_types::evm_types::{GasCost, OpcodeId}; use halo2_proofs::{circuit::Value, plonk::Error}; const MAXCODESIZE: u64 = 0x6000u64; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_invalid_creation_code.rs b/zkevm-circuits/src/evm_circuit/execution/error_invalid_creation_code.rs index 55d120070c..ac971a5bca 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_invalid_creation_code.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_invalid_creation_code.rs @@ -16,7 +16,8 @@ use crate::{ util::Expr, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian}; +use crate::util::Field; +use eth_types::{evm_types::OpcodeId, ToLittleEndian}; use halo2_proofs::{circuit::Value, plonk::Error}; /// Gadget for code store oog and max code size exceed diff --git a/zkevm-circuits/src/evm_circuit/execution/error_invalid_jump.rs b/zkevm-circuits/src/evm_circuit/execution/error_invalid_jump.rs index 8e4e6143f7..71ac93b1fb 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_invalid_jump.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_invalid_jump.rs @@ -11,9 +11,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field, U256}; +use eth_types::{evm_types::OpcodeId, U256}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_invalid_opcode.rs b/zkevm-circuits/src/evm_circuit/execution/error_invalid_opcode.rs index ea23483497..67a378b335 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_invalid_opcode.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_invalid_opcode.rs @@ -1,14 +1,16 @@ -use crate::evm_circuit::{ - execution::ExecutionGadget, - step::ExecutionState, - table::{FixedTableTag, Lookup}, - util::{ - common_gadget::CommonErrorGadget, constraint_builder::EVMConstraintBuilder, CachedRegion, - Cell, +use crate::{ + evm_circuit::{ + execution::ExecutionGadget, + step::ExecutionState, + table::{FixedTableTag, Lookup}, + util::{ + common_gadget::CommonErrorGadget, constraint_builder::EVMConstraintBuilder, + CachedRegion, Cell, + }, + witness::{Block, Call, ExecStep, Transaction}, }, - witness::{Block, Call, ExecStep, Transaction}, + util::Field, }; -use eth_types::Field; use gadgets::util::Expr; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_account_access.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_account_access.rs index d8aa5383f5..d86e226c20 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_account_access.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_account_access.rs @@ -13,11 +13,11 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use eth_types::{ evm_types::{GasCost, OpcodeId}, - Field, ToLittleEndian, + ToLittleEndian, }; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_call.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_call.rs index 5ab338a8d1..eca876c0e6 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_call.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_call.rs @@ -12,11 +12,11 @@ use crate::{ }, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, witness::{Block, Call, ExecStep, Transaction}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, U256}; +use eth_types::U256; use halo2_proofs::{circuit::Value, plonk::Error}; /// Gadget to implement the corresponding out of gas errors for diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_constant.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_constant.rs index 356428b5ad..a38e497113 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_constant.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_constant.rs @@ -11,9 +11,8 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::Field; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_create.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_create.rs index 2961fc3286..4e7c48b1ca 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_create.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_create.rs @@ -14,13 +14,14 @@ use crate::{ or, select, CachedRegion, Cell, Word, }, }, + util::Field, witness::{Block, Call, ExecStep, Transaction}, }; use eth_types::{ evm_types::{ GasCost, OpcodeId, CREATE2_GAS_PER_CODE_WORD, CREATE_GAS_PER_CODE_WORD, MAX_INIT_CODE_SIZE, }, - Field, ToLittleEndian, U256, + ToLittleEndian, U256, }; use gadgets::util::Expr; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_dynamic_memory.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_dynamic_memory.rs index b988073a14..e99e2fff7b 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_dynamic_memory.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_dynamic_memory.rs @@ -13,9 +13,10 @@ use crate::{ or, CachedRegion, Cell, }, }, + util::Field, witness::{Block, Call, ExecStep, Transaction}, }; -use eth_types::{evm_types::OpcodeId, Field}; +use eth_types::evm_types::OpcodeId; use gadgets::util::{select, Expr}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_exp.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_exp.rs index cade397da8..da8d07598b 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_exp.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_exp.rs @@ -11,11 +11,11 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use eth_types::{ evm_types::{GasCost, OpcodeId}, - Field, ToLittleEndian, + ToLittleEndian, }; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_log.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_log.rs index 0f0640d32e..fde0b12f5e 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_log.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_log.rs @@ -15,12 +15,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, -}; -use eth_types::{ - evm_types::{GasCost, OpcodeId}, - Field, + util::{Expr, Field}, }; +use eth_types::evm_types::{GasCost, OpcodeId}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_memory_copy.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_memory_copy.rs index ca3d279434..e2fc41647b 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_memory_copy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_memory_copy.rs @@ -17,11 +17,11 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use eth_types::{ evm_types::{GasCost, OpcodeId}, - Field, ToLittleEndian, U256, + ToLittleEndian, U256, }; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_precompile.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_precompile.rs index 4c08fdc1ed..5da333ea43 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_precompile.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_precompile.rs @@ -11,10 +11,11 @@ use crate::{ }, }, table::CallContextFieldTag, + util::Field, witness::{Block, Call, ExecStep, Transaction}, }; use bus_mapping::precompile::PrecompileCalls; -use eth_types::{evm_types::GasCost, Field, ToScalar}; +use eth_types::{evm_types::GasCost, ToScalar}; use gadgets::util::{sum, Expr}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_sha3.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_sha3.rs index 559ff73543..50e56c2145 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_sha3.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_sha3.rs @@ -15,12 +15,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, -}; -use eth_types::{ - evm_types::{GasCost, OpcodeId}, - Field, + util::{Expr, Field}, }; +use eth_types::evm_types::{GasCost, OpcodeId}; use halo2_proofs::{circuit::Value, plonk::Error}; /// Gadget to implement the corresponding out of gas error for diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_sload_sstore.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_sload_sstore.rs index 771be7592b..de9e3e7929 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_sload_sstore.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_sload_sstore.rs @@ -16,11 +16,11 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use eth_types::{ evm_types::{GasCost, OpcodeId}, - Field, ToScalar, U256, + ToScalar, U256, }; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/error_oog_static_memory.rs b/zkevm-circuits/src/evm_circuit/execution/error_oog_static_memory.rs index 5da343e435..d90e886ff9 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_oog_static_memory.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_oog_static_memory.rs @@ -18,9 +18,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field}; +use eth_types::evm_types::OpcodeId; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/error_precompile_failed.rs b/zkevm-circuits/src/evm_circuit/execution/error_precompile_failed.rs index ea6be965bb..fd5377fc34 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_precompile_failed.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_precompile_failed.rs @@ -10,11 +10,11 @@ use crate::{ }, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, witness::{Block, Call, ExecStep, Transaction}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian, U256}; +use eth_types::{ToLittleEndian, U256}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/error_return_data_oo_bound.rs b/zkevm-circuits/src/evm_circuit/execution/error_return_data_oo_bound.rs index e5f7f30932..35d6940407 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_return_data_oo_bound.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_return_data_oo_bound.rs @@ -10,9 +10,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian, ToScalar}; +use eth_types::{evm_types::OpcodeId, ToLittleEndian, ToScalar}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/error_stack.rs b/zkevm-circuits/src/evm_circuit/execution/error_stack.rs index eaf4fe9950..99229044fd 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_stack.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_stack.rs @@ -9,9 +9,8 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::Field; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/error_write_protection.rs b/zkevm-circuits/src/evm_circuit/execution/error_write_protection.rs index 3162baf4eb..b909276d04 100644 --- a/zkevm-circuits/src/evm_circuit/execution/error_write_protection.rs +++ b/zkevm-circuits/src/evm_circuit/execution/error_write_protection.rs @@ -11,9 +11,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian, U256}; +use eth_types::{evm_types::OpcodeId, ToLittleEndian, U256}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/exp.rs b/zkevm-circuits/src/evm_circuit/execution/exp.rs index 62b2fba5c1..b350fdfca0 100644 --- a/zkevm-circuits/src/evm_circuit/execution/exp.rs +++ b/zkevm-circuits/src/evm_circuit/execution/exp.rs @@ -1,5 +1,6 @@ +use crate::util::Field; use bus_mapping::evm::OpcodeId; -use eth_types::{evm_types::GasCost, Field, ToLittleEndian, ToScalar}; +use eth_types::{evm_types::GasCost, ToLittleEndian, ToScalar}; use gadgets::util::{and, not, split_u256, Expr}; use halo2_proofs::plonk::Error; diff --git a/zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs b/zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs index c39f80d318..75e24b54e4 100644 --- a/zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs @@ -19,9 +19,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{AccountFieldTag, CallContextFieldTag}, + util::Field, }; use bus_mapping::circuit_input_builder::CopyDataType; -use eth_types::{evm_types::GasCost, Field, ToLittleEndian, ToScalar}; +use eth_types::{evm_types::GasCost, ToLittleEndian, ToScalar}; use gadgets::util::Expr; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/extcodehash.rs b/zkevm-circuits/src/evm_circuit/execution/extcodehash.rs index 3e36360501..281ea9894c 100644 --- a/zkevm-circuits/src/evm_circuit/execution/extcodehash.rs +++ b/zkevm-circuits/src/evm_circuit/execution/extcodehash.rs @@ -13,9 +13,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{AccountFieldTag, CallContextFieldTag}, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::GasCost, Field, ToLittleEndian}; +use eth_types::{evm_types::GasCost, ToLittleEndian}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/extcodesize.rs b/zkevm-circuits/src/evm_circuit/execution/extcodesize.rs index c2bb2023a9..f1eea7e02f 100644 --- a/zkevm-circuits/src/evm_circuit/execution/extcodesize.rs +++ b/zkevm-circuits/src/evm_circuit/execution/extcodesize.rs @@ -16,9 +16,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{AccountFieldTag, CallContextFieldTag}, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::GasCost, Field, ToLittleEndian}; +use eth_types::{evm_types::GasCost, ToLittleEndian}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/gas.rs b/zkevm-circuits/src/evm_circuit/execution/gas.rs index 7985c76e8a..4277c68d74 100644 --- a/zkevm-circuits/src/evm_circuit/execution/gas.rs +++ b/zkevm-circuits/src/evm_circuit/execution/gas.rs @@ -13,9 +13,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field}; +use eth_types::evm_types::OpcodeId; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/gasprice.rs b/zkevm-circuits/src/evm_circuit/execution/gasprice.rs index 17d9e1381f..4bbb96e9ec 100644 --- a/zkevm-circuits/src/evm_circuit/execution/gasprice.rs +++ b/zkevm-circuits/src/evm_circuit/execution/gasprice.rs @@ -10,10 +10,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{CallContextFieldTag, TxContextFieldTag}, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/is_zero.rs b/zkevm-circuits/src/evm_circuit/execution/is_zero.rs index a0d5e12520..3de2470c27 100644 --- a/zkevm-circuits/src/evm_circuit/execution/is_zero.rs +++ b/zkevm-circuits/src/evm_circuit/execution/is_zero.rs @@ -9,10 +9,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/jump.rs b/zkevm-circuits/src/evm_circuit/execution/jump.rs index ead6133a5d..0441dbf1b6 100644 --- a/zkevm-circuits/src/evm_circuit/execution/jump.rs +++ b/zkevm-circuits/src/evm_circuit/execution/jump.rs @@ -13,9 +13,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian}; +use eth_types::{evm_types::OpcodeId, ToLittleEndian}; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/jumpdest.rs b/zkevm-circuits/src/evm_circuit/execution/jumpdest.rs index 57cf0edd67..1e2d2328d1 100644 --- a/zkevm-circuits/src/evm_circuit/execution/jumpdest.rs +++ b/zkevm-circuits/src/evm_circuit/execution/jumpdest.rs @@ -9,10 +9,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/jumpi.rs b/zkevm-circuits/src/evm_circuit/execution/jumpi.rs index 4a463bfd5a..8ea8598ab1 100644 --- a/zkevm-circuits/src/evm_circuit/execution/jumpi.rs +++ b/zkevm-circuits/src/evm_circuit/execution/jumpi.rs @@ -14,9 +14,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field}; +use eth_types::evm_types::OpcodeId; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/logs.rs b/zkevm-circuits/src/evm_circuit/execution/logs.rs index 29ac31bbf2..2f86e7e2ed 100644 --- a/zkevm-circuits/src/evm_circuit/execution/logs.rs +++ b/zkevm-circuits/src/evm_circuit/execution/logs.rs @@ -17,13 +17,13 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{CallContextFieldTag, RwTableTag, TxLogFieldTag}, - util::{build_tx_log_expression, Expr}, + util::{build_tx_log_expression, Expr, Field}, }; use array_init::array_init; use bus_mapping::circuit_input_builder::CopyDataType; use eth_types::{ evm_types::{GasCost, OpcodeId}, - Field, ToScalar, U256, + ToScalar, U256, }; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/memory.rs b/zkevm-circuits/src/evm_circuit/execution/memory.rs index 7eec30c750..858a666265 100644 --- a/zkevm-circuits/src/evm_circuit/execution/memory.rs +++ b/zkevm-circuits/src/evm_circuit/execution/memory.rs @@ -19,7 +19,8 @@ use crate::{ util::Expr, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian, U256}; +use crate::util::Field; +use eth_types::{evm_types::OpcodeId, ToLittleEndian, U256}; use halo2_proofs::plonk::Error; // MemoryGadget handles mload/mstore/mstore8 op codes gadget diff --git a/zkevm-circuits/src/evm_circuit/execution/msize.rs b/zkevm-circuits/src/evm_circuit/execution/msize.rs index 37d04e91fe..2e5ada329d 100644 --- a/zkevm-circuits/src/evm_circuit/execution/msize.rs +++ b/zkevm-circuits/src/evm_circuit/execution/msize.rs @@ -13,10 +13,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/mul_div_mod.rs b/zkevm-circuits/src/evm_circuit/execution/mul_div_mod.rs index e38ffd9d80..98a12d9ff3 100644 --- a/zkevm-circuits/src/evm_circuit/execution/mul_div_mod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/mul_div_mod.rs @@ -14,10 +14,10 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian, U256}; +use eth_types::{ToLittleEndian, U256}; use halo2_proofs::plonk::Error; /// MulGadget verifies opcode MUL, DIV, and MOD. diff --git a/zkevm-circuits/src/evm_circuit/execution/mulmod.rs b/zkevm-circuits/src/evm_circuit/execution/mulmod.rs index f1347b73c9..7af4633ae3 100644 --- a/zkevm-circuits/src/evm_circuit/execution/mulmod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/mulmod.rs @@ -14,10 +14,10 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian, U256}; +use eth_types::{ToLittleEndian, U256}; use halo2_proofs::plonk::Error; /// MulModGadget verifies opcode MULMOD diff --git a/zkevm-circuits/src/evm_circuit/execution/not.rs b/zkevm-circuits/src/evm_circuit/execution/not.rs index 8d72ebbf24..c72a1ada71 100644 --- a/zkevm-circuits/src/evm_circuit/execution/not.rs +++ b/zkevm-circuits/src/evm_circuit/execution/not.rs @@ -13,9 +13,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian}; +use eth_types::{evm_types::OpcodeId, ToLittleEndian}; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/origin.rs b/zkevm-circuits/src/evm_circuit/execution/origin.rs index f47f186463..b86591a54a 100644 --- a/zkevm-circuits/src/evm_circuit/execution/origin.rs +++ b/zkevm-circuits/src/evm_circuit/execution/origin.rs @@ -11,10 +11,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{CallContextFieldTag, TxContextFieldTag}, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/pc.rs b/zkevm-circuits/src/evm_circuit/execution/pc.rs index 9180cb5452..6a3cde065f 100644 --- a/zkevm-circuits/src/evm_circuit/execution/pc.rs +++ b/zkevm-circuits/src/evm_circuit/execution/pc.rs @@ -13,10 +13,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/pop.rs b/zkevm-circuits/src/evm_circuit/execution/pop.rs index 77c4ad3c3f..7912ab7b52 100644 --- a/zkevm-circuits/src/evm_circuit/execution/pop.rs +++ b/zkevm-circuits/src/evm_circuit/execution/pop.rs @@ -9,10 +9,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_add.rs b/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_add.rs index 6c2b4b8667..6f5dbec71b 100644 --- a/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_add.rs +++ b/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_add.rs @@ -1,5 +1,6 @@ +use crate::util::Field; use bus_mapping::precompile::{PrecompileAuxData, PrecompileCalls}; -use eth_types::{evm_types::GasCost, Field, ToLittleEndian, ToScalar}; +use eth_types::{evm_types::GasCost, ToLittleEndian, ToScalar}; use gadgets::util::{not, select, Expr}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_mul.rs b/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_mul.rs index b4fd0d6370..f9db4b52a9 100644 --- a/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_mul.rs +++ b/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_mul.rs @@ -12,10 +12,11 @@ use crate::{ }, }, table::CallContextFieldTag, + util::Field, witness::{Block, Call, ExecStep, Transaction}, }; use bus_mapping::precompile::{PrecompileAuxData, PrecompileCalls}; -use eth_types::{evm_types::GasCost, Field, ToLittleEndian, ToScalar, U256}; +use eth_types::{evm_types::GasCost, ToLittleEndian, ToScalar, U256}; use gadgets::util::{and, not, or, select, split_u256, sum, Expr}; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_pairing.rs b/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_pairing.rs index a5c777bf45..e73af94eb4 100644 --- a/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_pairing.rs +++ b/zkevm-circuits/src/evm_circuit/execution/precompiles/ec_pairing.rs @@ -1,8 +1,9 @@ +use crate::util::Field; use bus_mapping::{ circuit_input_builder::{N_BYTES_PER_PAIR, N_PAIRING_PER_OP}, precompile::{EcPairingError, PrecompileAuxData, PrecompileCalls}, }; -use eth_types::{evm_types::GasCost, Field, ToScalar}; +use eth_types::{evm_types::GasCost, ToScalar}; use gadgets::util::{and, not, or, select, Expr}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/precompiles/ecrecover.rs b/zkevm-circuits/src/evm_circuit/execution/precompiles/ecrecover.rs index 9ce0b116a8..10d33a6027 100644 --- a/zkevm-circuits/src/evm_circuit/execution/precompiles/ecrecover.rs +++ b/zkevm-circuits/src/evm_circuit/execution/precompiles/ecrecover.rs @@ -1,5 +1,6 @@ +use crate::util::Field; use bus_mapping::precompile::{PrecompileAuxData, PrecompileCalls}; -use eth_types::{evm_types::GasCost, word, Field, ToLittleEndian, ToScalar, U256}; +use eth_types::{evm_types::GasCost, word, ToLittleEndian, ToScalar, U256}; use gadgets::util::{and, not, or, select, sum, Expr}; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/evm_circuit/execution/precompiles/identity.rs b/zkevm-circuits/src/evm_circuit/execution/precompiles/identity.rs index 6de5306b81..8c14863f0a 100644 --- a/zkevm-circuits/src/evm_circuit/execution/precompiles/identity.rs +++ b/zkevm-circuits/src/evm_circuit/execution/precompiles/identity.rs @@ -1,5 +1,6 @@ +use crate::util::Field; use bus_mapping::precompile::PrecompileAuxData; -use eth_types::{evm_types::GasCost, Field, ToScalar}; +use eth_types::{evm_types::GasCost, ToScalar}; use gadgets::util::{select, Expr}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/precompiles/mod.rs b/zkevm-circuits/src/evm_circuit/execution/precompiles/mod.rs index 61b302494b..028684bb81 100644 --- a/zkevm-circuits/src/evm_circuit/execution/precompiles/mod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/precompiles/mod.rs @@ -9,10 +9,11 @@ use crate::{ }, }, table::CallContextFieldTag, + util::Field, witness::{Block, Call, ExecStep, Transaction}, }; use bus_mapping::precompile::PrecompileAuxData; -use eth_types::{Field, ToScalar}; +use eth_types::ToScalar; use gadgets::util::{select, Expr}; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/evm_circuit/execution/precompiles/modexp.rs b/zkevm-circuits/src/evm_circuit/execution/precompiles/modexp.rs index 7c7ebd28e1..c116c13f9d 100755 --- a/zkevm-circuits/src/evm_circuit/execution/precompiles/modexp.rs +++ b/zkevm-circuits/src/evm_circuit/execution/precompiles/modexp.rs @@ -1,7 +1,8 @@ +use crate::util::Field; use bus_mapping::precompile::{ PrecompileAuxData, PrecompileCalls, MODEXP_INPUT_LIMIT, MODEXP_SIZE_LIMIT, }; -use eth_types::{evm_types::GasCost, Field, ToBigEndian, ToScalar, U256}; +use eth_types::{evm_types::GasCost, ToBigEndian, ToScalar, U256}; use gadgets::util::{self, not, select, Expr}; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/evm_circuit/execution/precompiles/sha256.rs b/zkevm-circuits/src/evm_circuit/execution/precompiles/sha256.rs index 5c64f3e2dc..99c9a642d2 100644 --- a/zkevm-circuits/src/evm_circuit/execution/precompiles/sha256.rs +++ b/zkevm-circuits/src/evm_circuit/execution/precompiles/sha256.rs @@ -1,5 +1,6 @@ +use crate::util::Field; use bus_mapping::precompile::PrecompileAuxData; -use eth_types::{evm_types::GasCost, Field, ToScalar}; +use eth_types::{evm_types::GasCost, ToScalar}; use gadgets::util::{select, Expr}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/push.rs b/zkevm-circuits/src/evm_circuit/execution/push.rs index c56402bb00..87f8cd78c3 100644 --- a/zkevm-circuits/src/evm_circuit/execution/push.rs +++ b/zkevm-circuits/src/evm_circuit/execution/push.rs @@ -10,9 +10,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian}; +use eth_types::{evm_types::OpcodeId, ToLittleEndian}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/return_revert.rs b/zkevm-circuits/src/evm_circuit/execution/return_revert.rs index aaab0fd8ea..fc63891ca9 100644 --- a/zkevm-circuits/src/evm_circuit/execution/return_revert.rs +++ b/zkevm-circuits/src/evm_circuit/execution/return_revert.rs @@ -18,13 +18,13 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{AccountFieldTag, CallContextFieldTag}, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::circuit_input_builder::CopyDataType; use eth_types::{ evm_types::{GasCost, OpcodeId}, state_db::CodeDB, - Field, ToScalar, U256, + ToScalar, U256, }; use ethers_core::utils::keccak256; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/returndatacopy.rs b/zkevm-circuits/src/evm_circuit/execution/returndatacopy.rs index 7643c804d3..a8ebfd2146 100644 --- a/zkevm-circuits/src/evm_circuit/execution/returndatacopy.rs +++ b/zkevm-circuits/src/evm_circuit/execution/returndatacopy.rs @@ -19,10 +19,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::{circuit_input_builder::CopyDataType, evm::OpcodeId}; -use eth_types::{evm_types::GasCost, Field, ToScalar}; +use eth_types::{evm_types::GasCost, ToScalar}; use gadgets::util::not; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/returndatasize.rs b/zkevm-circuits/src/evm_circuit/execution/returndatasize.rs index 51aac27a97..f54f95c592 100644 --- a/zkevm-circuits/src/evm_circuit/execution/returndatasize.rs +++ b/zkevm-circuits/src/evm_circuit/execution/returndatasize.rs @@ -11,10 +11,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/sar.rs b/zkevm-circuits/src/evm_circuit/execution/sar.rs index 47879fda67..03819a3811 100644 --- a/zkevm-circuits/src/evm_circuit/execution/sar.rs +++ b/zkevm-circuits/src/evm_circuit/execution/sar.rs @@ -16,11 +16,11 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use array_init::array_init; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use halo2_proofs::{circuit::Value, plonk::Error}; /// SarGadget verifies SAR opcode. diff --git a/zkevm-circuits/src/evm_circuit/execution/sdiv_smod.rs b/zkevm-circuits/src/evm_circuit/execution/sdiv_smod.rs index 0c0fa3f9bd..8cd2156be2 100644 --- a/zkevm-circuits/src/evm_circuit/execution/sdiv_smod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/sdiv_smod.rs @@ -13,10 +13,10 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian, U256}; +use eth_types::{ToLittleEndian, U256}; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/selfbalance.rs b/zkevm-circuits/src/evm_circuit/execution/selfbalance.rs index cf15914541..94803d75aa 100644 --- a/zkevm-circuits/src/evm_circuit/execution/selfbalance.rs +++ b/zkevm-circuits/src/evm_circuit/execution/selfbalance.rs @@ -10,10 +10,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::{AccountFieldTag, CallContextFieldTag}, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToScalar}; +use eth_types::ToScalar; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/sha3.rs b/zkevm-circuits/src/evm_circuit/execution/sha3.rs index 62a3ac155e..6b2859c7ed 100644 --- a/zkevm-circuits/src/evm_circuit/execution/sha3.rs +++ b/zkevm-circuits/src/evm_circuit/execution/sha3.rs @@ -1,5 +1,6 @@ +use crate::util::Field; use bus_mapping::{circuit_input_builder::CopyDataType, evm::OpcodeId}; -use eth_types::{evm_types::GasCost, Field, ToLittleEndian, ToScalar}; +use eth_types::{evm_types::GasCost, ToLittleEndian, ToScalar}; use gadgets::util::{not, Expr}; use halo2_proofs::{circuit::Value, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/execution/shl_shr.rs b/zkevm-circuits/src/evm_circuit/execution/shl_shr.rs index 785cae9507..b6f9328c0f 100644 --- a/zkevm-circuits/src/evm_circuit/execution/shl_shr.rs +++ b/zkevm-circuits/src/evm_circuit/execution/shl_shr.rs @@ -16,10 +16,10 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian, U256}; +use eth_types::{ToLittleEndian, U256}; use halo2_proofs::{circuit::Value, plonk::Error}; /// ShlShrGadget verifies opcode SHL and SHR. diff --git a/zkevm-circuits/src/evm_circuit/execution/signed_comparator.rs b/zkevm-circuits/src/evm_circuit/execution/signed_comparator.rs index 11284033a1..f4edb1b02f 100644 --- a/zkevm-circuits/src/evm_circuit/execution/signed_comparator.rs +++ b/zkevm-circuits/src/evm_circuit/execution/signed_comparator.rs @@ -11,9 +11,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field, ToLittleEndian}; +use eth_types::{evm_types::OpcodeId, ToLittleEndian}; use halo2_proofs::{circuit::Value, plonk::Error}; /// Gadget that implements the ExecutionGadget trait to handle the Opcodes SLT diff --git a/zkevm-circuits/src/evm_circuit/execution/signextend.rs b/zkevm-circuits/src/evm_circuit/execution/signextend.rs index f42960e998..7ddc716861 100644 --- a/zkevm-circuits/src/evm_circuit/execution/signextend.rs +++ b/zkevm-circuits/src/evm_circuit/execution/signextend.rs @@ -15,11 +15,11 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; use array_init::array_init; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian}; +use eth_types::ToLittleEndian; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/sload.rs b/zkevm-circuits/src/evm_circuit/execution/sload.rs index b27318aacc..2e6ce3722e 100644 --- a/zkevm-circuits/src/evm_circuit/execution/sload.rs +++ b/zkevm-circuits/src/evm_circuit/execution/sload.rs @@ -12,9 +12,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{Field, ToScalar}; +use eth_types::ToScalar; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/sstore.rs b/zkevm-circuits/src/evm_circuit/execution/sstore.rs index e29565fbb7..42b31fbaf1 100644 --- a/zkevm-circuits/src/evm_circuit/execution/sstore.rs +++ b/zkevm-circuits/src/evm_circuit/execution/sstore.rs @@ -20,7 +20,8 @@ use crate::{ util::Expr, }; -use eth_types::{evm_types::GasCost, Field, ToScalar}; +use crate::util::Field; +use eth_types::{evm_types::GasCost, ToScalar}; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, diff --git a/zkevm-circuits/src/evm_circuit/execution/stop.rs b/zkevm-circuits/src/evm_circuit/execution/stop.rs index c3248ffe18..b38bab8f04 100644 --- a/zkevm-circuits/src/evm_circuit/execution/stop.rs +++ b/zkevm-circuits/src/evm_circuit/execution/stop.rs @@ -15,10 +15,9 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::Field; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/swap.rs b/zkevm-circuits/src/evm_circuit/execution/swap.rs index 951d8922f7..b97e1c05c4 100644 --- a/zkevm-circuits/src/evm_circuit/execution/swap.rs +++ b/zkevm-circuits/src/evm_circuit/execution/swap.rs @@ -9,9 +9,9 @@ use crate::{ }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{evm_types::OpcodeId, Field}; +use eth_types::evm_types::OpcodeId; use halo2_proofs::plonk::Error; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/tload.rs b/zkevm-circuits/src/evm_circuit/execution/tload.rs index 90b7d896d2..e7971a3e15 100644 --- a/zkevm-circuits/src/evm_circuit/execution/tload.rs +++ b/zkevm-circuits/src/evm_circuit/execution/tload.rs @@ -10,10 +10,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian, ToScalar}; +use eth_types::{ToLittleEndian, ToScalar}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/execution/tstore.rs b/zkevm-circuits/src/evm_circuit/execution/tstore.rs index fb0a51fb84..a7bd457917 100644 --- a/zkevm-circuits/src/evm_circuit/execution/tstore.rs +++ b/zkevm-circuits/src/evm_circuit/execution/tstore.rs @@ -13,10 +13,10 @@ use crate::{ witness::{Block, Call, ExecStep, Transaction}, }, table::CallContextFieldTag, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian, ToScalar}; +use eth_types::{ToLittleEndian, ToScalar}; use halo2_proofs::{circuit::Value, plonk::Error}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/step.rs b/zkevm-circuits/src/evm_circuit/step.rs index 02c6529296..2090134483 100644 --- a/zkevm-circuits/src/evm_circuit/step.rs +++ b/zkevm-circuits/src/evm_circuit/step.rs @@ -5,11 +5,11 @@ use crate::{ util::Cell, witness::{Block, Call, ExecStep}, }, - util::Expr, + util::{Expr, Field}, witness::Transaction, }; use bus_mapping::{evm::OpcodeId, precompile::PrecompileCalls}; -use eth_types::{evm_types::GasCost, Field}; +use eth_types::evm_types::GasCost; use halo2_proofs::{ circuit::Value, plonk::{Advice, Column, ConstraintSystem, Error, Expression}, diff --git a/zkevm-circuits/src/evm_circuit/table.rs b/zkevm-circuits/src/evm_circuit/table.rs index 62f7da7426..3a662120b6 100644 --- a/zkevm-circuits/src/evm_circuit/table.rs +++ b/zkevm-circuits/src/evm_circuit/table.rs @@ -2,9 +2,9 @@ pub use crate::table::TxContextFieldTag; use crate::{ evm_circuit::step::{ExecutionState, ResponsibleOp}, impl_expr, + util::Field, }; use bus_mapping::{evm::OpcodeId, precompile::PrecompileCalls}; -use eth_types::Field; use gadgets::util::Expr; use halo2_proofs::plonk::Expression; use strum::IntoEnumIterator; diff --git a/zkevm-circuits/src/evm_circuit/test.rs b/zkevm-circuits/src/evm_circuit/test.rs index b282deb3b1..e45bcf557e 100644 --- a/zkevm-circuits/src/evm_circuit/test.rs +++ b/zkevm-circuits/src/evm_circuit/test.rs @@ -2,7 +2,8 @@ pub use super::EvmCircuit; use crate::evm_circuit::{detect_fixed_table_tags, witness::Block}; -use eth_types::{Field, Word}; +use crate::util::Field; +use eth_types::Word; use rand::{ distributions::uniform::{SampleRange, SampleUniform}, random, thread_rng, Rng, diff --git a/zkevm-circuits/src/evm_circuit/util.rs b/zkevm-circuits/src/evm_circuit/util.rs index c229db67a8..b822ca29bb 100644 --- a/zkevm-circuits/src/evm_circuit/util.rs +++ b/zkevm-circuits/src/evm_circuit/util.rs @@ -7,10 +7,10 @@ use crate::{ table::Table, }, table::RwTableTag, - util::{query_expression, Challenges, Expr}, + util::{query_expression, Challenges, Expr, Field}, witness::{Block, ExecStep, Rw, RwMap}, }; -use eth_types::{state_db::CodeDB, Address, Field, ToLittleEndian, ToWord, U256}; +use eth_types::{state_db::CodeDB, Address, ToLittleEndian, ToWord, U256}; use halo2_proofs::{ circuit::{AssignedCell, Region, Value}, halo2curves::group::ff::BatchInvert, @@ -565,8 +565,10 @@ pub(crate) type MemoryAddress = RandomLinearCombination>(bytes: &[E]) -> Expression { @@ -600,8 +602,10 @@ pub(crate) mod from_bytes { /// Decodes a field element from its binary representation pub(crate) mod from_bits { - use crate::{evm_circuit::param::MAX_N_BYTES_INTEGER, util::Expr}; - use eth_types::Field; + use crate::{ + evm_circuit::param::MAX_N_BYTES_INTEGER, + util::{Expr, Field}, + }; use halo2_proofs::plonk::Expression; pub(crate) fn expr>(bits: &[E]) -> Expression { @@ -638,8 +642,7 @@ pub(crate) mod from_bits { pub(crate) mod rlc { use std::ops::{Add, Mul}; - use crate::util::Expr; - use eth_types::Field; + use crate::util::{Expr, Field}; use halo2_proofs::plonk::Expression; pub(crate) fn expr>(expressions: &[E], randomness: E) -> Expression { diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget.rs index e69fd7f511..a7cd291ed0 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget.rs @@ -20,11 +20,11 @@ use crate::{ }, }, table::{AccountFieldTag, CallContextFieldTag}, - util::Expr, + util::{Expr, Field}, witness::{Block, Call, ExecStep}, }; use either::Either; -use eth_types::{evm_types::GasCost, Field, ToLittleEndian, ToScalar, U256}; +use eth_types::{evm_types::GasCost, ToLittleEndian, ToScalar, U256}; use gadgets::util::{select, sum}; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs index 5a1a821c3c..5dcc3363d0 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_access_list.rs @@ -6,14 +6,13 @@ use crate::{ not, or, select, }, table::TxFieldTag, - util::Expr, + util::{Expr, Field}, witness::Transaction, }; use bus_mapping::circuit_input_builder::CopyDataType; use eth_types::{ evm_types::GasCost, geth_types::{access_list_size, TxType}, - Field, }; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_eip1559.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_eip1559.rs index 0923147984..9aa7b69e3a 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_eip1559.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_eip1559.rs @@ -15,8 +15,9 @@ use crate::{ witness::Transaction, }, table::{BlockContextFieldTag, TxFieldTag}, + util::Field, }; -use eth_types::{geth_types::TxType, Field, ToLittleEndian, U256}; +use eth_types::{geth_types::TxType, ToLittleEndian, U256}; use gadgets::util::select; use halo2_proofs::plonk::{Error, Expression}; diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs index 78c4e935e2..9e96751ca2 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_fee.rs @@ -7,13 +7,13 @@ use crate::{ from_bytes, U64Word, Word, }, }, - util::Expr, + util::{Expr, Field}, }; use bus_mapping::{ circuit_input_builder::{TxL1Fee, TX_L1_COMMIT_EXTRA_COST, TX_L1_FEE_PRECISION}, l2_predeployed::l1_gas_price_oracle, }; -use eth_types::{Field, ToLittleEndian, ToScalar, U256}; +use eth_types::{ToLittleEndian, ToScalar, U256}; use halo2_proofs::plonk::{Error, Expression}; /// Transaction L1 fee gadget for L1GasPriceOracle contract diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_msg.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_msg.rs index 001e07eb9b..cf33814390 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_msg.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget/tx_l1_msg.rs @@ -7,9 +7,9 @@ use crate::{ select, }, table::AccountFieldTag, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{geth_types::TxType, Field, U256}; +use eth_types::{geth_types::TxType, U256}; use halo2_proofs::plonk::{Error, Expression}; /// L1 Msg Transaction gadget for some extra handling diff --git a/zkevm-circuits/src/evm_circuit/util/constraint_builder.rs b/zkevm-circuits/src/evm_circuit/util/constraint_builder.rs index 5cafae6f6a..2b265c4b11 100644 --- a/zkevm-circuits/src/evm_circuit/util/constraint_builder.rs +++ b/zkevm-circuits/src/evm_circuit/util/constraint_builder.rs @@ -9,10 +9,10 @@ use crate::{ AccountFieldTag, BytecodeFieldTag, CallContextFieldTag, RwTableTag, TxContextFieldTag, TxLogFieldTag, TxReceiptFieldTag, }, - util::{build_tx_log_expression, Challenges, Expr}, + util::{build_tx_log_expression, Challenges, Expr, Field}, }; use bus_mapping::util::{KECCAK_CODE_HASH_EMPTY, POSEIDON_CODE_HASH_EMPTY}; -use eth_types::{state_db::EMPTY_CODE_HASH_LE, Field, ToLittleEndian, ToScalar, ToWord}; +use eth_types::{state_db::EMPTY_CODE_HASH_LE, ToLittleEndian, ToScalar, ToWord}; use gadgets::util::{and, not}; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/evm_circuit/util/instrumentation.rs b/zkevm-circuits/src/evm_circuit/util/instrumentation.rs index 7de58deb45..b2511a54e0 100644 --- a/zkevm-circuits/src/evm_circuit/util/instrumentation.rs +++ b/zkevm-circuits/src/evm_circuit/util/instrumentation.rs @@ -1,9 +1,11 @@ -use crate::evm_circuit::{ - step::ExecutionState, - table::Table, - util::{constraint_builder::EVMConstraintBuilder, CellType}, +use crate::{ + evm_circuit::{ + step::ExecutionState, + table::Table, + util::{constraint_builder::EVMConstraintBuilder, CellType}, + }, + util::Field, }; -use eth_types::Field; use itertools::Itertools; type StepSize = Vec<(CellType, ColumnSize)>; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget.rs index 250797c1bd..d771927a33 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget.rs @@ -1,5 +1,4 @@ -use crate::util::Expr; -use eth_types::Field; +use crate::util::{Expr, Field}; use halo2_proofs::plonk::Expression; mod abs_word; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/abs_word.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/abs_word.rs index e7bbe5dc8e..6f0ec63b61 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/abs_word.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/abs_word.rs @@ -6,9 +6,9 @@ use crate::{ math_gadget::*, CachedRegion, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{Field, ToLittleEndian, Word}; +use eth_types::{ToLittleEndian, Word}; use halo2_proofs::plonk::Error; /// Construction of 256-bit word original and absolute values, which is useful diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/add_words.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/add_words.rs index ac2c26fd6e..1f954f748c 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/add_words.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/add_words.rs @@ -4,9 +4,9 @@ use crate::{ constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, from_bytes, pow_of_two_expr, split_u256, sum, CachedRegion, Cell, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{Field, ToLittleEndian, ToScalar, Word}; +use eth_types::{ToLittleEndian, ToScalar, Word}; use halo2_proofs::{circuit::Value, plonk::Error}; /// Construction of 2 256-bit words addition and result, which is useful for diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/batched_is_zero.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/batched_is_zero.rs index 29b9971825..8af72c4129 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/batched_is_zero.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/batched_is_zero.rs @@ -3,9 +3,8 @@ use crate::{ constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, transpose_val_ret, CachedRegion, Cell, CellType, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::Field; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, @@ -87,6 +86,7 @@ impl BatchedIsZeroGadget { #[cfg(test)] mod tests { use super::{super::test_util::*, *}; + use crate::util::Field; use eth_types::*; use halo2_proofs::{halo2curves::bn256::Fr, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/binary_number.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/binary_number.rs index f96ea0f330..b91616b56d 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/binary_number.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/binary_number.rs @@ -1,4 +1,4 @@ -use eth_types::Field; +use crate::util::Field; use gadgets::{binary_number::AsBits, util::Expr}; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/byte_size.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/byte_size.rs index 9138b61bb4..a63b24a2f5 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/byte_size.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/byte_size.rs @@ -6,9 +6,9 @@ use crate::{ sum, CachedRegion, Cell, }, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{Field, ToLittleEndian, Word}; +use eth_types::{ToLittleEndian, Word}; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/cmp_words.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/cmp_words.rs index a24f7d5b30..2eb7299abb 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/cmp_words.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/cmp_words.rs @@ -3,9 +3,9 @@ use crate::{ self, constraint_builder::EVMConstraintBuilder, from_bytes, math_gadget::*, select, CachedRegion, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{Field, ToLittleEndian, Word}; +use eth_types::{ToLittleEndian, Word}; use halo2_proofs::plonk::{Error, Expression}; #[derive(Clone, Debug)] diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/comparison.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/comparison.rs index 66d5de4317..0c9c7d6a13 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/comparison.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/comparison.rs @@ -1,7 +1,9 @@ -use crate::evm_circuit::util::{ - constraint_builder::EVMConstraintBuilder, math_gadget::*, sum, CachedRegion, +use crate::{ + evm_circuit::util::{ + constraint_builder::EVMConstraintBuilder, math_gadget::*, sum, CachedRegion, + }, + util::Field, }; -use eth_types::Field; use halo2_proofs::plonk::{Error, Expression}; /// Returns (lt, eq): @@ -51,7 +53,10 @@ impl ComparisonGadget { #[cfg(test)] mod tests { use super::{test_util::*, *}; - use crate::evm_circuit::util::{constraint_builder::ConstrainBuilderCommon, Cell}; + use crate::{ + evm_circuit::util::{constraint_builder::ConstrainBuilderCommon, Cell}, + util::Field, + }; use eth_types::*; use halo2_proofs::{halo2curves::bn256::Fr, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/constant_division.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/constant_division.rs index 7129b84160..81b21295d0 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/constant_division.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/constant_division.rs @@ -7,9 +7,8 @@ use crate::{ transpose_val_ret, CachedRegion, Cell, CellType, }, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::Field; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, @@ -104,6 +103,7 @@ impl ConstantDivisionGadget { #[cfg(test)] mod tests { use super::{test_util::*, *}; + use crate::util::Field; use eth_types::*; use halo2_proofs::{halo2curves::bn256::Fr, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/is_equal.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/is_equal.rs index 54ee7fb673..374530fb12 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/is_equal.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/is_equal.rs @@ -1,7 +1,9 @@ -use crate::evm_circuit::util::{ - constraint_builder::EVMConstraintBuilder, math_gadget::*, transpose_val_ret, CachedRegion, +use crate::{ + evm_circuit::util::{ + constraint_builder::EVMConstraintBuilder, math_gadget::*, transpose_val_ret, CachedRegion, + }, + util::Field, }; -use eth_types::Field; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, @@ -55,8 +57,9 @@ impl IsEqualGadget { #[cfg(test)] mod tests { use super::{test_util::*, *}; - use crate::evm_circuit::util::{ - constraint_builder::ConstrainBuilderCommon, CachedRegion, Cell, + use crate::{ + evm_circuit::util::{constraint_builder::ConstrainBuilderCommon, CachedRegion, Cell}, + util::Field, }; use eth_types::*; use halo2_proofs::{halo2curves::bn256::Fr, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/is_zero.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/is_zero.rs index ce8a5ce8b2..4c48678397 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/is_zero.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/is_zero.rs @@ -3,9 +3,8 @@ use crate::{ constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, transpose_val_ret, CachedRegion, Cell, CellType, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::Field; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/lt.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/lt.rs index b16e757132..d340aae435 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/lt.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/lt.rs @@ -6,9 +6,8 @@ use crate::{ from_bytes, pow_of_two, transpose_val_ret, CachedRegion, Cell, }, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::Field; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, @@ -106,6 +105,7 @@ impl LtGadget { #[cfg(test)] mod tests { use super::{super::test_util::*, *}; + use crate::util::Field; use eth_types::*; use halo2_proofs::{halo2curves::bn256::Fr, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/lt_word.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/lt_word.rs index a19c62dbcd..2ccdaaac64 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/lt_word.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/lt_word.rs @@ -1,8 +1,11 @@ -use crate::evm_circuit::util::{ - self, constraint_builder::EVMConstraintBuilder, from_bytes, math_gadget::*, split_u256, - CachedRegion, +use crate::{ + evm_circuit::util::{ + self, constraint_builder::EVMConstraintBuilder, from_bytes, math_gadget::*, split_u256, + CachedRegion, + }, + util::Field, }; -use eth_types::{Field, Word}; +use eth_types::Word; use halo2_proofs::plonk::{Error, Expression}; /// Returns `1` when `lhs < rhs`, and returns `0` otherwise. @@ -70,6 +73,7 @@ mod tests { use crate::evm_circuit::util::constraint_builder::ConstrainBuilderCommon; use super::{test_util::*, *}; + use crate::util::Field; use eth_types::*; use halo2_proofs::{halo2curves::bn256::Fr, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/min_max.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/min_max.rs index 102a35a053..e2e9a7eda6 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/min_max.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/min_max.rs @@ -1,8 +1,10 @@ -use crate::evm_circuit::util::{ - constraint_builder::EVMConstraintBuilder, math_gadget::*, select, transpose_val_ret, - CachedRegion, +use crate::{ + evm_circuit::util::{ + constraint_builder::EVMConstraintBuilder, math_gadget::*, select, transpose_val_ret, + CachedRegion, + }, + util::Field, }; -use eth_types::Field; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/modulo.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/modulo.rs index bd9726bebf..6ed2e8c11b 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/modulo.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/modulo.rs @@ -5,9 +5,9 @@ use crate::{ math_gadget::*, select, sum, CachedRegion, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{Field, ToLittleEndian, Word}; +use eth_types::{ToLittleEndian, Word}; use halo2_proofs::plonk::Error; /// Constraints for the words a, n, r: diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words.rs index 9caa9b687f..a94642871b 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words.rs @@ -4,9 +4,9 @@ use crate::{ constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, from_bytes, pow_of_two_expr, split_u256, split_u256_limb64, CachedRegion, Cell, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{Field, ToLittleEndian, Word}; +use eth_types::{ToLittleEndian, Word}; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words512.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words512.rs index eef61035b4..327bb60d9f 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words512.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_add_words512.rs @@ -4,9 +4,9 @@ use crate::{ constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, from_bytes, pow_of_two_expr, split_u256, split_u256_limb64, CachedRegion, Cell, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{Field, ToLittleEndian, Word}; +use eth_types::{ToLittleEndian, Word}; use halo2_proofs::{circuit::Value, plonk::Error}; /// Construct the gadget that checks a * b + c == d * 2**256 + e diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_word_u64.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_word_u64.rs index 04942e96e3..1e306ca5dd 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_word_u64.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/mul_word_u64.rs @@ -4,9 +4,9 @@ use crate::{ constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, from_bytes, pow_of_two_expr, split_u256, CachedRegion, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::{Field, ToLittleEndian, Word}; +use eth_types::{ToLittleEndian, Word}; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/pair_select.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/pair_select.rs index 4eadd96b53..0afcb66776 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/pair_select.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/pair_select.rs @@ -3,9 +3,8 @@ use crate::{ constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, CachedRegion, Cell, }, - util::Expr, + util::{Expr, Field}, }; -use eth_types::Field; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, @@ -65,6 +64,7 @@ mod tests { use crate::evm_circuit::util::constraint_builder::ConstrainBuilderCommon; use super::{super::test_util::*, *}; + use crate::util::Field; use eth_types::*; use halo2_proofs::{halo2curves::bn256::Fr, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/range_check.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/range_check.rs index 709eb6a12b..7352a72cae 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/range_check.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/range_check.rs @@ -1,11 +1,13 @@ -use crate::evm_circuit::{ - param::MAX_N_BYTES_INTEGER, - util::{ - constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, - from_bytes, CachedRegion, Cell, +use crate::{ + evm_circuit::{ + param::MAX_N_BYTES_INTEGER, + util::{ + constraint_builder::{ConstrainBuilderCommon, EVMConstraintBuilder}, + from_bytes, CachedRegion, Cell, + }, }, + util::Field, }; -use eth_types::Field; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, @@ -51,6 +53,7 @@ impl RangeCheckGadget { #[cfg(test)] mod tests { use super::{super::test_util::*, *}; + use crate::util::Field; use eth_types::*; use gadgets::util::Expr; use halo2_proofs::{circuit::Value, halo2curves::bn256::Fr, plonk::Error}; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/rlp.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/rlp.rs index c8d76319dc..d6f1f65377 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/rlp.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/rlp.rs @@ -1,4 +1,5 @@ -use eth_types::{Address, Field, ToLittleEndian, ToScalar, Word}; +use crate::util::Field; +use eth_types::{Address, ToLittleEndian, ToScalar, Word}; use gadgets::util::{and, expr_from_bytes, not, select, sum, Expr}; use halo2_proofs::{ circuit::Value, @@ -422,7 +423,8 @@ impl ContractCreateGadget { #[cfg(test)] mod test { use super::{super::test_util::*, ContractCreateGadget}; - use eth_types::{state_db::CodeDB, Field, ToAddress, ToLittleEndian, ToWord, Word}; + use crate::util::Field; + use eth_types::{state_db::CodeDB, ToAddress, ToLittleEndian, ToWord, Word}; use ethers_core::utils::keccak256; use gadgets::util::{not, Expr}; use halo2_proofs::halo2curves::bn256::Fr; diff --git a/zkevm-circuits/src/evm_circuit/util/math_gadget/test_util.rs b/zkevm-circuits/src/evm_circuit/util/math_gadget/test_util.rs index 9741e6cd02..a26549f106 100644 --- a/zkevm-circuits/src/evm_circuit/util/math_gadget/test_util.rs +++ b/zkevm-circuits/src/evm_circuit/util/math_gadget/test_util.rs @@ -31,7 +31,8 @@ use halo2_proofs::plonk::SecondPhase; #[cfg(not(feature = "onephase"))] use halo2_proofs::plonk::ThirdPhase; -use eth_types::{Field, Word, U256}; +use crate::util::Field; +use eth_types::{Word, U256}; pub(crate) use halo2_proofs::circuit::{Layouter, Value}; use halo2_proofs::{ circuit::SimpleFloorPlanner, diff --git a/zkevm-circuits/src/evm_circuit/util/memory_gadget.rs b/zkevm-circuits/src/evm_circuit/util/memory_gadget.rs index 56335318c6..14751f43b8 100644 --- a/zkevm-circuits/src/evm_circuit/util/memory_gadget.rs +++ b/zkevm-circuits/src/evm_circuit/util/memory_gadget.rs @@ -16,12 +16,12 @@ use crate::{ not, or, select, sum, Cell, CellType, MemoryAddress, }, }, - util::Expr, + util::{Expr, Field}, }; use array_init::array_init; use eth_types::{ evm_types::{GasCost, MAX_EXPANDED_MEMORY_ADDRESS}, - Field, ToLittleEndian, U256, + ToLittleEndian, U256, }; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/evm_circuit/util/padding_gadget.rs b/zkevm-circuits/src/evm_circuit/util/padding_gadget.rs index 7ee9c9adbb..721d488033 100644 --- a/zkevm-circuits/src/evm_circuit/util/padding_gadget.rs +++ b/zkevm-circuits/src/evm_circuit/util/padding_gadget.rs @@ -1,5 +1,5 @@ +use crate::util::Field; use bus_mapping::precompile::PrecompileCalls; -use eth_types::Field; use gadgets::util::{not, Expr}; use halo2_proofs::{circuit::Value, plonk::Expression}; diff --git a/zkevm-circuits/src/evm_circuit/util/precompile_gadget.rs b/zkevm-circuits/src/evm_circuit/util/precompile_gadget.rs index ee6df2696b..312ea03e0a 100644 --- a/zkevm-circuits/src/evm_circuit/util/precompile_gadget.rs +++ b/zkevm-circuits/src/evm_circuit/util/precompile_gadget.rs @@ -1,5 +1,5 @@ +use crate::util::Field; use bus_mapping::precompile::PrecompileCalls; -use eth_types::Field; use gadgets::util::{and, not, Expr}; use halo2_proofs::plonk::Expression; diff --git a/zkevm-circuits/src/exp_circuit.rs b/zkevm-circuits/src/exp_circuit.rs index afc3582b4c..1388331b07 100644 --- a/zkevm-circuits/src/exp_circuit.rs +++ b/zkevm-circuits/src/exp_circuit.rs @@ -11,11 +11,11 @@ pub use dev::ExpCircuit as TestExpCircuit; use crate::{ evm_circuit::util::constraint_builder::{BaseConstraintBuilder, ConstrainBuilderCommon}, table::{ExpTable, LookupTable, U16Table}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, witness, }; use bus_mapping::circuit_input_builder::{ExpEvent, ExpStep}; -use eth_types::{Field, ToScalar, U256}; +use eth_types::{ToScalar, U256}; use gadgets::{ mul_add::{MulAddChip, MulAddConfig}, util::{and, not, Expr}, diff --git a/zkevm-circuits/src/exp_circuit/dev.rs b/zkevm-circuits/src/exp_circuit/dev.rs index 1c2114186b..4a6e84df12 100644 --- a/zkevm-circuits/src/exp_circuit/dev.rs +++ b/zkevm-circuits/src/exp_circuit/dev.rs @@ -3,9 +3,8 @@ pub use super::ExpCircuit; use crate::{ exp_circuit::{ExpCircuitArgs, ExpCircuitConfig}, table::{ExpTable, U16Table}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, }; -use eth_types::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, plonk::{Circuit, ConstraintSystem, Error}, diff --git a/zkevm-circuits/src/exp_circuit/test.rs b/zkevm-circuits/src/exp_circuit/test.rs index 2df199f217..5ff19185f3 100644 --- a/zkevm-circuits/src/exp_circuit/test.rs +++ b/zkevm-circuits/src/exp_circuit/test.rs @@ -2,14 +2,14 @@ use crate::{ evm_circuit::witness::{block_convert, Block}, exp_circuit::ExpCircuit, - util::{unusable_rows, SubCircuit}, + util::{unusable_rows, Field, SubCircuit}, }; use bus_mapping::{ circuit_input_builder::{CircuitInputBuilder, CircuitsParams}, evm::OpcodeId, mock::BlockData, }; -use eth_types::{bytecode, geth_types::GethData, Bytecode, Field, Word}; +use eth_types::{bytecode, geth_types::GethData, Bytecode, Word}; use halo2_proofs::{ circuit::SimpleFloorPlanner, dev::MockProver, halo2curves::bn256::Fr, plonk::Circuit, }; diff --git a/zkevm-circuits/src/keccak_circuit.rs b/zkevm-circuits/src/keccak_circuit.rs index d776358895..fa2ab6ac3c 100644 --- a/zkevm-circuits/src/keccak_circuit.rs +++ b/zkevm-circuits/src/keccak_circuit.rs @@ -34,10 +34,9 @@ use crate::{ split, split_uniform, transform, transform_to, Part, }, table::{KeccakTable, LookupTable}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, witness, }; -use eth_types::Field; use gadgets::util::{and, not, select, sum, Expr}; use halo2_proofs::{ circuit::{AssignedCell, Layouter, Region, Value}, diff --git a/zkevm-circuits/src/keccak_circuit/cell_manager.rs b/zkevm-circuits/src/keccak_circuit/cell_manager.rs index 3082daea02..6394f03158 100644 --- a/zkevm-circuits/src/keccak_circuit/cell_manager.rs +++ b/zkevm-circuits/src/keccak_circuit/cell_manager.rs @@ -1,5 +1,4 @@ -use crate::keccak_circuit::util::extract_field; -use eth_types::Field; +use crate::{keccak_circuit::util::extract_field, util::Field}; use gadgets::util::Expr; use halo2_proofs::{ circuit::Value, diff --git a/zkevm-circuits/src/keccak_circuit/dev.rs b/zkevm-circuits/src/keccak_circuit/dev.rs index fffade5318..86c9b795bf 100644 --- a/zkevm-circuits/src/keccak_circuit/dev.rs +++ b/zkevm-circuits/src/keccak_circuit/dev.rs @@ -3,9 +3,8 @@ pub use super::KeccakCircuit; use crate::{ keccak_circuit::{KeccakCircuitConfig, KeccakCircuitConfigArgs}, table::KeccakTable, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, }; -use eth_types::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, plonk::{Circuit, ConstraintSystem, Error}, diff --git a/zkevm-circuits/src/keccak_circuit/keccak_packed_multi.rs b/zkevm-circuits/src/keccak_circuit/keccak_packed_multi.rs index ddf921cf13..f737fb9ece 100644 --- a/zkevm-circuits/src/keccak_circuit/keccak_packed_multi.rs +++ b/zkevm-circuits/src/keccak_circuit/keccak_packed_multi.rs @@ -1,6 +1,8 @@ use super::{cell_manager::*, param::*, util::*}; -use crate::{evm_circuit::util::rlc, util::Challenges}; -use eth_types::Field; +use crate::{ + evm_circuit::util::rlc, + util::{Challenges, Field}, +}; use halo2_proofs::{ circuit::Value, plonk::{Error, Expression}, @@ -156,8 +158,10 @@ impl KeccakRegion { /// Recombines parts back together pub(crate) mod decode { use super::{Part, PartValue}; - use crate::{keccak_circuit::param::BIT_COUNT, util::Expr}; - use eth_types::Field; + use crate::{ + keccak_circuit::param::BIT_COUNT, + util::{Expr, Field}, + }; use halo2_proofs::plonk::Expression; pub(crate) fn expr(parts: Vec>) -> Expression { @@ -179,9 +183,8 @@ pub(crate) mod split { use crate::{ evm_circuit::util::constraint_builder::{BaseConstraintBuilder, ConstrainBuilderCommon}, keccak_circuit::util::{pack, pack_part, unpack, WordParts}, - util::Expr, + util::{Expr, Field}, }; - use eth_types::Field; use halo2_proofs::plonk::{ConstraintSystem, Expression}; #[allow(clippy::too_many_arguments)] @@ -245,9 +248,8 @@ pub(crate) mod split_uniform { param::BIT_COUNT, util::{pack, pack_part, rotate, rotate_rev, unpack, WordParts}, }, - util::Expr, + util::{Expr, Field}, }; - use eth_types::Field; use halo2_proofs::plonk::{ConstraintSystem, Expression}; #[allow(clippy::too_many_arguments)] @@ -409,7 +411,7 @@ pub(crate) mod split_uniform { // Transform values using a lookup table pub(crate) mod transform { use super::{transform_to, CellManager, KeccakRegion, Part, PartValue}; - use eth_types::Field; + use crate::util::Field; use halo2_proofs::plonk::{ConstraintSystem, TableColumn}; #[allow(clippy::too_many_arguments)] @@ -466,9 +468,8 @@ pub(crate) mod transform_to { use super::{Cell, KeccakRegion, Part, PartValue}; use crate::{ keccak_circuit::util::{pack, to_bytes, unpack}, - util::Expr, + util::{Expr, Field}, }; - use eth_types::Field; use halo2_proofs::plonk::{ConstraintSystem, TableColumn}; #[allow(clippy::too_many_arguments)] diff --git a/zkevm-circuits/src/keccak_circuit/table.rs b/zkevm-circuits/src/keccak_circuit/table.rs index 8d64c595e6..25f3878e71 100644 --- a/zkevm-circuits/src/keccak_circuit/table.rs +++ b/zkevm-circuits/src/keccak_circuit/table.rs @@ -1,6 +1,5 @@ use super::{param::*, util::*}; -use crate::keccak_circuit::keccak_packed_multi::get_num_bits_per_base_chi_lookup; -use eth_types::Field; +use crate::{keccak_circuit::keccak_packed_multi::get_num_bits_per_base_chi_lookup, util::Field}; use halo2_proofs::{ circuit::{Layouter, Value}, plonk::{Error, TableColumn}, diff --git a/zkevm-circuits/src/keccak_circuit/test.rs b/zkevm-circuits/src/keccak_circuit/test.rs index e3f6c3e813..8080e53d46 100644 --- a/zkevm-circuits/src/keccak_circuit/test.rs +++ b/zkevm-circuits/src/keccak_circuit/test.rs @@ -1,7 +1,6 @@ #![allow(unused_imports)] use super::*; -use crate::util::unusable_rows; -use eth_types::Field; +use crate::util::{unusable_rows, Field}; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, dev::MockProver, diff --git a/zkevm-circuits/src/keccak_circuit/util.rs b/zkevm-circuits/src/keccak_circuit/util.rs index 4a98fe1335..3180e4bb9f 100644 --- a/zkevm-circuits/src/keccak_circuit/util.rs +++ b/zkevm-circuits/src/keccak_circuit/util.rs @@ -1,7 +1,8 @@ //! Utility traits, functions used in the crate. use super::{keccak_packed_multi::keccak_unusable_rows, param::*}; -use eth_types::{Field, ToScalar, Word}; +use crate::util::Field; +use eth_types::{ToScalar, Word}; use halo2_proofs::circuit::Value; use std::env::var; @@ -244,7 +245,7 @@ pub(crate) fn extract_field(value: Value) -> F { /// Encodes the data using rlc pub(crate) mod compose_rlc { - use eth_types::Field; + use crate::util::Field; use halo2_proofs::plonk::Expression; pub(crate) fn expr(expressions: &[Expression], r: Expression) -> Expression { @@ -261,7 +262,7 @@ pub(crate) mod compose_rlc { /// Scatters a value into a packed word constant pub(crate) mod scatter { use super::pack; - use eth_types::Field; + use crate::util::Field; use halo2_proofs::plonk::Expression; pub(crate) fn expr(value: u8, count: usize) -> Expression { @@ -271,7 +272,7 @@ pub(crate) mod scatter { /// Packs bits into bytes pub(crate) mod to_bytes { - use eth_types::Field; + use crate::util::Field; use gadgets::util::Expr; use halo2_proofs::plonk::Expression; diff --git a/zkevm-circuits/src/lib.rs b/zkevm-circuits/src/lib.rs index 18b58857a8..7083e28748 100644 --- a/zkevm-circuits/src/lib.rs +++ b/zkevm-circuits/src/lib.rs @@ -5,6 +5,7 @@ #![allow(incomplete_features)] // Needed by DummyGadget in evm circuit #![feature(adt_const_params)] +#![feature(trait_alias)] #![feature(slice_group_by)] #![feature(lazy_cell)] // Needed by some builder patterns in testing modules. diff --git a/zkevm-circuits/src/modexp_circuit.rs b/zkevm-circuits/src/modexp_circuit.rs index b60ba4c452..9abbe75ddb 100644 --- a/zkevm-circuits/src/modexp_circuit.rs +++ b/zkevm-circuits/src/modexp_circuit.rs @@ -13,11 +13,11 @@ use halo2_proofs::{ use crate::{ table::ModExpTable, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, witness, }; use bus_mapping::circuit_input_builder::BigModExp; -use eth_types::{Field, Word}; +use eth_types::Word; //use misc_precompiled_circuit::value_for_assign; use misc_precompiled_circuit::circuits::{ diff --git a/zkevm-circuits/src/mpt_circuit.rs b/zkevm-circuits/src/mpt_circuit.rs index 6900752e00..e9fb900943 100644 --- a/zkevm-circuits/src/mpt_circuit.rs +++ b/zkevm-circuits/src/mpt_circuit.rs @@ -4,10 +4,9 @@ // use crate::mpt_circuit::mpt; use crate::{ table::{LookupTable, MptTable, PoseidonTable}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, witness, }; -use eth_types::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner, Value}, halo2curves::bn256::Fr, diff --git a/zkevm-circuits/src/pi_circuit.rs b/zkevm-circuits/src/pi_circuit.rs index 99930d4aad..59efa55e38 100644 --- a/zkevm-circuits/src/pi_circuit.rs +++ b/zkevm-circuits/src/pi_circuit.rs @@ -9,9 +9,11 @@ mod test; use std::{cell::RefCell, collections::BTreeMap, iter, marker::PhantomData, str::FromStr}; -use crate::{evm_circuit::util::constraint_builder::ConstrainBuilderCommon, table::KeccakTable}; +use crate::{ + evm_circuit::util::constraint_builder::ConstrainBuilderCommon, table::KeccakTable, util::Field, +}; use bus_mapping::circuit_input_builder::get_dummy_tx_hash; -use eth_types::{geth_types::TxType, Address, Field, Hash, ToBigEndian, ToWord, Word, H256}; +use eth_types::{geth_types::TxType, Address, Hash, ToBigEndian, ToWord, Word, H256}; use ethers_core::utils::keccak256; use halo2_proofs::plonk::{Assigned, Expression, Fixed, Instance}; diff --git a/zkevm-circuits/src/poseidon_circuit.rs b/zkevm-circuits/src/poseidon_circuit.rs index e9facbb3b6..a733c18f5b 100644 --- a/zkevm-circuits/src/poseidon_circuit.rs +++ b/zkevm-circuits/src/poseidon_circuit.rs @@ -6,7 +6,7 @@ use crate::{ witness::{self}, }; //use bus_mapping::state_db::CodeDB; -use eth_types::Field; +use crate::util::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner, Value}, plonk::{Circuit, ConstraintSystem, Error}, diff --git a/zkevm-circuits/src/rlp_circuit_fsm.rs b/zkevm-circuits/src/rlp_circuit_fsm.rs index 1b358573d3..310695530d 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm.rs @@ -10,7 +10,7 @@ use crate::{ table::{LookupTable, RlpFsmRlpTable, U8Table}, util::{ is_zero::{IsZeroChip, IsZeroConfig}, - Challenges, SubCircuit, SubCircuitConfig, + Challenges, Field, SubCircuit, SubCircuitConfig, }, witness::{ rlp_fsm::StackOp, @@ -21,7 +21,6 @@ use crate::{ Transaction, }, }; -use eth_types::Field; use gadgets::{ binary_number::{BinaryNumberChip, BinaryNumberConfig}, comparator::{ComparatorChip, ComparatorConfig, ComparatorInstruction}, diff --git a/zkevm-circuits/src/rlp_circuit_fsm/dev.rs b/zkevm-circuits/src/rlp_circuit_fsm/dev.rs index ec775f397c..8e7167e8c3 100644 --- a/zkevm-circuits/src/rlp_circuit_fsm/dev.rs +++ b/zkevm-circuits/src/rlp_circuit_fsm/dev.rs @@ -1,10 +1,9 @@ use crate::{ rlp_circuit_fsm::{RlpCircuit, RlpCircuitConfig, RlpCircuitConfigArgs}, table::{RlpFsmRlpTable, U8Table}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, witness::Transaction, }; -use eth_types::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, plonk::{Circuit, ConstraintSystem, Error}, diff --git a/zkevm-circuits/src/sha256_circuit.rs b/zkevm-circuits/src/sha256_circuit.rs index 55317cb140..6068eae45a 100644 --- a/zkevm-circuits/src/sha256_circuit.rs +++ b/zkevm-circuits/src/sha256_circuit.rs @@ -16,11 +16,10 @@ pub use halo2_gadgets::sha256::BLOCK_SIZE; use crate::{ table::{LookupTable, SHA256Table}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, witness, }; use bus_mapping::circuit_input_builder::SHA256; -use eth_types::Field; impl TableTrait for SHA256Table { fn cols(&self) -> [Column; 5] { diff --git a/zkevm-circuits/src/sig_circuit.rs b/zkevm-circuits/src/sig_circuit.rs index 6a3dec5645..91c85014a5 100644 --- a/zkevm-circuits/src/sig_circuit.rs +++ b/zkevm-circuits/src/sig_circuit.rs @@ -22,12 +22,11 @@ use crate::{ keccak_circuit::KeccakCircuit, sig_circuit::ecdsa::ecdsa_verify_no_pubkey_check, table::{KeccakTable, SigTable}, - util::{Challenges, Expr, SubCircuit, SubCircuitConfig}, + util::{Challenges, Expr, Field, SubCircuit, SubCircuitConfig}, }; use eth_types::{ self, sign_types::{pk_bytes_le, pk_bytes_swap_endianness, SignData}, - Field, }; use halo2_base::{ gates::{range::RangeConfig, GateInstructions, RangeInstructions}, diff --git a/zkevm-circuits/src/sig_circuit/test.rs b/zkevm-circuits/src/sig_circuit/test.rs index f4366c51d6..394ce11837 100644 --- a/zkevm-circuits/src/sig_circuit/test.rs +++ b/zkevm-circuits/src/sig_circuit/test.rs @@ -1,7 +1,5 @@ -use eth_types::{ - sign_types::{sign, SignData}, - Field, -}; +use crate::{sig_circuit::SigCircuit, util::Field}; +use eth_types::sign_types::{sign, SignData}; use halo2_proofs::{ arithmetic::Field as HaloField, dev::MockProver, @@ -13,8 +11,6 @@ use halo2_proofs::{ use rand::{Rng, RngCore}; use std::marker::PhantomData; -use crate::sig_circuit::SigCircuit; - #[test] fn test_edge_cases() { use super::utils::LOG_TOTAL_NUM_ROWS; diff --git a/zkevm-circuits/src/sig_circuit/utils.rs b/zkevm-circuits/src/sig_circuit/utils.rs index f9dc58d142..3716228ba3 100644 --- a/zkevm-circuits/src/sig_circuit/utils.rs +++ b/zkevm-circuits/src/sig_circuit/utils.rs @@ -1,4 +1,4 @@ -use eth_types::Field; +use crate::util::Field; use halo2_base::{AssignedValue, QuantumCell}; use halo2_ecc::{ bigint::CRTInteger, diff --git a/zkevm-circuits/src/state_circuit.rs b/zkevm-circuits/src/state_circuit.rs index 94f5427468..da4dbace6d 100644 --- a/zkevm-circuits/src/state_circuit.rs +++ b/zkevm-circuits/src/state_circuit.rs @@ -21,11 +21,11 @@ use self::{ use crate::{ evm_circuit::{param::N_BYTES_WORD, util::rlc}, table::{AccountFieldTag, LookupTable, MptTable, RwTable, RwTableTag}, - util::{Challenges, Expr, SubCircuit, SubCircuitConfig}, + util::{Challenges, Expr, Field, SubCircuit, SubCircuitConfig}, witness::{self, MptUpdates, Rw, RwMap}, }; use constraint_builder::{ConstraintBuilder, Queries}; -use eth_types::{Address, Field, ToLittleEndian}; +use eth_types::{Address, ToLittleEndian}; use gadgets::{ batched_is_zero::{BatchedIsZeroChip, BatchedIsZeroConfig}, binary_number::{BinaryNumberChip, BinaryNumberConfig}, diff --git a/zkevm-circuits/src/state_circuit/constraint_builder.rs b/zkevm-circuits/src/state_circuit/constraint_builder.rs index 8b60726bd7..c8692726fe 100644 --- a/zkevm-circuits/src/state_circuit/constraint_builder.rs +++ b/zkevm-circuits/src/state_circuit/constraint_builder.rs @@ -5,9 +5,8 @@ use super::{ use crate::{ evm_circuit::{param::N_BYTES_WORD, util::not}, table::{AccountFieldTag, MPTProofType as ProofType, RwTableTag}, - util::Expr, + util::{Expr, Field}, }; -use eth_types::Field; use gadgets::binary_number::BinaryNumberConfig; use halo2_proofs::plonk::Expression; use strum::IntoEnumIterator; diff --git a/zkevm-circuits/src/state_circuit/dev.rs b/zkevm-circuits/src/state_circuit/dev.rs index ee1006b1dd..031bc33c5e 100644 --- a/zkevm-circuits/src/state_circuit/dev.rs +++ b/zkevm-circuits/src/state_circuit/dev.rs @@ -3,9 +3,8 @@ pub use super::StateCircuit; use crate::{ state_circuit::{StateCircuitConfig, StateCircuitConfigArgs}, table::{MptTable, RwTable}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, }; -use eth_types::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, plonk::{Advice, Circuit, Column, ConstraintSystem, Error}, diff --git a/zkevm-circuits/src/state_circuit/lexicographic_ordering.rs b/zkevm-circuits/src/state_circuit/lexicographic_ordering.rs index 188b7f6a33..504b7105bd 100644 --- a/zkevm-circuits/src/state_circuit/lexicographic_ordering.rs +++ b/zkevm-circuits/src/state_circuit/lexicographic_ordering.rs @@ -1,6 +1,11 @@ use super::{lookups, param::*, SortKeysConfig}; -use crate::{evm_circuit::param::N_BYTES_WORD, impl_expr, util::Expr, witness::Rw}; -use eth_types::{Field, ToBigEndian}; +use crate::{ + evm_circuit::param::N_BYTES_WORD, + impl_expr, + util::{Expr, Field}, + witness::Rw, +}; +use eth_types::ToBigEndian; use gadgets::binary_number::{AsBits, BinaryNumberChip, BinaryNumberConfig}; use halo2_proofs::{ circuit::{Region, Value}, diff --git a/zkevm-circuits/src/state_circuit/lookups.rs b/zkevm-circuits/src/state_circuit/lookups.rs index 24a3128763..63056aa14a 100644 --- a/zkevm-circuits/src/state_circuit/lookups.rs +++ b/zkevm-circuits/src/state_circuit/lookups.rs @@ -1,5 +1,4 @@ -use crate::table::CallContextFieldTag; -use eth_types::Field; +use crate::{table::CallContextFieldTag, util::Field}; use halo2_proofs::{ circuit::{Layouter, Value}, plonk::{Column, ConstraintSystem, Error, Expression, Fixed, VirtualCells}, diff --git a/zkevm-circuits/src/state_circuit/multiple_precision_integer.rs b/zkevm-circuits/src/state_circuit/multiple_precision_integer.rs index e5c06647bf..5b6b3df843 100644 --- a/zkevm-circuits/src/state_circuit/multiple_precision_integer.rs +++ b/zkevm-circuits/src/state_circuit/multiple_precision_integer.rs @@ -1,6 +1,6 @@ use super::{lookups, param::*}; -use crate::util::Expr; -use eth_types::{Address, Field}; +use crate::util::{Expr, Field}; +use eth_types::Address; use halo2_proofs::{ circuit::{Layouter, Region, Value}, plonk::{Advice, Column, ConstraintSystem, Error, Expression, Fixed, VirtualCells}, diff --git a/zkevm-circuits/src/state_circuit/random_linear_combination.rs b/zkevm-circuits/src/state_circuit/random_linear_combination.rs index 2b7f2804d5..6db9af395e 100644 --- a/zkevm-circuits/src/state_circuit/random_linear_combination.rs +++ b/zkevm-circuits/src/state_circuit/random_linear_combination.rs @@ -1,5 +1,5 @@ -use crate::evm_circuit::util::rlc; -use eth_types::{Field, ToLittleEndian, U256}; +use crate::{evm_circuit::util::rlc, util::Field}; +use eth_types::{ToLittleEndian, U256}; use halo2_proofs::{ circuit::{Layouter, Region, Value}, plonk::{Advice, Column, ConstraintSystem, Error, Expression, Fixed, VirtualCells}, diff --git a/zkevm-circuits/src/state_circuit/test.rs b/zkevm-circuits/src/state_circuit/test.rs index b6849be85d..2f5472db43 100644 --- a/zkevm-circuits/src/state_circuit/test.rs +++ b/zkevm-circuits/src/state_circuit/test.rs @@ -2,7 +2,7 @@ pub use super::{dev::*, *}; use crate::{ table::{AccountFieldTag, CallContextFieldTag, RwTableTag, TxLogFieldTag, TxReceiptFieldTag}, - util::{unusable_rows, SubCircuit}, + util::{unusable_rows, Field, SubCircuit}, witness::{MptUpdates, Rw, RwMap}, }; use bus_mapping::operation::{ @@ -11,7 +11,7 @@ use bus_mapping::operation::{ use eth_types::{ address, evm_types::{MemoryAddress, StackAddress}, - Address, Field, ToAddress, Word, U256, + Address, ToAddress, Word, U256, }; use gadgets::binary_number::AsBits; use halo2_proofs::{ diff --git a/zkevm-circuits/src/super_circuit.rs b/zkevm-circuits/src/super_circuit.rs index 278751b558..4ddbcb8a4d 100644 --- a/zkevm-circuits/src/super_circuit.rs +++ b/zkevm-circuits/src/super_circuit.rs @@ -92,11 +92,12 @@ use crate::{ #[cfg(feature = "zktrie")] use crate::mpt_circuit::{MptCircuit, MptCircuitConfig, MptCircuitConfigArgs}; +use crate::util::Field; use bus_mapping::{ circuit_input_builder::{CircuitInputBuilder, CircuitsParams}, mock::BlockData, }; -use eth_types::{geth_types::GethData, Field}; +use eth_types::geth_types::GethData; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner, Value}, halo2curves::bn256::Fr, diff --git a/zkevm-circuits/src/table.rs b/zkevm-circuits/src/table.rs index b764fee986..663251bc81 100644 --- a/zkevm-circuits/src/table.rs +++ b/zkevm-circuits/src/table.rs @@ -8,7 +8,7 @@ use crate::{ }, exp_circuit::param::{OFFSET_INCREMENT, ROWS_PER_STEP}, impl_expr, - util::{build_tx_log_address, rlc_be_bytes, Challenges}, + util::{build_tx_log_address, rlc_be_bytes, Challenges, Field}, witness::{ Block, BlockContexts, Bytecode, MptUpdateRow, MptUpdates, RlpFsmWitnessGen, Rw, RwMap, RwRow, Transaction, @@ -22,7 +22,7 @@ use bus_mapping::{ precompile::PrecompileCalls, }; use core::iter::once; -use eth_types::{sign_types::SignData, Field, ToLittleEndian, ToScalar, ToWord, Word, H256, U256}; +use eth_types::{sign_types::SignData, ToLittleEndian, ToScalar, ToWord, Word, H256, U256}; use ethers_core::utils::keccak256; use gadgets::{ binary_number::{BinaryNumberChip, BinaryNumberConfig}, diff --git a/zkevm-circuits/src/tx_circuit.rs b/zkevm-circuits/src/tx_circuit.rs index 1f6d4e2131..2ee54ca346 100644 --- a/zkevm-circuits/src/tx_circuit.rs +++ b/zkevm-circuits/src/tx_circuit.rs @@ -12,6 +12,7 @@ mod test; #[cfg(any(feature = "test", test, feature = "test-circuits"))] pub use dev::TxCircuitTester as TestTxCircuit; +use crate::util::Field; use crate::{ evm_circuit::util::constraint_builder::{BaseConstraintBuilder, ConstrainBuilderCommon}, // sig_circuit::SigCircuit, @@ -51,7 +52,7 @@ use eth_types::{ TxType::{Eip155, Eip1559, Eip2930, L1Msg, PreEip155}, }, sign_types::SignData, - AccessList, Address, Field, ToAddress, ToBigEndian, ToScalar, + AccessList, Address, ToAddress, ToBigEndian, ToScalar, }; use ethers_core::utils::keccak256; use gadgets::{ diff --git a/zkevm-circuits/src/tx_circuit/dev.rs b/zkevm-circuits/src/tx_circuit/dev.rs index c304cf6dab..b78f81a4e0 100644 --- a/zkevm-circuits/src/tx_circuit/dev.rs +++ b/zkevm-circuits/src/tx_circuit/dev.rs @@ -11,10 +11,9 @@ use crate::{ U16Table, U8Table, }, tx_circuit::{TxCircuitConfig, TxCircuitConfigArgs}, - util::{Challenges, SubCircuit, SubCircuitConfig}, + util::{Challenges, Field, SubCircuit, SubCircuitConfig}, witness::Transaction, }; -use eth_types::Field; use halo2_proofs::{ circuit::{Layouter, SimpleFloorPlanner}, plonk::{Circuit, ConstraintSystem, Error, Expression}, diff --git a/zkevm-circuits/src/util.rs b/zkevm-circuits/src/util.rs index 1c3ca06fb0..9f94c646ff 100644 --- a/zkevm-circuits/src/util.rs +++ b/zkevm-circuits/src/util.rs @@ -14,13 +14,16 @@ use halo2_proofs::plonk::SecondPhase; use sha3::Digest; use crate::{evm_circuit::util::rlc, table::TxLogFieldTag, witness}; -use eth_types::{Field, ToAddress, Word}; +use eth_types::{ToAddress, Word}; pub use ethers_core::types::{Address, U256}; pub use gadgets::util::Expr; /// A wrapper of is_zero in gadgets which gives is_zero at any rotation pub mod is_zero; +/// The field used in circuits. We only support bn254fr now. +pub trait Field = eth_types::Field + halo2_base::utils::ScalarField; + pub(crate) fn query_expression( meta: &mut ConstraintSystem, mut f: impl FnMut(&mut VirtualCells) -> T, diff --git a/zkevm-circuits/src/util/is_zero.rs b/zkevm-circuits/src/util/is_zero.rs index 03f2a60936..dc8c483c7c 100644 --- a/zkevm-circuits/src/util/is_zero.rs +++ b/zkevm-circuits/src/util/is_zero.rs @@ -1,4 +1,4 @@ -use eth_types::Field; +use crate::util::Field; use gadgets::{ is_zero::{IsZeroChip as IsZeroGadgetChip, IsZeroConfig as IsZeroGadgetConfig}, util::Expr, diff --git a/zkevm-circuits/src/witness/block.rs b/zkevm-circuits/src/witness/block.rs index 0fa47ab001..53206169a6 100644 --- a/zkevm-circuits/src/witness/block.rs +++ b/zkevm-circuits/src/witness/block.rs @@ -7,7 +7,7 @@ use crate::evm_circuit::{detect_fixed_table_tags, EvmCircuit}; use crate::{ evm_circuit::util::rlc, table::{BlockContextFieldTag, RwTableTag}, - util::SubCircuit, + util::{Field, SubCircuit}, }; use bus_mapping::{ circuit_input_builder::{ @@ -16,7 +16,7 @@ use bus_mapping::{ }, Error, }; -use eth_types::{sign_types::SignData, Address, Field, ToLittleEndian, ToScalar, Word, U256}; +use eth_types::{sign_types::SignData, Address, ToLittleEndian, ToScalar, Word, U256}; use halo2_proofs::circuit::Value; use itertools::Itertools; diff --git a/zkevm-circuits/src/witness/bytecode.rs b/zkevm-circuits/src/witness/bytecode.rs index bdf5a2daab..325b9d4f15 100644 --- a/zkevm-circuits/src/witness/bytecode.rs +++ b/zkevm-circuits/src/witness/bytecode.rs @@ -1,5 +1,6 @@ +use crate::util::Field; use bus_mapping::evm::OpcodeId; -use eth_types::{Field, ToLittleEndian, Word}; +use eth_types::{ToLittleEndian, Word}; use halo2_proofs::circuit::Value; use crate::{evm_circuit::util::rlc, table::BytecodeFieldTag, util::Challenges}; diff --git a/zkevm-circuits/src/witness/mpt.rs b/zkevm-circuits/src/witness/mpt.rs index 92788c61a2..027a8d0b15 100644 --- a/zkevm-circuits/src/witness/mpt.rs +++ b/zkevm-circuits/src/witness/mpt.rs @@ -1,8 +1,9 @@ use crate::{ evm_circuit::{util::rlc, witness::Rw}, table::AccountFieldTag, + util::Field, }; -use eth_types::{Address, Field, ToLittleEndian, ToScalar, Word, U256}; +use eth_types::{Address, ToLittleEndian, ToScalar, Word, U256}; use halo2_proofs::circuit::Value; use itertools::Itertools; use mpt_zktrie::{ diff --git a/zkevm-circuits/src/witness/rlp_fsm.rs b/zkevm-circuits/src/witness/rlp_fsm.rs index 2b46ada1fd..83d8d2922c 100644 --- a/zkevm-circuits/src/witness/rlp_fsm.rs +++ b/zkevm-circuits/src/witness/rlp_fsm.rs @@ -1,4 +1,5 @@ -use eth_types::{Address, Field, H160, U256}; +use crate::util::Field; +use eth_types::{Address, H160, U256}; use gadgets::{impl_expr, util::Expr}; use halo2_proofs::{circuit::Value, halo2curves::ff::PrimeField, plonk::Expression}; use strum_macros::EnumIter; diff --git a/zkevm-circuits/src/witness/rw.rs b/zkevm-circuits/src/witness/rw.rs index f1aac689a5..1f19c1a4af 100644 --- a/zkevm-circuits/src/witness/rw.rs +++ b/zkevm-circuits/src/witness/rw.rs @@ -1,11 +1,12 @@ #![allow(missing_docs)] use std::collections::HashMap; +use crate::util::Field; use bus_mapping::{ operation::{self, AccountField, CallContextField, TxLogField, TxReceiptField}, Error, }; -use eth_types::{Address, Field, ToLittleEndian, ToScalar, Word, U256}; +use eth_types::{Address, ToLittleEndian, ToScalar, Word, U256}; use halo2_proofs::{circuit::Value, halo2curves::bn256::Fr}; use itertools::Itertools; diff --git a/zkevm-circuits/src/witness/tx.rs b/zkevm-circuits/src/witness/tx.rs index a6671c6535..1d8dd1fd71 100644 --- a/zkevm-circuits/src/witness/tx.rs +++ b/zkevm-circuits/src/witness/tx.rs @@ -1,7 +1,7 @@ use crate::{ evm_circuit::{step::ExecutionState, util::rlc}, table::TxContextFieldTag, - util::{rlc_be_bytes, Challenges}, + util::{rlc_be_bytes, Challenges, Field}, witness::{ rlp_fsm::{RlpStackOp, SmState}, DataTable, Format, @@ -22,8 +22,8 @@ use eth_types::{ sign_types::{ biguint_to_32bytes_le, ct_option_ok_or, get_dummy_tx, recover_pk2, SignData, SECP256K1_Q, }, - AccessList, Address, Error, Field, Signature, ToBigEndian, ToLittleEndian, ToScalar, ToWord, - Word, H256, + AccessList, Address, Error, Signature, ToBigEndian, ToLittleEndian, ToScalar, ToWord, Word, + H256, }; use ethers_core::{ types::TransactionRequest,