From 1746bafa28f6b0ebf97c17ddb0f06db76b447da8 Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Tue, 23 Dec 2025 19:51:08 -0800 Subject: [PATCH] add back static checks for selfdestruct/sstore and add extra gas check for selfdestruct stateless component --- core/vm/operations_acl.go | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/core/vm/operations_acl.go b/core/vm/operations_acl.go index c8046d2d95..560382bda3 100644 --- a/core/vm/operations_acl.go +++ b/core/vm/operations_acl.go @@ -28,6 +28,9 @@ import ( func makeGasSStoreFunc(clearingRefund uint64) gasFunc { return func(evm *EVM, contract *Contract, stack *Stack, mem *Memory, memorySize uint64) (uint64, error) { + if evm.readOnly { + return 0, ErrWriteProtection + } // If we fail the minimum gas availability invariant, fail (0) if contract.Gas <= params.SstoreSentryGasEIP2200 { return 0, errors.New("not enough gas for reentrancy sentry") @@ -188,11 +191,19 @@ func makeSelfdestructGasFn(refundsEnabled bool) gasFunc { gas uint64 address = common.Address(stack.peek().Bytes20()) ) + if evm.readOnly { + return 0, ErrWriteProtection + } + if !evm.StateDB.AddressInAccessList(address) { // If the caller cannot afford the cost, this change will be rolled back evm.StateDB.AddAddressToAccessList(address) gas = params.ColdAccountAccessCostEIP2929 } + if contract.Gas < gas { + return gas, nil + } + // if empty and transfers value if evm.StateDB.Empty(address) && evm.StateDB.GetBalance(contract.Address()).Sign() != 0 { gas += params.CreateBySelfdestructGas