Skip to content

Commit

Permalink
core/vm: witness write event for SSTORE (ethereum#80)
Browse files Browse the repository at this point in the history
* core/vm: witness write event for SSTORE

* remove TODO that is addressed by this branch
  • Loading branch information
jwasinger authored Feb 11, 2022
1 parent 1a98ca7 commit 7af62ef
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 0 additions & 1 deletion core/vm/instructions.go
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,6 @@ func opSload(pc *uint64, interpreter *EVMInterpreter, scope *ScopeContext) ([]by

if interpreter.evm.chainConfig.IsCancun(interpreter.evm.Context.BlockNumber) {
index := trieUtils.GetTreeKeyStorageSlot(scope.Contract.Address().Bytes(), loc)
// TODO SSTORE write events
interpreter.evm.Accesses.SetLeafValue(index, val.Bytes())
}
loc.SetBytes(val.Bytes())
Expand Down
6 changes: 6 additions & 0 deletions core/vm/operations_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ func makeGasSStoreFunc(clearingRefund uint64) gasFunc {
}
value := common.Hash(y.Bytes32())

if evm.chainConfig.IsCancun(evm.Context.BlockNumber) {
addr := contract.Address()
index := trieUtils.GetTreeKeyStorageSlot(addr[:], x)
cost += evm.Accesses.TouchAddressOnWriteAndComputeGas(index)
}

if current == value { // noop (1)
// EIP 2200 original clause:
// return params.SloadGasEIP2200, nil
Expand Down

0 comments on commit 7af62ef

Please sign in to comment.