Skip to content

Commit

Permalink
clean up extcodecopy's is_first_bytecode_table
Browse files Browse the repository at this point in the history
  • Loading branch information
DreamWuGit committed Sep 4, 2024
1 parent 8d85582 commit 7fd191a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 26 deletions.
22 changes: 9 additions & 13 deletions zkevm-circuits/src/evm_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -532,19 +532,15 @@ impl<F: Field> Circuit<F> for EvmCircuit<F> {
{
// when enable feature "dual-bytecode", get two sets of bytecodes here.
let (first_bytecodes, second_bytecodes) = block.get_bytecodes_for_dual_sub_circuits();
if !first_bytecodes.is_empty() {
// assign first bytecode_table
config
.bytecode_table
.dev_load(&mut layouter, first_bytecodes, &challenges)?;
}

if !second_bytecodes.is_empty() {
// assign second bytecode_table
config
.bytecode_table1
.dev_load(&mut layouter, second_bytecodes, &challenges)?;
}
// assign first bytecode_table
config
.bytecode_table
.dev_load(&mut layouter, first_bytecodes, &challenges)?;

// assign second bytecode_table
config
.bytecode_table1
.dev_load(&mut layouter, second_bytecodes, &challenges)?;
}

#[cfg(not(feature = "dual-bytecode"))]
Expand Down
13 changes: 0 additions & 13 deletions zkevm-circuits/src/evm_circuit/execution/extcodecopy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ pub(crate) struct ExtcodecopyGadget<F> {
copy_rwc_inc: Cell<F>,
memory_expansion: MemoryExpansionGadget<F, 1, N_BYTES_MEMORY_WORD_SIZE>,
memory_copier_gas: MemoryCopierGasGadget<F, { GasCost::COPY }>,
is_first_bytecode_table: Cell<F>,
}

impl<F: Field> ExecutionGadget<F> for ExtcodecopyGadget<F> {
Expand All @@ -54,7 +53,6 @@ impl<F: Field> ExecutionGadget<F> for ExtcodecopyGadget<F> {

fn configure(cb: &mut EVMConstraintBuilder<F>) -> Self {
let opcode = cb.query_cell();
let is_first_bytecode_table = cb.query_bool();

let external_address_word = cb.query_word_rlc();
let external_address =
Expand All @@ -67,11 +65,6 @@ impl<F: Field> ExecutionGadget<F> for ExtcodecopyGadget<F> {
let not_exists = IsZeroGadget::construct(cb, code_hash.clone().expr());
let exists = not::expr(not_exists.expr());

// the reason why not use `same_context.is_first_sub_bytecode` to construct `code_len_gadget` includes
// 1: `same_context` requires rw_counter_offset info, which depends on `code_offset` info, the latter relies on
// `code_len` of `code_len_gadget`
// 2: `same_context.is_first_sub_bytecode` returns current call bytecode info, in extcodecopy, code_hash is not
// necessary current call code hash.
let code_len_gadget = cb.condition(exists.expr(), |cb| {
BytecodeLengthGadget::construct(cb, code_hash.clone())
});
Expand Down Expand Up @@ -174,7 +167,6 @@ impl<F: Field> ExecutionGadget<F> for ExtcodecopyGadget<F> {
copy_rwc_inc,
memory_expansion,
memory_copier_gas,
is_first_bytecode_table,
}
}

Expand Down Expand Up @@ -248,11 +240,6 @@ impl<F: Field> ExecutionGadget<F> for ExtcodecopyGadget<F> {
memory_expansion_gas_cost,
)?;

self.is_first_bytecode_table.assign(
region,
offset,
Value::known(F::from(block.is_first_bytecode_circuit(&code_hash))),
)?;
Ok(())
}
}
Expand Down

0 comments on commit 7fd191a

Please sign in to comment.