Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
92 commits
Select commit Hold shift + click to select a range
8dff730
init
0xmountaintop Jan 18, 2022
45a2c19
cargo fmt
0xmountaintop Jan 18, 2022
6477034
fix state_write_with_reversion
0xmountaintop Jan 18, 2022
32684d8
fix table_assignment
0xmountaintop Jan 18, 2022
f77d2fc
Merge branch 'main' into rw_table/add_aux
0xmountaintop Jan 22, 2022
cad509d
add sload
0xmountaintop Jan 19, 2022
78fb7b0
init test sload_gadget
0xmountaintop Jan 19, 2022
7e173a3
fix storage_slot_access_list_write_with_reversion
0xmountaintop Jan 19, 2022
939db3a
fix
0xmountaintop Jan 25, 2022
930175f
update TODOs
0xmountaintop Jan 25, 2022
f674018
update
0xmountaintop Jan 26, 2022
c262711
cargo clippy
0xmountaintop Jan 26, 2022
da4021e
rename
0xmountaintop Jan 26, 2022
34afaac
WIP
0xmountaintop Jan 26, 2022
cb3c4e1
WIP
0xmountaintop Jan 26, 2022
0e05132
WIP
0xmountaintop Jan 26, 2022
8ca2ba9
WIP
0xmountaintop Jan 26, 2022
e8023e5
ojbk
0xmountaintop Jan 26, 2022
325f7cc
minor
0xmountaintop Jan 26, 2022
68549c2
WIP
0xmountaintop Jan 26, 2022
e230906
add
0xmountaintop Jan 26, 2022
f3fad86
update
0xmountaintop Jan 26, 2022
618811c
go go go
0xmountaintop Jan 26, 2022
c1d8218
clean up
0xmountaintop Jan 26, 2022
243e469
improve
0xmountaintop Jan 26, 2022
9622354
cargo fmt
0xmountaintop Jan 26, 2022
c7e2ee7
up up up
0xmountaintop Jan 26, 2022
1f283ba
Merge branch 'main' into rw_table/add_aux
0xmountaintop Jan 27, 2022
f01a41a
Merge branch 'rw_table/add_aux' into rework/storage
0xmountaintop Jan 27, 2022
5d87ec8
minor
0xmountaintop Jan 27, 2022
139ae6f
minor
0xmountaintop Jan 27, 2022
fdbbfdb
add aux
0xmountaintop Jan 27, 2022
70096e5
init tx_access_list
0xmountaintop Jan 27, 2022
39b68bd
Merge branch 'main' into rework/storage
0xmountaintop Jan 28, 2022
f3e499b
merge
0xmountaintop Feb 7, 2022
f399922
fix
0xmountaintop Feb 7, 2022
9da4e43
cargo fmt
0xmountaintop Feb 7, 2022
45ae07b
fix
0xmountaintop Feb 7, 2022
2828faa
minor
0xmountaintop Feb 7, 2022
ca6774a
WIP
0xmountaintop Feb 7, 2022
c6bec89
update step_convert
0xmountaintop Feb 7, 2022
2d6c3bb
cargo fmt
0xmountaintop Feb 7, 2022
85167a4
fix assign_exec_step
0xmountaintop Feb 7, 2022
53b3393
WIP
0xmountaintop Feb 7, 2022
d72ccd4
fix
0xmountaintop Feb 7, 2022
87ccaff
mark
0xmountaintop Feb 7, 2022
e56d77d
Debug (#91)
0xmountaintop Feb 8, 2022
7b5099a
init mock test_ok
0xmountaintop Feb 8, 2022
49626fb
update ExecStep
0xmountaintop Feb 8, 2022
3b34151
update
0xmountaintop Feb 8, 2022
01f1b54
minor
0xmountaintop Feb 8, 2022
682b640
fix
0xmountaintop Feb 8, 2022
35bc2b5
cargo fmt
0xmountaintop Feb 8, 2022
e33d25a
update
0xmountaintop Feb 8, 2022
7dd6872
update
0xmountaintop Feb 8, 2022
0566846
update
0xmountaintop Feb 8, 2022
da15d1a
update
0xmountaintop Feb 8, 2022
a737290
fix
0xmountaintop Feb 8, 2022
d074452
update
0xmountaintop Feb 8, 2022
cdf71d5
update
0xmountaintop Feb 8, 2022
933cdf8
finish
0xmountaintop Feb 8, 2022
e29d590
???
0xmountaintop Feb 8, 2022
7404ed6
fix
0xmountaintop Feb 8, 2022
22f7339
fix
0xmountaintop Feb 8, 2022
837bc31
fix
0xmountaintop Feb 8, 2022
8f271c2
minor
0xmountaintop Feb 9, 2022
0d7c4fd
minor
0xmountaintop Feb 9, 2022
11174fb
minor
0xmountaintop Feb 9, 2022
5543804
minor
0xmountaintop Feb 9, 2022
b64b1eb
fix tx_id
0xmountaintop Feb 9, 2022
4b32546
fix is_persistent
0xmountaintop Feb 9, 2022
2afe61b
fix rw_counter_end_of_reversion
0xmountaintop Feb 9, 2022
cf4742e
minor
0xmountaintop Feb 9, 2022
33db661
???
0xmountaintop Feb 9, 2022
98b1e9e
fix call_id
0xmountaintop Feb 9, 2022
11a3e37
minor
0xmountaintop Feb 9, 2022
4767fd4
committed_value
0xmountaintop Feb 9, 2022
867d7a0
rename
0xmountaintop Feb 11, 2022
2575139
rename
0xmountaintop Feb 11, 2022
32fc76a
update
0xmountaintop Feb 11, 2022
33d255b
only write
0xmountaintop Feb 11, 2022
f1e533c
change lookup for CalleeAddress from TxContextLookup to CallContextLo…
0xmountaintop Feb 11, 2022
c830cc5
minor
0xmountaintop Feb 11, 2022
1363d77
minor
0xmountaintop Feb 11, 2022
268807f
clean up tests
0xmountaintop Feb 11, 2022
5fdefcd
WIP
0xmountaintop Feb 11, 2022
13422f7
minor
0xmountaintop Feb 11, 2022
5926b5b
clean up
0xmountaintop Feb 12, 2022
3f5cccd
deal with address
0xmountaintop Feb 12, 2022
9bc7c6b
fix
0xmountaintop Feb 12, 2022
4eb2ff1
clean up
0xmountaintop Feb 12, 2022
ee2e2a7
fix
0xmountaintop Feb 13, 2022
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
42 changes: 41 additions & 1 deletion bus-mapping/src/evm/opcodes/sload.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use super::Opcode;
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this file

use crate::circuit_input_builder::CircuitInputStateRef;
use crate::{
operation::{StorageOp, RW},
operation::{StorageOp, TxAccessListAccountStorageOp, RW},
Error,
};
use eth_types::GethExecStep;
Expand All @@ -26,6 +26,16 @@ impl Opcode for Sload {
// Manage first stack read at latest stack position
state.push_stack_op(RW::READ, stack_position, stack_value_read);

// TxAccessList AccountStorage read
state.push_op(TxAccessListAccountStorageOp::new(
RW::READ,
1usize, // TODO: tx_id
state.call().address,
stack_value_read,
true, // TODO: assume is_warm for now
true,
));

// Storage read
let storage_value_read = step.storage.get_or_err(&stack_value_read)?;
state.push_op(StorageOp::new(
Expand All @@ -36,6 +46,16 @@ impl Opcode for Sload {
storage_value_read,
));

// TxAccessList AccountStorage write
state.push_op(TxAccessListAccountStorageOp::new(
RW::WRITE,
1usize, // TODO: tx_id
state.call().address,
stack_value_read,
true,
true, // TODO: assume always is_warm for now
));

// First stack write
state.push_stack_op(RW::WRITE, stack_position, storage_value_read);

Expand Down Expand Up @@ -88,6 +108,16 @@ mod sload_tests {
let mut state_ref = test_builder.state_ref(&mut tx, &mut tx_ctx, &mut step);
// Add StackOp associated to the stack pop.
state_ref.push_stack_op(RW::READ, StackAddress::from(1023), Word::from(0x0u32));
// Add TxAccessListAccountStorageOp associated to the TxAccessListAccountStorage
// read.
state_ref.push_op(TxAccessListAccountStorageOp::new(
RW::READ,
1usize, // TODO: tx_id
state_ref.tx.calls()[0].address,
Word::from(0x0u32),
true, // TODO: assume is_warm for now
true,
));
// Add StorageOp associated to the storage read.
state_ref.push_op(StorageOp::new(
RW::READ,
Expand All @@ -96,6 +126,16 @@ mod sload_tests {
Word::from(0x6fu32),
Word::from(0x6fu32),
));
// Add TxAccessListAccountStorageOp associated to the TxAccessListAccountStorage
// write.
state_ref.push_op(TxAccessListAccountStorageOp::new(
RW::WRITE,
1usize, // TODO: tx_id
state_ref.tx.calls()[0].address,
Word::from(0x0u32),
true,
true,
));
// Add StackOp associated to the stack push.
state_ref.push_stack_op(RW::WRITE, StackAddress::from(1023), Word::from(0x6fu32));
tx.steps_mut().push(step);
Expand Down
60 changes: 60 additions & 0 deletions bus-mapping/src/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,8 @@ impl Op for TxAccessListAccountOp {
/// `SLOAD` step of the [`ExecStep`](crate::circuit_input_builder::ExecStep).
#[derive(Clone, PartialEq, Eq)]
pub struct TxAccessListAccountStorageOp {
/// RW
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this file

pub rw: RW,
/// Transaction ID: Transaction index in the block starting at 1.
pub tx_id: usize,
/// Account Address
Expand All @@ -426,6 +428,64 @@ pub struct TxAccessListAccountStorageOp {
pub value_prev: bool,
}

impl TxAccessListAccountStorageOp {
/// Create a new instance of a `TxAccessListAccountStorageOp` from it's
/// components.
pub fn new(
rw: RW,
tx_id: usize,
address: Address,
key: Word,
value: bool,
value_prev: bool,
) -> TxAccessListAccountStorageOp {
TxAccessListAccountStorageOp {
rw,
tx_id,
address,
key,
value,
value_prev,
}
}

/// Returns the internal [`RW`] which says whether the operation corresponds
/// to a Read or a Write into storage_slot access_list.
pub const fn rw(&self) -> RW {
self.rw
}

/// Returns the [`Target`] (operation type) of this operation.
pub const fn target(&self) -> Target {
Target::TxAccessListAccountStorage
}

/// Returns the [`TxID`] corresponding to this operation.
pub const fn tx_id(&self) -> usize {
self.tx_id
}

/// Returns the [`Address`] corresponding to this operation.
pub const fn address(&self) -> &Address {
&self.address
}

/// Returns the [`Word`] used as key for this operation.
pub const fn key(&self) -> &Word {
&self.key
}

/// Returns the [`bool`] read or written by this operation.
pub const fn value(&self) -> bool {
self.value
}

/// Returns the [`bool`] at key found previous to this operation.
pub const fn value_prev(&self) -> bool {
self.value_prev
}
}

impl fmt::Debug for TxAccessListAccountStorageOp {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.write_str("TxAccessListAccountStorageOp { ")?;
Expand Down
10 changes: 10 additions & 0 deletions bus-mapping/src/operation/container.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,16 @@ impl OperationContainer {
pub fn sorted_storage(&self) -> Vec<Operation<StorageOp>> {
self.storage.iter().sorted().cloned().collect()
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revert this file

/// Returns a sorted vector of all of the [`TxAccessListAccountStorageOp`]s
/// contained inside of the container.
pub fn sorted_txaccesslist_storage(&self) -> Vec<Operation<TxAccessListAccountStorageOp>> {
self.tx_access_list_storage_slot
.iter()
.sorted()
.cloned()
.collect()
}
}

#[cfg(test)]
Expand Down
9 changes: 6 additions & 3 deletions zkevm-circuits/src/evm_circuit/execution.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ mod push;
mod signed_comparator;
mod signextend;
mod stop;
mod storage;
mod swap;
mod timestamp;

Expand All @@ -61,6 +62,7 @@ use push::PushGadget;
use signed_comparator::SignedComparatorGadget;
use signextend::SignextendGadget;
use stop::StopGadget;
use storage::SloadGadget;
use swap::SwapGadget;
use timestamp::TimestampGadget;

Expand Down Expand Up @@ -111,6 +113,7 @@ pub(crate) struct ExecutionConfig<F> {
msize_gadget: MsizeGadget<F>,
coinbase_gadget: CoinbaseGadget<F>,
timestamp_gadget: TimestampGadget<F>,
sload_gadget: SloadGadget<F>,
}

impl<F: FieldExt> ExecutionConfig<F> {
Expand Down Expand Up @@ -239,6 +242,7 @@ impl<F: FieldExt> ExecutionConfig<F> {
msize_gadget: configure_gadget!(),
coinbase_gadget: configure_gadget!(),
timestamp_gadget: configure_gadget!(),
sload_gadget: configure_gadget!(),
step: step_curr,
presets_map,
};
Expand Down Expand Up @@ -486,9 +490,8 @@ impl<F: FieldExt> ExecutionConfig<F> {
ExecutionState::DUP => assign_exec_step!(self.dup_gadget),
ExecutionState::SWAP => assign_exec_step!(self.swap_gadget),
ExecutionState::COINBASE => assign_exec_step!(self.coinbase_gadget),
ExecutionState::TIMESTAMP => {
assign_exec_step!(self.timestamp_gadget)
}
ExecutionState::TIMESTAMP => assign_exec_step!(self.timestamp_gadget),
ExecutionState::SLOAD => assign_exec_step!(self.sload_gadget),
ExecutionState::ErrorOutOfGasPureMemory => {
assign_exec_step!(self.error_oog_pure_memory_gadget)
}
Expand Down
3 changes: 3 additions & 0 deletions zkevm-circuits/src/evm_circuit/execution/storage.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
mod sload;

pub(crate) use sload::SloadGadget;
Loading