tests: update ethereum/tests to v17.0 (#31381)

Get the re-filled tests (plus removal of outdated EIP-2537 tests)
This commit is contained in:
Sina M 2025-03-14 18:53:05 +01:00 committed by GitHub
parent 475e87cbc1
commit e3853e910a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 57 additions and 52 deletions

View file

@ -63,6 +63,9 @@ func TestBlockchain(t *testing.T) {
// With chain history removal, TDs become unavailable, this transition tests based on TTD are unrunnable // With chain history removal, TDs become unavailable, this transition tests based on TTD are unrunnable
bt.skipLoad(`.*bcArrowGlacierToParis/powToPosBlockRejection.json`) bt.skipLoad(`.*bcArrowGlacierToParis/powToPosBlockRejection.json`)
// This directory contains no test.
bt.skipLoad(`.*\.meta/.*`)
bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) { bt.walk(t, blockTestDir, func(t *testing.T, name string, test *BlockTest) {
execBlockTest(t, bt, test) execBlockTest(t, bt, test)
}) })

View file

@ -54,18 +54,9 @@ func initMatcher(st *testMatcher) {
// Uses 1GB RAM per tested fork // Uses 1GB RAM per tested fork
st.skipLoad(`^stStaticCall/static_Call1MB`) st.skipLoad(`^stStaticCall/static_Call1MB`)
// Out-of-date EIP-2537 tests
// TODO (@s1na) reenable in the future
st.skipLoad(`^stEIP2537/`)
// Broken tests: // Broken tests:
// EOF is not part of cancun // EOF is not part of cancun
st.skipLoad(`^stEOF/`) st.skipLoad(`^stEOF/`)
// The tests under Pyspecs are the ones that are published as execution-spec tests.
// We run these tests separately, no need to _also_ run them as part of the
// reference tests.
st.skipLoad(`^Pyspecs/`)
} }
func TestState(t *testing.T) { func TestState(t *testing.T) {

@ -1 +1 @@
Subproject commit faf33b471465d3c6cdc3d04fbd690895f78d33f2 Subproject commit 81862e4848585a438d64f911a19b3825f0f4cd95

View file

@ -20,7 +20,6 @@ import (
"testing" "testing"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/params"
) )
func TestTransaction(t *testing.T) { func TestTransaction(t *testing.T) {
@ -58,8 +57,7 @@ func TestTransaction(t *testing.T) {
txt.skipLoad("^ttEIP1559/GasLimitPriceProductOverflow.json") txt.skipLoad("^ttEIP1559/GasLimitPriceProductOverflow.json")
txt.walk(t, transactionTestDir, func(t *testing.T, name string, test *TransactionTest) { txt.walk(t, transactionTestDir, func(t *testing.T, name string, test *TransactionTest) {
cfg := params.MainnetChainConfig if err := txt.checkFailure(t, test.Run()); err != nil {
if err := txt.checkFailure(t, test.Run(cfg)); err != nil {
t.Error(err) t.Error(err)
} }
}) })
@ -75,8 +73,7 @@ func TestExecutionSpecTransaction(t *testing.T) {
st.skipLoad("^prague/eip7702_set_code_tx/invalid_tx/empty_authorization_list.json") st.skipLoad("^prague/eip7702_set_code_tx/invalid_tx/empty_authorization_list.json")
st.walk(t, executionSpecTransactionTestDir, func(t *testing.T, name string, test *TransactionTest) { st.walk(t, executionSpecTransactionTestDir, func(t *testing.T, name string, test *TransactionTest) {
cfg := params.MainnetChainConfig if err := st.checkFailure(t, test.Run()); err != nil {
if err := st.checkFailure(t, test.Run(cfg)); err != nil {
t.Error(err) t.Error(err)
} }
}) })

View file

@ -18,6 +18,7 @@ package tests
import ( import (
"fmt" "fmt"
"math/big"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/common/hexutil"
@ -65,11 +66,11 @@ func (tt *TransactionTest) validateFork(fork *ttFork) error {
return nil return nil
} }
func (tt *TransactionTest) Run(config *params.ChainConfig) error { func (tt *TransactionTest) Run() error {
if err := tt.validate(); err != nil { if err := tt.validate(); err != nil {
return err return err
} }
validateTx := func(rlpData hexutil.Bytes, signer types.Signer, isHomestead, isIstanbul, isShanghai bool) (sender common.Address, hash common.Hash, requiredGas uint64, err error) { validateTx := func(rlpData hexutil.Bytes, signer types.Signer, rules *params.Rules) (sender common.Address, hash common.Hash, requiredGas uint64, err error) {
tx := new(types.Transaction) tx := new(types.Transaction)
if err = tx.UnmarshalBinary(rlpData); err != nil { if err = tx.UnmarshalBinary(rlpData); err != nil {
return return
@ -79,62 +80,75 @@ func (tt *TransactionTest) Run(config *params.ChainConfig) error {
return return
} }
// Intrinsic gas // Intrinsic gas
requiredGas, err = core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, isHomestead, isIstanbul, isShanghai) requiredGas, err = core.IntrinsicGas(tx.Data(), tx.AccessList(), tx.SetCodeAuthorizations(), tx.To() == nil, rules.IsHomestead, rules.IsIstanbul, rules.IsShanghai)
if err != nil { if err != nil {
return return
} }
if requiredGas > tx.Gas() { if requiredGas > tx.Gas() {
return sender, hash, 0, fmt.Errorf("insufficient gas ( %d < %d )", tx.Gas(), requiredGas) return sender, hash, 0, fmt.Errorf("insufficient gas ( %d < %d )", tx.Gas(), requiredGas)
} }
if rules.IsPrague {
var floorDataGas uint64
floorDataGas, err = core.FloorDataGas(tx.Data())
if err != nil {
return
}
if tx.Gas() < floorDataGas {
return sender, hash, 0, fmt.Errorf("%w: have %d, want %d", core.ErrFloorDataGas, tx.Gas(), floorDataGas)
}
}
hash = tx.Hash() hash = tx.Hash()
return sender, hash, requiredGas, nil return sender, hash, requiredGas, nil
} }
for _, testcase := range []struct { for _, testcase := range []struct {
name string name string
signer types.Signer isMerge bool
fork *ttFork
isHomestead bool
isIstanbul bool
isShanghai bool
}{ }{
{"Frontier", types.FrontierSigner{}, tt.Result["Frontier"], false, false, false}, {"Frontier", false},
{"Homestead", types.HomesteadSigner{}, tt.Result["Homestead"], true, false, false}, {"Homestead", false},
{"EIP150", types.HomesteadSigner{}, tt.Result["EIP150"], true, false, false}, {"EIP150", false},
{"EIP158", types.NewEIP155Signer(config.ChainID), tt.Result["EIP158"], true, false, false}, {"EIP158", false},
{"Byzantium", types.NewEIP155Signer(config.ChainID), tt.Result["Byzantium"], true, false, false}, {"Byzantium", false},
{"Constantinople", types.NewEIP155Signer(config.ChainID), tt.Result["Constantinople"], true, false, false}, {"Constantinople", false},
{"Istanbul", types.NewEIP155Signer(config.ChainID), tt.Result["Istanbul"], true, true, false}, {"Istanbul", false},
{"Berlin", types.NewEIP2930Signer(config.ChainID), tt.Result["Berlin"], true, true, false}, {"Berlin", false},
{"London", types.NewLondonSigner(config.ChainID), tt.Result["London"], true, true, false}, {"London", false},
{"Paris", types.NewLondonSigner(config.ChainID), tt.Result["Paris"], true, true, false}, {"Paris", true},
{"Shanghai", types.NewLondonSigner(config.ChainID), tt.Result["Shanghai"], true, true, true}, {"Shanghai", true},
{"Cancun", types.NewCancunSigner(config.ChainID), tt.Result["Cancun"], true, true, true}, {"Cancun", true},
{"Prague", types.NewPragueSigner(config.ChainID), tt.Result["Prague"], true, true, true}, {"Prague", true},
} { } {
if testcase.fork == nil { expected := tt.Result[testcase.name]
if expected == nil {
continue continue
} }
sender, hash, gas, err := validateTx(tt.Txbytes, testcase.signer, testcase.isHomestead, testcase.isIstanbul, testcase.isShanghai) config, ok := Forks[testcase.name]
if !ok || config == nil {
return UnsupportedForkError{Name: testcase.name}
}
var (
rules = config.Rules(new(big.Int), testcase.isMerge, 0)
signer = types.MakeSigner(config, new(big.Int), 0)
)
sender, hash, gas, err := validateTx(tt.Txbytes, signer, &rules)
if err != nil { if err != nil {
if testcase.fork.Hash != nil { if expected.Hash != nil {
return fmt.Errorf("unexpected error: %v", err) return fmt.Errorf("unexpected error fork %s: %v", testcase.name, err)
} }
continue continue
} }
if testcase.fork.Exception != nil { if expected.Exception != nil {
return fmt.Errorf("expected error %v, got none (%v)", *testcase.fork.Exception, err) return fmt.Errorf("expected error %v, got none (%v), fork %s", *expected.Exception, err, testcase.name)
} }
if common.Hash(*testcase.fork.Hash) != hash { if common.Hash(*expected.Hash) != hash {
return fmt.Errorf("hash mismatch: got %x, want %x", hash, common.Hash(*testcase.fork.Hash)) return fmt.Errorf("hash mismatch: got %x, want %x", hash, common.Hash(*expected.Hash))
} }
if common.Address(*testcase.fork.Sender) != sender { if common.Address(*expected.Sender) != sender {
return fmt.Errorf("sender mismatch: got %x, want %x", sender, testcase.fork.Sender) return fmt.Errorf("sender mismatch: got %x, want %x", sender, expected.Sender)
} }
if hash != common.Hash(*testcase.fork.Hash) { if uint64(expected.IntrinsicGas) != gas {
return fmt.Errorf("hash mismatch: got %x, want %x", hash, testcase.fork.Hash) return fmt.Errorf("intrinsic gas mismatch: got %d, want %d", gas, uint64(expected.IntrinsicGas))
}
if uint64(testcase.fork.IntrinsicGas) != gas {
return fmt.Errorf("intrinsic gas mismatch: got %d, want %d", gas, uint64(testcase.fork.IntrinsicGas))
} }
} }
return nil return nil