diff --git a/specs/opcode/54SLOAD_55SSTORE.md b/specs/opcode/54SLOAD_55SSTORE.md index 67cfe3ea6..dc0a2e339 100644 --- a/specs/opcode/54SLOAD_55SSTORE.md +++ b/specs/opcode/54SLOAD_55SSTORE.md @@ -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 @@ -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. diff --git a/src/zkevm_specs/evm/execution/storage.py b/src/zkevm_specs/evm/execution/storage.py index 7ea8c898e..1777ef0b9 100644 --- a/src/zkevm_specs/evm/execution/storage.py +++ b/src/zkevm_specs/evm/execution/storage.py @@ -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) @@ -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), diff --git a/tests/evm/test_sstore.py b/tests/evm/test_sstore.py index 82a52d201..b3d002cda 100644 --- a/tests/evm/test_sstore.py +++ b/tests/evm/test_sstore.py @@ -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) @@ -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,