Skip to content

Commit

Permalink
Fix Prague test runner (#3498)
Browse files Browse the repository at this point in the history
* prague: swap 3074 for 7702 eip

* vm: requests: ensure system address nonce does not get updated

* vm: state runner: fix some 7702 tests

* vm: state: fix all 7702 state tests
  • Loading branch information
jochem-brouwer authored Jul 12, 2024
1 parent 645cd91 commit 94d02e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
2 changes: 1 addition & 1 deletion packages/common/src/hardforks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -841,7 +841,7 @@ export const hardforks: HardforksDict = {
'Next feature hardfork after cancun, internally used for pectra testing/implementation (incomplete/experimental)',
url: 'https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/prague.md',
status: Status.Draft,
eips: [2537, 2935, 3074, 6110, 7002, 7251, 7685],
eips: [2537, 2935, 6110, 7002, 7251, 7685, 7702],
},
osaka: {
name: 'osaka',
Expand Down
14 changes: 10 additions & 4 deletions packages/vm/src/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const accumulateEIP7002Requests = async (
const systemAddressBytes = bigIntToAddressBytes(vm.common.param('vm', 'systemAddress'))
const systemAddress = Address.fromString(bytesToHex(systemAddressBytes))

const addrIsEmpty = (await vm.stateManager.getAccount(systemAddress)) === undefined
const originalAccount = await vm.stateManager.getAccount(systemAddress)

const results = await vm.evm.runCall({
caller: systemAddress,
Expand All @@ -98,8 +98,11 @@ const accumulateEIP7002Requests = async (
}
}

if (addrIsEmpty) {
if (originalAccount === undefined) {
await vm.stateManager.deleteAccount(systemAddress)
} else {
// Restore the original account (the `runCall` updates the nonce)
await vm.stateManager.putAccount(systemAddress, originalAccount)
}
}

Expand All @@ -125,7 +128,7 @@ const accumulateEIP7251Requests = async (
const systemAddressBytes = bigIntToAddressBytes(vm.common.param('vm', 'systemAddress'))
const systemAddress = Address.fromString(bytesToHex(systemAddressBytes))

const addrIsEmpty = (await vm.stateManager.getAccount(systemAddress)) === undefined
const originalAccount = await vm.stateManager.getAccount(systemAddress)

const results = await vm.evm.runCall({
caller: systemAddress,
Expand All @@ -147,8 +150,11 @@ const accumulateEIP7251Requests = async (
}
}

if (addrIsEmpty) {
if (originalAccount === undefined) {
await vm.stateManager.deleteAccount(systemAddress)
} else {
// Restore the original account (the `runCall` updates the nonce)
await vm.stateManager.putAccount(systemAddress, originalAccount)
}
}

Expand Down
16 changes: 15 additions & 1 deletion packages/vm/test/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { RLP } from '@ethereumjs/rlp'
import {
AccessListEIP2930Transaction,
BlobEIP4844Transaction,
EOACodeEIP7702Transaction,
FeeMarketEIP1559Transaction,
LegacyTransaction,
} from '@ethereumjs/tx'
Expand All @@ -18,6 +19,7 @@ import {
isHexString,
setLengthLeft,
toBytes,
unpadBytes,
} from '@ethereumjs/util'
import { keccak256 } from 'ethereum-cryptography/keccak'

Expand Down Expand Up @@ -116,12 +118,24 @@ export function makeTx(
txData: any,
opts?: TxOptions
):
| EOACodeEIP7702Transaction
| BlobEIP4844Transaction
| FeeMarketEIP1559Transaction
| AccessListEIP2930Transaction
| LegacyTransaction {
let tx
if (txData.blobVersionedHashes !== undefined) {
if (txData.authorizationList !== undefined) {
// Convert `v` keys to `yParity`
for (const signature of txData.authorizationList) {
if (signature.v !== undefined) {
signature.yParity = bytesToHex(unpadBytes(hexToBytes(signature.v)))
}
if (signature.nonce !== undefined && signature.nonce[0] === '0x00') {
signature.nonce[0] = '0x'
}
}
tx = EOACodeEIP7702Transaction.fromTxData(txData, opts)
} else if (txData.blobVersionedHashes !== undefined) {
tx = BlobEIP4844Transaction.fromTxData(txData, opts)
} else if (txData.maxFeePerGas !== undefined) {
tx = FeeMarketEIP1559Transaction.fromTxData(txData, opts)
Expand Down

0 comments on commit 94d02e6

Please sign in to comment.