From 0e3e3106d156dbd2471688ef13cf363d2d3a0f4d Mon Sep 17 00:00:00 2001 From: "sm.wu" Date: Tue, 9 May 2023 22:30:51 +0800 Subject: [PATCH] fix ide caused refactor error --- .../src/evm_circuit/execution/addmod.rs | 6 ++--- .../src/evm_circuit/execution/begin_tx.rs | 16 ++++++------ .../src/evm_circuit/execution/callop.rs | 2 +- .../execution/error_oog_static_memory.rs | 4 +-- .../src/evm_circuit/execution/mul_div_mod.rs | 10 +++---- .../src/evm_circuit/execution/mulmod.rs | 26 ++++++++----------- .../src/evm_circuit/execution/sdiv_smod.rs | 8 +++--- .../src/evm_circuit/execution/shl_shr.rs | 4 +-- 8 files changed, 36 insertions(+), 40 deletions(-) diff --git a/zkevm-circuits/src/evm_circuit/execution/addmod.rs b/zkevm-circuits/src/evm_circuit/execution/addmod.rs index 3d59053216c..51d350c096f 100644 --- a/zkevm-circuits/src/evm_circuit/execution/addmod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/addmod.rs @@ -89,7 +89,7 @@ impl ExecutionGadget for AddModGadget { cb.require_equal( "check a_reduced + b 512 bit carry if n != 0", - sum_areduced_b_overflow.word_expr(), + sum_areduced_b_overflow.expr(), sum_areduced_b.carry().clone().unwrap().expr() * not::expr(n_is_zero.expr()), ); @@ -104,10 +104,10 @@ impl ExecutionGadget for AddModGadget { // pop/push values // take care that if n==0 pushed value for r should be zero also - cb.stack_pop(a.word_expr()); + cb.stack_pop(a.expr()); cb.stack_pop(b.expr()); cb.stack_pop(n.expr()); - cb.stack_push(r.word_expr() * not::expr(n_is_zero.expr())); + cb.stack_push(r.expr() * not::expr(n_is_zero.expr())); // State transition let step_state_transition = StepStateTransition { diff --git a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs index ec9249b8888..6aeb2ba564c 100644 --- a/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs +++ b/zkevm-circuits/src/evm_circuit/execution/begin_tx.rs @@ -15,12 +15,12 @@ use crate::{ ContractCreateGadget, IsEqualGadget, IsZeroGadget, MulWordByU64Gadget, RangeCheckGadget, }, - not, or, select, CachedRegion, Cell, StepRws, Word, + not, or, select, CachedRegion, Cell, StepRws, }, witness::{Block, Call, ExecStep, Transaction}, }, table::{AccountFieldTag, CallContextFieldTag, TxFieldTag as TxContextFieldTag}, - util::Expr, + util::{word::Word32Cell, Expr}, }; use eth_types::{evm_types::GasCost, Field, ToLittleEndian, ToScalar}; use ethers_core::utils::{get_contract_address, keccak256}; @@ -32,14 +32,14 @@ pub(crate) struct BeginTxGadget { tx_id: Cell, tx_nonce: Cell, tx_gas: Cell, - tx_gas_price: Word, + tx_gas_price: Word32Cell, mul_gas_fee_by_gas: MulWordByU64Gadget, tx_caller_address: Cell, tx_caller_address_is_zero: IsZeroGadget, tx_callee_address: Cell, call_callee_address: Cell, tx_is_create: Cell, - tx_value: Word, + tx_value: Word32Cell, tx_call_data_length: Cell, tx_call_data_gas_cost: Cell, reversion_info: ReversionInfo, @@ -67,14 +67,14 @@ impl ExecutionGadget for BeginTxGadget { 1.expr(), Some(call_id.expr()), CallContextFieldTag::TxId, - Word::from_lo(tx_id.expr()), + tx_id.expr(), ); // rwc_delta += 1 let mut reversion_info = cb.reversion_info_write(None); // rwc_delta += 2 cb.call_context_lookup( 1.expr(), Some(call_id.expr()), CallContextFieldTag::IsSuccess, - Word::from_lo(reversion_info.is_persistent()), + reversion_info.is_persistent(), ); // rwc_delta += 1 let [tx_nonce, tx_gas, tx_caller_address, tx_callee_address, tx_is_create, tx_call_data_length, tx_call_data_gas_cost] = @@ -240,7 +240,7 @@ impl ExecutionGadget for BeginTxGadget { CallContextFieldTag::CallDataLength, tx_call_data_length.expr(), ), - (CallContextFieldTag::Value, tx_value.word_expr()), + (CallContextFieldTag::Value, tx_value.expr()), (CallContextFieldTag::IsStatic, 0.expr()), (CallContextFieldTag::LastCalleeId, 0.expr()), (CallContextFieldTag::LastCalleeReturnDataOffset, 0.expr()), @@ -343,7 +343,7 @@ impl ExecutionGadget for BeginTxGadget { CallContextFieldTag::CallDataLength, tx_call_data_length.expr(), ), - (CallContextFieldTag::Value, tx_value.word_expr()), + (CallContextFieldTag::Value, tx_value.expr()), (CallContextFieldTag::IsStatic, 0.expr()), (CallContextFieldTag::LastCalleeId, 0.expr()), (CallContextFieldTag::LastCalleeReturnDataOffset, 0.expr()), diff --git a/zkevm-circuits/src/evm_circuit/execution/callop.rs b/zkevm-circuits/src/evm_circuit/execution/callop.rs index e8090322d08..cdd1874a690 100644 --- a/zkevm-circuits/src/evm_circuit/execution/callop.rs +++ b/zkevm-circuits/src/evm_circuit/execution/callop.rs @@ -339,7 +339,7 @@ impl ExecutionGadget for CallOpGadget { CallContextFieldTag::Value, select::expr( is_delegatecall.expr(), - current_value.word_expr(), + current_value.expr(), call_gadget.value.expr(), ), ), 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 1f29fee8c11..82ae35f8a28 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 @@ -7,7 +7,7 @@ use crate::{ constraint_builder::EVMConstraintBuilder, math_gadget::{IsEqualGadget, IsZeroGadget, RangeCheckGadget}, memory_gadget::{address_high, address_low, MemoryExpansionGadget}, - CachedRegion, Cell, Word, + CachedRegion, Cell, }, witness::{Block, Call, ExecStep, Transaction}, }, @@ -71,7 +71,7 @@ impl ExecutionGadget for ErrorOOGStaticMemoryGadget { // Pop the address from the stack // We still have to do this to verify the correctness of `address` - cb.stack_pop(address.word_expr()); + cb.stack_pop(address.expr()); // TODO: Use ContextSwitchGadget to switch call context to caller's and // consume all gas_left. 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 a09a200346e..e38ffd9d807 100644 --- a/zkevm-circuits/src/evm_circuit/execution/mul_div_mod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/mul_div_mod.rs @@ -69,12 +69,12 @@ impl ExecutionGadget for MulDivModGadget { // The second pop is multiplicand for MUL and divisor for DIV/MOD // The push is product for MUL, quotient for DIV, and residue for MOD // Note that for DIV/MOD, when divisor == 0, the push value is also 0. - cb.stack_pop(select::expr(is_mul.clone(), a.word_expr(), d.word_expr())); - cb.stack_pop(b.word_expr()); + cb.stack_pop(select::expr(is_mul.clone(), a.expr(), d.expr())); + cb.stack_pop(b.expr()); cb.stack_push( - is_mul.clone() * d.word_expr() - + is_div * a.word_expr() * (1.expr() - divisor_is_zero.expr()) - + is_mod * c.word_expr() * (1.expr() - divisor_is_zero.expr()), + is_mul.clone() * d.expr() + + is_div * a.expr() * (1.expr() - divisor_is_zero.expr()) + + is_mod * c.expr() * (1.expr() - divisor_is_zero.expr()), ); // Constraint for MUL case diff --git a/zkevm-circuits/src/evm_circuit/execution/mulmod.rs b/zkevm-circuits/src/evm_circuit/execution/mulmod.rs index f5a268b840b..82a7f85f6d8 100644 --- a/zkevm-circuits/src/evm_circuit/execution/mulmod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/mulmod.rs @@ -3,18 +3,14 @@ use crate::{ execution::ExecutionGadget, step::ExecutionState, util::{ - self, common_gadget::SameContextGadget, - constraint_builder::{ - ConstrainBuilderCommon, EVMConstraintBuilder, StepStateTransition, - Transition::Delta, - }, + constraint_builder::{EVMConstraintBuilder, StepStateTransition, Transition::Delta}, math_gadget::{IsZeroGadget, LtWordGadget, ModGadget, MulAddWords512Gadget}, sum, CachedRegion, }, witness::{Block, Call, ExecStep, Transaction}, }, - util::Expr, + util::{word::Word32Cell, Expr}, }; use bus_mapping::evm::OpcodeId; use eth_types::{Field, ToLittleEndian, U256}; @@ -27,11 +23,11 @@ use halo2_proofs::plonk::Error; pub(crate) struct MulModGadget { same_context: SameContextGadget, // a, b, n, r - pub words: [util::Word; 4], - k: util::Word, - a_reduced: util::Word, - d: util::Word, - e: util::Word, + pub words: [Word32Cell; 4], + k: Word32Cell, + a_reduced: Word32Cell, + d: Word32Cell, + e: Word32Cell, modword: ModGadget, mul512_left: MulAddWords512Gadget, mul512_right: MulAddWords512Gadget, @@ -75,10 +71,10 @@ impl ExecutionGadget for MulModGadget { 1.expr() - lt.expr() - n_is_zero.expr(), ); - cb.stack_pop(a.word_expr()); - cb.stack_pop(b.word_expr()); - cb.stack_pop(n.word_expr()); - cb.stack_push(r.word_expr()); + cb.stack_pop(a.expr()); + cb.stack_pop(b.expr()); + cb.stack_pop(n.expr()); + cb.stack_push(r.expr()); // State transition let step_state_transition = StepStateTransition { diff --git a/zkevm-circuits/src/evm_circuit/execution/sdiv_smod.rs b/zkevm-circuits/src/evm_circuit/execution/sdiv_smod.rs index 0d860dab5df..95a8b451df0 100644 --- a/zkevm-circuits/src/evm_circuit/execution/sdiv_smod.rs +++ b/zkevm-circuits/src/evm_circuit/execution/sdiv_smod.rs @@ -52,12 +52,12 @@ impl ExecutionGadget for SignedDivModGadget { let remainder_is_zero = IsZeroGadget::construct(cb, sum::expr(&remainder_abs_word.x().cells)); - cb.stack_pop(dividend_abs_word.x().word_expr()); - cb.stack_pop(divisor_abs_word.x().word_expr()); + cb.stack_pop(dividend_abs_word.x().expr()); + cb.stack_pop(divisor_abs_word.x().expr()); cb.stack_push(select::expr( is_sdiv, - quotient_abs_word.x().word_expr() * (1.expr() - divisor_is_zero.expr()), - remainder_abs_word.x().word_expr() * (1.expr() - divisor_is_zero.expr()), + quotient_abs_word.x().expr() * (1.expr() - divisor_is_zero.expr()), + remainder_abs_word.x().expr() * (1.expr() - divisor_is_zero.expr()), )); // Constrain `|quotient| * |divisor| + |remainder| = |dividend|`. diff --git a/zkevm-circuits/src/evm_circuit/execution/shl_shr.rs b/zkevm-circuits/src/evm_circuit/execution/shl_shr.rs index 2bb59269240..409114b3cf7 100644 --- a/zkevm-circuits/src/evm_circuit/execution/shl_shr.rs +++ b/zkevm-circuits/src/evm_circuit/execution/shl_shr.rs @@ -77,9 +77,9 @@ impl ExecutionGadget for ShlShrGadget { // - for SHL, two pops are shift and quotient, and push is dividend. // - for SHR, two pops are shift and dividend, and push is quotient. cb.stack_pop(shift.expr()); - cb.stack_pop(is_shl.expr() * quotient.word_expr() + is_shr.expr() * dividend.word_expr()); + cb.stack_pop(is_shl.expr() * quotient.expr() + is_shr.expr() * dividend.expr()); cb.stack_push( - (is_shl.expr() * dividend.word_expr() + is_shr.expr() * quotient.word_expr()) + (is_shl.expr() * dividend.expr() + is_shr.expr() * quotient.expr()) * (1.expr() - divisor_is_zero.expr()), );