internal/ethapi: reject gasPrice together with authorizationList

TransactionArgs.ToTransaction downgrades usedType to LegacyTxType
whenever GasPrice is set, which silently drops an EIP-7702
authorization list because a legacy transaction cannot carry one.
Callers of eth_sendTransaction, eth_signTransaction and
eth_fillTransaction could therefore receive a plain legacy
transaction even though the requested delegation update was not
included.

Reject the combination in setFeeDefaults, mirroring the existing
gasPrice/EIP-1559 guard, so the request fails explicitly instead of
producing a transaction that omits the authorization list.
This commit is contained in:
ozpool 2026-07-08 11:48:15 +05:30
parent 4d2181aa41
commit 25587176ce
No known key found for this signature in database
2 changed files with 14 additions and 0 deletions

View file

@ -195,6 +195,12 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head
if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
return errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
}
// An EIP-7702 set-code transaction cannot be a legacy transaction, so gasPrice
// is incompatible with an authorization list. Reject the combination instead of
// silently dropping the authorization list in ToTransaction.
if args.GasPrice != nil && args.AuthorizationList != nil {
return errors.New("both gasPrice and authorizationList specified")
}
// If the tx has completely specified a fee mechanism, no default is needed.
// This allows users who are not yet synced past London to get defaults for
// other tx values. See https://github.com/ethereum/go-ethereum/pull/23274

View file

@ -58,6 +58,7 @@ func TestSetFeeDefaults(t *testing.T) {
fortytwo = (*hexutil.Big)(big.NewInt(42))
maxFee = (*hexutil.Big)(new(big.Int).Add(new(big.Int).Mul(b.current.BaseFee, big.NewInt(2)), fortytwo.ToInt()))
al = &types.AccessList{types.AccessTuple{Address: common.Address{0xaa}, StorageKeys: []common.Hash{{0x01}}}}
authList = []types.SetCodeAuthorization{{Address: common.Address{0xbb}}}
)
tests := []test{
@ -208,6 +209,13 @@ func TestSetFeeDefaults(t *testing.T) {
nil,
errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified"),
},
{
"set gas price and authorization list",
"london",
&TransactionArgs{GasPrice: fortytwo, AuthorizationList: authList},
nil,
errors.New("both gasPrice and authorizationList specified"),
},
// EIP-4844
{
"set gas price and maxFee for blob transaction",