Skip to content

Commit 5e46636

Browse files
committed
revert setFeeDefaults to original code from geth
1 parent f40a18e commit 5e46636

File tree

1 file changed

+6
-14
lines changed

1 file changed

+6
-14
lines changed

internal/ethapi/transaction_args.go

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,9 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head
194194
if args.BlobFeeCap != nil && args.BlobFeeCap.ToInt().Sign() == 0 {
195195
return errors.New("maxFeePerBlobGas, if specified, must be non-zero")
196196
}
197+
if b.ChainConfig().IsCancun(head.Number, head.Time, types.DeserializeHeaderExtraInformation(head).ArbOSFormatVersion) {
198+
args.setCancunFeeDefaults(b.ChainConfig(), head)
199+
}
197200
// If both gasPrice and at least one of the EIP-1559 fee parameters are specified, error.
198201
if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
199202
return errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
@@ -211,10 +214,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head
211214
if args.MaxFeePerGas.ToInt().Cmp(args.MaxPriorityFeePerGas.ToInt()) < 0 {
212215
return fmt.Errorf("maxFeePerGas (%v) < maxPriorityFeePerGas (%v)", args.MaxFeePerGas, args.MaxPriorityFeePerGas)
213216
}
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
218218
}
219219

220220
// Sanity check the non-EIP-1559 fee parameters.
@@ -228,14 +228,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head
228228
}
229229

230230
// 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 {
239232
// London is active, set maxPriorityFeePerGas and maxFeePerGas.
240233
if err := args.setLondonFeeDefaults(ctx, head, b); err != nil {
241234
return err
@@ -255,7 +248,7 @@ func (args *TransactionArgs) setFeeDefaults(ctx context.Context, b Backend, head
255248
}
256249

257250
// 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) {
259252
// Set maxFeePerBlobGas if it is missing.
260253
if args.BlobHashes != nil && args.BlobFeeCap == nil {
261254
blobBaseFee := eip4844.CalcBlobFee(config, head)
@@ -265,7 +258,6 @@ func (args *TransactionArgs) setCancunFeeDefaults(ctx context.Context, config *p
265258
val := new(big.Int).Mul(blobBaseFee, big.NewInt(2))
266259
args.BlobFeeCap = (*hexutil.Big)(val)
267260
}
268-
return args.setLondonFeeDefaults(ctx, head, b)
269261
}
270262

271263
// setLondonFeeDefaults fills in reasonable default fee values for unspecified fields.

0 commit comments

Comments
 (0)