Skip to content
This repository has been archived by the owner on Jul 5, 2024. It is now read-only.

Commit

Permalink
the abstraction is no longer needed
Browse files Browse the repository at this point in the history
  • Loading branch information
ChihChengLiang committed Feb 22, 2024
1 parent 78c856f commit 39b2ead
Showing 1 changed file with 14 additions and 32 deletions.
46 changes: 14 additions & 32 deletions zkevm-circuits/src/evm_circuit/util/common_gadget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,51 +385,33 @@ impl<F: Field> TransferToGadget<F> {
mut reversion_info: Option<&mut ReversionInfo<F>>,
) -> 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<F>,
receiver_address: WordLoHi<Expression<F>>,
receiver_exists: Expression<F>,
must_create: Expression<F>,
value_is_zero: Expression<F>,
reversion_info: Option<&mut ReversionInfo<F>>,
) {
// 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(
receiver_address.clone(),
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(
Expand Down

0 comments on commit 39b2ead

Please sign in to comment.