@@ -5,7 +5,7 @@ use crate::{
5
5
step:: ExecutionState ,
6
6
util:: {
7
7
and,
8
- common_gadget:: TransferWithGasFeeGadget ,
8
+ common_gadget:: TransferGadget ,
9
9
constraint_builder:: {
10
10
ConstrainBuilderCommon , EVMConstraintBuilder , ReversionInfo , StepStateTransition ,
11
11
Transition :: { Delta , To } ,
@@ -42,7 +42,7 @@ pub(crate) struct BeginTxGadget<F> {
42
42
call_callee_address : AccountAddress < F > ,
43
43
reversion_info : ReversionInfo < F > ,
44
44
sufficient_gas_left : RangeCheckGadget < F , N_BYTES_GAS > ,
45
- transfer_with_gas_fee : TransferWithGasFeeGadget < F > ,
45
+ transfer_with_gas_fee : TransferGadget < F , true > ,
46
46
code_hash : WordLoHiCell < F > ,
47
47
is_empty_code_hash : IsEqualWordGadget < F , WordLoHi < Expression < F > > , WordLoHi < Expression < F > > > ,
48
48
caller_nonce_hash_bytes : Word32Cell < F > ,
@@ -174,17 +174,16 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
174
174
AccountFieldTag :: CodeHash ,
175
175
code_hash. to_word ( ) ,
176
176
) ;
177
-
178
177
// 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 (
180
179
cb,
181
180
tx. caller_address . to_word ( ) ,
182
181
tx. callee_address . to_word ( ) ,
183
182
not:: expr ( callee_not_exists. expr ( ) ) ,
184
- or :: expr ( [ tx. is_create . expr ( ) , callee_not_exists . expr ( ) ] ) ,
183
+ tx. is_create . expr ( ) ,
185
184
tx. value . clone ( ) ,
186
- tx. mul_gas_fee_by_gas . product ( ) . clone ( ) ,
187
185
& mut reversion_info,
186
+ Some ( tx. mul_gas_fee_by_gas . product ( ) . clone ( ) ) ,
188
187
) ;
189
188
190
189
let caller_nonce_hash_bytes = cb. query_word32 ( ) ;
@@ -509,18 +508,15 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
509
508
}
510
509
let callee_exists =
511
510
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
+ ) ?;
524
520
self . begin_tx . assign ( region, offset, tx) ?;
525
521
self . tx . assign ( region, offset, tx) ?;
526
522
@@ -544,15 +540,6 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
544
540
) ?;
545
541
self . sufficient_gas_left
546
542
. 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
- ) ?;
556
543
self . code_hash
557
544
. assign_u256 ( region, offset, callee_code_hash) ?;
558
545
self . is_empty_code_hash . assign_u256 (
0 commit comments