@@ -194,6 +194,9 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head
194
194
if args .BlobFeeCap != nil && args .BlobFeeCap .ToInt ().Sign () == 0 {
195
195
return errors .New ("maxFeePerBlobGas, if specified, must be non-zero" )
196
196
}
197
+ if b .ChainConfig ().IsCancun (head .Number , head .Time , types .DeserializeHeaderExtraInformation (head ).ArbOSFormatVersion ) {
198
+ args .setCancunFeeDefaults (b .ChainConfig (), head )
199
+ }
197
200
// If both gasPrice and at least one of the EIP-1559 fee parameters are specified, error.
198
201
if args .GasPrice != nil && (args .MaxFeePerGas != nil || args .MaxPriorityFeePerGas != nil ) {
199
202
return errors .New ("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified" )
@@ -211,10 +214,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head
211
214
if args .MaxFeePerGas .ToInt ().Cmp (args .MaxPriorityFeePerGas .ToInt ()) < 0 {
212
215
return fmt .Errorf ("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)" , args .MaxFeePerGas , args .MaxPriorityFeePerGas )
213
216
}
214
- // No need to set anything other than CancunFeeDefaults, user already set MaxFeePerGas and MaxPriorityFeePerGas
215
- if err := args .setCancunFeeDefaults (ctx , b .ChainConfig (), head , b ); err != nil {
216
- return err
217
- }
217
+ return nil // No need to set anything, user already set MaxFeePerGas and MaxPriorityFeePerGas
218
218
}
219
219
220
220
// Sanity check the non-EIP-1559 fee parameters.
@@ -228,14 +228,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head
228
228
}
229
229
230
230
// Now attempt to fill in default value depending on whether London is active or not.
231
- if b .ChainConfig ().IsCancun (head .Number , head .Time , types .DeserializeHeaderExtraInformation (head ).ArbOSFormatVersion ) {
232
- if err := args .setCancunFeeDefaults (ctx , b .ChainConfig (), head , b ); err != nil {
233
- return err
234
- }
235
- } else if isLondon {
236
- if args .BlobFeeCap != nil {
237
- return errors .New ("maxFeePerBlobGas is not valid before Cancun is active" )
238
- }
231
+ if isLondon {
239
232
// London is active, set maxPriorityFeePerGas and maxFeePerGas.
240
233
if err := args .setLondonFeeDefaults (ctx , head , b ); err != nil {
241
234
return err
@@ -255,7 +248,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head
255
248
}
256
249
257
250
// setCancunFeeDefaults fills in reasonable default fee values for unspecified fields.
258
- func (args * TransactionArgs ) setCancunFeeDefaults (ctx context. Context , config * params.ChainConfig , head * types.Header , b Backend ) error {
251
+ func (args * TransactionArgs ) setCancunFeeDefaults (config * params.ChainConfig , head * types.Header ) {
259
252
// Set maxFeePerBlobGas if it is missing.
260
253
if args .BlobHashes != nil && args .BlobFeeCap == nil {
261
254
blobBaseFee := eip4844 .CalcBlobFee (config , head )
@@ -265,7 +258,6 @@ func (args *TransactionArgs) setCancunFeeDefaults(ctx context.Context, config *p
265
258
val := new (big.Int ).Mul (blobBaseFee , big .NewInt (2 ))
266
259
args .BlobFeeCap = (* hexutil .Big )(val )
267
260
}
268
- return args .setLondonFeeDefaults (ctx , head , b )
269
261
}
270
262
271
263
// setLondonFeeDefaults fills in reasonable default fee values for unspecified fields.
0 commit comments