diff --git a/packages/vm/lib/evm/opFns.ts b/packages/vm/lib/evm/opFns.ts index e4fcba004bb..4765065cb38 100644 --- a/packages/vm/lib/evm/opFns.ts +++ b/packages/vm/lib/evm/opFns.ts @@ -1197,6 +1197,7 @@ export const handlers: Map = new Map([ runState.eei.useGas(new BN(runState._common.param('gasPrices', 'callNewAccount'))) } + accessAddressEIP2929(runState, selfdestructToAddress, 0) return runState.eei.selfDestruct(selfdestructToAddressBuf) }, ], @@ -1278,13 +1279,14 @@ function accessAddressEIP2929(runState: RunState, address: BN | Buffer, baseFee? runState.accessedAddresses.add(addressStr) // CREATE, CREATE2 opcodes have the address warmed for free. - if (baseFee) { + // selfdestruct beneficiary address reads are charged an *additional* cold access + if (baseFee !== undefined) { runState.eei.useGas( new BN(runState._common.param('gasPrices', 'coldaccountaccess') - baseFee), ) } - // Warm - } else if (baseFee) { + // Warm: (selfdestruct beneficiary address reads are not charged when warm) + } else if (baseFee !== undefined && baseFee > 0) { runState.eei.useGas(new BN(runState._common.param('gasPrices', 'warmstorageread') - baseFee)) } }