Skip to content

Commit

Permalink
evm,vm: remove the hacks to prevent account cleanups of system contra…
Browse files Browse the repository at this point in the history
…cts (#3418)

* evm,vm: remove the hacks to prevent account cleanups of system contracts

* lint

---------

Co-authored-by: acolytec3 <[email protected]>
Co-authored-by: Holger Drewes <[email protected]>
  • Loading branch information
3 people authored May 19, 2024
1 parent c95499c commit 38c4a73
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
8 changes: 0 additions & 8 deletions packages/evm/src/journal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Hardfork } from '@ethereumjs/common'
import {
Address,
RIPEMD160_ADDRESS_STRING,
bigIntToHex,
bytesToHex,
bytesToUnprefixedHex,
stripHexPrefix,
Expand Down Expand Up @@ -198,13 +197,6 @@ export class Journal {
const address = new Address(hexToBytes(`0x${addressHex}`))
const account = await this.stateManager.getAccount(address)
if (account === undefined || account.isEmpty()) {
if (this.common.isActivatedEIP(2935)) {
// The history storage address is exempt of state clearing by EIP-158 if the EIP is activated
const addr = bigIntToHex(this.common.param('vm', 'historyStorageAddress')).slice(2)
if (addressHex === addr) {
continue
}
}
await this.deleteAccount(address)
if (this.DEBUG) {
this._debug(`Cleanup touched account address=${address} (>= SpuriousDragon)`)
Expand Down
6 changes: 6 additions & 0 deletions packages/vm/src/runBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,9 @@ export async function accumulateParentBlockHash(
}
// eslint-disable-next-line no-empty
} catch (_e) {}

// do cleanup if the code was not deployed
await this.evm.journal.cleanup()
}

export async function accumulateParentBeaconBlockRoot(
Expand Down Expand Up @@ -590,6 +593,9 @@ export async function accumulateParentBeaconBlockRoot(
setLengthLeft(bigIntToBytes(timestampExtended), 32),
root
)

// do cleanup if the code was not deployed
await this.evm.journal.cleanup()
}

/**
Expand Down

0 comments on commit 38c4a73

Please sign in to comment.