Skip to content

Commit 1847b5f

Browse files
s1nalightclient
andauthored
build: update EEST fixtures to prague devnet-6 (#31088)
Co-authored-by: lightclient <lightclient@protonmail.com>
1 parent 9e33b29 commit 1847b5f

File tree

5 files changed

+122
-62
lines changed

5 files changed

+122
-62
lines changed

build/checksums.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# This file contains sha256 checksums of optional build dependencies.
22

3-
# version:spec-tests 2.1.0
3+
# version:spec-tests pectra-devnet-6@v1.0.0
44
# https://github.com/ethereum/execution-spec-tests/releases
5-
# https://github.com/ethereum/execution-spec-tests/releases/download/v2.1.0/
6-
ca89c76851b0900bfcc3cbb9a26cbece1f3d7c64a3bed38723e914713290df6c fixtures_develop.tar.gz
5+
# https://github.com/ethereum/execution-spec-tests/releases/download/pectra-devnet-6%40v1.0.0/fixtures_pectra-devnet-6.tar.gz
6+
b69211752a3029083c020dc635fe12156ca1a6725a08559da540a0337586a77e fixtures_pectra-devnet-6.tar.gz
77

88
# version:golang 1.23.6
99
# https://go.dev/dl/

build/ci.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ func downloadSpecTestFixtures(csdb *build.ChecksumDB, cachedir string) string {
338338
log.Fatal(err)
339339
}
340340
ext := ".tar.gz"
341-
base := "fixtures_develop" // TODO(MariusVanDerWijden) rename once the version becomes part of the filename
342-
url := fmt.Sprintf("https://github.com/ethereum/execution-spec-tests/releases/download/v%s/%s%s", executionSpecTestsVersion, base, ext)
341+
base := "fixtures_pectra-devnet-6" // TODO(s1na) rename once the version becomes part of the filename
342+
url := fmt.Sprintf("https://github.com/ethereum/execution-spec-tests/releases/download/%s/%s%s", executionSpecTestsVersion, base, ext)
343343
archivePath := filepath.Join(cachedir, base+ext)
344344
if err := csdb.DownloadFile(url, archivePath); err != nil {
345345
log.Fatal(err)

tests/init_test.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,17 @@ import (
3434
)
3535

3636
var (
37-
baseDir = filepath.Join(".", "testdata")
38-
blockTestDir = filepath.Join(baseDir, "BlockchainTests")
39-
stateTestDir = filepath.Join(baseDir, "GeneralStateTests")
40-
legacyStateTestDir = filepath.Join(baseDir, "LegacyTests", "Constantinople", "GeneralStateTests")
41-
transactionTestDir = filepath.Join(baseDir, "TransactionTests")
42-
rlpTestDir = filepath.Join(baseDir, "RLPTests")
43-
difficultyTestDir = filepath.Join(baseDir, "BasicTests")
44-
executionSpecBlockchainTestDir = filepath.Join(".", "spec-tests", "fixtures", "blockchain_tests")
45-
executionSpecStateTestDir = filepath.Join(".", "spec-tests", "fixtures", "state_tests")
46-
benchmarksDir = filepath.Join(".", "evm-benchmarks", "benchmarks")
37+
baseDir = filepath.Join(".", "testdata")
38+
blockTestDir = filepath.Join(baseDir, "BlockchainTests")
39+
stateTestDir = filepath.Join(baseDir, "GeneralStateTests")
40+
legacyStateTestDir = filepath.Join(baseDir, "LegacyTests", "Constantinople", "GeneralStateTests")
41+
transactionTestDir = filepath.Join(baseDir, "TransactionTests")
42+
rlpTestDir = filepath.Join(baseDir, "RLPTests")
43+
difficultyTestDir = filepath.Join(baseDir, "BasicTests")
44+
executionSpecBlockchainTestDir = filepath.Join(".", "spec-tests", "fixtures", "blockchain_tests")
45+
executionSpecStateTestDir = filepath.Join(".", "spec-tests", "fixtures", "state_tests")
46+
executionSpecTransactionTestDir = filepath.Join(".", "spec-tests", "fixtures", "transaction_tests")
47+
benchmarksDir = filepath.Join(".", "evm-benchmarks", "benchmarks")
4748
)
4849

4950
func readJSON(reader io.Reader, value interface{}) error {

tests/transaction_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package tests
1919
import (
2020
"testing"
2121

22+
"github.com/ethereum/go-ethereum/common"
2223
"github.com/ethereum/go-ethereum/params"
2324
)
2425

@@ -42,10 +43,41 @@ func TestTransaction(t *testing.T) {
4243
// Geth accepts it, which is not a consensus issue since we use big.Int's
4344
// internally to calculate the cost
4445
txt.skipLoad("^ttValue/TransactionWithHighValueOverflow.json")
46+
47+
// The size of a create tx's initcode is only checked during the state
48+
// transition
49+
txt.skipLoad("^ttEIP3860/DataTestInitCodeTooBig.json")
50+
51+
// The following tests require the tx precheck to be performed
52+
// TODO(s1na): expose stateTransition.precheck publicly to be able to run these tests
53+
txt.skipLoad("^ttEIP1559/maxPriorityFeePerGass32BytesValue.json")
54+
txt.skipLoad("^ttEIP1559/maxPriorityFeePerGasOverflow.json")
55+
txt.skipLoad("^ttEIP1559/maxFeePerGas32BytesValue.json")
56+
txt.skipLoad("^ttEIP1559/maxFeePerGasOverflow.json")
57+
txt.skipLoad("^ttEIP1559/GasLimitPriceProductPlusOneOverflow.json")
58+
txt.skipLoad("^ttEIP1559/GasLimitPriceProductOverflow.json")
59+
4560
txt.walk(t, transactionTestDir, func(t *testing.T, name string, test *TransactionTest) {
4661
cfg := params.MainnetChainConfig
4762
if err := txt.checkFailure(t, test.Run(cfg)); err != nil {
4863
t.Error(err)
4964
}
5065
})
5166
}
67+
68+
func TestExecutionSpecTransaction(t *testing.T) {
69+
if !common.FileExist(executionSpecStateTestDir) {
70+
t.Skipf("directory %s does not exist", executionSpecStateTestDir)
71+
}
72+
st := new(testMatcher)
73+
74+
// Emptiness of authorization list is only validated during the tx precheck
75+
st.skipLoad("^prague/eip7702_set_code_tx/invalid_tx/empty_authorization_list.json")
76+
77+
st.walk(t, executionSpecTransactionTestDir, func(t *testing.T, name string, test *TransactionTest) {
78+
cfg := params.MainnetChainConfig
79+
if err := st.checkFailure(t, test.Run(cfg)); err != nil {
80+
t.Error(err)
81+
}
82+
})
83+
}

tests/transaction_test_util.go

Lines changed: 74 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -21,93 +21,120 @@ import (
2121

2222
"github.com/ethereum/go-ethereum/common"
2323
"github.com/ethereum/go-ethereum/common/hexutil"
24+
"github.com/ethereum/go-ethereum/common/math"
2425
"github.com/ethereum/go-ethereum/core"
2526
"github.com/ethereum/go-ethereum/core/types"
2627
"github.com/ethereum/go-ethereum/params"
27-
"github.com/ethereum/go-ethereum/rlp"
2828
)
2929

3030
// TransactionTest checks RLP decoding and sender derivation of transactions.
3131
type TransactionTest struct {
3232
Txbytes hexutil.Bytes `json:"txbytes"`
33-
Result ttResult
33+
Result map[string]*ttFork
3434
}
3535

36-
type ttResult struct {
37-
Byzantium ttFork
38-
Constantinople ttFork
39-
Istanbul ttFork
40-
EIP150 ttFork
41-
EIP158 ttFork
42-
Frontier ttFork
43-
Homestead ttFork
36+
type ttFork struct {
37+
Sender *common.UnprefixedAddress `json:"sender"`
38+
Hash *common.UnprefixedHash `json:"hash"`
39+
Exception *string `json:"exception"`
40+
IntrinsicGas math.HexOrDecimal64 `json:"intrinsicGas"`
4441
}
4542

46-
type ttFork struct {
47-
Sender common.UnprefixedAddress `json:"sender"`
48-
Hash common.UnprefixedHash `json:"hash"`
43+
func (tt *TransactionTest) validate() error {
44+
if tt.Txbytes == nil {
45+
return fmt.Errorf("missing txbytes")
46+
}
47+
for name, fork := range tt.Result {
48+
if err := tt.validateFork(fork); err != nil {
49+
return fmt.Errorf("invalid %s: %v", name, err)
50+
}
51+
}
52+
return nil
53+
}
54+
55+
func (tt *TransactionTest) validateFork(fork *ttFork) error {
56+
if fork == nil {
57+
return nil
58+
}
59+
if fork.Hash == nil && fork.Exception == nil {
60+
return fmt.Errorf("missing hash and exception")
61+
}
62+
if fork.Hash != nil && fork.Sender == nil {
63+
return fmt.Errorf("missing sender")
64+
}
65+
return nil
4966
}
5067

5168
func (tt *TransactionTest) Run(config *params.ChainConfig) error {
52-
validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead bool, isIstanbul bool) (*common.Address, *common.Hash, error) {
69+
if err := tt.validate(); err != nil {
70+
return err
71+
}
72+
validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead, isIstanbul, isShanghai bool) (sender common.Address, hash common.Hash, requiredGas uint64, err error) {
5373
tx := new(types.Transaction)
54-
if err := rlp.DecodeBytes(rlpData, tx); err != nil {
55-
return nil, nil, err
74+
if err = tx.UnmarshalBinary(rlpData); err != nil {
75+
return
5676
}
57-
sender, err := types.Sender(signer, tx)
77+
sender, err = types.Sender(signer, tx)
5878
if err != nil {
59-
return nil, nil, err
79+
return
6080
}
6181
// Intrinsic gas
62-
requiredGas, err := core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, isHomestead, isIstanbul, false)
82+
requiredGas, err = core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, isHomestead, isIstanbul, isShanghai)
6383
if err != nil {
64-
return nil, nil, err
84+
return
6585
}
6686
if requiredGas > tx.Gas() {
67-
return nil, nil, fmt.Errorf("insufficient gas ( %d < %d )", tx.Gas(), requiredGas)
87+
return sender, hash, 0, fmt.Errorf("insufficient gas ( %d < %d )", tx.Gas(), requiredGas)
6888
}
69-
h := tx.Hash()
70-
return &sender, &h, nil
89+
hash = tx.Hash()
90+
return sender, hash, requiredGas, nil
7191
}
72-
7392
for _, testcase := range []struct {
7493
name string
7594
signer types.Signer
76-
fork ttFork
95+
fork *ttFork
7796
isHomestead bool
7897
isIstanbul bool
98+
isShanghai bool
7999
}{
80-
{"Frontier", types.FrontierSigner{}, tt.Result.Frontier, false, false},
81-
{"Homestead", types.HomesteadSigner{}, tt.Result.Homestead, true, false},
82-
{"EIP150", types.HomesteadSigner{}, tt.Result.EIP150, true, false},
83-
{"EIP158", types.NewEIP155Signer(config.ChainID), tt.Result.EIP158, true, false},
84-
{"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Result.Byzantium, true, false},
85-
{"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Result.Constantinople, true, false},
86-
{"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Result.Istanbul, true, true},
100+
{"Frontier", types.FrontierSigner{}, tt.Result["Frontier"], false, false, false},
101+
{"Homestead", types.HomesteadSigner{}, tt.Result["Homestead"], true, false, false},
102+
{"EIP150", types.HomesteadSigner{}, tt.Result["EIP150"], true, false, false},
103+
{"EIP158", types.NewEIP155Signer(config.ChainID), tt.Result["EIP158"], true, false, false},
104+
{"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Result["Byzantium"], true, false, false},
105+
{"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Result["Constantinople"], true, false, false},
106+
{"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Result["Istanbul"], true, true, false},
107+
{"Berlin", types.NewEIP2930Signer(config.ChainID), tt.Result["Berlin"], true, true, false},
108+
{"London", types.NewLondonSigner(config.ChainID), tt.Result["London"], true, true, false},
109+
{"Paris", types.NewLondonSigner(config.ChainID), tt.Result["Paris"], true, true, false},
110+
{"Shanghai", types.NewLondonSigner(config.ChainID), tt.Result["Shanghai"], true, true, true},
111+
{"Cancun", types.NewCancunSigner(config.ChainID), tt.Result["Cancun"], true, true, true},
112+
{"Prague", types.NewPragueSigner(config.ChainID), tt.Result["Prague"], true, true, true},
87113
} {
88-
sender, txhash, err := validateTx(tt.Txbytes, testcase.signer, testcase.isHomestead, testcase.isIstanbul)
89-
90-
if testcase.fork.Sender == (common.UnprefixedAddress{}) {
91-
if err == nil {
92-
return fmt.Errorf("expected error, got none (address %v)[%v]", sender.String(), testcase.name)
93-
}
114+
if testcase.fork == nil {
94115
continue
95116
}
96-
// Should resolve the right address
117+
sender, hash, gas, err := validateTx(tt.Txbytes, testcase.signer, testcase.isHomestead, testcase.isIstanbul, testcase.isShanghai)
97118
if err != nil {
98-
return fmt.Errorf("got error, expected none: %v", err)
119+
if testcase.fork.Hash != nil {
120+
return fmt.Errorf("unexpected error: %v", err)
121+
}
122+
continue
123+
}
124+
if testcase.fork.Exception != nil {
125+
return fmt.Errorf("expected error %v, got none (%v)", *testcase.fork.Exception, err)
99126
}
100-
if sender == nil {
101-
return fmt.Errorf("sender was nil, should be %x", common.Address(testcase.fork.Sender))
127+
if common.Hash(*testcase.fork.Hash) != hash {
128+
return fmt.Errorf("hash mismatch: got %x, want %x", hash, common.Hash(*testcase.fork.Hash))
102129
}
103-
if *sender != common.Address(testcase.fork.Sender) {
130+
if common.Address(*testcase.fork.Sender) != sender {
104131
return fmt.Errorf("sender mismatch: got %x, want %x", sender, testcase.fork.Sender)
105132
}
106-
if txhash == nil {
107-
return fmt.Errorf("txhash was nil, should be %x", common.Hash(testcase.fork.Hash))
133+
if hash != common.Hash(*testcase.fork.Hash) {
134+
return fmt.Errorf("hash mismatch: got %x, want %x", hash, testcase.fork.Hash)
108135
}
109-
if *txhash != common.Hash(testcase.fork.Hash) {
110-
return fmt.Errorf("hash mismatch: got %x, want %x", *txhash, testcase.fork.Hash)
136+
if uint64(testcase.fork.IntrinsicGas) != gas {
137+
return fmt.Errorf("intrinsic gas mismatch: got %d, want %d", gas, uint64(testcase.fork.IntrinsicGas))
111138
}
112139
}
113140
return nil

0 commit comments

Comments
 (0)