diff --git a/internal/ethapi/api.go b/internal/ethapi/api.go index aa25144d2263..a7447e52e387 100644 --- a/internal/ethapi/api.go +++ b/internal/ethapi/api.go @@ -2147,6 +2147,7 @@ type CallBundleArgs struct { Timeout *int64 `json:"timeout"` GasLimit *uint64 `json:"gasLimit"` Difficulty *big.Int `json:"difficulty"` + BaseFee *big.Int `json:"baseFee"` } // CallBundle will simulate a bundle of transactions at the top of a given block @@ -2201,6 +2202,12 @@ func (s *BundleAPI) CallBundle(ctx context.Context, args CallBundleArgs) (map[st if args.GasLimit != nil { gasLimit = *args.GasLimit } + var baseFee *big.Int + if args.BaseFee != nil { + baseFee = args.BaseFee + } else if s.b.ChainConfig().IsLondon(big.NewInt(args.BlockNumber.Int64())) { + baseFee = misc.CalcBaseFee(s.b.ChainConfig(), parent) + } header := &types.Header{ ParentHash: parent.Hash(), Number: blockNumber, @@ -2208,6 +2215,7 @@ func (s *BundleAPI) CallBundle(ctx context.Context, args CallBundleArgs) (map[st Time: timestamp, Difficulty: difficulty, Coinbase: coinbase, + BaseFee: baseFee, } // Setup context so it may be cancelled the call has completed @@ -2260,7 +2268,11 @@ func (s *BundleAPI) CallBundle(ctx context.Context, args CallBundleArgs) (map[st "toAddress": to, } totalGasUsed += receipt.GasUsed - gasFeesTx := new(big.Int).Mul(big.NewInt(int64(receipt.GasUsed)), tx.GasPrice()) + gasPrice, err := tx.EffectiveGasTip(header.BaseFee) + if err != nil { + return nil, fmt.Errorf("err: %w; txhash %s", err, tx.Hash()) + } + gasFeesTx := new(big.Int).Mul(big.NewInt(int64(receipt.GasUsed)), gasPrice) gasFees.Add(gasFees, gasFeesTx) bundleHash.Write(tx.Hash().Bytes()) if result.Err != nil {