fix: filecoin stucked pending address operations (#10832)

* chore: log database related errors

* fix: do not buffer failed operations

* fix: do not hardcode Beryx API Filecoin mainnet base url
np-fix-forever-pending-verification
Fedor Ivanov 2 months ago committed by GitHub
parent 23b994dbc8
commit 435bba786f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 4
      apps/explorer/lib/explorer/chain/filecoin/pending_address_operation.ex
  2. 8
      apps/indexer/lib/indexer/fetcher/filecoin/address_info.ex
  3. 2
      apps/indexer/lib/indexer/fetcher/filecoin/beryx_api.ex
  4. 2
      config/runtime.exs

@ -19,7 +19,8 @@ defmodule Explorer.Chain.Filecoin.PendingAddressOperation do
@typedoc """
* `address_hash` - the hash of the address that is pending to be fetched.
* `http_status_code` - the unsuccessful (non-200) http code returned by Beryx
API if the fetcher failed to fetch the address.
API if the fetcher failed to fetch the address, set to `nil` if the fetcher
did not attempt to fetch the address yet.
"""
@primary_key false
typed_schema "filecoin_pending_address_operations" do
@ -63,6 +64,7 @@ defmodule Explorer.Chain.Filecoin.PendingAddressOperation do
from(
op in __MODULE__,
select: op,
where: is_nil(op.http_status_code),
order_by: [desc: op.address_hash]
)

@ -108,7 +108,9 @@ defmodule Indexer.Fetcher.Filecoin.AddressInfo do
else
_ ->
Logger.error("Could not fetch Filecoin address info: #{to_string(address_hash)}")
:retry
# TODO: We should consider implementing retry logic when fetching
# becomes more stable
:ok
end
end
@ -169,6 +171,10 @@ defmodule Indexer.Fetcher.Filecoin.AddressInfo do
end
)
|> Repo.transaction()
|> tap(fn
{:ok, _} -> :ok
error -> Logger.error("Error updating address and removing pending operation: #{inspect(error)}")
end)
end
@spec fetch_address_info_using_beryx_api(PendingAddressOperation.t()) ::

@ -27,7 +27,7 @@ defmodule Indexer.Fetcher.Filecoin.BeryxAPI do
base_url = config |> Keyword.get(:base_url) |> String.trim_trailing("/")
api_token = config[:api_token]
url = "#{base_url}/mainnet/account/info/#{eth_address_hash}"
url = "#{base_url}/account/info/#{eth_address_hash}"
headers = [
{"Authorization", "Bearer #{api_token}"},

@ -1065,7 +1065,7 @@ config :indexer, Indexer.Fetcher.Celo.EpochBlockOperations.Supervisor,
disabled?: not celo_epoch_fetchers_enabled?
config :indexer, Indexer.Fetcher.Filecoin.BeryxAPI,
base_url: ConfigHelper.safe_get_env("BERYX_API_BASE_URL", "https://api.zondax.ch/fil/data/v3"),
base_url: ConfigHelper.safe_get_env("BERYX_API_BASE_URL", "https://api.zondax.ch/fil/data/v3/mainnet"),
api_token: System.get_env("BERYX_API_TOKEN")
filecoin_native_address_fetcher_enabled? =

Loading…
Cancel
Save