Skip to content
This repository was archived by the owner on Jul 5, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions specs/opcode/54SLOAD_55SSTORE.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
- 2 stack operations
- 1 storage reads
- 1 access_list write
- `SSTORE`: +9
- 4 call_context read
- `SSTORE`: +10
- 5 call_context read
- 2 stack operations
- 1 storage reads/writes
- 1 access_list write
Expand Down Expand Up @@ -79,9 +79,10 @@
- `value` is pushed on top of the stack
- storage: The 32 bytes of `value` are read from storage at `key`
- access_list: Write as `true` for `key`
- `SSTORE`: 9 busmapping lookups
- `SSTORE`: 10 busmapping lookups
- call_context:
- `tx_id`: Read the `tx_id` for this tx.
- `is_static`: Read the call's property `is_static`
- `rw_counter_end_of_reversion`: Read the `rw_counter_end` if this tx get reverted.
- `is_persistent`: Read if this tx will be reverted.
- `callee_address`: Read the `callee_address` of this call.
Expand Down
7 changes: 6 additions & 1 deletion src/zkevm_specs/evm/execution/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ def sstore(instruction: Instruction):
instruction.constrain_equal(opcode, Opcode.SSTORE)

tx_id = instruction.call_context_lookup(CallContextFieldTag.TxId)
# check not static call
instruction.constrain_equal(
FQ(0), instruction.call_context_lookup(CallContextFieldTag.IsStatic)
)

reversion_info = instruction.reversion_info()
callee_address = instruction.call_context_lookup(CallContextFieldTag.CalleeAddress)

Expand Down Expand Up @@ -130,7 +135,7 @@ def sstore(instruction: Instruction):

instruction.step_state_transition_in_same_context(
opcode,
rw_counter=Transition.delta(9),
rw_counter=Transition.delta(10),
program_counter=Transition.delta(1),
stack_pointer=Transition.delta(2),
state_write_counter=Transition.delta(3),
Expand Down
3 changes: 2 additions & 1 deletion tests/evm/test_sstore.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ def test_sstore(
# fmt: off
RWDictionary(1)
.call_context_read(1, CallContextFieldTag.TxId, tx.id)
.call_context_read(1, CallContextFieldTag.IsStatic, 0)
.call_context_read(1, CallContextFieldTag.RwCounterEndOfReversion, 0 if is_success else 14)
.call_context_read(1, CallContextFieldTag.IsPersistent, is_success)
.call_context_read(1, CallContextFieldTag.CalleeAddress, tx.callee_address)
Expand Down Expand Up @@ -170,7 +171,7 @@ def test_sstore(
),
StepState(
execution_state=ExecutionState.STOP if is_success else ExecutionState.REVERT,
rw_counter=10,
rw_counter=11,
call_id=1,
is_root=True,
is_create=False,
Expand Down