Skip to content

Commit

Permalink
eth: Run max gas price check in SuggestGasTipCap
Browse files Browse the repository at this point in the history
  • Loading branch information
yondonfu committed Sep 30, 2021
1 parent 63a8a2d commit e73a5a8
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,17 +111,20 @@ func (b *backend) SuggestGasPrice(ctx context.Context) (*big.Int, error) {
}

func (b *backend) SuggestGasTipCap(ctx context.Context) (*big.Int, error) {
// This runs the max gas price check against the value returned by eth_gasPrice which should be priority fee + base fee.
// We may use the returned value later on to derive the priority fee if the eth_maxPriorityFeePerGas method is not supported.
gasPrice, err := b.SuggestGasPrice(ctx)
if err != nil {
return nil, err
}

tip, err := b.Client.SuggestGasTipCap(ctx)
if err != nil {
// SuggestGasTipCap() uses the eth_maxPriorityFeePerGas RPC call under the hood which
// is not a part of the ETH JSON-RPC spec.
// In the future, eth_maxPriorityFeePerGas can be replaced with an eth_feeHistory based algorithm (see https://github.com/ethereum/go-ethereum/issues/23479).
// For now, if the provider does not support eth_maxPriorityFeePerGas (i.e. not geth), then we calculate the priority fee as
// eth_gasPrice - baseFee.
gasPrice, err := b.SuggestGasPrice(ctx)
if err != nil {
return nil, err
}
head, err := b.HeaderByNumber(ctx, nil)
if err != nil {
return nil, err
Expand Down

0 comments on commit e73a5a8

Please sign in to comment.