Ganache ignores internal transactions

Why:

* We were using the `EthereumJSONRPC.Geth` variant for Ganache but we
recently learned that it doesn't support the `tracer` option for
[debug_traceTransaction](https://github.com/ethereum/go-ethereum/wiki/Management-APIs#debug_tracetransaction).
This `tracer` option is what we currently use to fetch internal
transactions for Geth. This was the cause of errors as shown on issue
1152 (link below).
* Issue link:
https://github.com/poanetwork/blockscout/issues/1152

This change addresses the need by:

* Creating `EthereumJSONRPC.Ganache`. It ignores fetching beneficiaries,
internal transactions, and pending transactions.
* Editing ganache config to use the `EthereumJSONRPC.Ganache` variant
instead of `EthereumJSONRPC.Geth`.
* Updating inaccurate doc in `EthereumJSONRPC.Geth`. It previously said
fetching internal transactions was not supported for Geth which is
inaccurate.
pull/1160/head
Sebastian Abondano 6 years ago
parent 3c0c96d738
commit 1bdb8c1166
  1. 31
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/ganache.ex
  2. 4
      apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth.ex
  3. 4
      apps/explorer/config/dev/ganache.exs
  4. 4
      apps/explorer/config/prod/ganache.exs
  5. 4
      apps/explorer/config/test/ganache.exs
  6. 2
      apps/indexer/config/dev/ganache.exs
  7. 2
      apps/indexer/config/prod/ganache.exs

@ -0,0 +1,31 @@
defmodule EthereumJSONRPC.Ganache do
@moduledoc """
Ethereum JSONRPC methods that are only supported by [Ganache](https://github.com/trufflesuite/ganache-core#implemented-methods).
"""
@behaviour EthereumJSONRPC.Variant
@doc """
Block reward contract beneficiary fetching is not supported currently for Ganache.
To signal to the caller that fetching is not supported, `:ignore` is returned.
"""
@impl EthereumJSONRPC.Variant
def fetch_beneficiaries(_block_range, _json_rpc_named_arguments), do: :ignore
@doc """
Internal transaction fetching is not currently supported for Ganache.
To signal to the caller that fetching is not supported, `:ignore` is returned.
"""
@impl EthereumJSONRPC.Variant
def fetch_internal_transactions(_transactions_params, _json_rpc_named_arguments), do: :ignore
@doc """
Pending transaction fetching is not supported currently for Ganache.
To signal to the caller that fetching is not supported, `:ignore` is returned.
"""
@impl EthereumJSONRPC.Variant
def fetch_pending_transactions(_json_rpc_named_arguments), do: :ignore
end

@ -18,9 +18,7 @@ defmodule EthereumJSONRPC.Geth do
def fetch_beneficiaries(_block_range, _json_rpc_named_arguments), do: :ignore
@doc """
Internal transaction fetching is not supported currently for Geth.
To signal to the caller that fetching is not supported, `:ignore` is returned.
Fetches the `t:Explorer.Chain.InternalTransaction.changeset/2` params.
"""
@impl EthereumJSONRPC.Variant
def fetch_internal_transactions(transactions_params, json_rpc_named_arguments) when is_list(transactions_params) do

@ -8,7 +8,7 @@ config :explorer,
url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "http://localhost:7545",
http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]]
],
variant: EthereumJSONRPC.Geth
variant: EthereumJSONRPC.Ganache
],
subscribe_named_arguments: [
transport: EthereumJSONRPC.WebSocket,
@ -16,5 +16,5 @@ config :explorer,
web_socket: EthereumJSONRPC.WebSocket.WebSocketClient,
url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "ws://localhost:7545"
],
variant: EthereumJSONRPC.Geth
variant: EthereumJSONRPC.Ganache
]

@ -8,7 +8,7 @@ config :explorer,
url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "http://localhost:7545",
http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]]
],
variant: EthereumJSONRPC.Geth
variant: EthereumJSONRPC.Ganache
],
subscribe_named_arguments: [
transport: EthereumJSONRPC.WebSocket,
@ -16,5 +16,5 @@ config :explorer,
web_socket: EthereumJSONRPC.WebSocket.WebSocketClient,
url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "ws://localhost:7545"
],
variant: EthereumJSONRPC.Geth
variant: EthereumJSONRPC.Ganache
]

@ -4,10 +4,10 @@ config :explorer,
json_rpc_named_arguments: [
transport: EthereumJSONRPC.Mox,
transport_options: [],
variant: EthereumJSONRPC.Geth
variant: EthereumJSONRPC.Ganache
],
subscribe_named_arguments: [
transport: EthereumJSONRPC.Mox,
transport_options: [],
variant: EthereumJSONRPC.Geth
variant: EthereumJSONRPC.Ganache
]

@ -9,7 +9,7 @@ config :indexer,
url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "http://localhost:7545",
http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]]
],
variant: EthereumJSONRPC.Geth
variant: EthereumJSONRPC.Ganache
],
subscribe_named_arguments: [
transport: EthereumJSONRPC.WebSocket,

@ -9,7 +9,7 @@ config :indexer,
url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "http://localhost:7545",
http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]]
],
variant: EthereumJSONRPC.Geth
variant: EthereumJSONRPC.Ganache
],
subscribe_named_arguments: [
transport: EthereumJSONRPC.WebSocket,

Loading…
Cancel
Save