diff --git a/core/error.go b/core/error.go index 885acc8f24..f1cc7d8c03 100644 --- a/core/error.go +++ b/core/error.go @@ -117,12 +117,10 @@ var ( // -- EIP-7702 errors -- - // ErrEmptyAuthList is returned if a set code transaction has an empty auth list. - ErrEmptyAuthList = errors.New("set code transaction with empty auth list") - - // ErrAuthSignatureVeryHigh is returned if a set code transaction has a - // signature with R or S larger than 2^256-1. - ErrAuthSignatureVeryHigh = errors.New("set code transaction has authorization with R or S value greater than 2^256 - 1") + // 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") // EIP-7702 state transition errors: ErrAuthorizationWrongChainID = errors.New("EIP-7702 authorization chain ID mismatch") diff --git a/core/state_transition.go b/core/state_transition.go index 43eb3b6d17..a8b600d60f 100644 --- a/core/state_transition.go +++ b/core/state_transition.go @@ -372,12 +372,20 @@ func (st *stateTransition) preCheck() error { } } // Check that EIP-7702 authorization list signatures are well formed. - 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) + if msg.AuthList != nil { + if msg.To == nil { + return fmt.Errorf("%w (sender %v)", ErrSetCodeTxCreate, msg.From) + } + 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() @@ -451,11 +459,6 @@ func (st *stateTransition) execute() (*ExecutionResult, error) { return nil, fmt.Errorf("%w: code size %v limit %v", ErrMaxInitCodeSizeExceeded, len(msg.Data), params.MaxInitCodeSize) } - // If an authorization list exists, verify it is not empty. - if msg.AuthList != nil && len(msg.AuthList) == 0 { - return nil, fmt.Errorf("%w: address %v", ErrEmptyAuthList, msg.From.Hex()) - } - // Execute the preparatory steps for state transition which includes: // - prepare accessList(post-berlin) // - reset transient storage(eip 1153)