From 172c3d747df3503904805f1265e48808a0591c26 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Wed, 16 Mar 2022 14:03:30 -0400 Subject: [PATCH] feat: use SuggestGasTipCap fallback when not using Alchemy --- .changeset/blue-carrots-vanish.md | 5 +++++ go/teleportr/api/server.go | 12 +++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 .changeset/blue-carrots-vanish.md diff --git a/.changeset/blue-carrots-vanish.md b/.changeset/blue-carrots-vanish.md new file mode 100644 index 0000000000000..36b0e6fa36129 --- /dev/null +++ b/.changeset/blue-carrots-vanish.md @@ -0,0 +1,5 @@ +--- +'@eth-optimism/teleportr': patch +--- + +Add SuggestGasTipCap fallback diff --git a/go/teleportr/api/server.go b/go/teleportr/api/server.go index 582b1f39f2fdf..f4f2f3afdc7e2 100644 --- a/go/teleportr/api/server.go +++ b/go/teleportr/api/server.go @@ -17,6 +17,7 @@ import ( bsscore "github.com/ethereum-optimism/optimism/go/bss-core" "github.com/ethereum-optimism/optimism/go/bss-core/dial" + "github.com/ethereum-optimism/optimism/go/bss-core/drivers" "github.com/ethereum-optimism/optimism/go/bss-core/txmgr" "github.com/ethereum-optimism/optimism/go/teleportr/bindings/deposit" "github.com/ethereum-optimism/optimism/go/teleportr/db" @@ -346,7 +347,16 @@ func (s *Server) HandleEstimate( gasTipCap, err := s.l1Client.SuggestGasTipCap(ctx) if err != nil { rpcErrorsTotal.WithLabelValues("suggest_gas_tip_cap").Inc() - return err + // If the request failed because the backend does not support + // eth_maxPriorityFeePerGas, fallback to using the default constant. + // Currently Alchemy is the only backend provider that exposes this + // method, so in the event their API is unreachable we can fallback to a + // degraded mode of operation. This also applies to our test + // environments, as hardhat doesn't support the query either. + if !drivers.IsMaxPriorityFeePerGasNotFoundError(err) { + return err + } + gasTipCap = drivers.FallbackGasTipCap } header, err := s.l1Client.HeaderByNumber(ctx, nil)