From e7ad8707c74410125a84ce6394f0f1d5cc1c0974 Mon Sep 17 00:00:00 2001 From: Gary Rong Date: Mon, 13 Jul 2026 11:14:38 +0800 Subject: [PATCH] core, tests: fix --- core/vm/evm.go | 2 +- tests/block_test.go | 1 - tests/gen_sttransaction.go | 8 ++++---- tests/state_test_util.go | 16 +++++++++++++--- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/core/vm/evm.go b/core/vm/evm.go index 49660b19bd..ca347a9db9 100644 --- a/core/vm/evm.go +++ b/core/vm/evm.go @@ -524,7 +524,7 @@ func (evm *EVM) create(caller common.Address, code []byte, gas GasBudget, value // Since Amsterdam, the precheck has been folded into the parent frame // due to account-creation determination, so skip the duplicate check here. if !evm.chainRules.IsAmsterdam { - evm.createFramePreCheck(caller, value) + err = evm.createFramePreCheck(caller, value) } if evm.Config.Tracer != nil { evm.captureBegin(evm.depth, typ, caller, address, code, gas, value.ToBig()) diff --git a/tests/block_test.go b/tests/block_test.go index 8c1a7ace0f..a054e59e0f 100644 --- a/tests/block_test.go +++ b/tests/block_test.go @@ -94,7 +94,6 @@ func TestExecutionSpecBlocktests(t *testing.T) { // Broken tests bt.skipLoad(`.*eip7610_create_collision/initcollision/.*`) bt.skipLoad(`.*eip7610_create_collision/revert_in_create/.*`) - bt.skipLoad(`.*stRandom2/random_statetest642/.*`) bt.walk(t, executionSpecBlockchainTestDir, func(t *testing.T, name string, test *BlockTest) { execBlockTest(t, bt, test) diff --git a/tests/gen_sttransaction.go b/tests/gen_sttransaction.go index b25ce76166..31ff38bede 100644 --- a/tests/gen_sttransaction.go +++ b/tests/gen_sttransaction.go @@ -20,7 +20,7 @@ func (s stTransaction) MarshalJSON() ([]byte, error) { GasPrice *math.HexOrDecimal256 `json:"gasPrice"` MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` - Nonce math.HexOrDecimal64 `json:"nonce"` + Nonce *math.HexOrDecimal256 `json:"nonce"` To string `json:"to"` Data []string `json:"data"` AccessLists []*types.AccessList `json:"accessLists,omitempty"` @@ -36,7 +36,7 @@ func (s stTransaction) MarshalJSON() ([]byte, error) { enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice) enc.MaxFeePerGas = (*math.HexOrDecimal256)(s.MaxFeePerGas) enc.MaxPriorityFeePerGas = (*math.HexOrDecimal256)(s.MaxPriorityFeePerGas) - enc.Nonce = math.HexOrDecimal64(s.Nonce) + enc.Nonce = (*math.HexOrDecimal256)(s.Nonce) enc.To = s.To enc.Data = s.Data enc.AccessLists = s.AccessLists @@ -61,7 +61,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error { GasPrice *math.HexOrDecimal256 `json:"gasPrice"` MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` - Nonce *math.HexOrDecimal64 `json:"nonce"` + Nonce *math.HexOrDecimal256 `json:"nonce"` To *string `json:"to"` Data []string `json:"data"` AccessLists []*types.AccessList `json:"accessLists,omitempty"` @@ -87,7 +87,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error { s.MaxPriorityFeePerGas = (*big.Int)(dec.MaxPriorityFeePerGas) } if dec.Nonce != nil { - s.Nonce = uint64(*dec.Nonce) + s.Nonce = (*big.Int)(dec.Nonce) } if dec.To != nil { s.To = *dec.To diff --git a/tests/state_test_util.go b/tests/state_test_util.go index c41e680463..6e1fd1b634 100644 --- a/tests/state_test_util.go +++ b/tests/state_test_util.go @@ -116,7 +116,7 @@ type stTransaction struct { GasPrice *big.Int `json:"gasPrice"` MaxFeePerGas *big.Int `json:"maxFeePerGas"` MaxPriorityFeePerGas *big.Int `json:"maxPriorityFeePerGas"` - Nonce uint64 `json:"nonce"` + Nonce *big.Int `json:"nonce"` To string `json:"to"` Data []string `json:"data"` AccessLists []*types.AccessList `json:"accessLists,omitempty"` @@ -133,7 +133,7 @@ type stTransactionMarshaling struct { GasPrice *math.HexOrDecimal256 MaxFeePerGas *math.HexOrDecimal256 MaxPriorityFeePerGas *math.HexOrDecimal256 - Nonce math.HexOrDecimal64 + Nonce *math.HexOrDecimal256 GasLimit []math.HexOrDecimal64 PrivateKey hexutil.Bytes BlobGasFeeCap *math.HexOrDecimal256 @@ -392,6 +392,16 @@ func (t *StateTest) genesis(config *params.ChainConfig) *core.Genesis { } func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Message, error) { + // The nonce is parsed as an arbitrary-precision integer so that fixtures + // probing the EIP-2681 limit can be loaded; such a transaction can never + // be RLP-decoded and must be rejected here. + var nonce uint64 + if tx.Nonce != nil { + if !tx.Nonce.IsUint64() { + return nil, fmt.Errorf("nonce %v exceeds 2^64-1 (EIP-2681)", tx.Nonce) + } + nonce = tx.Nonce.Uint64() + } var from common.Address // If 'sender' field is present, use that if tx.Sender != nil { @@ -481,7 +491,7 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Mess msg := &core.Message{ From: from, To: to, - Nonce: tx.Nonce, + Nonce: nonce, Value: uint256.MustFromBig(value), GasLimit: gasLimit, GasPrice: uint256.MustFromBig(gasPrice),