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

Fix statemanager empty code bug #3483

Merged
merged 28 commits into from
Jul 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
5bf8c17
common/tx: implement EIP7702
jochem-brouwer Jun 23, 2024
4079bb5
tx: add 7702 cap and update authority checks
jochem-brouwer Jun 23, 2024
2632f4c
vm: add 7702 support
jochem-brouwer Jun 23, 2024
6dd25ae
tx: add 7702 tests
jochem-brouwer Jun 24, 2024
0a8b27a
client: fix build
jochem-brouwer Jun 24, 2024
0ae6f00
evm: support 7702
jochem-brouwer Jun 24, 2024
09108c5
vm: add basic 7702 test and fix decoding auth list
jochem-brouwer Jun 24, 2024
13ec300
vm: add specific eip-161 test
jochem-brouwer Jun 24, 2024
aeccb99
Merge branch 'master' into eip7702
jochem-brouwer Jul 1, 2024
f079602
vm: bump 7702 test coverage with one passing test
jochem-brouwer Jul 1, 2024
9dbb55c
vm: add more 7702 tests
jochem-brouwer Jul 1, 2024
a764192
vm: add extra 7702 tests
jochem-brouwer Jul 1, 2024
74446c1
tx: address feedback
jochem-brouwer Jul 1, 2024
6502801
vm: address review
jochem-brouwer Jul 1, 2024
4d59281
vm: add 7702 test to check for empty code (fails)
jochem-brouwer Jul 1, 2024
69e7268
vm: fix 7702 empty code clearing
jochem-brouwer Jul 2, 2024
d54ff6b
Merge branch 'master' into eip7702
jochem-brouwer Jul 2, 2024
3cebd3c
Merge remote-tracking branch 'origin/master' into eip7702
acolytec3 Jul 2, 2024
bc178f7
Merge branch 'master' into eip7702
ScottyPoi Jul 3, 2024
149c061
add 7702 type to tx factory constructors
acolytec3 Jul 4, 2024
8583642
add 7702 test to runBlock test
acolytec3 Jul 4, 2024
6e31e14
vm: comment 7702 test
jochem-brouwer Jul 4, 2024
554270d
stateManager: fix bug by putting empty code on an existing account
jochem-brouwer Jul 4, 2024
fac0dc7
vm: 7702: remove modifyAccountFields
jochem-brouwer Jul 4, 2024
1b724c6
vm: remove .only from runBlock test
jochem-brouwer Jul 4, 2024
c520da4
vm: remove runBlock .only
jochem-brouwer Jul 4, 2024
09a7e43
Merge branch 'eip7702' into fix-statemanager-empty-code-bug
jochem-brouwer Jul 4, 2024
fc74443
Merge remote-tracking branch 'origin/master' into fix-statemanager-em…
acolytec3 Jul 4, 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
3 changes: 0 additions & 3 deletions packages/statemanager/src/stateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,6 @@ export class DefaultStateManager implements EVMStateManagerInterface {
async putContractCode(address: Address, value: Uint8Array): Promise<void> {
this._codeCache?.put(address, value)
const codeHash = this.keccakFunction(value)
if (equalsBytes(codeHash, KECCAK256_NULL)) {
return
}

if (this.DEBUG) {
this._debug(`Update codeHash (-> ${short(codeHash)}) for account ${address}`)
Expand Down
10 changes: 10 additions & 0 deletions packages/statemanager/test/stateManager.code.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,15 @@ describe('StateManager -> Code', () => {
assert.ok(true, 'successfully threw')
}
})

it('putContractCode with empty code on existing address should correctly propagate', async () => {
const stateManager = new DefaultStateManager()
const address = Address.zero()
await stateManager.putContractCode(address, new Uint8Array([1]))
await stateManager.putContractCode(address, new Uint8Array())
const account = await stateManager.getAccount(address)
assert.ok(account !== undefined)
assert.ok(account?.isEmpty())
})
}
})
4 changes: 0 additions & 4 deletions packages/vm/src/runTx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,10 +680,6 @@ async function _runTx(this: VM, opts: RunTxOpts): Promise<RunTxResult> {
for (const str of writtenAddresses) {
const address = Address.fromString(str)
await this.stateManager.putContractCode(address, new Uint8Array())
// TODO verify if this is necessary
// `putContractCode` will not `modifyAccountFields` if one tries to put empty code
// So explicitly add this here - does this have side effects?
await this.stateManager.modifyAccountFields(address, { codeHash: KECCAK256_NULL })
}

if (enableProfiler) {
Expand Down
Loading