diff --git a/zkevm-circuits/src/evm_circuit/util/common_gadget.rs b/zkevm-circuits/src/evm_circuit/util/common_gadget.rs index 7d578749484..f8e11ef9e86 100644 --- a/zkevm-circuits/src/evm_circuit/util/common_gadget.rs +++ b/zkevm-circuits/src/evm_circuit/util/common_gadget.rs @@ -385,40 +385,11 @@ impl TransferToGadget { mut reversion_info: Option<&mut ReversionInfo>, ) -> Self { let value_is_zero = cb.is_zero_word(&value); - - Self::create_account( - cb, - receiver_address.clone(), - receiver_exists.clone(), - must_create.clone(), - value_is_zero.expr(), - reversion_info.as_deref_mut(), - ); - - let receiver = cb.condition(not::expr(value_is_zero.expr()), |cb| { - cb.increase_balance(receiver_address, value.clone(), reversion_info) - }); - - Self { - receiver, - receiver_exists, - must_create, - value_is_zero, - } - } - - pub(crate) fn create_account( - cb: &mut EVMConstraintBuilder, - receiver_address: WordLoHi>, - receiver_exists: Expression, - must_create: Expression, - value_is_zero: Expression, - reversion_info: Option<&mut ReversionInfo>, - ) { + // Create account cb.condition( and::expr([ not::expr(receiver_exists.expr()), - or::expr([not::expr(value_is_zero.expr()), must_create]), + or::expr([not::expr(value_is_zero.expr()), must_create.clone()]), ]), |cb| { cb.account_write( @@ -426,10 +397,21 @@ impl TransferToGadget { AccountFieldTag::CodeHash, cb.empty_code_hash(), WordLoHi::zero(), - reversion_info, + reversion_info.as_deref_mut(), ); }, ); + + let receiver = cb.condition(not::expr(value_is_zero.expr()), |cb| { + cb.increase_balance(receiver_address, value.clone(), reversion_info) + }); + + Self { + receiver, + receiver_exists, + must_create, + value_is_zero, + } } pub(crate) fn assign(