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

Commit

Permalink
remove reversion info from tload
Browse files Browse the repository at this point in the history
  • Loading branch information
zemse committed Apr 12, 2024
1 parent a58a645 commit 2425cdb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 47 deletions.
42 changes: 9 additions & 33 deletions bus-mapping/src/evm/opcodes/tload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,6 @@ impl Opcode for Tload {
Word::from(state.tx_ctx.id()),
)?;

state.call_context_read(
&mut exec_step,
call_id,
CallContextField::RwCounterEndOfReversion,
Word::from(state.call()?.rw_counter_end_of_reversion),
)?;

state.call_context_read(
&mut exec_step,
call_id,
CallContextField::IsPersistent,
Word::from(state.call()?.is_persistent as u8),
)?;

state.call_context_read(
&mut exec_step,
call_id,
Expand Down Expand Up @@ -78,16 +64,11 @@ impl Opcode for Tload {
#[cfg(test)]
mod tload_tests {
use super::*;
use crate::{
circuit_input_builder::ExecState,
mock::BlockData,
operation::{StackOp, TransientStorageOp},
};
use crate::{circuit_input_builder::ExecState, mock::BlockData, operation::StackOp};
use eth_types::{
bytecode,
evm_types::{OpcodeId, StackAddress},
geth_types::GethData,
Word,
};
use mock::{
test_ctx::{helpers::*, TestContext},
Expand Down Expand Up @@ -126,24 +107,19 @@ mod tload_tests {
.find(|step| step.exec_state == ExecState::Op(OpcodeId::TLOAD))
.unwrap();

println!("{:?}", step.bus_mapping_instance);

assert_eq!(
[4, 6]
.map(|idx| &builder.block.container.stack[step.bus_mapping_instance[idx].as_usize()])
[&builder.block.container.stack[step.bus_mapping_instance[2].as_usize()]]
.map(|operation| (operation.rw(), operation.op())),
[
(
RW::READ,
&StackOp::new(1, StackAddress::from(1023), Word::from(0x0u32))
),
(
RW::WRITE,
&StackOp::new(1, StackAddress::from(1023), Word::from(expected_loaded_value))
)
]
[(
RW::READ,
&StackOp::new(1, StackAddress::from(1023), Word::from(0x0u32))
)]
);

let transient_storage_op =
&builder.block.container.transient_storage[step.bus_mapping_instance[5].as_usize()];
&builder.block.container.transient_storage[step.bus_mapping_instance[3].as_usize()];
assert_eq!(
(transient_storage_op.rw(), transient_storage_op.op()),
(
Expand Down
17 changes: 3 additions & 14 deletions zkevm-circuits/src/evm_circuit/execution/tload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@ use crate::{
step::ExecutionState,
util::{
common_gadget::SameContextGadget,
constraint_builder::{
EVMConstraintBuilder, ReversionInfo, StepStateTransition, Transition::Delta,
},
constraint_builder::{EVMConstraintBuilder, StepStateTransition, Transition::Delta},
CachedRegion, Cell, StepRws,
},
witness::{Block, Call, Chunk, ExecStep, Transaction},
Expand All @@ -25,7 +23,6 @@ use halo2_proofs::{circuit::Value, plonk::Error};
pub(crate) struct TloadGadget<F> {
same_context: SameContextGadget<F>,
tx_id: Cell<F>,
reversion_info: ReversionInfo<F>, // TODO maybe TLOAD doesn't need this
callee_address: WordLoHiCell<F>,
key: WordLoHiCell<F>,
value: WordLoHiCell<F>,
Expand All @@ -40,7 +37,6 @@ impl<F: Field> ExecutionGadget<F> for TloadGadget<F> {
let opcode = cb.query_cell();

let tx_id = cb.call_context(None, CallContextFieldTag::TxId);
let reversion_info = cb.reversion_info_read(None);
let callee_address = cb.call_context_read_as_word(None, CallContextFieldTag::CalleeAddress);

let key = cb.query_word_unchecked();
Expand All @@ -58,7 +54,7 @@ impl<F: Field> ExecutionGadget<F> for TloadGadget<F> {
cb.stack_push(value.to_word());

let step_state_transition = StepStateTransition {
rw_counter: Delta(7.expr()),
rw_counter: Delta(5.expr()),
program_counter: Delta(1.expr()),
reversible_write_counter: Delta(0.expr()),
gas_left: Delta(-OpcodeId::TLOAD.constant_gas_cost().expr()),
Expand All @@ -69,7 +65,6 @@ impl<F: Field> ExecutionGadget<F> for TloadGadget<F> {
Self {
same_context,
tx_id,
reversion_info,
callee_address,
key,
value,
Expand All @@ -90,18 +85,12 @@ impl<F: Field> ExecutionGadget<F> for TloadGadget<F> {

self.tx_id
.assign(region, offset, Value::known(F::from(tx.id)))?;
self.reversion_info.assign(
region,
offset,
call.rw_counter_end_of_reversion,
call.is_persistent,
)?;
self.callee_address
.assign_h160(region, offset, call.address)?;

let mut rws = StepRws::new(block, step);

rws.offset_add(4);
rws.offset_add(2);

let key = rws.next().stack_value();
rws.next(); // TLOAD rw
Expand Down

0 comments on commit 2425cdb

Please sign in to comment.