Skip to content

Commit

Permalink
Fix issue: client.BlockByNumber failed in ETH L2
Browse files Browse the repository at this point in the history
  • Loading branch information
10gic committed Mar 13, 2024
1 parent 5de7363 commit 050b128
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions cmd/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,11 +518,11 @@ func getEIP1559GasPrice(client *ethclient.Client) (*big.Int, *big.Int, error) {
// maxPriorityFeePerGas = tip * 113%
maxPriorityFeePerGas := new(big.Int).Add(tip, buffer)

block, err := client.BlockByNumber(context.Background(), nil)
header, err := client.HeaderByNumber(context.Background(), nil)
if err != nil {
return nil, nil, fmt.Errorf("BlockByNumber failed: %w", err)
return nil, nil, fmt.Errorf("HeaderByNumber failed: %w", err)
}
baseFee := block.Header().BaseFee
baseFee := header.BaseFee
var maxFeePerGas *big.Int
if baseFee == nil {
maxFeePerGas = maxPriorityFeePerGas
Expand Down Expand Up @@ -613,11 +613,11 @@ func getEIP1559GasPriceByFeeHistory(client *ethclient.Client) (*big.Int, *big.In
maxPriorityFeePerGasEstimate = &average
// log.Printf("maxPriorityFeePerGasEstimate = %v", maxPriorityFeePerGasEstimate.String())

pendingBlock, err := client.BlockByNumber(context.Background(), nil)
header, err := client.HeaderByNumber(context.Background(), nil)
if err != nil {
return nil, nil, fmt.Errorf("BlockByNumber failed: %w", err)
return nil, nil, fmt.Errorf("HeaderByNumber failed: %w", err)
}
maxFeePerGasEstimate = maxFeePerGasEstimate.Add(pendingBlock.BaseFee(), maxPriorityFeePerGasEstimate)
maxFeePerGasEstimate = maxFeePerGasEstimate.Add(header.BaseFee, maxPriorityFeePerGasEstimate)
// log.Printf("maxFeePerGasEstimate = %v", maxFeePerGasEstimate.String())

return maxFeePerGasEstimate, maxPriorityFeePerGasEstimate, nil
Expand Down

0 comments on commit 050b128

Please sign in to comment.