From cf1be63b60d7275f356a9db5ef64496ed1e79cf2 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Ferreira Date: Thu, 25 Oct 2018 16:52:31 -0300 Subject: [PATCH 1/4] add new field to address extractor --- apps/indexer/lib/indexer/address_extraction.ex | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/apps/indexer/lib/indexer/address_extraction.ex b/apps/indexer/lib/indexer/address_extraction.ex index 6f9720378d..995465589a 100644 --- a/apps/indexer/lib/indexer/address_extraction.ex +++ b/apps/indexer/lib/indexer/address_extraction.ex @@ -78,6 +78,10 @@ defmodule Indexer.AddressExtraction do ] ], transactions: [ + [ + %{from: :block_number, to: :fetched_coin_balance_block_number}, + %{from: :created_contract_address_hash, to: :hash} + ], [ %{from: :block_number, to: :fetched_coin_balance_block_number}, %{from: :from_address_hash, to: :hash} @@ -362,7 +366,8 @@ defmodule Indexer.AddressExtraction do %{ required(:block_number) => non_neg_integer(), required(:from_address_hash) => String.t(), - optional(:to_address_hash) => String.t() + optional(:to_address_hash) => String.t(), + optional(:created_contract_address_hash) => String.t() } ], optional(:logs) => [ From e2b20f95bb1860fdcc6585c60b1fe12b354af391 Mon Sep 17 00:00:00 2001 From: Gustavo Santos Ferreira Date: Thu, 25 Oct 2018 16:53:35 -0300 Subject: [PATCH 2/4] add new field to Receipt elixir_to_params --- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex | 3 +++ 1 file changed, 3 insertions(+) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex index ce1f4dc672..52af2031f4 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex @@ -108,6 +108,7 @@ defmodule EthereumJSONRPC.Receipt do @spec elixir_to_params(elixir) :: %{ cumulative_gas_used: non_neg_integer, gas_used: non_neg_integer, + created_contract_address_hash: String.t() | nil, status: Status.t(), transaction_hash: String.t(), transaction_index: non_neg_integer() @@ -116,6 +117,7 @@ defmodule EthereumJSONRPC.Receipt do %{ "cumulativeGasUsed" => cumulative_gas_used, "gasUsed" => gas_used, + "contractAddress" => created_contract_address_hash, "transactionHash" => transaction_hash, "transactionIndex" => transaction_index } = elixir @@ -125,6 +127,7 @@ defmodule EthereumJSONRPC.Receipt do %{ cumulative_gas_used: cumulative_gas_used, gas_used: gas_used, + created_contract_address_hash: created_contract_address_hash, status: status, transaction_hash: transaction_hash, transaction_index: transaction_index From 1b239dadcc766fa08fc8612a8562f2ca75b2ad0c Mon Sep 17 00:00:00 2001 From: Gustavo Santos Ferreira Date: Thu, 25 Oct 2018 17:42:14 -0300 Subject: [PATCH 3/4] update tests --- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex | 2 ++ apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipts.ex | 1 + apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipts_test.exs | 4 ++++ 3 files changed, 7 insertions(+) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex index 52af2031f4..b2a0271e80 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipt.ex @@ -65,6 +65,7 @@ defmodule EthereumJSONRPC.Receipt do ...> } ...> ) %{ + created_contract_address_hash: "0xffc87239eb0267bc3ca2cd51d12fbf278e02ccb4", cumulative_gas_used: 269607, gas_used: 269607, status: :ok, @@ -97,6 +98,7 @@ defmodule EthereumJSONRPC.Receipt do ...> } ...> ) %{ + created_contract_address_hash: nil, cumulative_gas_used: 21001, gas_used: 21001, status: nil, diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipts.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipts.ex index 6056e07ba4..e5d706589c 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipts.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/receipts.ex @@ -97,6 +97,7 @@ defmodule EthereumJSONRPC.Receipts do ...> ]) [ %{ + created_contract_address_hash: nil, cumulative_gas_used: 50450, gas_used: 50450, status: :ok, diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipts_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipts_test.exs index 59e29b2511..d8eef3b6da 100644 --- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipts_test.exs +++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/receipts_test.exs @@ -14,6 +14,7 @@ defmodule EthereumJSONRPC.ReceiptsTest do describe "fetch/2" do test "with receipts and logs", %{json_rpc_named_arguments: json_rpc_named_arguments} do %{ + created_contract_address_hash: nil, cumulative_gas_used: cumulative_gas_used, gas_used: gas_used, address_hash: address_hash, @@ -29,6 +30,7 @@ defmodule EthereumJSONRPC.ReceiptsTest do case Keyword.fetch!(json_rpc_named_arguments, :variant) do EthereumJSONRPC.Geth -> %{ + created_contract_address_hash: nil, cumulative_gas_used: 884_322, address_hash: "0x1e2fbe6be9eb39fc894d38be976111f332172d83", block_number: 3_560_000, @@ -45,6 +47,7 @@ defmodule EthereumJSONRPC.ReceiptsTest do EthereumJSONRPC.Parity -> %{ + created_contract_address_hash: nil, cumulative_gas_used: 50450, gas_used: 50450, address_hash: "0x8bf38d4764929064f2d4d3a56520a76ab3df415b", @@ -73,6 +76,7 @@ defmodule EthereumJSONRPC.ReceiptsTest do %{ id: 0, result: %{ + "contractAddress" => nil, "cumulativeGasUsed" => integer_to_quantity(cumulative_gas_used), "gasUsed" => integer_to_quantity(gas_used), "logs" => [ From a9fd475df4b76e4702bb5383b84a153c6ef9008a Mon Sep 17 00:00:00 2001 From: Konstantin Zolotarev Date: Fri, 26 Oct 2018 16:05:03 +0300 Subject: [PATCH 4/4] Unified config variables for all JSON RPC variants --- apps/explorer/config/dev/ganache.exs | 2 +- apps/explorer/config/dev/geth.exs | 2 +- apps/explorer/config/dev/parity.exs | 10 +++++----- apps/explorer/config/prod/ganache.exs | 20 ++++++++++++++++++++ apps/explorer/config/prod/geth.exs | 2 +- apps/explorer/config/prod/parity.exs | 10 +++++----- apps/explorer/config/test/ganache.exs | 13 +++++++++++++ apps/indexer/config/dev/ganache.exs | 2 +- apps/indexer/config/dev/geth.exs | 2 +- apps/indexer/config/dev/parity.exs | 10 +++++----- apps/indexer/config/prod/ganache.exs | 20 ++++++++++++++++++++ apps/indexer/config/prod/geth.exs | 2 +- apps/indexer/config/prod/parity.exs | 10 +++++----- 13 files changed, 79 insertions(+), 26 deletions(-) create mode 100644 apps/explorer/config/prod/ganache.exs create mode 100644 apps/explorer/config/test/ganache.exs create mode 100644 apps/indexer/config/prod/ganache.exs diff --git a/apps/explorer/config/dev/ganache.exs b/apps/explorer/config/dev/ganache.exs index 2e66b814ef..3067ac0c68 100644 --- a/apps/explorer/config/dev/ganache.exs +++ b/apps/explorer/config/dev/ganache.exs @@ -14,7 +14,7 @@ config :explorer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: System.get_env("ETHEREUM_JSONRPC_WEB_SOCKET_URL") || "ws://localhost:7545" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "ws://localhost:7545" ], variant: EthereumJSONRPC.Geth ] diff --git a/apps/explorer/config/dev/geth.exs b/apps/explorer/config/dev/geth.exs index ed7e7da1d4..6bdba9a0b0 100644 --- a/apps/explorer/config/dev/geth.exs +++ b/apps/explorer/config/dev/geth.exs @@ -14,7 +14,7 @@ config :explorer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: System.get_env("ETHEREUM_JSONRPC_WEB_SOCKET_URL") || "wss://mainnet.infura.io/8lTvJTKmHPCHazkneJsY/ws" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "wss://mainnet.infura.io/8lTvJTKmHPCHazkneJsY/ws" ], variant: EthereumJSONRPC.Geth ] diff --git a/apps/explorer/config/dev/parity.exs b/apps/explorer/config/dev/parity.exs index 3b2a6b9cd9..64e9ee1a37 100644 --- a/apps/explorer/config/dev/parity.exs +++ b/apps/explorer/config/dev/parity.exs @@ -5,11 +5,11 @@ config :explorer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: "https://sokol.poa.network", + url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "https://sokol.poa.network", method_to_url: [ - eth_call: "https://sokol-trace.poa.network", - eth_getBalance: "https://sokol-trace.poa.network", - trace_replayTransaction: "https://sokol-trace.poa.network" + eth_call: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network", + eth_getBalance: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network", + trace_replayTransaction: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network" ], http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], @@ -19,7 +19,7 @@ config :explorer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: "wss://sokol-ws.poa.network/ws" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "wss://sokol-ws.poa.network/ws" ], variant: EthereumJSONRPC.Parity ] diff --git a/apps/explorer/config/prod/ganache.exs b/apps/explorer/config/prod/ganache.exs new file mode 100644 index 0000000000..3067ac0c68 --- /dev/null +++ b/apps/explorer/config/prod/ganache.exs @@ -0,0 +1,20 @@ +use Mix.Config + +config :explorer, + json_rpc_named_arguments: [ + transport: EthereumJSONRPC.HTTP, + transport_options: [ + http: EthereumJSONRPC.HTTP.HTTPoison, + 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 + ], + subscribe_named_arguments: [ + transport: EthereumJSONRPC.WebSocket, + transport_options: [ + web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "ws://localhost:7545" + ], + variant: EthereumJSONRPC.Geth + ] diff --git a/apps/explorer/config/prod/geth.exs b/apps/explorer/config/prod/geth.exs index eb2df2d549..6bdba9a0b0 100644 --- a/apps/explorer/config/prod/geth.exs +++ b/apps/explorer/config/prod/geth.exs @@ -14,7 +14,7 @@ config :explorer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "wss://mainnet.infura.io/8lTvJTKmHPCHazkneJsY/ws" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "wss://mainnet.infura.io/8lTvJTKmHPCHazkneJsY/ws" ], variant: EthereumJSONRPC.Geth ] diff --git a/apps/explorer/config/prod/parity.exs b/apps/explorer/config/prod/parity.exs index 50bc221517..64e9ee1a37 100644 --- a/apps/explorer/config/prod/parity.exs +++ b/apps/explorer/config/prod/parity.exs @@ -5,11 +5,11 @@ config :explorer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: System.get_env("ETHEREUM_URL") || "https://sokol.poa.network", + url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "https://sokol.poa.network", method_to_url: [ - eth_call: System.get_env("TRACE_URL") || "https://sokol-trace.poa.network", - eth_getBalance: System.get_env("TRACE_URL") || "https://sokol-trace.poa.network", - trace_replayTransaction: System.get_env("TRACE_URL") || "https://sokol-trace.poa.network" + eth_call: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network", + eth_getBalance: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network", + trace_replayTransaction: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network" ], http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], @@ -19,7 +19,7 @@ config :explorer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: System.get_env("WS_URL") || "wss://sokol-ws.poa.network/ws" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "wss://sokol-ws.poa.network/ws" ], variant: EthereumJSONRPC.Parity ] diff --git a/apps/explorer/config/test/ganache.exs b/apps/explorer/config/test/ganache.exs new file mode 100644 index 0000000000..73869e31a3 --- /dev/null +++ b/apps/explorer/config/test/ganache.exs @@ -0,0 +1,13 @@ +use Mix.Config + +config :explorer, + json_rpc_named_arguments: [ + transport: EthereumJSONRPC.Mox, + transport_options: [], + variant: EthereumJSONRPC.Geth + ], + subscribe_named_arguments: [ + transport: EthereumJSONRPC.Mox, + transport_options: [], + variant: EthereumJSONRPC.Geth + ] diff --git a/apps/indexer/config/dev/ganache.exs b/apps/indexer/config/dev/ganache.exs index eb133dd9d2..9c8512e246 100644 --- a/apps/indexer/config/dev/ganache.exs +++ b/apps/indexer/config/dev/ganache.exs @@ -15,6 +15,6 @@ config :indexer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: System.get_env("ETHEREUM_JSONRPC_WEB_SOCKET_URL") || "ws://localhost:7545" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "ws://localhost:7545" ] ] diff --git a/apps/indexer/config/dev/geth.exs b/apps/indexer/config/dev/geth.exs index 5d77bd550a..4950dccd3f 100644 --- a/apps/indexer/config/dev/geth.exs +++ b/apps/indexer/config/dev/geth.exs @@ -15,6 +15,6 @@ config :indexer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: System.get_env("ETHEREUM_JSONRPC_WEB_SOCKET_URL") || "wss://mainnet.infura.io/ws/8lTvJTKmHPCHazkneJsY" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "wss://mainnet.infura.io/ws/8lTvJTKmHPCHazkneJsY" ] ] diff --git a/apps/indexer/config/dev/parity.exs b/apps/indexer/config/dev/parity.exs index b4c984152b..8bd5e87c07 100644 --- a/apps/indexer/config/dev/parity.exs +++ b/apps/indexer/config/dev/parity.exs @@ -6,11 +6,11 @@ config :indexer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: "https://sokol.poa.network", + url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "https://sokol.poa.network", method_to_url: [ - eth_getBalance: "https://sokol-trace.poa.network", - trace_block: "https://sokol-trace.poa.network", - trace_replayTransaction: "https://sokol-trace.poa.network" + eth_getBalance: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network", + trace_block: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network", + trace_replayTransaction: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network" ], http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], @@ -20,6 +20,6 @@ config :indexer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: "wss://sokol-ws.poa.network/ws" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "wss://sokol-ws.poa.network/ws" ] ] diff --git a/apps/indexer/config/prod/ganache.exs b/apps/indexer/config/prod/ganache.exs new file mode 100644 index 0000000000..9c8512e246 --- /dev/null +++ b/apps/indexer/config/prod/ganache.exs @@ -0,0 +1,20 @@ +use Mix.Config + +config :indexer, + block_interval: 5_000, + json_rpc_named_arguments: [ + transport: EthereumJSONRPC.HTTP, + transport_options: [ + http: EthereumJSONRPC.HTTP.HTTPoison, + 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 + ], + subscribe_named_arguments: [ + transport: EthereumJSONRPC.WebSocket, + transport_options: [ + web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "ws://localhost:7545" + ] + ] diff --git a/apps/indexer/config/prod/geth.exs b/apps/indexer/config/prod/geth.exs index 8cb882ec38..4950dccd3f 100644 --- a/apps/indexer/config/prod/geth.exs +++ b/apps/indexer/config/prod/geth.exs @@ -15,6 +15,6 @@ config :indexer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: "wss://mainnet.infura.io/ws/8lTvJTKmHPCHazkneJsY" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "wss://mainnet.infura.io/ws/8lTvJTKmHPCHazkneJsY" ] ] diff --git a/apps/indexer/config/prod/parity.exs b/apps/indexer/config/prod/parity.exs index 441a856392..8bd5e87c07 100644 --- a/apps/indexer/config/prod/parity.exs +++ b/apps/indexer/config/prod/parity.exs @@ -6,11 +6,11 @@ config :indexer, transport: EthereumJSONRPC.HTTP, transport_options: [ http: EthereumJSONRPC.HTTP.HTTPoison, - url: System.get_env("ETHEREUM_URL") || "https://sokol.poa.network", + url: System.get_env("ETHEREUM_JSONRPC_HTTP_URL") || "https://sokol.poa.network", method_to_url: [ - eth_getBalance: System.get_env("TRACE_URL") || "https://sokol-trace.poa.network", - trace_block: System.get_env("TRACE_URL") || "https://sokol-trace.poa.network", - trace_replayTransaction: System.get_env("TRACE_URL") || "https://sokol-trace.poa.network" + eth_getBalance: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network", + trace_block: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network", + trace_replayTransaction: System.get_env("ETHEREUM_JSONRPC_TRACE_URL") || "https://sokol-trace.poa.network" ], http_options: [recv_timeout: 60_000, timeout: 60_000, hackney: [pool: :ethereum_jsonrpc]] ], @@ -20,6 +20,6 @@ config :indexer, transport: EthereumJSONRPC.WebSocket, transport_options: [ web_socket: EthereumJSONRPC.WebSocket.WebSocketClient, - url: System.get_env("WS_URL") || "wss://sokol-ws.poa.network/ws" + url: System.get_env("ETHEREUM_JSONRPC_WS_URL") || "wss://sokol-ws.poa.network/ws" ] ]