From 14d1dd409bc124fd113c38f3070ac2fa7b0cd09c Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 27 Jul 2021 16:41:04 +0200 Subject: [PATCH 1/3] tests: update tests to 9.0.4 for london --- tests/block_test_util.go | 18 +++++++++--------- tests/gen_btheader.go | 10 +++++----- tests/testdata | 2 +- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/tests/block_test_util.go b/tests/block_test_util.go index c9c0afb1ba25..bcf861e09b9c 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -85,17 +85,17 @@ type btHeader struct { GasLimit uint64 GasUsed uint64 Timestamp uint64 - BaseFee *big.Int + BaseFeePerGas *big.Int } type btHeaderMarshaling struct { - ExtraData hexutil.Bytes - Number *math.HexOrDecimal256 - Difficulty *math.HexOrDecimal256 - GasLimit math.HexOrDecimal64 - GasUsed math.HexOrDecimal64 - Timestamp math.HexOrDecimal64 - BaseFee *math.HexOrDecimal256 + ExtraData hexutil.Bytes + Number *math.HexOrDecimal256 + Difficulty *math.HexOrDecimal256 + GasLimit math.HexOrDecimal64 + GasUsed math.HexOrDecimal64 + Timestamp math.HexOrDecimal64 + BaseFeePerGas *math.HexOrDecimal256 } func (t *BlockTest) Run(snapshotter bool) error { @@ -170,7 +170,7 @@ func (t *BlockTest) genesis(config *params.ChainConfig) *core.Genesis { Mixhash: t.json.Genesis.MixHash, Coinbase: t.json.Genesis.Coinbase, Alloc: t.json.Pre, - BaseFee: t.json.Genesis.BaseFee, + BaseFee: t.json.Genesis.BaseFeePerGas, } } diff --git a/tests/gen_btheader.go b/tests/gen_btheader.go index 07df1ecb3657..4387f8db41c8 100644 --- a/tests/gen_btheader.go +++ b/tests/gen_btheader.go @@ -33,7 +33,7 @@ func (b btHeader) MarshalJSON() ([]byte, error) { GasLimit math.HexOrDecimal64 GasUsed math.HexOrDecimal64 Timestamp math.HexOrDecimal64 - BaseFee *math.HexOrDecimal256 + BaseFeePerGas *math.HexOrDecimal256 } var enc btHeader enc.Bloom = b.Bloom @@ -52,7 +52,7 @@ func (b btHeader) MarshalJSON() ([]byte, error) { enc.GasLimit = math.HexOrDecimal64(b.GasLimit) enc.GasUsed = math.HexOrDecimal64(b.GasUsed) enc.Timestamp = math.HexOrDecimal64(b.Timestamp) - enc.BaseFee = (*math.HexOrDecimal256)(b.BaseFee) + enc.BaseFeePerGas = (*math.HexOrDecimal256)(b.BaseFeePerGas) return json.Marshal(&enc) } @@ -75,7 +75,7 @@ func (b *btHeader) UnmarshalJSON(input []byte) error { GasLimit *math.HexOrDecimal64 GasUsed *math.HexOrDecimal64 Timestamp *math.HexOrDecimal64 - BaseFee *math.HexOrDecimal256 + BaseFeePerGas *math.HexOrDecimal256 } var dec btHeader if err := json.Unmarshal(input, &dec); err != nil { @@ -129,8 +129,8 @@ func (b *btHeader) UnmarshalJSON(input []byte) error { if dec.Timestamp != nil { b.Timestamp = uint64(*dec.Timestamp) } - if dec.BaseFee != nil { - b.BaseFee = (*big.Int)(dec.BaseFee) + if dec.BaseFeePerGas != nil { + b.BaseFeePerGas = (*big.Int)(dec.BaseFeePerGas) } return nil } diff --git a/tests/testdata b/tests/testdata index fa0ab110f3f4..5d534e37b80e 160000 --- a/tests/testdata +++ b/tests/testdata @@ -1 +1 @@ -Subproject commit fa0ab110f3f45d1f6786f978ea596a18ecbe8275 +Subproject commit 5d534e37b80e9310e8c7751f805ca481a451123e From 94ea8e2cda4dbf0104ad972a972ab4afb02585ce Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 27 Jul 2021 23:05:58 +0200 Subject: [PATCH 2/3] tests: added ExpectException to tests, signer validation --- tests/state_test.go | 10 +++++++++- tests/state_test_util.go | 21 ++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/tests/state_test.go b/tests/state_test.go index 2ed98b650987..a42d9b666a92 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -64,10 +64,14 @@ func TestState(t *testing.T) { for _, subtest := range test.Subtests() { subtest := subtest key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index) - + fmt.Println(name) t.Run(key+"/trie", func(t *testing.T) { withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error { _, _, err := test.Run(subtest, vmconfig, false) + if err != nil && len(test.json.Post[subtest.Fork][subtest.Index].ExpectException) > 0 { + // Ignore expected errors (TODO MariusVanDerWijden check error string) + return nil + } return st.checkFailure(t, err) }) }) @@ -79,6 +83,10 @@ func TestState(t *testing.T) { return err } } + if err != nil && len(test.json.Post[subtest.Fork][subtest.Index].ExpectException) > 0 { + // Ignore expected errors (TODO MariusVanDerWijden check error string) + return nil + } return st.checkFailure(t, err) }) }) diff --git a/tests/state_test_util.go b/tests/state_test_util.go index 97fd3fb6a89e..4f57fee8909b 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -65,9 +65,11 @@ type stJSON struct { } type stPostState struct { - Root common.UnprefixedHash `json:"hash"` - Logs common.UnprefixedHash `json:"logs"` - Indexes struct { + Root common.UnprefixedHash `json:"hash"` + Logs common.UnprefixedHash `json:"logs"` + TxBytes hexutil.Bytes `json:"txbytes"` + ExpectException string `json:"expectException"` + Indexes struct { Data int `json:"data"` Gas int `json:"gas"` Value int `json:"value"` @@ -198,6 +200,19 @@ func (t *StateTest) RunNoVerify(subtest StateSubtest, vmconfig vm.Config, snapsh return nil, nil, common.Hash{}, err } + // Try to recover tx with current signer + if len(post.TxBytes) != 0 { + var ttx types.Transaction + err := ttx.UnmarshalBinary(post.TxBytes) + if err != nil { + return nil, nil, common.Hash{}, err + } + + if _, err := types.Sender(types.LatestSigner(config), &ttx); err != nil { + return nil, nil, common.Hash{}, err + } + } + // Prepare the EVM. txContext := core.NewEVMTxContext(msg) context := core.NewEVMBlockContext(block.Header(), nil, &t.json.Env.Coinbase) From 428a3bbf88078cf2215ac70ee0b6476a6bb2129c Mon Sep 17 00:00:00 2001 From: Marius van der Wijden Date: Tue, 27 Jul 2021 23:12:32 +0200 Subject: [PATCH 3/3] tests: rem nit --- tests/state_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/state_test.go b/tests/state_test.go index a42d9b666a92..c2ca0e8d6948 100644 --- a/tests/state_test.go +++ b/tests/state_test.go @@ -64,7 +64,7 @@ func TestState(t *testing.T) { for _, subtest := range test.Subtests() { subtest := subtest key := fmt.Sprintf("%s/%d", subtest.Fork, subtest.Index) - fmt.Println(name) + t.Run(key+"/trie", func(t *testing.T) { withTrace(t, test.gasLimit(subtest), func(vmconfig vm.Config) error { _, _, err := test.Run(subtest, vmconfig, false)