diff --git a/core/error.go b/core/error.go index 71a7e9be5f..82f7ddcf5d 100644 --- a/core/error.go +++ b/core/error.go @@ -118,12 +118,13 @@ var ( // -- EIP-7702 errors -- // Message validation errors: - ErrEmptyAuthList = errors.New("EIP-7702 transaction with empty auth list") - ErrSetCodeTxCreate = errors.New("EIP-7702 transaction cannot be used to create contract") - ErrAuthSignatureVeryHigh = errors.New("EIP-7702 authorization with R or S value greater than 2^256 - 1") + ErrEmptyAuthList = errors.New("EIP-7702 transaction with empty auth list") + ErrSetCodeTxCreate = errors.New("EIP-7702 transaction cannot be used to create contract") +) - // EIP-7702 state transition errors: - // Note these are just informational, and do not cause tx execution abort. +// EIP-7702 state transition errors. +// Note these are just informational, and do not cause tx execution abort. +var ( ErrAuthorizationWrongChainID = errors.New("EIP-7702 authorization chain ID mismatch") ErrAuthorizationNonceOverflow = errors.New("EIP-7702 authorization nonce > 64 bit") ErrAuthorizationInvalidSignature = errors.New("EIP-7702 authorization has invalid signature") diff --git a/core/state_processor_test.go b/core/state_processor_test.go index 9a4fd1161c..e8d8c2ca2e 100644 --- a/core/state_processor_test.go +++ b/core/state_processor_test.go @@ -63,6 +63,7 @@ func TestStateProcessorErrors(t *testing.T) { TerminalTotalDifficulty: big.NewInt(0), ShanghaiTime: new(uint64), CancunTime: new(uint64), + PragueTime: new(uint64), } signer = types.LatestSigner(config) key1, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291") @@ -110,6 +111,21 @@ func TestStateProcessorErrors(t *testing.T) { } return tx } + var mkSetCodeTx = func(nonce uint64, to common.Address, gasLimit uint64, gasTipCap, gasFeeCap *big.Int, authlist []types.Authorization) *types.Transaction { + tx, err := types.SignTx(types.NewTx(&types.SetCodeTx{ + Nonce: nonce, + GasTipCap: uint256.MustFromBig(gasTipCap), + GasFeeCap: uint256.MustFromBig(gasFeeCap), + Gas: gasLimit, + To: to, + Value: new(uint256.Int), + AuthList: authlist, + }), signer, key1) + if err != nil { + t.Fatal(err) + } + return tx + } { // Tests against a 'recent' chain definition var ( @@ -251,6 +267,13 @@ func TestStateProcessorErrors(t *testing.T) { }, want: "could not apply tx 0 [0x6c11015985ce82db691d7b2d017acda296db88b811c3c60dc71449c76256c716]: max fee per gas less than block base fee: address 0x71562b71999873DB5b286dF957af199Ec94617F7, maxFeePerGas: 1, baseFee: 875000000", }, + { // ErrEmptyAuthList + txs: []*types.Transaction{ + mkSetCodeTx(0, common.Address{}, params.TxGas, big.NewInt(params.InitialBaseFee), big.NewInt(params.InitialBaseFee), nil), + }, + want: "could not apply tx 0 [0xc18d10f4c809dbdfa1a074c3300de9bc4b7f16a20f0ec667f6f67312b71b956a]: EIP-7702 transaction with empty auth list (sender 0x71562b71999873DB5b286dF957af199Ec94617F7)", + }, + // ErrSetCodeTxCreate cannot be tested: it is impossible to create a SetCode-tx with nil `to`. } { block := GenerateBadBlock(gspec.ToBlock(), beacon.New(ethash.NewFaker()), tt.txs, gspec.Config, false) _, err := blockchain.InsertChain(types.Blocks{block}) diff --git a/core/state_transition.go b/core/state_transition.go index 851725c5f9..58728e470e 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -379,14 +379,6 @@ func (st *stateTransition) preCheck() error { if len(msg.AuthList) == 0 { return fmt.Errorf("%w (sender %v)", ErrEmptyAuthList, msg.From) } - for i, auth := range msg.AuthList { - switch { - case auth.R.BitLen() > 256: - return fmt.Errorf("%w: address %v, authorization %d", ErrAuthSignatureVeryHigh, msg.From.Hex(), i) - case auth.S.BitLen() > 256: - return fmt.Errorf("%w: address %v, authorization %d", ErrAuthSignatureVeryHigh, msg.From.Hex(), i) - } - } } return st.buyGas() }