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

Commit 4390f88

Browse files
committed
fix(zkevm-circuits/begin_tx): add comments
1 parent 8c231e1 commit 4390f88

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
113113
tx_id.expr(),
114114
WordLoHi::new([addr.expr(), 0.expr()]),
115115
1.expr(),
116-
0.expr(),
116+
0.expr(), // Here value_prev is 0
117117
None,
118118
);
119119
} // rwc_delta += PRECOMPILE_COUNT
@@ -123,17 +123,17 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
123123
tx_id.expr(),
124124
tx.caller_address.to_word(),
125125
1.expr(),
126-
0.expr(),
126+
0.expr(), // Here too
127127
None,
128128
); // rwc_delta += 1
129-
let is_caller_callee_equal = cb.query_bool();
129+
let is_caller_callee_equal = cb.query_bool(); // What does this variable mean?
130130
cb.account_access_list_write_unchecked(
131131
tx_id.expr(),
132132
tx.callee_address.to_word(),
133133
1.expr(),
134134
// No extra constraint being used here.
135135
// Correctness will be enforced in build_tx_access_list_account_constraints
136-
is_caller_callee_equal.expr(),
136+
is_caller_callee_equal.expr(), // And value_prev = is_caller_callee_equal
137137
None,
138138
); // rwc_delta += 1
139139

@@ -149,7 +149,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
149149
tx_id.expr(),
150150
coinbase.to_word(),
151151
1.expr(),
152-
is_coinbase_warm.expr(),
152+
is_coinbase_warm.expr(), // Why value_prev is = is_coinbase_warm?
153153
None,
154154
); // rwc_delta += 1
155155

@@ -160,6 +160,7 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
160160
// no_callee_code is true when the account exists and has empty
161161
// code hash, or when the account doesn't exist (which we encode with
162162
// code_hash = 0).
163+
// Why do we have summation here if any of the terms is enough?
163164
let no_callee_code = is_empty_code_hash.expr() + callee_not_exists.expr();
164165

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

186-
let caller_nonce_hash_bytes = cb.query_word32();
187+
let caller_nonce_hash_bytes = cb.query_word32(); // What's this variable for?
187188
let create = ContractCreateGadget::construct(cb);
188189
cb.require_equal_word(
189190
"tx caller address equivalence",
@@ -209,8 +210,6 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
209210
create.caller_nonce(),
210211
);
211212

212-
// TODO: add missing constraints:
213-
214213
// 1. Handle contract creation transaction.
215214
cb.condition(tx.is_create.expr(), |cb| {
216215
cb.keccak_table_lookup(

0 commit comments

Comments
 (0)