Skip to content
This repository was archived by the owner on Apr 18, 2025. It is now read-only.

(WIP): add sstore op #98

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
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
10 changes: 10 additions & 0 deletions eth-types/src/evm_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,16 @@ impl GasCost {
pub const COLD_ACCOUNT_ACCESS_COST: Self = Self(2600);
/// Constant cost for a warm storage read
pub const WARM_STORAGE_READ_COST: Self = Self(100);

/// Constant cost for a warm storage read XXXXXX
pub const SLOAD_GAS: Self = Self(100);
/// Constant cost for a warm storage read XXXXXX
pub const SSTORE_SET_GAS: Self = Self(20000);
/// Constant cost for a warm storage read XXXXXX
pub const SSTORE_RESET_GAS: Self = Self(2900);
/// Constant cost for a warm storage read XXXXXX
pub const SSTORE_CLEARS_SCHEDULE: Self = Self(15000);

/// Constant cost for a non-creation transaction
pub const TX: Self = Self(21000);
/// Constant cost for creation transaction
Expand Down
5 changes: 5 additions & 0 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::SstoreGadget;
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>,
sstore_gadget: SstoreGadget<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!(),
sstore_gadget: configure_gadget!(),
step: step_curr,
presets_map,
};
Expand Down Expand Up @@ -489,6 +493,7 @@ impl<F: FieldExt> ExecutionConfig<F> {
ExecutionState::TIMESTAMP => {
assign_exec_step!(self.timestamp_gadget)
}
ExecutionState::SSTORE => assign_exec_step!(self.sstore_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 sstore;

pub(crate) use sstore::SstoreGadget;
Loading