diff --git a/CHANGELOG.md b/CHANGELOG.md index 6bf8d00c3a..76acc264cc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,7 @@ ### Chore +- [#6192](https://github.com/blockscout/blockscout/pull/6192) - Hide Indexing Internal Transactions message, if INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=true - [#6183](https://github.com/blockscout/blockscout/pull/6183) - Transparent coin name definition - [#6155](https://github.com/blockscout/blockscout/pull/6155), [#6189](https://github.com/blockscout/blockscout/pull/6189) - Refactor Ethereum JSON RPC variants - [#6125](https://github.com/blockscout/blockscout/pull/6125) - Rename obsolete "parity" EthereumJSONRPC.Variant to "nethermind" diff --git a/apps/block_scout_web/assets/js/lib/indexing.js b/apps/block_scout_web/assets/js/lib/indexing.js index be410da5b8..894481f2f7 100644 --- a/apps/block_scout_web/assets/js/lib/indexing.js +++ b/apps/block_scout_web/assets/js/lib/indexing.js @@ -8,7 +8,7 @@ function tryUpdateIndexedStatus (el, indexedRatio = el.dataset.indexedRatio, ind const blocksPercentComplete = numeral(indexedRatio).format('0%') let indexedText if (blocksPercentComplete === '100%') { - indexedText = window.localized['Indexing Tokens'] + indexedText = window.localized['Indexing Internal Transactions'] } else { indexedText = `${blocksPercentComplete} ${window.localized['Blocks Indexed']}` } diff --git a/apps/block_scout_web/lib/block_scout_web/counters/blocks_indexed_counter.ex b/apps/block_scout_web/lib/block_scout_web/counters/blocks_indexed_counter.ex index 3eede51f90..79fb6b166a 100644 --- a/apps/block_scout_web/lib/block_scout_web/counters/blocks_indexed_counter.ex +++ b/apps/block_scout_web/lib/block_scout_web/counters/blocks_indexed_counter.ex @@ -41,7 +41,7 @@ defmodule BlockScoutWeb.Counters.BlocksIndexedCounter do finished? = case Decimal.compare(ratio, 1) do :lt -> false - _ -> Chain.finished_indexing?() + _ -> Chain.finished_internal_transactions_indexing?() end Notifier.broadcast_blocks_indexed_ratio(ratio, finished?) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex index f2e64a8426..ba2edd6aae 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex @@ -41,7 +41,7 @@ window.localized = { 'Blocks Indexed': '<%= gettext("Blocks Indexed") %>', 'Block Processing': '<%= gettext("Block Mined, awaiting import...") %>', - 'Indexing Tokens': '<%= gettext("Indexing Tokens") %>', + 'Indexing Internal Transactions': '<%= gettext("Indexing Internal Transactions") %>', 'Less than': '<%= gettext("Less than") %>', 'Market Cap': '<%= gettext("Market Cap") %>', 'Price': '<%= gettext("Price") %>', @@ -216,7 +216,7 @@ <%= raw(System.get_env("MAINTENANCE_ALERT_MESSAGE")) %> <% end %> - <%= if not Explorer.Chain.finished_indexing?() do %> + <%= if not Explorer.Chain.finished_internal_transactions_indexing?() do %>
<%= render BlockScoutWeb.CommonComponentsView, "_loading_spinner.html" %> diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 5c8813bbf9..65482ecf33 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -1414,11 +1414,6 @@ msgstr "" msgid "Indexed?" msgstr "" -#: lib/block_scout_web/templates/layout/app.html.eex:44 -#, elixir-autogen, elixir-format -msgid "Indexing Tokens" -msgstr "" - #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:3 #, elixir-autogen, elixir-format msgid "Input" @@ -3261,3 +3256,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "truffle flattener" msgstr "" + +#: lib/block_scout_web/templates/layout/app.html.eex:44 +#, elixir-autogen, elixir-format +msgid "Indexing Internal Transactions" +msgstr "" diff --git a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po index 5c8813bbf9..0046a950b0 100644 --- a/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po +++ b/apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po @@ -1414,11 +1414,6 @@ msgstr "" msgid "Indexed?" msgstr "" -#: lib/block_scout_web/templates/layout/app.html.eex:44 -#, elixir-autogen, elixir-format -msgid "Indexing Tokens" -msgstr "" - #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:3 #, elixir-autogen, elixir-format msgid "Input" @@ -3261,3 +3256,8 @@ msgstr "" #, elixir-autogen, elixir-format msgid "truffle flattener" msgstr "" + +#: lib/block_scout_web/templates/layout/app.html.eex:44 +#, elixir-autogen, elixir-format, fuzzy +msgid "Indexing Internal Transactions" +msgstr "" diff --git a/apps/block_scout_web/test/block_scout_web/features/viewing_app_test.exs b/apps/block_scout_web/test/block_scout_web/features/viewing_app_test.exs index 83877c8e46..fc78f01e6d 100644 --- a/apps/block_scout_web/test/block_scout_web/features/viewing_app_test.exs +++ b/apps/block_scout_web/test/block_scout_web/features/viewing_app_test.exs @@ -52,7 +52,7 @@ defmodule BlockScoutWeb.ViewingAppTest do # session # |> AppPage.visit_page() - # |> assert_has(AppPage.indexed_status("Indexing Tokens")) + # |> assert_has(AppPage.indexed_status("Indexing Internal Transactions")) # end # test "updates blocks indexed percentage", %{session: session} do @@ -106,7 +106,7 @@ defmodule BlockScoutWeb.ViewingAppTest do # BlocksIndexedCounter.calculate_blocks_indexed() - # assert_has(session, AppPage.indexed_status("Indexing Tokens")) + # assert_has(session, AppPage.indexed_status("Indexing Internal Transactions")) # end # test "removes message when chain is indexed", %{session: session} do @@ -129,7 +129,7 @@ defmodule BlockScoutWeb.ViewingAppTest do # session # |> AppPage.visit_page() - # |> assert_has(AppPage.indexed_status("Indexing Tokens")) + # |> assert_has(AppPage.indexed_status("Indexing Internal Transactions")) # Repo.update_all( # from(p in PendingBlockOperation, where: p.block_hash == ^block_hash), diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index c967eb257d..12069c6765 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1162,33 +1162,39 @@ defmodule Explorer.Chain do Checks to see if the chain is down indexing based on the transaction from the oldest block and the `fetch_internal_transactions` pending operation """ - @spec finished_indexing?() :: boolean() - def finished_indexing? do - json_rpc_named_arguments = Application.fetch_env!(:indexer, :json_rpc_named_arguments) - variant = Keyword.fetch!(json_rpc_named_arguments, :variant) + @spec finished_internal_transactions_indexing?() :: boolean() + def finished_internal_transactions_indexing? do + internal_transactions_disabled? = System.get_env("INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER", "false") == "true" - if variant == EthereumJSONRPC.Ganache || variant == EthereumJSONRPC.Arbitrum do + if internal_transactions_disabled? do true else - with {:transactions_exist, true} <- {:transactions_exist, Repo.exists?(Transaction)}, - min_block_number when not is_nil(min_block_number) <- Repo.aggregate(Transaction, :min, :block_number) do - min_block_number = - min_block_number - |> Decimal.max(EthereumJSONRPC.first_block_to_fetch(:trace_first_block)) - |> Decimal.to_integer() - - query = - from( - b in Block, - join: pending_ops in assoc(b, :pending_operations), - where: pending_ops.fetch_internal_transactions, - where: b.consensus and b.number == ^min_block_number - ) + json_rpc_named_arguments = Application.fetch_env!(:indexer, :json_rpc_named_arguments) + variant = Keyword.fetch!(json_rpc_named_arguments, :variant) - !Repo.exists?(query) + if variant == EthereumJSONRPC.Ganache || variant == EthereumJSONRPC.Arbitrum do + true else - {:transactions_exist, false} -> true - nil -> false + with {:transactions_exist, true} <- {:transactions_exist, Repo.exists?(Transaction)}, + min_block_number when not is_nil(min_block_number) <- Repo.aggregate(Transaction, :min, :block_number) do + min_block_number = + min_block_number + |> Decimal.max(EthereumJSONRPC.first_block_to_fetch(:trace_first_block)) + |> Decimal.to_integer() + + query = + from( + b in Block, + join: pending_ops in assoc(b, :pending_operations), + where: pending_ops.fetch_internal_transactions, + where: b.consensus and b.number == ^min_block_number + ) + + !Repo.exists?(query) + else + {:transactions_exist, false} -> true + nil -> false + end end end end diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs index ac0afb47fc..8bb189e7ef 100644 --- a/apps/explorer/test/explorer/chain_test.exs +++ b/apps/explorer/test/explorer/chain_test.exs @@ -1185,7 +1185,7 @@ defmodule Explorer.ChainTest do end end - describe "finished_indexing?/0" do + describe "finished_internal_transactions_indexing?/0" do test "finished indexing" do block = insert(:block, number: 1) @@ -1193,11 +1193,11 @@ defmodule Explorer.ChainTest do |> insert() |> with_block(block) - assert Chain.finished_indexing?() + assert Chain.finished_internal_transactions_indexing?() end test "finished indexing (no txs)" do - assert Chain.finished_indexing?() + assert Chain.finished_internal_transactions_indexing?() end test "not finished indexing" do @@ -1209,7 +1209,7 @@ defmodule Explorer.ChainTest do insert(:pending_block_operation, block: block, fetch_internal_transactions: true) - refute Chain.finished_indexing?() + refute Chain.finished_internal_transactions_indexing?() end end