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

all: implement eip-7702 set code tx #30078

Merged
merged 48 commits into from
Dec 16, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
7a4bafa
all: impl eip-7702
lightclient Jun 26, 2024
8a49fd8
cmd/evm: add 7702 test for t8n
lightclient Oct 18, 2024
a173914
internal/ethapi: add 7702 tests to eth_estimateGas
lightclient Oct 29, 2024
7dceb35
core/vm: make 7702 variants of EXT* ops
lightclient Nov 21, 2024
f9e0222
core: remove resolve code mechanism from statedb, put in vm
lightclient Nov 27, 2024
f32e9bf
core: use parse delegation for code check in state transition
lightclient Nov 27, 2024
48ef8da
legacypool: don't allow 7702 txs in pool yet
lightclient Nov 27, 2024
f709826
common: remove zero address
lightclient Nov 27, 2024
630b42c
accounts/external: handle set code tx type in backend
lightclient Nov 27, 2024
bebcdd8
internal/ethapi: handle set code tx type in transaction args
lightclient Nov 27, 2024
d3e82b4
core: clarify test a bit
holiman Nov 27, 2024
b8fb4d6
core/types: remove AuthorizationList and use Authorization as value i…
fjl Dec 2, 2024
1506e06
core/types: change Authorization signature value to uint256
fjl Dec 2, 2024
09d1a16
core/types: change Authority method to pointer receiver
fjl Dec 2, 2024
ab2f070
core: fix account reference
fjl Dec 2, 2024
e137c47
internal/ethapi: remove reference to blob fields in setcode tx
fjl Dec 2, 2024
bb182a6
core/types: improve authority signature handling
fjl Dec 2, 2024
0926de3
core: track validation error for authorizations
fjl Dec 2, 2024
0f85021
core: style improvement in applyAuthorization
fjl Dec 2, 2024
bf01e0d
core: add comment about nonce update order
fjl Dec 2, 2024
a1c1860
core/vm: add comment about chained EIP-7702 delegations
fjl Dec 2, 2024
23baaee
core: remove debug print
fjl Dec 2, 2024
a0274e0
cmd/evm: update testdata
fjl Dec 2, 2024
33888a9
graphql: add support for fee parameters of SetCodeTx
fjl Dec 2, 2024
e7c0f80
core: improve checks for 7702
fjl Dec 2, 2024
bd36423
core: add comment about 7702 state transition error
fjl Dec 2, 2024
3764d42
core/state: fix hooks to account for setcode on non-empty code
holiman Dec 2, 2024
5fccdfb
core/state: fix journal to account for setcode over non-empty code
holiman Dec 2, 2024
ace3a3f
core: reformat comment
fjl Dec 2, 2024
1110fc5
core: clarify delegation deletion flow
fjl Dec 2, 2024
9b94402
core: more comment
fjl Dec 2, 2024
9ee0d10
core: lift convenience warming of tx destination from per auth to pos…
lightclient Dec 5, 2024
f4b5798
core: refactor non-create processing flow
lightclient Dec 5, 2024
eda288c
internal/ethapi: removed commented out code from test
lightclient Dec 5, 2024
0a129da
core/vm: direct check code hash during creation instead of resolving
lightclient Dec 6, 2024
6505e50
tests: use big int for stAuthorization because eest needs math.HexOrD…
lightclient Dec 6, 2024
46a6482
core: rm extra whitespace
lightclient Dec 9, 2024
7ecda7d
t8n: do not omit requests when empty
lightclient Dec 10, 2024
fdfc159
core/vm: return delegation designator prefix for code reading ops
lightclient Dec 10, 2024
e98e686
core/vm: report gas used warming 7702 delegation targets correctly in…
lightclient Dec 10, 2024
aed705b
eth/tracers: add support for setcode tx in prestate tracer
lightclient Dec 10, 2024
034f897
core: mod errors + add test
holiman Dec 12, 2024
857641d
core: create official prague instruction set, name eof set
lightclient Dec 12, 2024
f33b87a
cmd/evm: fix expected output for 7702 t8n test
lightclient Dec 12, 2024
f3a427e
internal/ethapi: rename authlist to authorizationList in transaction …
lightclient Dec 12, 2024
e4e381d
core/vm: rm dynamic gas calculators for core reading ops
lightclient Dec 16, 2024
98521a5
core/vm: revert changes to extcodecopy in verkle
lightclient Dec 16, 2024
55cb1db
core/vm: simplify 7702 enabler
holiman Dec 16, 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
2 changes: 1 addition & 1 deletion cmd/evm/eofparse.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ var jt vm.JumpTable
const initcode = "INITCODE"

func init() {
jt = vm.NewPragueEOFInstructionSetForTesting()
jt = vm.NewEOFInstructionSetForTesting()
}

var (
Expand Down
2 changes: 1 addition & 1 deletion cmd/evm/eofparse_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func FuzzEofParsing(f *testing.F) {
// And do the fuzzing
f.Fuzz(func(t *testing.T, data []byte) {
var (
jt = vm.NewPragueEOFInstructionSetForTesting()
jt = vm.NewEOFInstructionSetForTesting()
c vm.Container
)
cpy := common.CopyBytes(data)
Expand Down
20 changes: 9 additions & 11 deletions cmd/evm/testdata/33/exp.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"balance": "0x29a2241af62c0000"
},
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba": {
"balance": "0x2bf52"
"balance": "0x2ab02"
},
"0x703c4b2bd70c169f5717101caee543299fc946c7": {
"code": "0xef0100000000000000000000000000000000000000bbbb",
Expand All @@ -21,7 +21,7 @@
},
"0x71562b71999873db5b286df957af199ec94617f7": {
"code": "0xef0100000000000000000000000000000000000000aaaa",
"balance": "0x6124fee993afa30e",
"balance": "0x6124fee993affe76",
"nonce": "0x2"
},
"0x8a0a19589531694250d570040a0c4b74576919b8": {
Expand All @@ -35,29 +35,27 @@
}
},
"result": {
"stateRoot": "0x9fdcacd4510e93c4488e537dc51578b5c6d505771db64a2610036eeb4be7b26f",
"stateRoot": "0x90e868da38bc6aff256832d72710207a04fa5ecfd86b0fc326e73d8fcb09dc1c",
"txRoot": "0x5d13a0b074e80388dc754da92b22922313a63417b3e25a10f324935e09697a53",
"receiptsRoot": "0x504c5d86c34391f70d210e6c482615b391db4bdb9f43479366399d9c5599850a",
"receiptsRoot": "0xdd64f30ac99db69f75893bb4b7bb10a76c86cf192ca48c4bfe724d7fe96c469a",
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"receipts": [
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","receipts": [
{
"type": "0x4",
"root": "0x",
"status": "0x1",
"cumulativeGasUsed": "0x15fa9",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
"logs": null,
"cumulativeGasUsed": "0x15581",
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","logs": null,
"transactionHash": "0x0417aab7c1d8a3989190c3167c132876ce9b8afd99262c5a0f9d06802de3d7ef",
"contractAddress": "0x0000000000000000000000000000000000000000",
"gasUsed": "0x15fa9",
"gasUsed": "0x15581",
"effectiveGasPrice": null,
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"transactionIndex": "0x0"
}
],
"currentDifficulty": null,
"gasUsed": "0x15fa9",
"gasUsed": "0x15581",
"currentBaseFee": "0x7",
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"requestsHash": "0xe3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
Expand Down
16 changes: 8 additions & 8 deletions core/vm/eof_validation_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func TestValidateCode(t *testing.T) {
data: make([]byte, 0),
subContainers: make([]*Container, 0),
}
_, err := validateCode(test.code, test.section, container, &pragueEOFInstructionSet, false)
_, err := validateCode(test.code, test.section, container, &eofInstructionSet, false)
if !errors.Is(err, test.err) {
t.Errorf("test %d (%s): unexpected error (want: %v, got: %v)", i, common.Bytes2Hex(test.code), test.err, err)
}
Expand All @@ -277,7 +277,7 @@ func BenchmarkRJUMPI(b *testing.B) {
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := validateCode(code, 0, container, &pragueEOFInstructionSet, false)
_, err := validateCode(code, 0, container, &eofInstructionSet, false)
if err != nil {
b.Fatal(err)
}
Expand Down Expand Up @@ -309,7 +309,7 @@ func BenchmarkRJUMPV(b *testing.B) {
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := validateCode(code, 0, container, &pragueEOFInstructionSet, false)
_, err := validateCode(code, 0, container, &pragueInstructionSet, false)
if err != nil {
b.Fatal(err)
}
Expand Down Expand Up @@ -357,7 +357,7 @@ func BenchmarkEOFValidation(b *testing.B) {
if err := container2.UnmarshalBinary(bin, true); err != nil {
b.Fatal(err)
}
if err := container2.ValidateCode(&pragueEOFInstructionSet, false); err != nil {
if err := container2.ValidateCode(&pragueInstructionSet, false); err != nil {
b.Fatal(err)
}
}
Expand Down Expand Up @@ -412,7 +412,7 @@ func BenchmarkEOFValidation2(b *testing.B) {
if err := container2.UnmarshalBinary(bin, true); err != nil {
b.Fatal(err)
}
if err := container2.ValidateCode(&pragueEOFInstructionSet, false); err != nil {
if err := container2.ValidateCode(&pragueInstructionSet, false); err != nil {
b.Fatal(err)
}
}
Expand Down Expand Up @@ -468,7 +468,7 @@ func BenchmarkEOFValidation3(b *testing.B) {
if err := container2.UnmarshalBinary(bin, true); err != nil {
b.Fatal(err)
}
if err := container2.ValidateCode(&pragueEOFInstructionSet, false); err != nil {
if err := container2.ValidateCode(&pragueInstructionSet, false); err != nil {
b.Fatal(err)
}
}
Expand All @@ -494,7 +494,7 @@ func BenchmarkRJUMPI_2(b *testing.B) {
}
b.ResetTimer()
for i := 0; i < b.N; i++ {
_, err := validateCode(code, 0, container, &pragueEOFInstructionSet, false)
_, err := validateCode(code, 0, container, &pragueInstructionSet, false)
if err != nil {
b.Fatal(err)
}
Expand All @@ -512,6 +512,6 @@ func FuzzValidate(f *testing.F) {
f.Fuzz(func(_ *testing.T, code []byte, maxStack uint16) {
var container Container
container.types = append(container.types, &functionMetadata{inputs: 0, outputs: 0x80, maxStackHeight: maxStack})
validateCode(code, 0, &container, &pragueEOFInstructionSet, true)
validateCode(code, 0, &container, &pragueInstructionSet, true)
})
}
2 changes: 2 additions & 0 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
case evm.chainRules.IsVerkle:
// TODO replace with proper instruction set when fork is specified
table = &verkleInstructionSet
case evm.chainRules.IsPrague:
table = &pragueInstructionSet
case evm.chainRules.IsCancun:
table = &cancunInstructionSet
case evm.chainRules.IsShanghai:
Expand Down
18 changes: 12 additions & 6 deletions core/vm/jump_table.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,8 @@ var (
shanghaiInstructionSet = newShanghaiInstructionSet()
cancunInstructionSet = newCancunInstructionSet()
verkleInstructionSet = newVerkleInstructionSet()
pragueEOFInstructionSet = newPragueEOFInstructionSet()
pragueInstructionSet = newPragueInstructionSet()
eofInstructionSet = newEOFInstructionSetForTesting()
)

// JumpTable contains the EVM opcodes supported at a given fork.
Expand Down Expand Up @@ -91,24 +92,29 @@ func newVerkleInstructionSet() JumpTable {
return validate(instructionSet)
}

func NewPragueEOFInstructionSetForTesting() JumpTable {
return newPragueEOFInstructionSet()
func NewEOFInstructionSetForTesting() JumpTable {
return newEOFInstructionSetForTesting()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have an exported and unexported version of the same function?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume because we added the testing function just to do fuzz testing, but didn't want to churn core geth code when we decide to delete it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Happy to remove to consolidate it into the exported function if that's better. Just trying to retain what was there.

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exported is named "ForTesting" to signal that nobody should rely on it as official api. Fuzzing yes, and maybe also goevmlab

}

func newPragueEOFInstructionSet() JumpTable {
instructionSet := newCancunInstructionSet()
func newEOFInstructionSetForTesting() JumpTable {
instructionSet := newPragueInstructionSet()
enableEOF(&instructionSet)
return validate(instructionSet)
}

func newPragueInstructionSet() JumpTable {
instructionSet := newCancunInstructionSet()
enable7702(&instructionSet) // EIP-7702 Setcode transaction type
return validate(instructionSet)
}

func newCancunInstructionSet() JumpTable {
instructionSet := newShanghaiInstructionSet()
enable4844(&instructionSet) // EIP-4844 (BLOBHASH opcode)
enable7516(&instructionSet) // EIP-7516 (BLOBBASEFEE opcode)
enable1153(&instructionSet) // EIP-1153 "Transient Storage"
enable5656(&instructionSet) // EIP-5656 (MCOPY opcode)
enable6780(&instructionSet) // EIP-6780 SELFDESTRUCT only in same transaction
enable7702(&instructionSet)
return validate(instructionSet)
}

Expand Down
Loading