Hide Indexing Internal Transactions message, if INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER=true

pull/6192/head
Viktor Baranov 2 years ago
parent cabfdfa6b1
commit aa4d78c9a2
  1. 1
      CHANGELOG.md
  2. 2
      apps/block_scout_web/assets/js/lib/indexing.js
  3. 2
      apps/block_scout_web/lib/block_scout_web/counters/blocks_indexed_counter.ex
  4. 4
      apps/block_scout_web/lib/block_scout_web/templates/layout/app.html.eex
  5. 10
      apps/block_scout_web/priv/gettext/default.pot
  6. 10
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  7. 6
      apps/block_scout_web/test/block_scout_web/features/viewing_app_test.exs
  8. 50
      apps/explorer/lib/explorer/chain.ex
  9. 8
      apps/explorer/test/explorer/chain_test.exs

@ -22,6 +22,7 @@
### Chore ### 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 - [#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 - [#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" - [#6125](https://github.com/blockscout/blockscout/pull/6125) - Rename obsolete "parity" EthereumJSONRPC.Variant to "nethermind"

@ -8,7 +8,7 @@ function tryUpdateIndexedStatus (el, indexedRatio = el.dataset.indexedRatio, ind
const blocksPercentComplete = numeral(indexedRatio).format('0%') const blocksPercentComplete = numeral(indexedRatio).format('0%')
let indexedText let indexedText
if (blocksPercentComplete === '100%') { if (blocksPercentComplete === '100%') {
indexedText = window.localized['Indexing Tokens'] indexedText = window.localized['Indexing Internal Transactions']
} else { } else {
indexedText = `${blocksPercentComplete} ${window.localized['Blocks Indexed']}` indexedText = `${blocksPercentComplete} ${window.localized['Blocks Indexed']}`
} }

@ -41,7 +41,7 @@ defmodule BlockScoutWeb.Counters.BlocksIndexedCounter do
finished? = finished? =
case Decimal.compare(ratio, 1) do case Decimal.compare(ratio, 1) do
:lt -> false :lt -> false
_ -> Chain.finished_indexing?() _ -> Chain.finished_internal_transactions_indexing?()
end end
Notifier.broadcast_blocks_indexed_ratio(ratio, finished?) Notifier.broadcast_blocks_indexed_ratio(ratio, finished?)

@ -41,7 +41,7 @@
window.localized = { window.localized = {
'Blocks Indexed': '<%= gettext("Blocks Indexed") %>', 'Blocks Indexed': '<%= gettext("Blocks Indexed") %>',
'Block Processing': '<%= gettext("Block Mined, awaiting import...") %>', 'Block Processing': '<%= gettext("Block Mined, awaiting import...") %>',
'Indexing Tokens': '<%= gettext("Indexing Tokens") %>', 'Indexing Internal Transactions': '<%= gettext("Indexing Internal Transactions") %>',
'Less than': '<%= gettext("Less than") %>', 'Less than': '<%= gettext("Less than") %>',
'Market Cap': '<%= gettext("Market Cap") %>', 'Market Cap': '<%= gettext("Market Cap") %>',
'Price': '<%= gettext("Price") %>', 'Price': '<%= gettext("Price") %>',
@ -216,7 +216,7 @@
<%= raw(System.get_env("MAINTENANCE_ALERT_MESSAGE")) %> <%= raw(System.get_env("MAINTENANCE_ALERT_MESSAGE")) %>
</div> </div>
<% end %> <% end %>
<%= if not Explorer.Chain.finished_indexing?() do %> <%= if not Explorer.Chain.finished_internal_transactions_indexing?() do %>
<div class="alert alert-warning text-center mb-0 p-3" data-selector="indexed-status"> <div class="alert alert-warning text-center mb-0 p-3" data-selector="indexed-status">
<%= render BlockScoutWeb.CommonComponentsView, "_loading_spinner.html" %> <%= render BlockScoutWeb.CommonComponentsView, "_loading_spinner.html" %>
<span data-indexed-ratio="<%=Explorer.Chain.indexed_ratio() %>"></span> <span data-indexed-ratio="<%=Explorer.Chain.indexed_ratio() %>"></span>

@ -1414,11 +1414,6 @@ msgstr ""
msgid "Indexed?" msgid "Indexed?"
msgstr "" 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 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:3
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Input" msgid "Input"
@ -3261,3 +3256,8 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "truffle flattener" msgid "truffle flattener"
msgstr "" msgstr ""
#: lib/block_scout_web/templates/layout/app.html.eex:44
#, elixir-autogen, elixir-format
msgid "Indexing Internal Transactions"
msgstr ""

@ -1414,11 +1414,6 @@ msgstr ""
msgid "Indexed?" msgid "Indexed?"
msgstr "" 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 #: lib/block_scout_web/templates/transaction/_decoded_input.html.eex:3
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "Input" msgid "Input"
@ -3261,3 +3256,8 @@ msgstr ""
#, elixir-autogen, elixir-format #, elixir-autogen, elixir-format
msgid "truffle flattener" msgid "truffle flattener"
msgstr "" msgstr ""
#: lib/block_scout_web/templates/layout/app.html.eex:44
#, elixir-autogen, elixir-format, fuzzy
msgid "Indexing Internal Transactions"
msgstr ""

@ -52,7 +52,7 @@ defmodule BlockScoutWeb.ViewingAppTest do
# session # session
# |> AppPage.visit_page() # |> AppPage.visit_page()
# |> assert_has(AppPage.indexed_status("Indexing Tokens")) # |> assert_has(AppPage.indexed_status("Indexing Internal Transactions"))
# end # end
# test "updates blocks indexed percentage", %{session: session} do # test "updates blocks indexed percentage", %{session: session} do
@ -106,7 +106,7 @@ defmodule BlockScoutWeb.ViewingAppTest do
# BlocksIndexedCounter.calculate_blocks_indexed() # BlocksIndexedCounter.calculate_blocks_indexed()
# assert_has(session, AppPage.indexed_status("Indexing Tokens")) # assert_has(session, AppPage.indexed_status("Indexing Internal Transactions"))
# end # end
# test "removes message when chain is indexed", %{session: session} do # test "removes message when chain is indexed", %{session: session} do
@ -129,7 +129,7 @@ defmodule BlockScoutWeb.ViewingAppTest do
# session # session
# |> AppPage.visit_page() # |> AppPage.visit_page()
# |> assert_has(AppPage.indexed_status("Indexing Tokens")) # |> assert_has(AppPage.indexed_status("Indexing Internal Transactions"))
# Repo.update_all( # Repo.update_all(
# from(p in PendingBlockOperation, where: p.block_hash == ^block_hash), # from(p in PendingBlockOperation, where: p.block_hash == ^block_hash),

@ -1162,33 +1162,39 @@ defmodule Explorer.Chain do
Checks to see if the chain is down indexing based on the transaction from the Checks to see if the chain is down indexing based on the transaction from the
oldest block and the `fetch_internal_transactions` pending operation oldest block and the `fetch_internal_transactions` pending operation
""" """
@spec finished_indexing?() :: boolean() @spec finished_internal_transactions_indexing?() :: boolean()
def finished_indexing? do def finished_internal_transactions_indexing? do
json_rpc_named_arguments = Application.fetch_env!(:indexer, :json_rpc_named_arguments) internal_transactions_disabled? = System.get_env("INDEXER_DISABLE_INTERNAL_TRANSACTIONS_FETCHER", "false") == "true"
variant = Keyword.fetch!(json_rpc_named_arguments, :variant)
if variant == EthereumJSONRPC.Ganache || variant == EthereumJSONRPC.Arbitrum do if internal_transactions_disabled? do
true true
else else
with {:transactions_exist, true} <- {:transactions_exist, Repo.exists?(Transaction)}, json_rpc_named_arguments = Application.fetch_env!(:indexer, :json_rpc_named_arguments)
min_block_number when not is_nil(min_block_number) <- Repo.aggregate(Transaction, :min, :block_number) do variant = Keyword.fetch!(json_rpc_named_arguments, :variant)
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) if variant == EthereumJSONRPC.Ganache || variant == EthereumJSONRPC.Arbitrum do
true
else else
{:transactions_exist, false} -> true with {:transactions_exist, true} <- {:transactions_exist, Repo.exists?(Transaction)},
nil -> false 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 end
end end

@ -1185,7 +1185,7 @@ defmodule Explorer.ChainTest do
end end
end end
describe "finished_indexing?/0" do describe "finished_internal_transactions_indexing?/0" do
test "finished indexing" do test "finished indexing" do
block = insert(:block, number: 1) block = insert(:block, number: 1)
@ -1193,11 +1193,11 @@ defmodule Explorer.ChainTest do
|> insert() |> insert()
|> with_block(block) |> with_block(block)
assert Chain.finished_indexing?() assert Chain.finished_internal_transactions_indexing?()
end end
test "finished indexing (no txs)" do test "finished indexing (no txs)" do
assert Chain.finished_indexing?() assert Chain.finished_internal_transactions_indexing?()
end end
test "not finished indexing" do test "not finished indexing" do
@ -1209,7 +1209,7 @@ defmodule Explorer.ChainTest do
insert(:pending_block_operation, block: block, fetch_internal_transactions: true) insert(:pending_block_operation, block: block, fetch_internal_transactions: true)
refute Chain.finished_indexing?() refute Chain.finished_internal_transactions_indexing?()
end end
end end

Loading…
Cancel
Save