From 624946a12bf090e1e02e47755e5fbf5fcc954319 Mon Sep 17 00:00:00 2001 From: pasqu4le Date: Tue, 24 Sep 2019 19:13:26 +0200 Subject: [PATCH 01/25] Add pending transactions cache --- CHANGELOG.md | 1 + .../block_scout_web/test/support/conn_case.ex | 2 + .../test/support/feature_case.ex | 2 + apps/explorer/config/config.exs | 4 ++ apps/explorer/lib/explorer/application.ex | 4 +- apps/explorer/lib/explorer/chain.ex | 19 +++++++++ .../chain/cache/pending_transactions.ex | 42 +++++++++++++++++++ .../explorer/chain/import/runner/blocks.ex | 12 +----- .../chain/cache/pending_transactions_test.exs | 17 ++++++++ apps/explorer/test/support/data_case.ex | 2 + apps/indexer/lib/indexer/block/fetcher.ex | 8 ++-- .../indexer/fetcher/pending_transaction.ex | 3 +- .../lib/indexer/fetcher/uncle_block.ex | 8 ++-- 13 files changed, 106 insertions(+), 18 deletions(-) create mode 100644 apps/explorer/lib/explorer/chain/cache/pending_transactions.ex create mode 100644 apps/explorer/test/explorer/chain/cache/pending_transactions_test.exs diff --git a/CHANGELOG.md b/CHANGELOG.md index 2311bc9d4c..68d65f4c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2735](https://github.com/poanetwork/blockscout/pull/2735) - Add pending transactions cache - [#2717](https://github.com/poanetwork/blockscout/pull/2717) - Improve speed of nonconsensus data removal - [#2679](https://github.com/poanetwork/blockscout/pull/2679) - added fixed height for card chain blocks and card chain transactions - [#2678](https://github.com/poanetwork/blockscout/pull/2678) - fixed dashboard banner height bug diff --git a/apps/block_scout_web/test/support/conn_case.ex b/apps/block_scout_web/test/support/conn_case.ex index ed3f094c34..5540346d34 100644 --- a/apps/block_scout_web/test/support/conn_case.ex +++ b/apps/block_scout_web/test/support/conn_case.ex @@ -44,6 +44,8 @@ defmodule BlockScoutWeb.ConnCase do Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Transactions.child_id()) Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Accounts.child_id()) Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Accounts.child_id()) + Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.PendingTransactions.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.PendingTransactions.child_id()) {:ok, conn: Phoenix.ConnTest.build_conn()} end diff --git a/apps/block_scout_web/test/support/feature_case.ex b/apps/block_scout_web/test/support/feature_case.ex index f6b1aedf24..2dd1d0635c 100644 --- a/apps/block_scout_web/test/support/feature_case.ex +++ b/apps/block_scout_web/test/support/feature_case.ex @@ -31,6 +31,8 @@ defmodule BlockScoutWeb.FeatureCase do Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Transactions.child_id()) Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Accounts.child_id()) Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Accounts.child_id()) + Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.PendingTransactions.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.PendingTransactions.child_id()) metadata = Phoenix.Ecto.SQL.Sandbox.metadata_for(Explorer.Repo, self()) {:ok, session} = Wallaby.start_session(metadata: metadata) diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index 0cf1a05b53..1d4fbc6204 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -145,6 +145,10 @@ config :explorer, Explorer.Chain.Cache.Accounts, ttl_check_interval: if(System.get_env("DISABLE_INDEXER") == "true", do: :timer.seconds(1), else: false), global_ttl: if(System.get_env("DISABLE_INDEXER") == "true", do: :timer.seconds(5)) +config :explorer, Explorer.Chain.Cache.PendingTransactions, + ttl_check_interval: if(System.get_env("DISABLE_INDEXER") == "true", do: :timer.seconds(1), else: false), + global_ttl: if(System.get_env("DISABLE_INDEXER") == "true", do: :timer.seconds(5)) + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/apps/explorer/lib/explorer/application.ex b/apps/explorer/lib/explorer/application.ex index 53d8c03ea3..9a8dff98d0 100644 --- a/apps/explorer/lib/explorer/application.ex +++ b/apps/explorer/lib/explorer/application.ex @@ -13,6 +13,7 @@ defmodule Explorer.Application do BlockNumber, Blocks, NetVersion, + PendingTransactions, TransactionCount, Transactions } @@ -51,7 +52,8 @@ defmodule Explorer.Application do con_cache_child_spec(MarketHistoryCache.cache_name()), con_cache_child_spec(RSK.cache_name(), ttl_check_interval: :timer.minutes(1), global_ttl: :timer.minutes(30)), Transactions, - Accounts + Accounts, + PendingTransactions ] children = base_children ++ configurable_children() diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index f89d933d6d..81f6061da5 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -53,6 +53,7 @@ defmodule Explorer.Chain do BlockCount, BlockNumber, Blocks, + PendingTransactions, TransactionCount, Transactions } @@ -2215,6 +2216,24 @@ defmodule Explorer.Chain do necessity_by_association = Keyword.get(options, :necessity_by_association, %{}) paging_options = Keyword.get(options, :paging_options, @default_paging_options) + if is_nil(paging_options.key) do + paging_options.page_size + |> PendingTransactions.take_enough() + |> case do + nil -> + pending_transactions = fetch_recent_pending_transactions(paging_options, necessity_by_association) + PendingTransactions.update(pending_transactions) + pending_transactions + + pending_transactions -> + pending_transactions + end + else + fetch_recent_pending_transactions(paging_options, necessity_by_association) + end + end + + defp fetch_recent_pending_transactions(paging_options, necessity_by_association) do Transaction |> page_pending_transaction(paging_options) |> limit(^paging_options.page_size) diff --git a/apps/explorer/lib/explorer/chain/cache/pending_transactions.ex b/apps/explorer/lib/explorer/chain/cache/pending_transactions.ex new file mode 100644 index 0000000000..686b5e7372 --- /dev/null +++ b/apps/explorer/lib/explorer/chain/cache/pending_transactions.ex @@ -0,0 +1,42 @@ +defmodule Explorer.Chain.Cache.PendingTransactions do + @moduledoc """ + Caches the latest pending transactions + """ + + alias Explorer.Chain.Transaction + + use Explorer.Chain.OrderedCache, + name: :pending_transactions, + max_size: 51, + preloads: [ + :block, + created_contract_address: :names, + from_address: :names, + to_address: :names, + token_transfers: :token, + token_transfers: :from_address, + token_transfers: :to_address + ], + ttl_check_interval: Application.get_env(:explorer, __MODULE__)[:ttl_check_interval], + global_ttl: Application.get_env(:explorer, __MODULE__)[:global_ttl] + + @type element :: Transaction.t() + + @type id :: {non_neg_integer(), non_neg_integer()} + + def element_to_id(%Transaction{inserted_at: inserted_at, hash: hash}) do + {inserted_at, hash} + end + + def update_pending(transactions) when is_nil(transactions), do: :ok + + def update_pending(transactions) do + transactions + |> Enum.filter(&pending?(&1)) + |> update() + end + + defp pending?(transaction) do + is_nil(transaction.block_hash) and (is_nil(transaction.error) or transaction.error != "dropped/replaced") + end +end diff --git a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex index 394e21cbaa..c6eab88d10 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex @@ -168,11 +168,7 @@ defmodule Explorer.Chain.Import.Runner.Blocks do query = from( transaction in where_forked(blocks_changes), - select: %{ - block_hash: transaction.block_hash, - index: transaction.index, - hash: transaction.hash - }, + select: transaction, # Enforce Transaction ShareLocks order (see docs: sharelocks.md) order_by: [asc: :hash], lock: "FOR UPDATE" @@ -196,11 +192,7 @@ defmodule Explorer.Chain.Import.Runner.Blocks do updated_at: ^updated_at ] ], - select: %{ - block_hash: s.block_hash, - index: s.index, - hash: s.hash - } + select: s ) {_num, transactions} = repo.update_all(update_query, [], timeout: timeout) diff --git a/apps/explorer/test/explorer/chain/cache/pending_transactions_test.exs b/apps/explorer/test/explorer/chain/cache/pending_transactions_test.exs new file mode 100644 index 0000000000..26339bc3d7 --- /dev/null +++ b/apps/explorer/test/explorer/chain/cache/pending_transactions_test.exs @@ -0,0 +1,17 @@ +defmodule Explorer.Chain.Cache.PendingTransactionsTest do + use Explorer.DataCase + + alias Explorer.Chain.Cache.PendingTransactions + + describe "update_pending/1" do + test "adds a new pending transaction" do + transaction = insert(:transaction, block_hash: nil, error: nil) + + PendingTransactions.update([transaction]) + + transaction_hash = transaction.hash + + assert [%{hash: transaction_hash}] = PendingTransactions.all() + end + end +end diff --git a/apps/explorer/test/support/data_case.ex b/apps/explorer/test/support/data_case.ex index e12dd24a82..90167e676d 100644 --- a/apps/explorer/test/support/data_case.ex +++ b/apps/explorer/test/support/data_case.ex @@ -47,6 +47,8 @@ defmodule Explorer.DataCase do Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Transactions.child_id()) Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Accounts.child_id()) Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Accounts.child_id()) + Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.PendingTransactions.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.PendingTransactions.child_id()) :ok end diff --git a/apps/indexer/lib/indexer/block/fetcher.ex b/apps/indexer/lib/indexer/block/fetcher.ex index 1b95d84086..d7cdd88664 100644 --- a/apps/indexer/lib/indexer/block/fetcher.ex +++ b/apps/indexer/lib/indexer/block/fetcher.ex @@ -13,7 +13,7 @@ defmodule Indexer.Block.Fetcher do alias Explorer.Chain alias Explorer.Chain.{Address, Block, Hash, Import, Transaction} alias Explorer.Chain.Cache.Blocks, as: BlocksCache - alias Explorer.Chain.Cache.{Accounts, BlockNumber, Transactions} + alias Explorer.Chain.Cache.{Accounts, BlockNumber, PendingTransactions, Transactions} alias Indexer.Block.Fetcher.Receipts alias Indexer.Fetcher.{ @@ -175,7 +175,7 @@ defmodule Indexer.Block.Fetcher do ) do result = {:ok, %{inserted: inserted, errors: blocks_errors}} update_block_cache(inserted[:blocks]) - update_transactions_cache(inserted[:transactions]) + update_transactions_cache(inserted[:transactions], inserted[:fork_transactions]) update_addresses_cache(inserted[:addresses]) result else @@ -194,8 +194,10 @@ defmodule Indexer.Block.Fetcher do defp update_block_cache(_), do: :ok - defp update_transactions_cache(transactions) do + defp update_transactions_cache(transactions, forked_transactions) do Transactions.update(transactions) + PendingTransactions.update_pending(transactions) + PendingTransactions.update_pending(forked_transactions) end defp update_addresses_cache(addresses), do: Accounts.drop(addresses) diff --git a/apps/indexer/lib/indexer/fetcher/pending_transaction.ex b/apps/indexer/lib/indexer/fetcher/pending_transaction.ex index 176d8dc9b7..0a8389a991 100644 --- a/apps/indexer/lib/indexer/fetcher/pending_transaction.ex +++ b/apps/indexer/lib/indexer/fetcher/pending_transaction.ex @@ -14,7 +14,7 @@ defmodule Indexer.Fetcher.PendingTransaction do alias Ecto.Changeset alias Explorer.Chain - alias Explorer.Chain.Cache.Accounts + alias Explorer.Chain.Cache.{Accounts, PendingTransactions} alias Indexer.Fetcher.PendingTransaction alias Indexer.Transform.Addresses @@ -151,6 +151,7 @@ defmodule Indexer.Fetcher.PendingTransaction do }) do {:ok, imported} -> Accounts.drop(imported[:addresses]) + PendingTransactions.update_pending(imported[:transactions]) :ok {:error, [%Changeset{} | _] = changesets} -> diff --git a/apps/indexer/lib/indexer/fetcher/uncle_block.ex b/apps/indexer/lib/indexer/fetcher/uncle_block.ex index e597d16ca2..3e7ab8da63 100644 --- a/apps/indexer/lib/indexer/fetcher/uncle_block.ex +++ b/apps/indexer/lib/indexer/fetcher/uncle_block.ex @@ -12,7 +12,7 @@ defmodule Indexer.Fetcher.UncleBlock do alias Ecto.Changeset alias EthereumJSONRPC.Blocks alias Explorer.Chain - alias Explorer.Chain.Cache.Accounts + alias Explorer.Chain.Cache.{Accounts, PendingTransactions} alias Explorer.Chain.Hash alias Indexer.{Block, BufferedTask, Tracer} alias Indexer.Fetcher.UncleBlock @@ -155,7 +155,7 @@ defmodule Indexer.Fetcher.UncleBlock do @impl Block.Fetcher def import(_, options) when is_map(options) do - with {:ok, %{block_second_degree_relations: block_second_degree_relations}} = ok <- + with {:ok, %{block_second_degree_relations: block_second_degree_relations} = imported} <- options |> Map.drop(@ignored_options) |> uncle_blocks() @@ -168,8 +168,10 @@ defmodule Indexer.Fetcher.UncleBlock do # * TokenBalance.async_fetch is not called because it uses block numbers from consensus, not uncles UncleBlock.async_fetch_blocks(block_second_degree_relations) + PendingTransactions.update_pending(imported[:transactions]) + PendingTransactions.update_pending(imported[:fork_transactions]) - ok + {:ok, imported} end end From 6b7e1ce2fe6e5537299542d2269bd04b23dd5a8d Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 26 Sep 2019 19:55:29 +0300 Subject: [PATCH 02/25] do not fail block `internal_transactions_indexed_at` field update this runner updates internal_transactions_index_at field in blocks table. but before this, it checks if these blocks are consensus, some blocks may lose consensus. we just shouldn't check if the number of updated records is exactly equal to the number of records that we want to insert. blocks that lost consensus will be re-fetched --- .../import/runner/internal_transactions_indexed_at_blocks.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex index 2726670a30..4f82b67715 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex @@ -68,7 +68,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactionsIndexedAtBlocks do block_count = Enum.count(block_numbers) try do - {^block_count, result} = + {_, result} = repo.update_all( from(b in Block, join: s in subquery(query), on: b.hash == s.hash), [set: [internal_transactions_indexed_at: timestamps.updated_at]], From 69ad1408f77d81c666e522449fa358072e499bf5 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 26 Sep 2019 20:00:19 +0300 Subject: [PATCH 03/25] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d5a5f82a..eb34f671a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -29,6 +29,7 @@ - [#2671](https://github.com/poanetwork/blockscout/pull/2671) - fixed buttons color at smart contract section - [#2660](https://github.com/poanetwork/blockscout/pull/2660) - set correct last value for coin balances chart data - [#2619](https://github.com/poanetwork/blockscout/pull/2619) - Enforce DB transaction's order to prevent deadlocks +- [#2738](https://github.com/poanetwork/blockscout/pull/2738) - do not fail block `internal_transactions_indexed_at` field update ### Chore - [#2724](https://github.com/poanetwork/blockscout/pull/2724) - fix ci by commenting a line in hackney library From 2c8a6d6fa305363bdb315eb802bbe938a7d4b5e3 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 26 Sep 2019 20:01:06 +0300 Subject: [PATCH 04/25] remove unused variable --- .../import/runner/internal_transactions_indexed_at_blocks.ex | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex index 4f82b67715..f2a3d482c8 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex @@ -65,8 +65,6 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactionsIndexedAtBlocks do lock: "FOR UPDATE" ) - block_count = Enum.count(block_numbers) - try do {_, result} = repo.update_all( From 480252140f70a7bb3b6377b698b12c3db010248c Mon Sep 17 00:00:00 2001 From: pasqu4le Date: Mon, 23 Sep 2019 18:17:03 +0200 Subject: [PATCH 05/25] Remove internal_transaction block_number setting from blocks runner Problem: Explorer's blocks runner is severely slowed down by doing two operation on internal transactions: - populating their block_number field - removing those in blocks that have lost consensus Solution: The field setting was introduced only to keep it correct in case of a reorg, but those internal_transactions do not pose this problem anymore because they are removed. For this reason we can remove the block_number field setting and simplify the remaining removal operation --- CHANGELOG.md | 1 + .../explorer/chain/import/runner/blocks.ex | 68 ++++++------------- .../import/runner/internal_transactions.ex | 53 +++++++-------- 3 files changed, 45 insertions(+), 77 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d5a5f82a..a45836d031 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2726](https://github.com/poanetwork/blockscout/pull/2726) - Remove internal_transaction block_number setting from blocks runner - [#2717](https://github.com/poanetwork/blockscout/pull/2717) - Improve speed of nonconsensus data removal - [#2679](https://github.com/poanetwork/blockscout/pull/2679) - added fixed height for card chain blocks and card chain transactions - [#2678](https://github.com/poanetwork/blockscout/pull/2678) - fixed dashboard banner height bug diff --git a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex index 394e21cbaa..7f94d8668c 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex @@ -56,7 +56,7 @@ defmodule Explorer.Chain.Import.Runner.Blocks do # Note, needs to be executed after `lose_consensus` for lock acquisition insert(repo, changes_list, insert_options) end) - |> Multi.run(:uncle_fetched_block_second_degree_relations, fn repo, %{blocks: blocks} when is_list(blocks) -> + |> Multi.run(:uncle_fetched_block_second_degree_relations, fn repo, _ -> update_block_second_degree_relations(repo, hashes, %{ timeout: options[Runner.Block.SecondDegreeRelations.option_key()][:timeout] || @@ -86,15 +86,9 @@ defmodule Explorer.Chain.Import.Runner.Blocks do |> Multi.run(:remove_nonconsensus_logs, fn repo, %{derive_transaction_forks: transactions} -> remove_nonconsensus_logs(repo, transactions, insert_options) end) - |> Multi.run(:acquire_internal_transactions, fn repo, %{derive_transaction_forks: transactions} -> - acquire_internal_transactions(repo, hashes, transactions) - end) |> Multi.run(:remove_nonconsensus_internal_transactions, fn repo, %{derive_transaction_forks: transactions} -> remove_nonconsensus_internal_transactions(repo, transactions, insert_options) end) - |> Multi.run(:internal_transaction_transaction_block_number, fn repo, _ -> - update_internal_transaction_block_number(repo, hashes) - end) |> Multi.run(:acquire_contract_address_tokens, fn repo, _ -> acquire_contract_address_tokens(repo, consensus_block_numbers) end) @@ -139,26 +133,6 @@ defmodule Explorer.Chain.Import.Runner.Blocks do Tokens.acquire_contract_address_tokens(repo, contract_address_hashes) end - defp acquire_internal_transactions(repo, hashes, forked_transaction_hashes) do - query = - from(internal_transaction in InternalTransaction, - join: transaction in Transaction, - on: internal_transaction.transaction_hash == transaction.hash, - where: transaction.block_hash in ^hashes, - or_where: transaction.hash in ^forked_transaction_hashes, - select: {internal_transaction.transaction_hash, internal_transaction.index}, - # Enforce InternalTransaction ShareLocks order (see docs: sharelocks.md) - order_by: [ - internal_transaction.transaction_hash, - internal_transaction.index - ], - # NOTE: find a better way to know the alias that ecto gives to token - lock: "FOR UPDATE OF i0" - ) - - {:ok, repo.all(query)} - end - defp fork_transactions(%{ repo: repo, timeout: timeout, @@ -379,13 +353,27 @@ defmodule Explorer.Chain.Import.Runner.Blocks do defp remove_nonconsensus_internal_transactions(repo, forked_transaction_hashes, %{timeout: timeout}) do query = - from(internal_transaction in InternalTransaction, + from( + internal_transaction in InternalTransaction, where: internal_transaction.transaction_hash in ^forked_transaction_hashes, - select: map(internal_transaction, [:transaction_hash, :index]) + select: %{transaction_hash: internal_transaction.transaction_hash}, + # Enforce InternalTransaction ShareLocks order (see docs: sharelocks.md) + order_by: [ + internal_transaction.transaction_hash, + internal_transaction.index + ], + lock: "FOR UPDATE" + ) + + delete_query = + from( + i in InternalTransaction, + join: s in subquery(query), + on: i.transaction_hash == s.transaction_hash, + select: map(i, [:transaction_hash, :index]) ) - # ShareLocks order already enforced by `acquire_internal_transactions` (see docs: sharelocks.md) - {_count, deleted_internal_transactions} = repo.delete_all(query, timeout: timeout) + {_count, deleted_internal_transactions} = repo.delete_all(delete_query, timeout: timeout) {:ok, deleted_internal_transactions} rescue @@ -645,24 +633,6 @@ defmodule Explorer.Chain.Import.Runner.Blocks do end end - defp update_internal_transaction_block_number(repo, blocks_hashes) when is_list(blocks_hashes) do - query = - from( - internal_transaction in InternalTransaction, - join: transaction in Transaction, - on: internal_transaction.transaction_hash == transaction.hash, - join: block in Block, - on: block.hash == transaction.block_hash, - where: block.hash in ^blocks_hashes, - update: [set: [block_number: block.number]] - ) - - # ShareLocks order already enforced by `acquire_internal_transactions` (see docs: sharelocks.md) - {total, _} = repo.update_all(query, []) - - {:ok, total} - end - defp where_forked(blocks_changes) when is_list(blocks_changes) do initial = from(t in Transaction, where: false) diff --git a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex index 93e3bdb6b5..67657d6542 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex @@ -52,32 +52,36 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |> Multi.run(:acquire_transactions, fn repo, _ -> acquire_transactions(repo, changes_list) end) - |> Multi.run(:internal_transactions, fn repo, _ -> - insert(repo, changes_list, insert_options) + |> Multi.run(:internal_transactions, fn repo, %{acquire_transactions: transactions} -> + insert(repo, changes_list, transactions, insert_options) end) - |> Multi.run(:internal_transactions_indexed_at_transactions, fn repo, %{acquire_transactions: transaction_hashes} -> - update_transactions(repo, transaction_hashes, update_transactions_options) + |> Multi.run(:internal_transactions_indexed_at_transactions, fn repo, %{acquire_transactions: transactions} -> + update_transactions(repo, transactions, update_transactions_options) end) end @impl Runner def timeout, do: @timeout - @spec insert(Repo.t(), [map], %{ + @spec insert(Repo.t(), [map], [Transaction.t()], %{ optional(:on_conflict) => Runner.on_conflict(), required(:timeout) => timeout, required(:timestamps) => Import.timestamps() }) :: {:ok, [%{index: non_neg_integer, transaction_hash: Hash.t()}]} | {:error, [Changeset.t()]} - defp insert(repo, changes_list, %{timeout: timeout, timestamps: timestamps} = options) + defp insert(repo, changes_list, transactions, %{timeout: timeout, timestamps: timestamps} = options) when is_list(changes_list) do on_conflict = Map.get_lazy(options, :on_conflict, &default_on_conflict/0) + transactions_map = Map.new(transactions, &{&1.hash, &1}) + # Enforce InternalTransaction ShareLocks order (see docs: sharelocks.md) ordered_changes_list = Enum.sort_by(changes_list, &{&1.transaction_hash, &1.index}) - final_changes_list = reject_pending_transactions(ordered_changes_list, repo) + final_changes_list = + ordered_changes_list + |> reject_pending_transactions(transactions_map) {:ok, internal_transactions} = Import.insert_changes_list( @@ -158,8 +162,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do from( t in Transaction, where: t.hash in ^transaction_hashes, - where: not is_nil(t.block_hash), - select: t.hash, + select: map(t, [:hash, :block_hash, :block_number]), # Enforce Transaction ShareLocks order (see docs: sharelocks.md) order_by: t.hash, lock: "FOR UPDATE" @@ -170,15 +173,19 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do {:ok, hashes} end - defp update_transactions(repo, transaction_hashes, %{ + defp update_transactions(repo, transactions, %{ timeout: timeout, timestamps: timestamps }) - when is_list(transaction_hashes) do + when is_list(transactions) do + transaction_hashes = Enum.map(transactions, & &1.hash) + update_query = from( t in Transaction, where: t.hash in ^transaction_hashes, + # do not try to update pending transactions + where: not is_nil(t.block_hash), # ShareLocks order already enforced by `acquire_transactions` (see docs: sharelocks.md) update: [ set: [ @@ -214,22 +221,12 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do end end - defp reject_pending_transactions(ordered_changes_list, repo) do - transaction_hashes = - ordered_changes_list - |> Enum.map(& &1.transaction_hash) - |> Enum.dedup() - - query = - from(t in Transaction, - where: t.hash in ^transaction_hashes, - where: is_nil(t.block_hash), - select: t.hash - ) - - pending_transactions = repo.all(query) - - ordered_changes_list - |> Enum.reject(fn %{transaction_hash: hash} -> Enum.member?(pending_transactions, hash) end) + defp reject_pending_transactions(ordered_changes_list, transactions_map) do + Enum.reject(ordered_changes_list, fn %{transaction_hash: hash} -> + transactions_map + |> Map.fetch!(hash) + |> Map.get(:block_hash) + |> is_nil() + end) end end From b244789492fddf60157a21d58eb17b9c26d154f4 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Mon, 30 Sep 2019 10:31:55 +0300 Subject: [PATCH 06/25] Fixed menu hovers in dark mode desktop view --- .tool-versions | 4 +- .../assets/css/theme/_dark-theme.scss | 42 ++++++++++--------- 2 files changed, 24 insertions(+), 22 deletions(-) diff --git a/.tool-versions b/.tool-versions index 785ba751f8..a5c42939bf 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -elixir 1.9.1-otp-22 -erlang 22.0 +elixir 1.9.0 +erlang 21.0 nodejs 10.11.0 diff --git a/apps/block_scout_web/assets/css/theme/_dark-theme.scss b/apps/block_scout_web/assets/css/theme/_dark-theme.scss index bd4a97aa11..b3d902d1c0 100644 --- a/apps/block_scout_web/assets/css/theme/_dark-theme.scss +++ b/apps/block_scout_web/assets/css/theme/_dark-theme.scss @@ -804,23 +804,25 @@ $labels-dark: #8a8dba; // header nav, labels color: $dark-primary; position: relative; } -.dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link:hover, -.dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link.activeLink, -.dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link:focus { - background-image: none; - width: 100%; - background-color: #35335d!important; - color: white; - border: none; - } - .dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link:hover:before - { - content: "|"; - height: 50px; - width: 50%; - opacity: 1; - background: none; - left: 24%; - top: 14%; - color: $dark-primary; - } \ No newline at end of file +@media (max-width: 991.98px) { + .dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link:hover, + .dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link.activeLink, + .dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link:focus { + background-image: none; + width: 100%; + background-color: #35335d!important; + color: white; + border: none; + } + .dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link:hover:before + { + content: "|"; + height: 50px; + width: 50%; + opacity: 1; + background: none; + left: 24%; + top: 14%; + color: $dark-primary; + } + } \ No newline at end of file From 2256208ff6eef6816a3745ad7b59705545876860 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Mon, 30 Sep 2019 10:48:47 +0300 Subject: [PATCH 07/25] Updated Changelog.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d5a5f82a..28ed60d253 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ - [#2663](https://github.com/poanetwork/blockscout/pull/2663) - Fetch address counters in parallel ### Fixes +- [#2742](https://github.com/poanetwork/blockscout/pull/2742) - +fixed menu hovers in dark mode desktop view - [#2737](https://github.com/poanetwork/blockscout/pull/2737) - switched hardcoded subnetwork value to elixir expression for mobile menu - [#2736](https://github.com/poanetwork/blockscout/pull/2736) - do not update cache if no blocks were inserted - [#2731](https://github.com/poanetwork/blockscout/pull/2731) - fix library verification From e427568c94820ec58d26846f146bd2d500a82c84 Mon Sep 17 00:00:00 2001 From: Yegor Date: Mon, 30 Sep 2019 13:22:27 +0300 Subject: [PATCH 08/25] Update .tool-versions --- .tool-versions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index a5c42939bf..785ba751f8 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -elixir 1.9.0 -erlang 21.0 +elixir 1.9.1-otp-22 +erlang 22.0 nodejs 10.11.0 From 50ad94f47b1046dbc5282f31348fa2f26df1c405 Mon Sep 17 00:00:00 2001 From: pasqu4le Date: Wed, 25 Sep 2019 20:18:59 +0200 Subject: [PATCH 09/25] Avoid internal_transactions import retries on blocks without valid transactions Problem: for some block numbers we fetch and receive internal transactions, but in the database the transactions they are part of either do not exist for that block or are pending. This causes a foreign key error and an endless cycle of import retries. Solution: instead of failing we remove consensus for such problematic blocks, so that they can be refetched with the correct transactions. --- .../import/runner/internal_transactions.ex | 80 ++++++++++++++----- ...internal_transactions_indexed_at_blocks.ex | 2 +- .../runner/internal_transactions_test.exs | 74 ++++++++++++++++- 3 files changed, 133 insertions(+), 23 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex index 67657d6542..b4704d382b 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions.ex @@ -4,9 +4,10 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do """ require Ecto.Query + require Logger alias Ecto.{Changeset, Multi, Repo} - alias Explorer.Chain.{Hash, Import, InternalTransaction, Transaction} + alias Explorer.Chain.{Block, Hash, Import, InternalTransaction, Transaction} alias Explorer.Chain.Import.Runner import Ecto.Query, only: [from: 2] @@ -58,6 +59,14 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do |> Multi.run(:internal_transactions_indexed_at_transactions, fn repo, %{acquire_transactions: transactions} -> update_transactions(repo, transactions, update_transactions_options) end) + |> Multi.run( + :remove_consensus_of_missing_transactions_blocks, + fn repo, %{internal_transactions: inserted} = results_map -> + # NOTE: for this to work it has to follow the runner `internal_transactions_indexed_at_blocks` + block_hashes = Map.get(results_map, :internal_transactions_indexed_at_blocks, []) + remove_consensus_of_missing_transactions_blocks(repo, block_hashes, changes_list, inserted) + end + ) end @impl Runner @@ -76,12 +85,11 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do transactions_map = Map.new(transactions, &{&1.hash, &1}) - # Enforce InternalTransaction ShareLocks order (see docs: sharelocks.md) - ordered_changes_list = Enum.sort_by(changes_list, &{&1.transaction_hash, &1.index}) - final_changes_list = - ordered_changes_list - |> reject_pending_transactions(transactions_map) + changes_list + # Enforce InternalTransaction ShareLocks order (see docs: sharelocks.md) + |> Enum.sort_by(&{&1.transaction_hash, &1.index}) + |> reject_missing_transactions(transactions_map) {:ok, internal_transactions} = Import.insert_changes_list( @@ -90,16 +98,12 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do conflict_target: [:transaction_hash, :index], for: InternalTransaction, on_conflict: on_conflict, - returning: [:transaction_hash, :index], + returning: true, timeout: timeout, timestamps: timestamps ) - {:ok, - for( - internal_transaction <- internal_transactions, - do: Map.take(internal_transaction, [:id, :index, :transaction_hash]) - )} + {:ok, internal_transactions} end defp default_on_conflict do @@ -162,15 +166,15 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do from( t in Transaction, where: t.hash in ^transaction_hashes, + # do not consider pending transactions + where: not is_nil(t.block_hash), select: map(t, [:hash, :block_hash, :block_number]), # Enforce Transaction ShareLocks order (see docs: sharelocks.md) order_by: t.hash, lock: "FOR UPDATE" ) - hashes = repo.all(query) - - {:ok, hashes} + {:ok, repo.all(query)} end defp update_transactions(repo, transactions, %{ @@ -183,9 +187,8 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do update_query = from( t in Transaction, + # pending transactions are already excluded by `acquire_transactions` where: t.hash in ^transaction_hashes, - # do not try to update pending transactions - where: not is_nil(t.block_hash), # ShareLocks order already enforced by `acquire_transactions` (see docs: sharelocks.md) update: [ set: [ @@ -221,10 +224,49 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactions do end end - defp reject_pending_transactions(ordered_changes_list, transactions_map) do + # If not using Parity this is not relevant + defp remove_consensus_of_missing_transactions_blocks(_, [], _, _), do: {:ok, []} + + defp remove_consensus_of_missing_transactions_blocks(repo, block_hashes, changes_list, inserted) do + inserted_block_numbers = MapSet.new(inserted, & &1.block_number) + + missing_transactions_block_numbers = + changes_list + |> MapSet.new(& &1.block_number) + |> MapSet.difference(inserted_block_numbers) + |> MapSet.to_list() + + update_query = + from( + b in Block, + where: b.number in ^missing_transactions_block_numbers, + where: b.hash in ^block_hashes, + # ShareLocks order already enforced by `internal_transactions_indexed_at_blocks` (see docs: sharelocks.md) + update: [set: [consensus: false, internal_transactions_indexed_at: nil]] + ) + + try do + {_num, result} = repo.update_all(update_query, []) + + Logger.debug(fn -> + [ + "consensus removed from blocks with numbers: ", + inspect(missing_transactions_block_numbers), + " because of missing transactions" + ] + end) + + {:ok, result} + rescue + postgrex_error in Postgrex.Error -> + {:error, %{exception: postgrex_error, missing_transactions_block_numbers: missing_transactions_block_numbers}} + end + end + + defp reject_missing_transactions(ordered_changes_list, transactions_map) do Enum.reject(ordered_changes_list, fn %{transaction_hash: hash} -> transactions_map - |> Map.fetch!(hash) + |> Map.get(hash, %{}) |> Map.get(:block_hash) |> is_nil() end) diff --git a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex index 2726670a30..07008e0b72 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/internal_transactions_indexed_at_blocks.ex @@ -70,7 +70,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactionsIndexedAtBlocks do try do {^block_count, result} = repo.update_all( - from(b in Block, join: s in subquery(query), on: b.hash == s.hash), + from(b in Block, join: s in subquery(query), on: b.hash == s.hash, select: b.hash), [set: [internal_transactions_indexed_at: timestamps.updated_at]], timeout: timeout ) diff --git a/apps/explorer/test/explorer/chain/import/runner/internal_transactions_test.exs b/apps/explorer/test/explorer/chain/import/runner/internal_transactions_test.exs index 66d62ae940..700106ffb5 100644 --- a/apps/explorer/test/explorer/chain/import/runner/internal_transactions_test.exs +++ b/apps/explorer/test/explorer/chain/import/runner/internal_transactions_test.exs @@ -2,7 +2,7 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactionsTest do use Explorer.DataCase alias Ecto.Multi - alias Explorer.Chain.{Data, Wei, Transaction, InternalTransaction} + alias Explorer.Chain.{Block, Data, Wei, Transaction, InternalTransaction} alias Explorer.Chain.Import.Runner.InternalTransactions describe "run/1" do @@ -42,10 +42,78 @@ defmodule Explorer.Chain.Import.Runner.InternalTransactionsTest do assert is_nil(Repo.get(Transaction, pending.hash).block_hash) end + + test "removes consensus to blocks where transactions are missing" do + empty_block = insert(:block) + pending = insert(:transaction) + + assert is_nil(pending.block_hash) + + full_block = insert(:block) + inserted = insert(:transaction) |> with_block(full_block) + + assert full_block.hash == inserted.block_hash + + index = 0 + + pending_transaction_changes = + pending.hash + |> make_internal_transaction_changes(index, nil) + |> Map.put(:block_number, empty_block.number) + + transaction_changes = + inserted.hash + |> make_internal_transaction_changes(index, nil) + |> Map.put(:block_number, full_block.number) + + multi = + Multi.new() + |> Multi.run(:internal_transactions_indexed_at_blocks, fn _, _ -> {:ok, [empty_block.hash, full_block.hash]} end) + + assert {:ok, _} = run_internal_transactions([pending_transaction_changes, transaction_changes], multi) + + assert from(i in InternalTransaction, where: i.transaction_hash == ^pending.hash) |> Repo.one() |> is_nil() + + assert %{consensus: false} = Repo.get(Block, empty_block.hash) + + assert from(i in InternalTransaction, where: i.transaction_hash == ^inserted.hash) |> Repo.one() |> is_nil() == + false + + assert %{consensus: true} = Repo.get(Block, full_block.hash) + end + + test "does not remove consensus when block is empty and no transactions are missing" do + empty_block = insert(:block) + + full_block = insert(:block) + inserted = insert(:transaction) |> with_block(full_block) + + assert full_block.hash == inserted.block_hash + + index = 0 + + transaction_changes = + inserted.hash + |> make_internal_transaction_changes(index, nil) + |> Map.put(:block_number, full_block.number) + + multi = + Multi.new() + |> Multi.run(:internal_transactions_indexed_at_blocks, fn _, _ -> {:ok, [empty_block.hash, full_block.hash]} end) + + assert {:ok, _} = run_internal_transactions([transaction_changes], multi) + + assert %{consensus: true} = Repo.get(Block, empty_block.hash) + + assert from(i in InternalTransaction, where: i.transaction_hash == ^inserted.hash) |> Repo.one() |> is_nil() == + false + + assert %{consensus: true} = Repo.get(Block, full_block.hash) + end end - defp run_internal_transactions(changes_list) when is_list(changes_list) do - Multi.new() + defp run_internal_transactions(changes_list, multi \\ Multi.new()) when is_list(changes_list) do + multi |> InternalTransactions.run(changes_list, %{ timeout: :infinity, timestamps: %{inserted_at: DateTime.utc_now(), updated_at: DateTime.utc_now()} From 41fdb67cc5d10404183181036ea040fcac03776d Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 1 Oct 2019 10:24:28 +0300 Subject: [PATCH 10/25] optimize addresses page the longest part of addreses page loading was fetching validation count for every address. addresses are loaded from cache. it takes less than a second but fetching validation count takes more than 5 seconds. Moreover, validation_count is not used. --- .../lib/block_scout_web/controllers/address_controller.ex | 3 +-- .../lib/block_scout_web/templates/address/_tile.html.eex | 5 ----- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex index e2cb1f6db7..d91552229a 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_controller.ex @@ -44,8 +44,7 @@ defmodule BlockScoutWeb.AddressController do index: index, exchange_rate: exchange_rate, total_supply: total_supply, - tx_count: tx_count, - validation_count: validation_count(address.hash) + tx_count: tx_count ) end) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex index 56f1a2bbb2..4945dca50c 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address/_tile.html.eex @@ -29,11 +29,6 @@ <%= @tx_count %> <%= gettext "Transactions sent" %> - <% if validator?(@address) do %> - - <%= @validation_count %> - <%= gettext "Validations" %> - <% end %> From a2929c4bc483354c17a2167368d1f387730389af Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 1 Oct 2019 10:29:27 +0300 Subject: [PATCH 11/25] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb34f671a9..aa86164e89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - [#2663](https://github.com/poanetwork/blockscout/pull/2663) - Fetch address counters in parallel ### Fixes +- [#2745](https://github.com/poanetwork/blockscout/pull/2745) - optimize addresses page - [#2737](https://github.com/poanetwork/blockscout/pull/2737) - switched hardcoded subnetwork value to elixir expression for mobile menu - [#2736](https://github.com/poanetwork/blockscout/pull/2736) - do not update cache if no blocks were inserted - [#2731](https://github.com/poanetwork/blockscout/pull/2731) - fix library verification From c0221a98a42ebd474e42cc7e11bca668ca8c806d Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 1 Oct 2019 10:30:22 +0300 Subject: [PATCH 12/25] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 5 ----- apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po | 5 ----- 2 files changed, 10 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 4d6f2cc136..8febd38487 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -1676,11 +1676,6 @@ msgstr "" msgid "Validated Transactions" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/address/_tile.html.eex:35 -msgid "Validations" -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:30 msgid "Validator Creation Date" 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 4d6f2cc136..8febd38487 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 @@ -1676,11 +1676,6 @@ msgstr "" msgid "Validated Transactions" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/address/_tile.html.eex:35 -msgid "Validations" -msgstr "" - #, elixir-format #: lib/block_scout_web/templates/address/_validator_metadata_modal.html.eex:30 msgid "Validator Creation Date" From 1a1905631d73df17bf5e56d94245b9419a37207d Mon Sep 17 00:00:00 2001 From: YegorSan Date: Tue, 1 Oct 2019 12:10:48 +0300 Subject: [PATCH 13/25] Deleted :before for menu links on desktop view --- .../assets/css/theme/_dark-theme.scss | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/apps/block_scout_web/assets/css/theme/_dark-theme.scss b/apps/block_scout_web/assets/css/theme/_dark-theme.scss index b3d902d1c0..a17bfb64b9 100644 --- a/apps/block_scout_web/assets/css/theme/_dark-theme.scss +++ b/apps/block_scout_web/assets/css/theme/_dark-theme.scss @@ -793,16 +793,6 @@ $labels-dark: #8a8dba; // header nav, labels background-image: none; width: 100%; background-color: #35335d!important; -} - .dark-theme-applied .dropdown-item:hover:before { - content: "|"; - height: 50px; - width: 50%; - opacity: 1; - background: none; - right: 17%; - color: $dark-primary; - position: relative; } @media (max-width: 991.98px) { .dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link:hover, @@ -814,6 +804,16 @@ $labels-dark: #8a8dba; // header nav, labels color: white; border: none; } + .dark-theme-applied .dropdown-item:hover:before { + content: "|"; + height: 50px; + width: 50%; + opacity: 1; + background: none; + right: 17%; + color: $dark-primary; + position: relative; + } .dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link:hover:before { content: "|"; From 69b3c29d4dc3f06ddc7d840613f1d4d9e4217946 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Tue, 1 Oct 2019 14:25:29 +0300 Subject: [PATCH 14/25] fixed address alignment in logs decoded view --- .../assets/css/components/_address-overview.scss | 4 ++++ .../lib/block_scout_web/templates/address_logs/_logs.html.eex | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/css/components/_address-overview.scss b/apps/block_scout_web/assets/css/components/_address-overview.scss index a936aec99f..b2a118db64 100644 --- a/apps/block_scout_web/assets/css/components/_address-overview.scss +++ b/apps/block_scout_web/assets/css/components/_address-overview.scss @@ -79,4 +79,8 @@ &:last-child { margin-bottom: 0; } +} + +.logs-decoded { + line-height: 25px; } \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex index 92a8ebc6cc..945049ace6 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_logs/_logs.html.eex @@ -17,7 +17,7 @@
<%= gettext "Transaction" %>
-

+

<%= link( @log.transaction, to: transaction_path(@conn, :show, @log.transaction), From f8cbc9e1ba6846746e720f940be9dc673078e212 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Tue, 1 Oct 2019 14:47:12 +0300 Subject: [PATCH 15/25] updated changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d5a5f82a..ead369a17f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - [#2663](https://github.com/poanetwork/blockscout/pull/2663) - Fetch address counters in parallel ### Fixes +- [#2746](https://github.com/poanetwork/blockscout/pull/2746) - fixed wrong alignment in logs decoded view - [#2737](https://github.com/poanetwork/blockscout/pull/2737) - switched hardcoded subnetwork value to elixir expression for mobile menu - [#2736](https://github.com/poanetwork/blockscout/pull/2736) - do not update cache if no blocks were inserted - [#2731](https://github.com/poanetwork/blockscout/pull/2731) - fix library verification From b0ad71037f6157b7445bbb071ed6e2151d311b54 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Wed, 2 Oct 2019 10:41:18 +0300 Subject: [PATCH 16/25] Changed menu item desktop hover color --- apps/block_scout_web/assets/css/theme/_dark-theme.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/css/theme/_dark-theme.scss b/apps/block_scout_web/assets/css/theme/_dark-theme.scss index a17bfb64b9..a7de393d89 100644 --- a/apps/block_scout_web/assets/css/theme/_dark-theme.scss +++ b/apps/block_scout_web/assets/css/theme/_dark-theme.scss @@ -792,7 +792,7 @@ $labels-dark: #8a8dba; // header nav, labels .dark-theme-applied .dropdown-item.active, .dark-theme-applied .dropdown-item:hover, .dark-theme-applied .dropdown-item:focus { background-image: none; width: 100%; - background-color: #35335d!important; + background-color: #3f426c!important; } @media (max-width: 991.98px) { .dark-theme-applied .navbar.navbar-primary .navbar-nav .nav-link:hover, From d2dcaf83ac8b88f26b4e598872f95ed414e62790 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Wed, 2 Oct 2019 11:08:44 +0300 Subject: [PATCH 17/25] Update for logs decoded view --- .../assets/css/components/_address-overview.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/css/components/_address-overview.scss b/apps/block_scout_web/assets/css/components/_address-overview.scss index b2a118db64..f758e4affc 100644 --- a/apps/block_scout_web/assets/css/components/_address-overview.scss +++ b/apps/block_scout_web/assets/css/components/_address-overview.scss @@ -82,5 +82,5 @@ } .logs-decoded { - line-height: 25px; + line-height: 25px!important; } \ No newline at end of file From c83c0d39c749de865623546e16f1284928a9e761 Mon Sep 17 00:00:00 2001 From: pasqu4le Date: Tue, 24 Sep 2019 16:48:57 +0200 Subject: [PATCH 18/25] Add cache for first page of uncles --- CHANGELOG.md | 1 + .../controllers/block_controller_test.exs | 2 + .../controllers/chain_controller_test.exs | 2 + apps/explorer/config/config.exs | 4 ++ apps/explorer/lib/explorer/application.ex | 6 ++- apps/explorer/lib/explorer/chain.ex | 48 ++++++++++++++----- .../lib/explorer/chain/cache/uncles.ex | 48 +++++++++++++++++++ .../explorer/chain/import/runner/blocks.ex | 3 +- .../test/explorer/chain/cache/uncles_test.exs | 28 +++++++++++ apps/indexer/lib/indexer/block/fetcher.ex | 7 ++- .../lib/indexer/fetcher/uncle_block.ex | 3 +- .../indexer/temporary/uncles_without_index.ex | 2 + 12 files changed, 137 insertions(+), 17 deletions(-) create mode 100644 apps/explorer/lib/explorer/chain/cache/uncles.ex create mode 100644 apps/explorer/test/explorer/chain/cache/uncles_test.exs diff --git a/CHANGELOG.md b/CHANGELOG.md index 6dda8910b3..77e7873840 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2733](https://github.com/poanetwork/blockscout/pull/2733) - Add cache for first page of uncles - [#2735](https://github.com/poanetwork/blockscout/pull/2735) - Add pending transactions cache - [#2726](https://github.com/poanetwork/blockscout/pull/2726) - Remove internal_transaction block_number setting from blocks runner - [#2717](https://github.com/poanetwork/blockscout/pull/2717) - Improve speed of nonconsensus data removal diff --git a/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs index 6c0bfabfa0..a467c7c73c 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/block_controller_test.exs @@ -5,6 +5,8 @@ defmodule BlockScoutWeb.BlockControllerTest do setup do Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) + Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Uncles.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Uncles.child_id()) :ok end diff --git a/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs index def232741c..93777e16e3 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/chain_controller_test.exs @@ -11,6 +11,8 @@ defmodule BlockScoutWeb.ChainControllerTest do setup do Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Blocks.child_id()) + Supervisor.terminate_child(Explorer.Supervisor, Explorer.Chain.Cache.Uncles.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Explorer.Chain.Cache.Uncles.child_id()) start_supervised!(AddressesCounter) AddressesCounter.consolidate() diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index 1d4fbc6204..7e17c086b0 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -149,6 +149,10 @@ config :explorer, Explorer.Chain.Cache.PendingTransactions, ttl_check_interval: if(System.get_env("DISABLE_INDEXER") == "true", do: :timer.seconds(1), else: false), global_ttl: if(System.get_env("DISABLE_INDEXER") == "true", do: :timer.seconds(5)) +config :explorer, Explorer.Chain.Cache.Uncles, + ttl_check_interval: if(System.get_env("DISABLE_INDEXER") == "true", do: :timer.seconds(1), else: false), + global_ttl: if(System.get_env("DISABLE_INDEXER") == "true", do: :timer.seconds(5)) + # Import environment specific config. This must remain at the bottom # of this file so it overrides the configuration defined above. import_config "#{Mix.env()}.exs" diff --git a/apps/explorer/lib/explorer/application.ex b/apps/explorer/lib/explorer/application.ex index 9a8dff98d0..f903f4ad17 100644 --- a/apps/explorer/lib/explorer/application.ex +++ b/apps/explorer/lib/explorer/application.ex @@ -15,7 +15,8 @@ defmodule Explorer.Application do NetVersion, PendingTransactions, TransactionCount, - Transactions + Transactions, + Uncles } alias Explorer.Chain.Supply.RSK @@ -53,7 +54,8 @@ defmodule Explorer.Application do con_cache_child_spec(RSK.cache_name(), ttl_check_interval: :timer.minutes(1), global_ttl: :timer.minutes(30)), Transactions, Accounts, - PendingTransactions + PendingTransactions, + Uncles ] children = base_children ++ configurable_children() diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 81f6061da5..01e71b7297 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -55,7 +55,8 @@ defmodule Explorer.Chain do Blocks, PendingTransactions, TransactionCount, - Transactions + Transactions, + Uncles } alias Explorer.Chain.Import.Runner @@ -1344,20 +1345,43 @@ defmodule Explorer.Chain do paging_options = Keyword.get(options, :paging_options) || @default_paging_options block_type = Keyword.get(options, :block_type, "Block") - if block_type == "Block" && !paging_options.key do - case Blocks.take_enough(paging_options.page_size) do - nil -> - elements = fetch_blocks(block_type, paging_options, necessity_by_association) + cond do + block_type == "Block" && !paging_options.key -> + block_from_cache(block_type, paging_options, necessity_by_association) - Blocks.update(elements) + block_type == "Uncle" && !paging_options.key -> + uncles_from_cache(block_type, paging_options, necessity_by_association) - elements + true -> + fetch_blocks(block_type, paging_options, necessity_by_association) + end + end - blocks -> - blocks - end - else - fetch_blocks(block_type, paging_options, necessity_by_association) + defp block_from_cache(block_type, paging_options, necessity_by_association) do + case Blocks.take_enough(paging_options.page_size) do + nil -> + elements = fetch_blocks(block_type, paging_options, necessity_by_association) + + Blocks.update(elements) + + elements + + blocks -> + blocks + end + end + + def uncles_from_cache(block_type, paging_options, necessity_by_association) do + case Uncles.take_enough(paging_options.page_size) do + nil -> + elements = fetch_blocks(block_type, paging_options, necessity_by_association) + + Uncles.update(elements) + + elements + + blocks -> + blocks end end diff --git a/apps/explorer/lib/explorer/chain/cache/uncles.ex b/apps/explorer/lib/explorer/chain/cache/uncles.ex new file mode 100644 index 0000000000..9afe0bf71b --- /dev/null +++ b/apps/explorer/lib/explorer/chain/cache/uncles.ex @@ -0,0 +1,48 @@ +defmodule Explorer.Chain.Cache.Uncles do + @moduledoc """ + Caches the last known uncles + """ + + alias Explorer.Chain.Block + alias Explorer.Repo + + use Explorer.Chain.OrderedCache, + name: :uncles, + max_size: 60, + ids_list_key: "uncle_numbers", + preload: :transactions, + preload: [miner: :names], + preload: :rewards, + preload: :nephews, + ttl_check_interval: Application.get_env(:explorer, __MODULE__)[:ttl_check_interval], + global_ttl: Application.get_env(:explorer, __MODULE__)[:global_ttl] + + import Ecto.Query + + @type element :: Block.t() + + @type id :: non_neg_integer() + + def element_to_id(%Block{number: number}), do: number + + def update_from_second_degree_relations(second_degree_relations) when is_nil(second_degree_relations), do: :ok + + def update_from_second_degree_relations(second_degree_relations) do + uncle_hashes = + second_degree_relations + |> Enum.map(& &1.uncle_hash) + |> Enum.uniq() + + query = + from( + block in Block, + where: block.consensus == false and block.hash in ^uncle_hashes, + inner_join: nephews in assoc(block, :nephews), + preload: [nephews: block] + ) + + query + |> Repo.all() + |> update() + end +end diff --git a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex index 21b8f49fe5..ff970faad6 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/blocks.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/blocks.ex @@ -612,7 +612,8 @@ defmodule Explorer.Chain.Import.Runner.Blocks do b in Block.SecondDegreeRelation, join: s in subquery(query), on: b.nephew_hash == s.nephew_hash and b.uncle_hash == s.uncle_hash, - update: [set: [uncle_fetched_at: ^updated_at]] + update: [set: [uncle_fetched_at: ^updated_at]], + select: map(b, [:nephew_hash, :uncle_hash, :index]) ) try do diff --git a/apps/explorer/test/explorer/chain/cache/uncles_test.exs b/apps/explorer/test/explorer/chain/cache/uncles_test.exs new file mode 100644 index 0000000000..c8984d34ea --- /dev/null +++ b/apps/explorer/test/explorer/chain/cache/uncles_test.exs @@ -0,0 +1,28 @@ +defmodule Explorer.Chain.Cache.UnclesTest do + use Explorer.DataCase + + alias Explorer.Chain.Cache.Uncles + alias Explorer.Repo + + setup do + Supervisor.terminate_child(Explorer.Supervisor, Uncles.child_id()) + Supervisor.restart_child(Explorer.Supervisor, Uncles.child_id()) + + :ok + end + + describe "update_from_second_degree_relations/1" do + test "fetches an uncle from a second_degree_relation and adds it to the cache" do + block = insert(:block) + uncle = insert(:block, consensus: false) + + uncle_hash = uncle.hash + + second_degree_relation = insert(:block_second_degree_relation, uncle_hash: uncle_hash, nephew: block) + + Uncles.update_from_second_degree_relations([second_degree_relation]) + + assert [%{hash: uncle_hash}] = Uncles.all() + end + end +end diff --git a/apps/indexer/lib/indexer/block/fetcher.ex b/apps/indexer/lib/indexer/block/fetcher.ex index 061785298b..7b51602ddf 100644 --- a/apps/indexer/lib/indexer/block/fetcher.ex +++ b/apps/indexer/lib/indexer/block/fetcher.ex @@ -13,7 +13,7 @@ defmodule Indexer.Block.Fetcher do alias Explorer.Chain alias Explorer.Chain.{Address, Block, Hash, Import, Transaction} alias Explorer.Chain.Cache.Blocks, as: BlocksCache - alias Explorer.Chain.Cache.{Accounts, BlockNumber, PendingTransactions, Transactions} + alias Explorer.Chain.Cache.{Accounts, BlockNumber, PendingTransactions, Transactions, Uncles} alias Indexer.Block.Fetcher.Receipts alias Indexer.Fetcher.{ @@ -177,6 +177,7 @@ defmodule Indexer.Block.Fetcher do update_block_cache(inserted[:blocks]) update_transactions_cache(inserted[:transactions], inserted[:fork_transactions]) update_addresses_cache(inserted[:addresses]) + update_uncles_cache(inserted[:block_second_degree_relations]) result else {step, {:error, reason}} -> {:error, {step, reason}} @@ -204,6 +205,10 @@ defmodule Indexer.Block.Fetcher do defp update_addresses_cache(addresses), do: Accounts.drop(addresses) + defp update_uncles_cache(updated_relations) do + Uncles.update_from_second_degree_relations(updated_relations) + end + def import( %__MODULE__{broadcast: broadcast, callback_module: callback_module} = state, options diff --git a/apps/indexer/lib/indexer/fetcher/uncle_block.ex b/apps/indexer/lib/indexer/fetcher/uncle_block.ex index 3e7ab8da63..03c6892964 100644 --- a/apps/indexer/lib/indexer/fetcher/uncle_block.ex +++ b/apps/indexer/lib/indexer/fetcher/uncle_block.ex @@ -12,7 +12,7 @@ defmodule Indexer.Fetcher.UncleBlock do alias Ecto.Changeset alias EthereumJSONRPC.Blocks alias Explorer.Chain - alias Explorer.Chain.Cache.{Accounts, PendingTransactions} + alias Explorer.Chain.Cache.{Accounts, PendingTransactions, Uncles} alias Explorer.Chain.Hash alias Indexer.{Block, BufferedTask, Tracer} alias Indexer.Fetcher.UncleBlock @@ -129,6 +129,7 @@ defmodule Indexer.Fetcher.UncleBlock do }) do {:ok, imported} -> Accounts.drop(imported[:addresses]) + Uncles.update_from_second_degree_relations(imported[:block_second_degree_relations]) retry(errors) {:error, {:import = step, [%Changeset{} | _] = changesets}} -> diff --git a/apps/indexer/lib/indexer/temporary/uncles_without_index.ex b/apps/indexer/lib/indexer/temporary/uncles_without_index.ex index 948f26b60d..12f133ff1a 100644 --- a/apps/indexer/lib/indexer/temporary/uncles_without_index.ex +++ b/apps/indexer/lib/indexer/temporary/uncles_without_index.ex @@ -15,6 +15,7 @@ defmodule Indexer.Temporary.UnclesWithoutIndex do alias EthereumJSONRPC.Blocks alias Explorer.{Chain, Repo} alias Explorer.Chain.Block.SecondDegreeRelation + alias Explorer.Chain.Cache.Uncles alias Indexer.{BufferedTask, Tracer} alias Indexer.Fetcher.UncleBlock @@ -99,6 +100,7 @@ defmodule Indexer.Temporary.UnclesWithoutIndex do case Chain.import(%{block_second_degree_relations: %{params: block_second_degree_relations_params}}) do {:ok, %{block_second_degree_relations: block_second_degree_relations}} -> UncleBlock.async_fetch_blocks(block_second_degree_relations) + Uncles.update_from_second_degree_relations(block_second_degree_relations) retry(errors) From a98b4218c79767d0ebc99d156b6e51ef3a329e78 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Thu, 3 Oct 2019 13:31:34 +0300 Subject: [PATCH 19/25] fixed logs alignment --- apps/block_scout_web/assets/css/_layout.scss | 4 ++++ .../block_scout_web/templates/transaction_log/_logs.html.eex | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/css/_layout.scss b/apps/block_scout_web/assets/css/_layout.scss index f1a4e92312..da36762bee 100644 --- a/apps/block_scout_web/assets/css/_layout.scss +++ b/apps/block_scout_web/assets/css/_layout.scss @@ -8,3 +8,7 @@ background-color: #fbfafc; } } + +.logs-hash { + line-height: 24px !important; +} \ No newline at end of file diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex index 6615ec8259..0d958b938c 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction_log/_logs.html.eex @@ -18,7 +18,7 @@
<%= gettext "Address" %>
-

+

<%= link( @log.address, to: address_path(@conn, :show, @log.address), From 511d33005d719b59c7c4a0963845e570daf5147c Mon Sep 17 00:00:00 2001 From: YegorSan Date: Thu, 3 Oct 2019 17:29:55 +0300 Subject: [PATCH 20/25] Fixed contract buttons color for each theme --- .tool-versions | 4 ++-- apps/block_scout_web/assets/css/theme/_ether1_variables.scss | 2 +- .../assets/css/theme/_ethereum_classic_variables.scss | 1 + .../block_scout_web/assets/css/theme/_ethereum_variables.scss | 1 + apps/block_scout_web/assets/css/theme/_goerli_variables.scss | 1 + apps/block_scout_web/assets/css/theme/_kovan_variables.scss | 1 + apps/block_scout_web/assets/css/theme/_poa_variables.scss | 1 + apps/block_scout_web/assets/css/theme/_rinkeby_variables.scss | 1 + apps/block_scout_web/assets/css/theme/_ropsten_variables.scss | 1 + apps/block_scout_web/assets/css/theme/_rsk_variables.scss | 2 +- apps/block_scout_web/assets/css/theme/_social_variables.scss | 2 +- apps/block_scout_web/assets/css/theme/_sokol_variables.scss | 2 +- .../assets/css/theme/_tomochain_variables.scss | 1 + .../assets/css/theme/_variables-non-critical.scss | 2 +- 14 files changed, 15 insertions(+), 7 deletions(-) diff --git a/.tool-versions b/.tool-versions index 785ba751f8..a5c42939bf 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -elixir 1.9.1-otp-22 -erlang 22.0 +elixir 1.9.0 +erlang 21.0 nodejs 10.11.0 diff --git a/apps/block_scout_web/assets/css/theme/_ether1_variables.scss b/apps/block_scout_web/assets/css/theme/_ether1_variables.scss index 323ceb22ac..ec5e65bb95 100644 --- a/apps/block_scout_web/assets/css/theme/_ether1_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_ether1_variables.scss @@ -37,7 +37,7 @@ $btn-line-bg: #fff; // button bg $btn-line-color: #4b021e; // button border and font color && hover bg color $btn-copy-color: #4b021e; // btn copy $btn-qr-color: #4b021e; // btn qr-code - +$btn-contract-color: #4b021e; //links & tile .tile a { color: $tertiary !important; } // links color for badges .tile-type-block { diff --git a/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables.scss b/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables.scss index 6b8d6d7f96..ffcdc4a44b 100644 --- a/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_ethereum_classic_variables.scss @@ -35,6 +35,7 @@ $btn-line-color: $tertiary; // button border and font color && hover bg color $btn-copy-color: $tertiary; // btn copy $btn-qr-color: $tertiary; // btn qr-code $btn-address-card-icon-color: $tertiary; // btn address color +$btn-contract-color: $tertiary; //links & tile $tile-body-a-color: $tertiary; diff --git a/apps/block_scout_web/assets/css/theme/_ethereum_variables.scss b/apps/block_scout_web/assets/css/theme/_ethereum_variables.scss index a06e0be93e..564242b150 100644 --- a/apps/block_scout_web/assets/css/theme/_ethereum_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_ethereum_variables.scss @@ -38,6 +38,7 @@ $btn-line-color: $secondary; // button border and font color && hover bg color $btn-copy-color: $secondary; // btn copy $btn-qr-color: $secondary; // btn qr-code $btn-address-card-icon-color: $secondary; // btn address color +$btn-contract-color: $secondary; //links & tile $tile-body-a-color: $secondary; diff --git a/apps/block_scout_web/assets/css/theme/_goerli_variables.scss b/apps/block_scout_web/assets/css/theme/_goerli_variables.scss index af57f2d1a2..d9d5d2ea17 100644 --- a/apps/block_scout_web/assets/css/theme/_goerli_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_goerli_variables.scss @@ -44,6 +44,7 @@ $btn-line-color: $sub-accent-color; // button border and font color && hover bg $btn-copy-color: $sub-accent-color; // btn copy $btn-qr-color: $sub-accent-color; // btn qr-code $btn-address-card-icon-color: $sub-accent-color; // btn address color +$btn-contract-color: $sub-accent-color; //links & tile $tile-body-a-color: $sub-accent-color; diff --git a/apps/block_scout_web/assets/css/theme/_kovan_variables.scss b/apps/block_scout_web/assets/css/theme/_kovan_variables.scss index b47c3de0b2..dc1cceafbd 100644 --- a/apps/block_scout_web/assets/css/theme/_kovan_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_kovan_variables.scss @@ -39,6 +39,7 @@ $btn-line-color: $tertiary; // button border and font color && hover bg color $btn-copy-color: $tertiary; // btn copy $btn-qr-color: $tertiary; // btn qr-code $btn-address-card-icon-color: $tertiary; // btn address color +$btn-contract-color: $tertiary; //links & tile $tile-body-a-color: $tertiary; diff --git a/apps/block_scout_web/assets/css/theme/_poa_variables.scss b/apps/block_scout_web/assets/css/theme/_poa_variables.scss index 536ecdc105..88dcb6eb06 100644 --- a/apps/block_scout_web/assets/css/theme/_poa_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_poa_variables.scss @@ -41,6 +41,7 @@ $btn-line-color: $primary; // button border and font color && hover bg color $btn-copy-color: $primary; // btn copy $btn-qr-color: $primary; // btn qr-code $btn-address-card-icon-color: $primary; // btn address color +$btn-contract-color: $primary; //links & tile $tile-body-a-color: $primary; diff --git a/apps/block_scout_web/assets/css/theme/_rinkeby_variables.scss b/apps/block_scout_web/assets/css/theme/_rinkeby_variables.scss index 21388bb315..68631dc349 100644 --- a/apps/block_scout_web/assets/css/theme/_rinkeby_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_rinkeby_variables.scss @@ -38,6 +38,7 @@ $btn-line-color: $secondary; // button border and font color && hover bg color $btn-copy-color: $secondary; // btn copy $btn-qr-color: $secondary; // btn qr-code $btn-address-card-icon-color: $secondary; // btn address color +$btn-contract-color: $secondary; //links & tile $tile-body-a-color: $secondary; diff --git a/apps/block_scout_web/assets/css/theme/_ropsten_variables.scss b/apps/block_scout_web/assets/css/theme/_ropsten_variables.scss index 21388bb315..68631dc349 100644 --- a/apps/block_scout_web/assets/css/theme/_ropsten_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_ropsten_variables.scss @@ -38,6 +38,7 @@ $btn-line-color: $secondary; // button border and font color && hover bg color $btn-copy-color: $secondary; // btn copy $btn-qr-color: $secondary; // btn qr-code $btn-address-card-icon-color: $secondary; // btn address color +$btn-contract-color: $secondary; //links & tile $tile-body-a-color: $secondary; diff --git a/apps/block_scout_web/assets/css/theme/_rsk_variables.scss b/apps/block_scout_web/assets/css/theme/_rsk_variables.scss index 8d3bff31d2..1e23b819c4 100644 --- a/apps/block_scout_web/assets/css/theme/_rsk_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_rsk_variables.scss @@ -39,7 +39,7 @@ $btn-line-color: $secondary; // button border and font color && hover bg color $btn-copy-color: $secondary; // btn copy $btn-qr-color: $secondary; // btn qr-code $btn-address-card-icon-color: $secondary; // btn address color - +$btn-contract-color: $secondary; // card $card-background-1: $secondary; $card-tab-active: $secondary; diff --git a/apps/block_scout_web/assets/css/theme/_social_variables.scss b/apps/block_scout_web/assets/css/theme/_social_variables.scss index 3d878dcf10..22718bd084 100644 --- a/apps/block_scout_web/assets/css/theme/_social_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_social_variables.scss @@ -5,4 +5,4 @@ $tertiary: #53a9ff; $footer-background-color: $primary; $footer-title-color: #fff; $footer-text-color: #fff; -$footer-item-disc-color: $secondary; +$footer-item-disc-color: $secondary; \ No newline at end of file diff --git a/apps/block_scout_web/assets/css/theme/_sokol_variables.scss b/apps/block_scout_web/assets/css/theme/_sokol_variables.scss index 2860342f1e..836cc8a114 100644 --- a/apps/block_scout_web/assets/css/theme/_sokol_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_sokol_variables.scss @@ -50,7 +50,7 @@ $btn-line-color: $sub-accent-color; // button border and font color && hover bg $btn-copy-color: $sub-accent-color; // btn copy $btn-qr-color: $sub-accent-color; // btn qr-code $btn-address-card-icon-color: $sub-accent-color; // btn address color - +$btn-contract-color: $sub-accent-color; //links & tile $tile-body-a-color: $sub-accent-color; $tile-type-block-color: $sub-accent-color; diff --git a/apps/block_scout_web/assets/css/theme/_tomochain_variables.scss b/apps/block_scout_web/assets/css/theme/_tomochain_variables.scss index 6f7694de7d..d3c3a166d5 100644 --- a/apps/block_scout_web/assets/css/theme/_tomochain_variables.scss +++ b/apps/block_scout_web/assets/css/theme/_tomochain_variables.scss @@ -1,3 +1,4 @@ $primary: #211841; $secondary: #f16950; $tertiary: #8b84bc; +$btn-contract-color: $primary; diff --git a/apps/block_scout_web/assets/css/theme/_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_variables-non-critical.scss index 39762ec68a..035e862540 100644 --- a/apps/block_scout_web/assets/css/theme/_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_variables-non-critical.scss @@ -1,5 +1,5 @@ @import "theme/base_variables"; -@import "neutral_variables-non-critical"; +//@import "neutral_variables-non-critical"; // @import "xusdt_variables-non-critical"; // @import "dai_variables-non-critical"; // @import "ethereum_classic_variables-non-critical"; From 648f99d00c964e145489266245ab502ab62dfacd Mon Sep 17 00:00:00 2001 From: YegorSan Date: Thu, 3 Oct 2019 17:35:50 +0300 Subject: [PATCH 21/25] Modified tool-versions file --- .tool-versions | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.tool-versions b/.tool-versions index a5c42939bf..785ba751f8 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -elixir 1.9.0 -erlang 21.0 +elixir 1.9.1-otp-22 +erlang 22.0 nodejs 10.11.0 From abc0cf1b053af8d73ec626941b9c0c278be48a47 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Thu, 3 Oct 2019 17:42:05 +0300 Subject: [PATCH 22/25] Changed non critical css file to initial state --- .../assets/css/theme/_variables-non-critical.scss | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/css/theme/_variables-non-critical.scss b/apps/block_scout_web/assets/css/theme/_variables-non-critical.scss index 035e862540..39762ec68a 100644 --- a/apps/block_scout_web/assets/css/theme/_variables-non-critical.scss +++ b/apps/block_scout_web/assets/css/theme/_variables-non-critical.scss @@ -1,5 +1,5 @@ @import "theme/base_variables"; -//@import "neutral_variables-non-critical"; +@import "neutral_variables-non-critical"; // @import "xusdt_variables-non-critical"; // @import "dai_variables-non-critical"; // @import "ethereum_classic_variables-non-critical"; From 725b136874bf00d433ade2c8e0dee35e1a2a3fb5 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Thu, 3 Oct 2019 17:45:54 +0300 Subject: [PATCH 23/25] updated Changelog file --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b13c4d6b64..dd43a97252 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - [#2663](https://github.com/poanetwork/blockscout/pull/2663) - Fetch address counters in parallel ### Fixes +- [#2750](https://github.com/poanetwork/blockscout/pull/2750) - fixed contract buttons color for NFT token instance on each theme - [#2718](https://github.com/poanetwork/blockscout/pull/2718) - Include all addresses taking part in transactions in wallets' addresses counter - [#2709](https://github.com/poanetwork/blockscout/pull/2709) - Fix stuck label and value for uncle block height - [#2707](https://github.com/poanetwork/blockscout/pull/2707) - fix for dashboard banner chart legend items From 4fe0bfc58583edf2072d079904539055bf6d9ce8 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 4 Oct 2019 10:18:15 +0300 Subject: [PATCH 24/25] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 138ddf18d8..d8cb35d7a0 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Currently available full-featured block explorers (Etherscan, Etherchain, Blockc |--------------------------------------------------------|-------------------------------------------------------|------------------------------------------------------|----------------------------------------------------------------| | [Callisto](https://blockscout.com/callisto/mainnet) | [Goerli Testnet](https://blockscout.com/eth/goerli) | [ARTIS](https://explorer.sigma1.artis.network) | [Celo Testnet](https://alfajores-blockscout.celo-testnet.org/) | | [Ethereum Classic](https://blockscout.com/etc/mainnet) | [Kovan Testnet](https://blockscout.com/eth/kovan) | [Ether-1](https://blocks.ether1.wattpool.net/) | [Matic Testnet](https://explorer.testnet2.matic.network/) | -| [Ethereum Mainnet](https://blockscout.com/eth/mainnet) | [LUKSO L14 Testnet](https://blockscout.com/lukso/l14) | [Kotti Testnet](https://kottiexplorer.ethernode.io/) | | +| [Ethereum Mainnet](https://blockscout.com/eth/mainnet) | [LUKSO L14 Testnet](https://blockscout.com/lukso/l14) | [Kotti Testnet](https://kottiexplorer.ethernode.io/) | [Mordor Testnet](https://mordorexplorer.ethernode.io/) | | [POA Core Network](https://blockscout.com/poa/core) | [POA Sokol Testnet](https://blockscout.com/poa/sokol) | [Fuse Network](https://explorer.fuse.io/) | | | [RSK](https://blockscout.com/rsk/mainnet) | [Rinkeby Testnet](https://blockscout.com/eth/rinkeby) | [Oasis Labs](https://blockexplorer.oasiscloud.io/) | | | [xDai Chain](https://blockscout.com/poa/dai) | [Ropsten Testnet](https://blockscout.com/eth/ropsten) | [Petrichor](https://explorer.petrachor.com/) | | From 039babc396e074a396cd6591feefd0d4d74ccab3 Mon Sep 17 00:00:00 2001 From: YegorSan Date: Fri, 4 Oct 2019 15:57:40 +0300 Subject: [PATCH 25/25] Removed unnecessary inline listener from mobile menu toggle button --- .../lib/block_scout_web/templates/layout/_topnav.html.eex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex index 0463d28a15..f0720ab5fd 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/layout/_topnav.html.eex @@ -27,7 +27,7 @@ document.getElementById("navbar-logo").style.filter = "brightness(0) invert(1)"; } -