@@ -137,20 +137,35 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend) erro
137
137
if args .GasPrice != nil && (args .MaxFeePerGas != nil || args .MaxPriorityFeePerGas != nil ) {
138
138
return errors .New ("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified" )
139
139
}
140
- // If the tx has completely specified a fee mechanism, no default is needed. This allows users
141
- // who are not yet synced past London to get defaults for other tx values. See
142
- // https://github.com/ethereum/go-ethereum/pull/23274 for more information.
140
+ // If the tx has completely specified a fee mechanism, no default is needed.
141
+ // This allows users who are not yet synced past London to get defaults for
142
+ // other tx values. See https://github.com/ethereum/go-ethereum/pull/23274
143
+ // for more information.
143
144
eip1559ParamsSet := args .MaxFeePerGas != nil && args .MaxPriorityFeePerGas != nil
144
- if (args .GasPrice != nil && ! eip1559ParamsSet ) || (args .GasPrice == nil && eip1559ParamsSet ) {
145
- // Sanity check the EIP-1559 fee parameters if present.
146
- if args .GasPrice == nil && args .MaxFeePerGas .ToInt ().Cmp (args .MaxPriorityFeePerGas .ToInt ()) < 0 {
145
+
146
+ // Sanity check the EIP-1559 fee parameters if present.
147
+ if args .GasPrice == nil && eip1559ParamsSet {
148
+ if args .MaxFeePerGas .ToInt ().Sign () == 0 {
149
+ return errors .New ("maxFeePerGas must be non-zero" )
150
+ }
151
+ if args .MaxFeePerGas .ToInt ().Cmp (args .MaxPriorityFeePerGas .ToInt ()) < 0 {
147
152
return fmt .Errorf ("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)" , args .MaxFeePerGas , args .MaxPriorityFeePerGas )
148
153
}
149
- return nil
154
+ return nil // No need to set anything, user already set MaxFeePerGas and MaxPriorityFeePerGas
150
155
}
151
- // Now attempt to fill in default value depending on whether London is active or not .
156
+ // Sanity check the non-EIP-1559 fee parameters .
152
157
head := b .CurrentHeader ()
153
- if b .ChainConfig ().IsLondon (head .Number ) {
158
+ isLondon := b .ChainConfig ().IsLondon (head .Number )
159
+ if args .GasPrice != nil && ! eip1559ParamsSet {
160
+ // Zero gas-price is not allowed after London fork
161
+ if args .GasPrice .ToInt ().Sign () == 0 && isLondon {
162
+ return errors .New ("gasPrice must be non-zero after london fork" )
163
+ }
164
+ return nil // No need to set anything, user already set GasPrice
165
+ }
166
+
167
+ // Now attempt to fill in default value depending on whether London is active or not.
168
+ if isLondon {
154
169
// London is active, set maxPriorityFeePerGas and maxFeePerGas.
155
170
if err := args .setLondonFeeDefaults (ctx , head , b ); err != nil {
156
171
return err
0 commit comments