Merge pull request #5504 from blockscout/vb-trace-first-block-geth

Extend TRACE_FIRST_BLOCK env var to use with Geth-like node
pull/5508/head
Victor Baranov 3 years ago committed by GitHub
commit 5eb319b965
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 5
      apps/block_scout_web/assets/package-lock.json
  3. 25
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex
  4. 3
      apps/explorer/lib/explorer/chain.ex
  5. 17
      apps/indexer/lib/indexer/fetcher/internal_transaction.ex

@ -7,6 +7,7 @@
- [#5268](https://github.com/blockscout/blockscout/pull/5268), [#5313](https://github.com/blockscout/blockscout/pull/5313) - Contract names display improvement - [#5268](https://github.com/blockscout/blockscout/pull/5268), [#5313](https://github.com/blockscout/blockscout/pull/5313) - Contract names display improvement
### Fixes ### Fixes
- [#5504](https://github.com/blockscout/blockscout/pull/5504) - Extend TRACE_FIRST_BLOCK env var to geth variant
- [#5488](https://github.com/blockscout/blockscout/pull/5488) - Split long contract output to multiple lines - [#5488](https://github.com/blockscout/blockscout/pull/5488) - Split long contract output to multiple lines
- [#5487](https://github.com/blockscout/blockscout/pull/5487) - Fix array displaying in decoded constructor args - [#5487](https://github.com/blockscout/blockscout/pull/5487) - Fix array displaying in decoded constructor args
- [#5482](https://github.com/blockscout/blockscout/pull/5482) - Fix for querying of the contract read functions - [#5482](https://github.com/blockscout/blockscout/pull/5482) - Fix for querying of the contract read functions

@ -95,10 +95,11 @@
} }
}, },
"../../../deps/phoenix": { "../../../deps/phoenix": {
"version": "0.0.1" "version": "1.5.13",
"license": "MIT"
}, },
"../../../deps/phoenix_html": { "../../../deps/phoenix_html": {
"version": "0.0.1" "version": "2.14.3"
}, },
"node_modules/@babel/code-frame": { "node_modules/@babel/code-frame": {
"version": "7.16.7", "version": "7.16.7",

@ -219,13 +219,7 @@ defmodule EthereumJSONRPC do
@spec fetch_beneficiaries([block_number], json_rpc_named_arguments) :: @spec fetch_beneficiaries([block_number], json_rpc_named_arguments) ::
{:ok, FetchedBeneficiaries.t()} | {:error, reason :: term} | :ignore {:ok, FetchedBeneficiaries.t()} | {:error, reason :: term} | :ignore
def fetch_beneficiaries(block_numbers, json_rpc_named_arguments) when is_list(block_numbers) do def fetch_beneficiaries(block_numbers, json_rpc_named_arguments) when is_list(block_numbers) do
min_block = trace_first_block_to_fetch() filtered_block_numbers = block_numbers_in_range(block_numbers)
filtered_block_numbers =
block_numbers
|> Enum.filter(fn block_number ->
block_number >= min_block
end)
Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_beneficiaries( Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_beneficiaries(
filtered_block_numbers, filtered_block_numbers,
@ -310,13 +304,7 @@ defmodule EthereumJSONRPC do
Fetches internal transactions for entire blocks from variant API. Fetches internal transactions for entire blocks from variant API.
""" """
def fetch_block_internal_transactions(block_numbers, json_rpc_named_arguments) when is_list(block_numbers) do def fetch_block_internal_transactions(block_numbers, json_rpc_named_arguments) when is_list(block_numbers) do
min_block = trace_first_block_to_fetch() filtered_block_numbers = block_numbers_in_range(block_numbers)
filtered_block_numbers =
block_numbers
|> Enum.filter(fn block_number ->
block_number >= min_block
end)
Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_block_internal_transactions( Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_block_internal_transactions(
filtered_block_numbers, filtered_block_numbers,
@ -324,6 +312,15 @@ defmodule EthereumJSONRPC do
) )
end end
def block_numbers_in_range(block_numbers) do
min_block = trace_first_block_to_fetch()
block_numbers
|> Enum.filter(fn block_number ->
block_number >= min_block
end)
end
@doc """ @doc """
Retrieves traces from variant API. Retrieves traces from variant API.
""" """

@ -7028,7 +7028,8 @@ defmodule Explorer.Chain do
if transaction_index == 0 do if transaction_index == 0 do
0 0
else else
{:ok, traces} = fetch_block_internal_transactions([block_number], json_rpc_named_arguments) filtered_block_numbers = EthereumJSONRPC.block_numbers_in_range([block_number])
{:ok, traces} = fetch_block_internal_transactions(filtered_block_numbers, json_rpc_named_arguments)
sorted_traces = sorted_traces =
traces traces

@ -98,9 +98,10 @@ defmodule Indexer.Fetcher.InternalTransaction do
) )
def run(block_numbers, json_rpc_named_arguments) do def run(block_numbers, json_rpc_named_arguments) do
unique_numbers = Enum.uniq(block_numbers) unique_numbers = Enum.uniq(block_numbers)
filtered_unique_numbers = EthereumJSONRPC.block_numbers_in_range(unique_numbers)
unique_numbers_count = Enum.count(unique_numbers) filtered_unique_numbers_count = Enum.count(filtered_unique_numbers)
Logger.metadata(count: unique_numbers_count) Logger.metadata(count: filtered_unique_numbers_count)
Logger.debug("fetching internal transactions for blocks") Logger.debug("fetching internal transactions for blocks")
@ -108,14 +109,14 @@ defmodule Indexer.Fetcher.InternalTransaction do
|> Keyword.fetch!(:variant) |> Keyword.fetch!(:variant)
|> case do |> case do
EthereumJSONRPC.Parity -> EthereumJSONRPC.Parity ->
EthereumJSONRPC.fetch_block_internal_transactions(unique_numbers, json_rpc_named_arguments) EthereumJSONRPC.fetch_block_internal_transactions(filtered_unique_numbers, json_rpc_named_arguments)
EthereumJSONRPC.Besu -> EthereumJSONRPC.Besu ->
EthereumJSONRPC.fetch_block_internal_transactions(unique_numbers, json_rpc_named_arguments) EthereumJSONRPC.fetch_block_internal_transactions(filtered_unique_numbers, json_rpc_named_arguments)
_ -> _ ->
try do try do
fetch_block_internal_transactions_by_transactions(unique_numbers, json_rpc_named_arguments) fetch_block_internal_transactions_by_transactions(filtered_unique_numbers, json_rpc_named_arguments)
rescue rescue
error -> error ->
{:error, error} {:error, error}
@ -123,15 +124,15 @@ defmodule Indexer.Fetcher.InternalTransaction do
end end
|> case do |> case do
{:ok, internal_transactions_params} -> {:ok, internal_transactions_params} ->
import_internal_transaction(internal_transactions_params, unique_numbers) import_internal_transaction(internal_transactions_params, filtered_unique_numbers)
{:error, reason} -> {:error, reason} ->
Logger.error(fn -> ["failed to fetch internal transactions for blocks: ", inspect(reason)] end, Logger.error(fn -> ["failed to fetch internal transactions for blocks: ", inspect(reason)] end,
error_count: unique_numbers_count error_count: filtered_unique_numbers_count
) )
# re-queue the de-duped entries # re-queue the de-duped entries
{:retry, unique_numbers} {:retry, filtered_unique_numbers}
:ignore -> :ignore ->
:ok :ok

Loading…
Cancel
Save