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

Commit bd0c75e

Browse files
fix the read write order
1 parent dacf577 commit bd0c75e

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

zkevm-circuits/src/evm_circuit/execution/begin_tx.rs

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -468,16 +468,20 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
468468
is_precompiled(&tx.to_or_contract_addr()) || !callee_code_hash.is_zero();
469469
let caller_balance_sub_fee_pair = rws.next().account_balance_pair();
470470
let must_create = tx.is_create();
471+
472+
let caller_balance_sub_value_pair = if !tx.value.is_zero() {
473+
rws.next().account_balance_pair()
474+
} else {
475+
(zero, zero)
476+
};
471477
if !callee_exists && (!tx.value.is_zero() || must_create) {
472478
callee_code_hash = rws.next().account_codehash_pair().1;
473479
}
474-
let mut caller_balance_sub_value_pair = (zero, zero);
475-
let mut callee_balance_pair = (zero, zero);
476-
if !tx.value.is_zero() {
477-
caller_balance_sub_value_pair = rws.next().account_balance_pair();
478-
callee_balance_pair = rws.next().account_balance_pair();
480+
let callee_balance_pair = if !tx.value.is_zero() {
481+
rws.next().account_balance_pair()
482+
} else {
483+
(zero, zero)
479484
};
480-
481485
self.begin_tx.assign(region, offset, tx)?;
482486
self.tx.assign(region, offset, tx)?;
483487

0 commit comments

Comments
 (0)