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

fix(zkevm-circuits/begin_tx): add missing constraints #1776

Merged
merged 14 commits into from
Mar 12, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions zkevm-circuits/src/evm_circuit/execution/begin_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
tx_id.expr(),
WordLoHi::new([addr.expr(), 0.expr()]),
1.expr(),
0.expr(),
0.expr(), // Here value_prev is 0
None,
);
} // rwc_delta += PRECOMPILE_COUNT
Expand All @@ -123,17 +123,17 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
tx_id.expr(),
tx.caller_address.to_word(),
1.expr(),
0.expr(),
0.expr(), // Here too
None,
); // rwc_delta += 1
let is_caller_callee_equal = cb.query_bool();
let is_caller_callee_equal = cb.query_bool(); // What does this variable mean?
ChihChengLiang marked this conversation as resolved.
Show resolved Hide resolved
cb.account_access_list_write_unchecked(
tx_id.expr(),
tx.callee_address.to_word(),
1.expr(),
// No extra constraint being used here.
// Correctness will be enforced in build_tx_access_list_account_constraints
is_caller_callee_equal.expr(),
is_caller_callee_equal.expr(), // And value_prev = is_caller_callee_equal
ChihChengLiang marked this conversation as resolved.
Show resolved Hide resolved
None,
); // rwc_delta += 1

Expand All @@ -149,7 +149,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
tx_id.expr(),
coinbase.to_word(),
1.expr(),
is_coinbase_warm.expr(),
is_coinbase_warm.expr(), // Why value_prev is = is_coinbase_warm?
ChihChengLiang marked this conversation as resolved.
Show resolved Hide resolved
None,
); // rwc_delta += 1

Expand All @@ -160,6 +160,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
// no_callee_code is true when the account exists and has empty
// code hash, or when the account doesn't exist (which we encode with
// code_hash = 0).
// Why do we have summation here if any of the terms is enough?
let no_callee_code = is_empty_code_hash.expr() + callee_not_exists.expr();
ChihChengLiang marked this conversation as resolved.
Show resolved Hide resolved

// TODO: And not precompile
Expand All @@ -183,7 +184,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
&mut reversion_info,
);

let caller_nonce_hash_bytes = cb.query_word32();
let caller_nonce_hash_bytes = cb.query_word32(); // What's this variable for?
ChihChengLiang marked this conversation as resolved.
Show resolved Hide resolved
let create = ContractCreateGadget::construct(cb);
cb.require_equal_word(
"tx caller address equivalence",
Expand Down
Loading