Skip to content

Commit

Permalink
+ fix copyevent condition in begin tx (#1295)
Browse files Browse the repository at this point in the history
+ add comment for two other events

Signed-off-by: noelwei <fan@scroll.io>
Co-authored-by: Zhang Zhuo <mycinbrin@gmail.com>
  • Loading branch information
noel2004 and lispc authored May 27, 2024
1 parent 9993226 commit 74cc763
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
26 changes: 14 additions & 12 deletions zkevm-circuits/src/evm_circuit/execution/begin_tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -583,18 +583,20 @@ impl<F: Field> ExecutionGadget<F> for BeginTxGadget<F> {
// - from caller's memory (`call_data_length` bytes starting at `call_data_offset`)
// - to the precompile input.
let precompile_input_bytes_rlc = cb.query_cell_phase2();
cb.copy_table_lookup(
tx_id.expr(), //cb.curr.state.call_id.expr(),
CopyDataType::TxCalldata.expr(),
call_id.expr(),
CopyDataType::RlcAcc.expr(),
0.expr(),
precompile_input_len.expr(),
0.expr(),
precompile_input_len.expr(),
precompile_input_bytes_rlc.expr(),
0.expr(), // notice copy from calldata -> rlc do not cost rwc
); // rwc_delta += `call_gadget.cd_address.length()` for precompile
cb.condition(not::expr(is_call_data_empty.expr()), |cb| {
cb.copy_table_lookup(
tx_id.expr(), //cb.curr.state.call_id.expr(),
CopyDataType::TxCalldata.expr(),
call_id.expr(),
CopyDataType::RlcAcc.expr(),
0.expr(),
precompile_input_len.expr(),
0.expr(),
precompile_input_len.expr(),
precompile_input_bytes_rlc.expr(),
0.expr(), // notice copy from calldata -> rlc do not cost rwc
)
}); // rwc_delta += `call_gadget.cd_address.length()` for precompile

cb.require_step_state_transition(StepStateTransition {
// 23 reads and writes + input data copy:
Expand Down
1 change: 1 addition & 0 deletions zkevm-circuits/src/evm_circuit/execution/callop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,7 @@ impl<F: Field> ExecutionGadget<F> for CallOpGadget<F> {
// - from caller's memory (`call_data_length` bytes starting at `call_data_offset`)
// - to the precompile input.
let precompile_input_bytes_rlc =
// cd_address.has_length is not zero means call_data_length > 0
cb.condition(call_gadget.cd_address.has_length(), |cb| {
let precompile_input_bytes_rlc = cb.query_cell_phase2();
cb.copy_table_lookup(
Expand Down
2 changes: 2 additions & 0 deletions zkevm-circuits/src/evm_circuit/execution/return_revert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ impl<F: Field> ExecutionGadget<F> for ReturnRevertGadget<F> {
// circuit does the lookup to poseidon table.
let code_hash = cb.query_cell_phase2();
let deployed_bytecode_rlc = cb.query_cell_phase2();
// if contract is deployed, there must be some code bytes
// need to be copied
cb.copy_table_lookup(
cb.curr.state.call_id.expr(),
CopyDataType::Memory.expr(),
Expand Down

0 comments on commit 74cc763

Please sign in to comment.