@@ -5,7 +5,7 @@ use crate::{
55 step:: ExecutionState ,
66 util:: {
77 and,
8- common_gadget:: TransferWithGasFeeGadget ,
8+ common_gadget:: TransferGadget ,
99 constraint_builder:: {
1010 ConstrainBuilderCommon , EVMConstraintBuilder , ReversionInfo , StepStateTransition ,
1111 Transition :: { Delta , To } ,
@@ -42,7 +42,7 @@ pub(crate) struct BeginTxGadget<F> {
4242 call_callee_address : AccountAddress < F > ,
4343 reversion_info : ReversionInfo < F > ,
4444 sufficient_gas_left : RangeCheckGadget < F , N_BYTES_GAS > ,
45- transfer_with_gas_fee : TransferWithGasFeeGadget < F > ,
45+ transfer_with_gas_fee : TransferGadget < F , true > ,
4646 code_hash : WordLoHiCell < F > ,
4747 is_empty_code_hash : IsEqualWordGadget < F , WordLoHi < Expression < F > > , WordLoHi < Expression < F > > > ,
4848 caller_nonce_hash_bytes : Word32Cell < F > ,
@@ -174,17 +174,16 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
174174 AccountFieldTag :: CodeHash ,
175175 code_hash. to_word ( ) ,
176176 ) ;
177-
178177 // Transfer value from caller to callee, creating account if necessary.
179- let transfer_with_gas_fee = TransferWithGasFeeGadget :: construct (
178+ let transfer_with_gas_fee = TransferGadget :: construct (
180179 cb,
181180 tx. caller_address . to_word ( ) ,
182181 tx. callee_address . to_word ( ) ,
183182 not:: expr ( callee_not_exists. expr ( ) ) ,
184- or :: expr ( [ tx. is_create . expr ( ) , callee_not_exists . expr ( ) ] ) ,
183+ tx. is_create . expr ( ) ,
185184 tx. value . clone ( ) ,
186- tx. mul_gas_fee_by_gas . product ( ) . clone ( ) ,
187185 & mut reversion_info,
186+ Some ( tx. mul_gas_fee_by_gas . product ( ) . clone ( ) ) ,
188187 ) ;
189188
190189 let caller_nonce_hash_bytes = cb. query_word32 ( ) ;
@@ -509,18 +508,15 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
509508 }
510509 let callee_exists =
511510 is_precompiled ( & tx. to_or_contract_addr ( ) ) || !callee_code_hash. is_zero ( ) ;
512- let caller_balance_sub_fee_pair = rws. next ( ) . account_balance_pair ( ) ;
513- let must_create = tx. is_create ( ) ;
514- if !callee_exists && ( !tx. value . is_zero ( ) || must_create) {
515- callee_code_hash = rws. next ( ) . account_codehash_pair ( ) . 1 ;
516- }
517- let mut caller_balance_sub_value_pair = ( zero, zero) ;
518- let mut callee_balance_pair = ( zero, zero) ;
519- if !tx. value . is_zero ( ) {
520- caller_balance_sub_value_pair = rws. next ( ) . account_balance_pair ( ) ;
521- callee_balance_pair = rws. next ( ) . account_balance_pair ( ) ;
522- } ;
523-
511+ self . transfer_with_gas_fee . assign (
512+ region,
513+ offset,
514+ & mut rws,
515+ callee_exists,
516+ tx. value ,
517+ tx. is_create ( ) ,
518+ Some ( gas_fee) ,
519+ ) ?;
524520 self . begin_tx . assign ( region, offset, tx) ?;
525521 self . tx . assign ( region, offset, tx) ?;
526522
@@ -544,15 +540,6 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
544540 ) ?;
545541 self . sufficient_gas_left
546542 . assign ( region, offset, F :: from ( tx. gas ( ) - step. gas_cost ) ) ?;
547- self . transfer_with_gas_fee . assign (
548- region,
549- offset,
550- caller_balance_sub_fee_pair,
551- caller_balance_sub_value_pair,
552- callee_balance_pair,
553- tx. value ,
554- gas_fee,
555- ) ?;
556543 self . code_hash
557544 . assign_u256 ( region, offset, callee_code_hash) ?;
558545 self . is_empty_code_hash . assign_u256 (
0 commit comments