From a58f3d57994ca894158495dd5ba04fb789368bfa Mon Sep 17 00:00:00 2001 From: Viktor Baranov Date: Wed, 27 Apr 2022 12:56:53 +0300 Subject: [PATCH] Extend TRACE_FIRST_BLOCK env var to geth variant --- CHANGELOG.md | 1 + apps/block_scout_web/assets/package-lock.json | 5 ++-- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex | 25 ++++++++----------- apps/explorer/lib/explorer/chain.ex | 3 ++- .../indexer/fetcher/internal_transaction.ex | 17 +++++++------ 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fdea7caf56..0b25857c98 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#5268](https://github.com/blockscout/blockscout/pull/5268), [#5313](https://github.com/blockscout/blockscout/pull/5313) - Contract names display improvement ### 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 - [#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 diff --git a/apps/block_scout_web/assets/package-lock.json b/apps/block_scout_web/assets/package-lock.json index 2512c4aac1..13898d4dd7 100644 --- a/apps/block_scout_web/assets/package-lock.json +++ b/apps/block_scout_web/assets/package-lock.json @@ -95,10 +95,11 @@ } }, "../../../deps/phoenix": { - "version": "0.0.1" + "version": "1.5.13", + "license": "MIT" }, "../../../deps/phoenix_html": { - "version": "0.0.1" + "version": "2.14.3" }, "node_modules/@babel/code-frame": { "version": "7.16.7", diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex index e42aad256e..d3a7ddfe95 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex @@ -219,13 +219,7 @@ defmodule EthereumJSONRPC do @spec fetch_beneficiaries([block_number], json_rpc_named_arguments) :: {:ok, FetchedBeneficiaries.t()} | {:error, reason :: term} | :ignore 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 - |> Enum.filter(fn block_number -> - block_number >= min_block - end) + filtered_block_numbers = block_numbers_in_range(block_numbers) Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_beneficiaries( filtered_block_numbers, @@ -310,13 +304,7 @@ defmodule EthereumJSONRPC do 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 - min_block = trace_first_block_to_fetch() - - filtered_block_numbers = - block_numbers - |> Enum.filter(fn block_number -> - block_number >= min_block - end) + filtered_block_numbers = block_numbers_in_range(block_numbers) Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_block_internal_transactions( filtered_block_numbers, @@ -324,6 +312,15 @@ defmodule EthereumJSONRPC do ) 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 """ Retrieves traces from variant API. """ diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 559ae11099..5d9d7aa113 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -7028,7 +7028,8 @@ defmodule Explorer.Chain do if transaction_index == 0 do 0 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 = traces diff --git a/apps/indexer/lib/indexer/fetcher/internal_transaction.ex b/apps/indexer/lib/indexer/fetcher/internal_transaction.ex index 6a112dfeb6..13716a88c4 100644 --- a/apps/indexer/lib/indexer/fetcher/internal_transaction.ex +++ b/apps/indexer/lib/indexer/fetcher/internal_transaction.ex @@ -98,9 +98,10 @@ defmodule Indexer.Fetcher.InternalTransaction do ) def run(block_numbers, json_rpc_named_arguments) do unique_numbers = Enum.uniq(block_numbers) + filtered_unique_numbers = EthereumJSONRPC.block_numbers_in_range(unique_numbers) - unique_numbers_count = Enum.count(unique_numbers) - Logger.metadata(count: unique_numbers_count) + filtered_unique_numbers_count = Enum.count(filtered_unique_numbers) + Logger.metadata(count: filtered_unique_numbers_count) Logger.debug("fetching internal transactions for blocks") @@ -108,14 +109,14 @@ defmodule Indexer.Fetcher.InternalTransaction do |> Keyword.fetch!(:variant) |> case do 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.fetch_block_internal_transactions(unique_numbers, json_rpc_named_arguments) + EthereumJSONRPC.fetch_block_internal_transactions(filtered_unique_numbers, json_rpc_named_arguments) _ -> 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 error -> {:error, error} @@ -123,15 +124,15 @@ defmodule Indexer.Fetcher.InternalTransaction do end |> case do {:ok, internal_transactions_params} -> - import_internal_transaction(internal_transactions_params, unique_numbers) + import_internal_transaction(internal_transactions_params, filtered_unique_numbers) {:error, reason} -> 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 - {:retry, unique_numbers} + {:retry, filtered_unique_numbers} :ignore -> :ok