core, tests: fix

This commit is contained in:
Gary Rong 2026-07-13 11:14:38 +08:00
parent 46256649a3
commit e7ad8707c7
4 changed files with 18 additions and 9 deletions

View file

@ -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 // Since Amsterdam, the precheck has been folded into the parent frame
// due to account-creation determination, so skip the duplicate check here. // due to account-creation determination, so skip the duplicate check here.
if !evm.chainRules.IsAmsterdam { if !evm.chainRules.IsAmsterdam {
evm.createFramePreCheck(caller, value) err = evm.createFramePreCheck(caller, value)
} }
if evm.Config.Tracer != nil { if evm.Config.Tracer != nil {
evm.captureBegin(evm.depth, typ, caller, address, code, gas, value.ToBig()) evm.captureBegin(evm.depth, typ, caller, address, code, gas, value.ToBig())

View file

@ -94,7 +94,6 @@ func TestExecutionSpecBlocktests(t *testing.T) {
// Broken tests // Broken tests
bt.skipLoad(`.*eip7610_create_collision/initcollision/.*`) bt.skipLoad(`.*eip7610_create_collision/initcollision/.*`)
bt.skipLoad(`.*eip7610_create_collision/revert_in_create/.*`) 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) { bt.walk(t, executionSpecBlockchainTestDir, func(t *testing.T, name string, test *BlockTest) {
execBlockTest(t, bt, test) execBlockTest(t, bt, test)

View file

@ -20,7 +20,7 @@ func (s stTransaction) MarshalJSON() ([]byte, error) {
GasPrice *math.HexOrDecimal256 `json:"gasPrice"` GasPrice *math.HexOrDecimal256 `json:"gasPrice"`
MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"`
MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"`
Nonce math.HexOrDecimal64 `json:"nonce"` Nonce *math.HexOrDecimal256 `json:"nonce"`
To string `json:"to"` To string `json:"to"`
Data []string `json:"data"` Data []string `json:"data"`
AccessLists []*types.AccessList `json:"accessLists,omitempty"` AccessLists []*types.AccessList `json:"accessLists,omitempty"`
@ -36,7 +36,7 @@ func (s stTransaction) MarshalJSON() ([]byte, error) {
enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice) enc.GasPrice = (*math.HexOrDecimal256)(s.GasPrice)
enc.MaxFeePerGas = (*math.HexOrDecimal256)(s.MaxFeePerGas) enc.MaxFeePerGas = (*math.HexOrDecimal256)(s.MaxFeePerGas)
enc.MaxPriorityFeePerGas = (*math.HexOrDecimal256)(s.MaxPriorityFeePerGas) enc.MaxPriorityFeePerGas = (*math.HexOrDecimal256)(s.MaxPriorityFeePerGas)
enc.Nonce = math.HexOrDecimal64(s.Nonce) enc.Nonce = (*math.HexOrDecimal256)(s.Nonce)
enc.To = s.To enc.To = s.To
enc.Data = s.Data enc.Data = s.Data
enc.AccessLists = s.AccessLists enc.AccessLists = s.AccessLists
@ -61,7 +61,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error {
GasPrice *math.HexOrDecimal256 `json:"gasPrice"` GasPrice *math.HexOrDecimal256 `json:"gasPrice"`
MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"` MaxFeePerGas *math.HexOrDecimal256 `json:"maxFeePerGas"`
MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"` MaxPriorityFeePerGas *math.HexOrDecimal256 `json:"maxPriorityFeePerGas"`
Nonce *math.HexOrDecimal64 `json:"nonce"` Nonce *math.HexOrDecimal256 `json:"nonce"`
To *string `json:"to"` To *string `json:"to"`
Data []string `json:"data"` Data []string `json:"data"`
AccessLists []*types.AccessList `json:"accessLists,omitempty"` AccessLists []*types.AccessList `json:"accessLists,omitempty"`
@ -87,7 +87,7 @@ func (s *stTransaction) UnmarshalJSON(input []byte) error {
s.MaxPriorityFeePerGas = (*big.Int)(dec.MaxPriorityFeePerGas) s.MaxPriorityFeePerGas = (*big.Int)(dec.MaxPriorityFeePerGas)
} }
if dec.Nonce != nil { if dec.Nonce != nil {
s.Nonce = uint64(*dec.Nonce) s.Nonce = (*big.Int)(dec.Nonce)
} }
if dec.To != nil { if dec.To != nil {
s.To = *dec.To s.To = *dec.To

View file

@ -116,7 +116,7 @@ type stTransaction struct {
GasPrice *big.Int `json:"gasPrice"` GasPrice *big.Int `json:"gasPrice"`
MaxFeePerGas *big.Int `json:"maxFeePerGas"` MaxFeePerGas *big.Int `json:"maxFeePerGas"`
MaxPriorityFeePerGas *big.Int `json:"maxPriorityFeePerGas"` MaxPriorityFeePerGas *big.Int `json:"maxPriorityFeePerGas"`
Nonce uint64 `json:"nonce"` Nonce *big.Int `json:"nonce"`
To string `json:"to"` To string `json:"to"`
Data []string `json:"data"` Data []string `json:"data"`
AccessLists []*types.AccessList `json:"accessLists,omitempty"` AccessLists []*types.AccessList `json:"accessLists,omitempty"`
@ -133,7 +133,7 @@ type stTransactionMarshaling struct {
GasPrice *math.HexOrDecimal256 GasPrice *math.HexOrDecimal256
MaxFeePerGas *math.HexOrDecimal256 MaxFeePerGas *math.HexOrDecimal256
MaxPriorityFeePerGas *math.HexOrDecimal256 MaxPriorityFeePerGas *math.HexOrDecimal256
Nonce math.HexOrDecimal64 Nonce *math.HexOrDecimal256
GasLimit []math.HexOrDecimal64 GasLimit []math.HexOrDecimal64
PrivateKey hexutil.Bytes PrivateKey hexutil.Bytes
BlobGasFeeCap *math.HexOrDecimal256 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) { 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 var from common.Address
// If 'sender' field is present, use that // If 'sender' field is present, use that
if tx.Sender != nil { if tx.Sender != nil {
@ -481,7 +491,7 @@ func (tx *stTransaction) toMessage(ps stPostState, baseFee *big.Int) (*core.Mess
msg := &core.Message{ msg := &core.Message{
From: from, From: from,
To: to, To: to,
Nonce: tx.Nonce, Nonce: nonce,
Value: uint256.MustFromBig(value), Value: uint256.MustFromBig(value),
GasLimit: gasLimit, GasLimit: gasLimit,
GasPrice: uint256.MustFromBig(gasPrice), GasPrice: uint256.MustFromBig(gasPrice),