Skip to content

Commit

Permalink
fix sstore
Browse files Browse the repository at this point in the history
  • Loading branch information
enitrat committed Jan 17, 2025
1 parent 3563b9d commit 58acfb5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions cairo/ethereum/cancun/vm/instructions/storage.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,13 @@ func sstore{
let poseidon_ptr = cast([ap - 2], PoseidonBuiltin*);
let dict_ptr = cast([ap - 1], DictAccess*);

let new_dict_ptr = cast(dict_ptr, SetTupleAddressBytes32DictAccess*);
tempvar new_accessed_storage_keys = SetTupleAddressBytes32(
new SetTupleAddressBytes32Struct(
evm.value.accessed_storage_keys.value.dict_ptr_start, new_dict_ptr
),
);

// Calculate storage gas cost
tempvar zero_u256 = U256(new U256Struct(0, 0));
let is_original_eq_current = U256__eq__(original_value, current_value);
Expand Down Expand Up @@ -229,6 +236,7 @@ func sstore{
EvmImpl.set_env(env);
EvmImpl.set_pc_stack(Uint(evm.value.pc.value + 1), stack);
EvmImpl.set_refund_counter(refund_counter);
EvmImpl.set_accessed_storage_keys(new_accessed_storage_keys);
let ok = cast(0, ExceptionalHalt*);
return ok;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def test_sstore(self, cairo_run, evm: Evm):
try:
cairo_evm = cairo_run("sstore", evm)
except Exception as cairo_error:
with assert_raises_exactly(type(cairo_error)):
with strict_raises(type(cairo_error)):
sstore(evm)
return
sstore(evm)
Expand Down

0 comments on commit 58acfb5

Please sign in to comment.