From ee3a819c3f1731cf76ce430e333843b615038923 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Fri, 24 Apr 2020 10:04:35 +0300 Subject: [PATCH 01/15] Besu support --- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex | 4 ++-- .../lib/ethereum_jsonrpc/parity.ex | 2 +- .../indexer/fetcher/internal_transaction.ex | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex index dfe5fa4ea5..e4ecadfa6a 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex @@ -295,7 +295,7 @@ defmodule EthereumJSONRPC do Fetches internal transactions for entire blocks from variant API. """ def fetch_block_internal_transactions(params_list, json_rpc_named_arguments) when is_list(params_list) do - Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_block_internal_transactions( + EthereumJSONRPC.Parity.fetch_block_internal_transactions( params_list, json_rpc_named_arguments ) @@ -315,7 +315,7 @@ defmodule EthereumJSONRPC do Fetches pending transactions from variant API. """ def fetch_pending_transactions(json_rpc_named_arguments) do - Keyword.fetch!(json_rpc_named_arguments, :variant).fetch_pending_transactions(json_rpc_named_arguments) + EthereumJSONRPC.Parity.fetch_pending_transactions(json_rpc_named_arguments) end @spec fetch_transaction_receipts( diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/parity.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/parity.ex index 84a1b94702..5ca0f5e5a8 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/parity.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/parity.ex @@ -94,7 +94,7 @@ defmodule EthereumJSONRPC.Parity do {:ok, [Transaction.params()]} | {:error, reason :: term} def fetch_pending_transactions(json_rpc_named_arguments) do with {:ok, transactions} <- - %{id: 1, method: "parity_pendingTransactions", params: []} + %{id: 1, method: "txpool_besuTransactions", params: []} |> request() |> json_rpc(json_rpc_named_arguments) do transactions_params = diff --git a/apps/indexer/lib/indexer/fetcher/internal_transaction.ex b/apps/indexer/lib/indexer/fetcher/internal_transaction.ex index e9d914bd8c..0be16bf040 100644 --- a/apps/indexer/lib/indexer/fetcher/internal_transaction.ex +++ b/apps/indexer/lib/indexer/fetcher/internal_transaction.ex @@ -99,15 +99,16 @@ defmodule Indexer.Fetcher.InternalTransaction do Logger.debug("fetching internal transactions for blocks") - json_rpc_named_arguments - |> Keyword.fetch!(:variant) - |> case do - EthereumJSONRPC.Parity -> - EthereumJSONRPC.fetch_block_internal_transactions(unique_numbers, json_rpc_named_arguments) - - _ -> - fetch_block_internal_transactions_by_transactions(unique_numbers, json_rpc_named_arguments) - end + # json_rpc_named_arguments + # |> Keyword.fetch!(:variant) + # |> case do + # EthereumJSONRPC.Parity -> + # EthereumJSONRPC.fetch_block_internal_transactions(unique_numbers, json_rpc_named_arguments) + + # _ -> + # fetch_block_internal_transactions_by_transactions(unique_numbers, json_rpc_named_arguments) + # end + EthereumJSONRPC.fetch_block_internal_transactions(unique_numbers, json_rpc_named_arguments) |> case do {:ok, internal_transactions_params} -> import_internal_transaction(internal_transactions_params, unique_numbers) From 41dc4bdb4d56474726f1caea31a7b6fc7c20349e Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Tue, 12 May 2020 15:59:40 +0300 Subject: [PATCH 02/15] Finalize Besu variant --- .../templates/layout/_topnav.html.eex | 16 +- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex | 4 +- .../lib/ethereum_jsonrpc/besu.ex | 287 ++++++++++++++++++ .../lib/ethereum_jsonrpc/geth.ex | 2 +- .../lib/ethereum_jsonrpc/parity.ex | 2 +- apps/explorer/config/config.exs | 5 + apps/explorer/config/dev/besu.exs | 25 ++ apps/explorer/config/prod/besu.exs | 25 ++ apps/explorer/config/test/besu.exs | 14 + apps/indexer/config/dev/besu.exs | 30 ++ apps/indexer/config/prod/besu.exs | 29 ++ apps/indexer/config/test/besu.exs | 8 + .../indexer/fetcher/internal_transaction.ex | 22 +- 13 files changed, 449 insertions(+), 20 deletions(-) create mode 100644 apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/besu.ex create mode 100644 apps/explorer/config/dev/besu.exs create mode 100644 apps/explorer/config/prod/besu.exs create mode 100644 apps/explorer/config/test/besu.exs create mode 100644 apps/indexer/config/dev/besu.exs create mode 100644 apps/indexer/config/prod/besu.exs create mode 100644 apps/indexer/config/test/besu.exs 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 ce01098d43..d54f71fb41 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 @@ -55,12 +55,16 @@ class: "dropdown-item #{tab_status("txs", @conn.request_path)}", to: transaction_path(@conn, :index) ) %> - <%= link( - gettext("Pending"), - class: "dropdown-item #{tab_status("pending_transactions", @conn.request_path)}", - "data-test": "pending_transactions_link", - to: pending_transaction_path(@conn, :index) - ) %> + <% json_rpc_named_arguments = Application.fetch_env!(:indexer, :json_rpc_named_arguments)%> + <% variant = Keyword.fetch!(json_rpc_named_arguments, :variant) %> + <%= if variant !== EthereumJSONRPC.Besu do %> + <%= link( + gettext("Pending"), + class: "dropdown-item #{tab_status("pending_transactions", @conn.request_path)}", + "data-test": "pending_transactions_link", + to: pending_transaction_path(@conn, :index) + ) %> + <% end %>