Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIP-7702 devnet-3 readiness #3581

Merged
merged 41 commits into from
Sep 11, 2024
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
2f26e9d
tx: implement strict 7702 validation
jochem-brouwer Aug 12, 2024
f59b5a0
vm: update 7702 tx validation
jochem-brouwer Aug 12, 2024
5d8ba39
evm: update 7702 [no ci]
jochem-brouwer Aug 12, 2024
4a20346
tx: add / fix 7702 tests
jochem-brouwer Aug 12, 2024
5e8e756
Merge branch 'master' into 7702-update
jochem-brouwer Aug 12, 2024
ad3effb
vm: fix test encoding of authorization lists [no ci]
jochem-brouwer Aug 12, 2024
f6da2c4
Merge branch 'master' into 7702-update
jochem-brouwer Aug 13, 2024
f8950b8
vm: correctly put authority nonce
jochem-brouwer Aug 14, 2024
842db9d
vm: add test 7702 extcodehash/extcodesize
jochem-brouwer Aug 16, 2024
0b6692f
vm: expand extcode* tests 7702 [no ci]
jochem-brouwer Aug 16, 2024
6136308
Merge branch 'master' into 7702-update
jochem-brouwer Aug 17, 2024
7a01e81
tx/vm: update tests [no ci]
jochem-brouwer Aug 17, 2024
0310175
evm/vm: update opcodes and fix tests 7702
jochem-brouwer Aug 17, 2024
81d2da2
Merge branch 'master' into 7702-update
jochem-brouwer Aug 17, 2024
d773d2b
fix cspell [no ci]
jochem-brouwer Aug 17, 2024
d4d3100
vm: get params from tx for 7702 [no ci]
jochem-brouwer Aug 19, 2024
0fa00d3
vm: 7702 correctly apply the refund [no ci]
jochem-brouwer Aug 19, 2024
1a21f86
vm: 7702: correctly handle self-sponsored txs [no ci]
jochem-brouwer Aug 19, 2024
6162957
tx: throw if authorization list is empty
jochem-brouwer Aug 19, 2024
2043d1e
vm: requests do not throw if code is non-existant
jochem-brouwer Aug 19, 2024
9bd46ad
evm: ensure correct extcodehash reporting if account is delegated to …
jochem-brouwer Aug 19, 2024
a617c3b
Merge branch 'master' into 7702-update
jochem-brouwer Aug 19, 2024
d4f9c60
vm: 7702 ensure delegated accounts are not deleted [no ci]
jochem-brouwer Aug 20, 2024
d26ddb3
Merge branch 'master' into 7702-update
jochem-brouwer Aug 20, 2024
a41ef16
evm: 7702 correctly check for gas on delegated code
jochem-brouwer Aug 23, 2024
30072e2
evm: add verkle gas logic for 7702
jochem-brouwer Aug 23, 2024
33b8523
vm/tx: fix 7702 tests
jochem-brouwer Aug 25, 2024
5b4313a
tx: throw if 7702-tx has no `to` field
jochem-brouwer Aug 25, 2024
07793c7
vm/tx: fix 7702 tests
jochem-brouwer Aug 25, 2024
2f0d1ab
VM: exit early on non-existing system contracts
jochem-brouwer Aug 26, 2024
ec85a45
7702: add delegated account to warm address
jochem-brouwer Aug 27, 2024
8b0cc5c
vm: requests do restore system account
jochem-brouwer Aug 28, 2024
e710e78
7702: continue processing once auth ecrecover is invalid
jochem-brouwer Aug 28, 2024
8cc5755
evm/vm: add 7702 delegation constant
jochem-brouwer Sep 2, 2024
21f1de1
Merge branch 'master' into 7702-update
jochem-brouwer Sep 2, 2024
6325bc3
vm: fix requests
jochem-brouwer Sep 2, 2024
0d77c3f
Merge branch 'master' into 7702-update
jochem-brouwer Sep 2, 2024
4287e95
vm: unduplify 3607 error msg
jochem-brouwer Sep 2, 2024
aed93cd
Merge remote-tracking branch 'origin/master' into 7702-update
acolytec3 Sep 11, 2024
ea9f88d
Merge branch 'master' into 7702-update
acolytec3 Sep 11, 2024
88dfdd0
fix example
acolytec3 Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
vm: update 7702 tx validation
jochem-brouwer committed Aug 12, 2024
commit f59b5a0e15d57b542927907d9eeab9d333dd614a
32 changes: 22 additions & 10 deletions packages/vm/src/runTx.ts
Original file line number Diff line number Diff line change
@@ -439,33 +439,45 @@ async function _runTx(vm: VM, opts: RunTxOpts): Promise<RunTxResult> {
}
// Address to take code from
const address = data[1]
const nonceList = data[2]
const nonce = data[2]
const yParity = bytesToBigInt(data[3])
const r = data[4]
const s = data[5]

const rlpdSignedMessage = RLP.encode([chainId, address, nonceList])
const rlpdSignedMessage = RLP.encode([chainId, address, nonce])
const toSign = keccak256(concatBytes(MAGIC, rlpdSignedMessage))
const pubKey = ecrecover(toSign, yParity, r, s)
// Address to set code to
const authority = new Address(publicToAddress(pubKey))
const account = (await vm.stateManager.getAccount(authority)) ?? new Account()
const accountMaybeUndefined = await vm.stateManager.getAccount(authority)
const accountExists = accountMaybeUndefined !== undefined
const account = accountMaybeUndefined ?? new Account()

// Add authority address to warm addresses
vm.evm.journal.addAlwaysWarmAddress(authority.toString())
if (account.isContract()) {
// Note: vm also checks if the code has already been set once by a previous tuple
// So, if there are multiply entires for the same address, then vm is fine
continue
const code = await vm.stateManager.getCode(authority)
if (!equalsBytes(code.slice(0, 3), new Uint8Array([0xef, 0x01, 0x00]))) {
// Account is a "normal" contract
continue
}
}
if (nonceList.length !== 0 && account.nonce !== bytesToBigInt(nonceList[0])) {
if (account.nonce !== bytesToBigInt(nonce)) {
continue
}

const addressConverted = new Address(address)
const addressCode = await vm.stateManager.getCode(addressConverted)
if (accountExists) {
const refund = vm.common.param('perEmptyAccountCost') - vm.common.param('perAuthBaseGas')
fromAccount.balance += refund
}

fromAccount.nonce++
await vm.evm.journal.putAccount(caller, fromAccount)

const addressCode = concatBytes(new Uint8Array([0xef, 0x01, 0x00]), address)
await vm.stateManager.putCode(authority, addressCode)

writtenAddresses.add(authority.toString())
vm.evm.journal.addAlwaysWarmAddress(authority.toString())
}
}