From a7f8a4a8a8fdd03e32c1efb8d5e46146702dab96 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 27 Jun 2019 09:46:21 +0300 Subject: [PATCH 01/30] bump elixir version to 1.9.0 --- .tool-versions | 2 +- apps/block_scout_web/mix.exs | 2 +- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transport.ex | 7 ++----- apps/ethereum_jsonrpc/mix.exs | 2 +- apps/explorer/mix.exs | 2 +- apps/indexer/mix.exs | 2 +- docs/requirements.md | 2 +- mix.exs | 2 +- 8 files changed, 9 insertions(+), 12 deletions(-) diff --git a/.tool-versions b/.tool-versions index dc46bc2cfb..71379b2fa7 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,3 +1,3 @@ -elixir 1.8.1 +elixir 1.9 erlang 21.0.4 nodejs 10.11.0 diff --git a/apps/block_scout_web/mix.exs b/apps/block_scout_web/mix.exs index 02e9d203fb..e431d4ecf5 100644 --- a/apps/block_scout_web/mix.exs +++ b/apps/block_scout_web/mix.exs @@ -15,7 +15,7 @@ defmodule BlockScoutWeb.Mixfile do plt_add_deps: :transitive, ignore_warnings: "../../.dialyzer-ignore" ], - elixir: "~> 1.8", + elixir: "~> 1.9", elixirc_paths: elixirc_paths(Mix.env()), lockfile: "../../mix.lock", package: package(), diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transport.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transport.ex index 1301fa5675..dc7f1839a6 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transport.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/transport.ex @@ -88,10 +88,6 @@ defmodule EthereumJSONRPC.Transport do `%{"id" => ..., "error" => reason}`. The transport can also give any `term()` for `reason` if a more specific reason is possible. - """ - @callback json_rpc(request, options) :: {:ok, result} | {:error, reason :: term()} - - @doc """ Runs a batch of Remote Procedure Call (RPC) `request`s with `options`. ## Returns @@ -99,8 +95,9 @@ defmodule EthereumJSONRPC.Transport do * `{:ok, [response]}` unlike `json_rpc(request, options)`, the individual `t:response.t/0` are not unwrapped and it is the callers responsibility to extract the `t:result/0` or error `reason`. * `{:error, reason}` an error that affects *all* `t:request/0`s, such as the batch as a whole being rejected. - """ + @callback json_rpc(request, options) :: {:ok, result} | {:error, reason :: term()} + @callback json_rpc(batch_request, options) :: {:ok, batch_response} | {:error, reason :: term()} @doc """ diff --git a/apps/ethereum_jsonrpc/mix.exs b/apps/ethereum_jsonrpc/mix.exs index a805dbd649..7c2299c4a8 100644 --- a/apps/ethereum_jsonrpc/mix.exs +++ b/apps/ethereum_jsonrpc/mix.exs @@ -15,7 +15,7 @@ defmodule EthereumJsonrpc.MixProject do plt_add_apps: [:mix], ignore_warnings: "../../.dialyzer-ignore" ], - elixir: "~> 1.8", + elixir: "~> 1.9", elixirc_paths: elixirc_paths(Mix.env()), lockfile: "../../mix.lock", preferred_cli_env: [ diff --git a/apps/explorer/mix.exs b/apps/explorer/mix.exs index f224471740..65ec9b3771 100644 --- a/apps/explorer/mix.exs +++ b/apps/explorer/mix.exs @@ -15,7 +15,7 @@ defmodule Explorer.Mixfile do plt_add_apps: ~w(ex_unit mix)a, ignore_warnings: "../../.dialyzer-ignore" ], - elixir: "~> 1.8", + elixir: "~> 1.9", elixirc_paths: elixirc_paths(Mix.env()), lockfile: "../../mix.lock", package: package(), diff --git a/apps/indexer/mix.exs b/apps/indexer/mix.exs index 9b8bd4d6ed..255aa756a3 100644 --- a/apps/indexer/mix.exs +++ b/apps/indexer/mix.exs @@ -10,7 +10,7 @@ defmodule Indexer.MixProject do deps: deps(), deps_path: "../../deps", description: "Fetches block chain data from on-chain node for later reading with Explorer.", - elixir: "~> 1.8", + elixir: "~> 1.9", elixirc_paths: elixirc_paths(Mix.env()), lockfile: "../../mix.lock", preferred_cli_env: [ diff --git a/docs/requirements.md b/docs/requirements.md index 2df13c6936..c64558afbc 100644 --- a/docs/requirements.md +++ b/docs/requirements.md @@ -5,7 +5,7 @@ | Dependency | Mac | Linux | |-------------|-----|-------| | [Erlang/OTP 21.0.4](https://github.com/erlang/otp) | `brew install erlang` | [Erlang Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L134) | -| [Elixir 1.8.1](https://elixir-lang.org/) | :point_up: | [Elixir Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L138) | +| [Elixir 1.9.0](https://elixir-lang.org/) | :point_up: | [Elixir Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L138) | | [Postgres 10.3](https://www.postgresql.org/) | `brew install postgresql` | [Postgres Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L187) | | [Node.js 10.x.x](https://nodejs.org/en/) | `brew install node` | [Node.js Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L66) | | [Automake](https://www.gnu.org/software/automake/) | `brew install automake` | [Automake Install Example](https://github.com/poanetwork/blockscout-terraform/blob/33f68e816e36dc2fb055911fa0372531f0e956e7/modules/stack/libexec/init.sh#L72) | diff --git a/mix.exs b/mix.exs index 47ee0f7a75..0643a20376 100644 --- a/mix.exs +++ b/mix.exs @@ -13,7 +13,7 @@ defmodule BlockScout.Mixfile do plt_add_apps: ~w(ex_unit mix)a, ignore_warnings: ".dialyzer-ignore" ], - elixir: "~> 1.8", + elixir: "~> 1.9", preferred_cli_env: [ coveralls: :test, "coveralls.detail": :test, From dc586f9c7acee99164c320fe9edf503bae85b3e7 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 27 Jun 2019 09:49:02 +0300 Subject: [PATCH 02/30] add CHNAGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index a578eab389..3c6b8fe2da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -54,6 +54,7 @@ ### Chore - [#2127](https://github.com/poanetwork/blockscout/pull/2127) - use previouse chromedriver version - [#2118](https://github.com/poanetwork/blockscout/pull/2118) - show only the last decompiled contract +- [#2255](https://github.com/poanetwork/blockscout/pull/2255) - upgrade elixir version to 1.9.0 ### Chore From e757543e5687bb17f4e920cdeb311a2e4cf44578 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 27 Jun 2019 09:54:14 +0300 Subject: [PATCH 03/30] update elixir in ci --- .circleci/config.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 53e5680e78..788dfc0133 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,9 +1,9 @@ version: 2 -jobs: +ojobs: build: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1-node-browsers + - image: circleci/elixir:1.9.0-node-browsers environment: MIX_ENV: test # match POSTGRES_PASSWORD for postgres image below @@ -129,7 +129,7 @@ jobs: check_formatted: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1 + - image: circleci/elixir:1.9.0 environment: MIX_ENV: test @@ -143,7 +143,7 @@ jobs: credo: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1 + - image: circleci/elixir:1.9.0 environment: MIX_ENV: test @@ -177,7 +177,7 @@ jobs: dialyzer: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1 + - image: circleci/elixir:1.9.0 environment: MIX_ENV: test @@ -247,7 +247,7 @@ jobs: gettext: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1 + - image: circleci/elixir:1.9.0 environment: MIX_ENV: test @@ -286,7 +286,7 @@ jobs: release: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1 + - image: circleci/elixir:1.9.0 environment: MIX_ENV: prod @@ -312,7 +312,7 @@ jobs: sobelow: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1 + - image: circleci/elixir:1.9.0 environment: MIX_ENV: test @@ -336,7 +336,7 @@ jobs: test_geth_http_websocket: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1-node-browsers + - image: circleci/elixir:1.9.0-node-browsers environment: MIX_ENV: test # match POSTGRES_PASSWORD for postgres image below @@ -390,7 +390,7 @@ jobs: test_geth_mox: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1-node-browsers + - image: circleci/elixir:1.9.0-node-browsers environment: MIX_ENV: test # match POSTGRES_PASSWORD for postgres image below @@ -444,7 +444,7 @@ jobs: test_parity_http_websocket: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1-node-browsers + - image: circleci/elixir:1.9.0-node-browsers environment: MIX_ENV: test # match POSTGRES_PASSWORD for postgres image below @@ -498,7 +498,7 @@ jobs: test_parity_mox: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1-node-browsers + - image: circleci/elixir:1.9.0-node-browsers environment: MIX_ENV: test # match POSTGRES_PASSWORD for postgres image below @@ -552,7 +552,7 @@ jobs: coveralls_merge: docker: # Ensure .tool-versions matches - - image: circleci/elixir:1.8.1 + - image: circleci/elixir:1.9.0 environment: MIX_ENV: test From 49bee0b6705d11ddb7d4274aac9aedf670fad532 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 27 Jun 2019 09:55:59 +0300 Subject: [PATCH 04/30] fix typo --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 788dfc0133..bc747ac1a2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,5 +1,5 @@ version: 2 -ojobs: +jobs: build: docker: # Ensure .tool-versions matches From 3ee917e2cc14e8ff32208c52dc943ffb891d9e32 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 14:37:36 +0300 Subject: [PATCH 05/30] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 2 ++ apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po | 2 ++ 2 files changed, 4 insertions(+) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 686000880d..9884980a38 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -509,11 +509,13 @@ msgstr "" #: lib/block_scout_web/templates/chain/show.html.eex:31 #: lib/block_scout_web/templates/layout/app.html.eex:53 #: lib/block_scout_web/views/address_view.ex:121 +#: lib/block_scout_web/views/address_view.ex:121 msgid "Market Cap" msgstr "" #, elixir-format #: lib/block_scout_web/views/transaction_view.ex:129 +#: lib/block_scout_web/views/transaction_view.ex:129 msgid "Max of" msgstr "" 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 d31714ba4c..6b24c15fa7 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 @@ -509,11 +509,13 @@ msgstr "" #: lib/block_scout_web/templates/chain/show.html.eex:31 #: lib/block_scout_web/templates/layout/app.html.eex:53 #: lib/block_scout_web/views/address_view.ex:121 +#: lib/block_scout_web/views/address_view.ex:121 msgid "Market Cap" msgstr "" #, elixir-format #: lib/block_scout_web/views/transaction_view.ex:129 +#: lib/block_scout_web/views/transaction_view.ex:129 msgid "Max of" msgstr "" From 5f424c01130a0011e36fd52034ee879e37c65390 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 14:41:49 +0300 Subject: [PATCH 06/30] fix release --- .circleci/config.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index bc747ac1a2..29d0e5ba20 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -298,7 +298,7 @@ jobs: - run: mix local.hex --force - run: mix local.rebar --force - - run: mix release --verbose --env prod + - run: MIX_ENV=prod mix release - run: name: Collecting artifacts command: | From 2af8cd8f25eaae05c23db28c8a8fb3315a1fa19e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 16:58:22 +0300 Subject: [PATCH 07/30] add release params --- mix.exs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/mix.exs b/mix.exs index 0643a20376..c6c74689f9 100644 --- a/mix.exs +++ b/mix.exs @@ -6,6 +6,7 @@ defmodule BlockScout.Mixfile do def project do [ aliases: aliases(Mix.env()), + version: "2.0", apps_path: "apps", deps: deps(), dialyzer: [ @@ -23,7 +24,17 @@ defmodule BlockScout.Mixfile do dialyzer: :test ], start_permanent: Mix.env() == :prod, - test_coverage: [tool: ExCoveralls] + test_coverage: [tool: ExCoveralls], + releases: [ + blockscout: [ + applications: [ + block_scout_web: :permanent, + ethereum_jsonrpc: :permanent, + explorer: :permanent, + indexer: :permanent + ] + ] + ] ] end @@ -61,8 +72,6 @@ defmodule BlockScout.Mixfile do # and cannot be accessed from applications inside the apps folder defp deps do [ - # Release - {:distillery, "~> 2.0", runtime: false}, # Documentation {:ex_doc, "~> 0.19.0", only: [:dev]}, # Code coverage From 0a13e0225b4ca8af38d9731168cc17292c845f84 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 17:25:18 +0300 Subject: [PATCH 08/30] fix test --- .../lib/ethereum_jsonrpc/rolling_window.ex | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex index 82e4a54072..0f83568f33 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex @@ -211,12 +211,16 @@ defmodule EthereumJSONRPC.RollingWindow do """ @spec inspect(table :: atom, key :: term()) :: nonempty_list(non_neg_integer) def inspect(table, key) do - case :ets.lookup(table, key) do - [{_, current_window, windows}] -> - [current_window | windows] - - _ -> - [] + if :ets.whereis(table) == :undefined do + [] + else + case :ets.lookup(table, key) do + [{_, current_window, windows}] -> + [current_window | windows] + + _ -> + [] + end end end end From 591e57630a6f6c550e1eeeb6a13f801a99bb4aef Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 20:17:46 +0300 Subject: [PATCH 09/30] fix dialyzer --- .dialyzer-ignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index 53e3554c6e..ce51d3b5ca 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -2,6 +2,6 @@ :0: Unknown function 'Elixir.ExUnit.CaseTemplate':'__proxy__'/2 :0: Unknown type 'Elixir.Map':t/0 apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex:400: Function timestamp_to_datetime/1 has no local return -apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: Function microseconds_time/1 has no local return -apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: The call 'Elixir.System':convert_time_unit(__@1::any(),'native','microseconds') breaks the contract (integer(),time_unit() | 'native',time_unit() | 'native') -> integer() -apps/block_scout_web/lib/block_scout_web/views/layout_view.ex:174: The call 'Elixir.Poison.Parser':'parse!'(any(),#{'keys':='atoms!'}) will never return since the success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []),[{atom(),_}]) -> 'false' | 'nil' | 'true' | binary() | ['false' | 'nil' | 'true' | binary() | [any()] | number() | map()] | number() | map() and the contract is (iodata(),'Elixir.Keyword':t()) -> t() \ No newline at end of file +lib/block_scout_web/views/layout_view.ex:174: The call 'Elixir.Poison.Parser':'parse!'(any(),#{'keys':='atoms!'}) will never return since the success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []),[{atom(),_}]) -> 'false' | 'nil' | 'true' | binary() | ['false' | 'nil' | 'true' | binary() | [any()] | number() | map()] | number() | map() and the contract is (iodata(),'Elixir.Keyword':t()) -> t() +lib/explorer/repo/prometheus_logger.ex:8: Function microseconds_time/1 has no local return +lib/explorer/repo/prometheus_logger.ex:8: The call 'Elixir.System':convert_time_unit(__@1::any(),'native','microseconds') breaks the contract (integer(),time_unit() | 'native',time_unit() | 'native') -> integer() From 70ee731da6188d111bc7a57af2481083b6a16a36 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 20:31:02 +0300 Subject: [PATCH 10/30] update dialyzer cache --- .circleci/config.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 29d0e5ba20..f410162b48 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -191,9 +191,9 @@ jobs: - restore_cache: keys: - - v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.lock" }} - - v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.exs" }} - - v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }} + - v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.lock" }} + - v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.exs" }} + - v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }} - run: name: Unpack PLT cache @@ -213,15 +213,15 @@ jobs: cp ~/.mix/dialyxir*.plt plts/ - save_cache: - key: v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.lock" }} + key: v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.lock" }} paths: - plts - save_cache: - key: v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.exs" }} + key: v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }}-{{ checksum "mix.exs" }} paths: - plts - save_cache: - key: v7-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }} + key: v8-mix-dialyzer-{{ checksum "OTP_VERSION.lock" }}-{{ checksum "ELIXIR_VERSION.lock" }} paths: - plts From 37566338f29052457187bef4d618b532fdd3ac76 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 21:31:08 +0300 Subject: [PATCH 11/30] add only line numbers --- .dialyzer-ignore | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index ce51d3b5ca..0608f8c79c 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -3,5 +3,5 @@ :0: Unknown type 'Elixir.Map':t/0 apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex:400: Function timestamp_to_datetime/1 has no local return lib/block_scout_web/views/layout_view.ex:174: The call 'Elixir.Poison.Parser':'parse!'(any(),#{'keys':='atoms!'}) will never return since the success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []),[{atom(),_}]) -> 'false' | 'nil' | 'true' | binary() | ['false' | 'nil' | 'true' | binary() | [any()] | number() | map()] | number() | map() and the contract is (iodata(),'Elixir.Keyword':t()) -> t() -lib/explorer/repo/prometheus_logger.ex:8: Function microseconds_time/1 has no local return -lib/explorer/repo/prometheus_logger.ex:8: The call 'Elixir.System':convert_time_unit(__@1::any(),'native','microseconds') breaks the contract (integer(),time_unit() | 'native',time_unit() | 'native') -> integer() +lib/explorer/repo/prometheus_logger.ex:8 +lib/block_scout_web/views/layout_view.ex:174 \ No newline at end of file From f713033fae922f6acfcba9ce5879bf31ba4bf024 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 11 Jul 2019 11:57:38 +0300 Subject: [PATCH 12/30] fix dialyzer --- .dialyzer-ignore | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index a2bf21fa45..ad80c473ec 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -8,5 +8,4 @@ lib/block_scout_web/views/layout_view.ex:174 apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: Function microseconds_time/1 has no local return apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: The call 'Elixir.System':convert_time_unit(__@1::any(),'native','microseconds') breaks the contract (integer(),time_unit() | 'native',time_unit() | 'native') -> integer() apps/block_scout_web/lib/block_scout_web/views/layout_view.ex:174: The call 'Elixir.Poison.Parser':'parse!'(any(),#{'keys':='atoms!'}) will never return since the success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []),[{atom(),_}]) -> 'false' | 'nil' | 'true' | binary() | ['false' | 'nil' | 'true' | binary() | [any()] | number() | map()] | number() | map() and the contract is (iodata(),'Elixir.Keyword':t()) -> t() -apps/explorer/lib/explorer/smart_contract/publisher_worker.ex:6: The pattern 'false' can never match the type 'true' -apps/explorer/lib/explorer/smart_contract/publisher_worker.ex:6: The test 5 == 'infinity' can never evaluate to 'true' +lib/explorer/smart_contract/publisher_worker.ex:6' From 2111d2ba31722c67d08546c92af3114c23263050 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 11 Jul 2019 12:21:50 +0300 Subject: [PATCH 13/30] setup rolling window tests --- .../test/ethereum_jsonrpc/rolling_window_test.exs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs index 25b7e41382..43f400434a 100644 --- a/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs +++ b/apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs @@ -10,7 +10,10 @@ defmodule EthereumJSONRPC.RollingWindowTest do setup do # We set `window_length` to a large time frame so that we can sweep manually to simulate # time passing - RollingWindow.start_link([table: @table, duration: :timer.minutes(120), window_count: 3], name: RollingWindow) + {:ok, pid} = + RollingWindow.start_link([table: @table, duration: :timer.minutes(120), window_count: 3], name: RollingWindow) + + on_exit(fn -> Process.exit(pid, :normal) end) :ok end From d794b7bc9fd1fcbb9ef1a23d864e00bda547e829 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 11 Jul 2019 12:30:38 +0300 Subject: [PATCH 14/30] fix dialyzer --- .dialyzer-ignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index ad80c473ec..62a4774c6d 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -5,7 +5,7 @@ apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex:400: Function timestamp_to_datetim lib/block_scout_web/views/layout_view.ex:174: The call 'Elixir.Poison.Parser':'parse!'(any(),#{'keys':='atoms!'}) will never return since the success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []),[{atom(),_}]) -> 'false' | 'nil' | 'true' | binary() | ['false' | 'nil' | 'true' | binary() | [any()] | number() | map()] | number() | map() and the contract is (iodata(),'Elixir.Keyword':t()) -> t() lib/explorer/repo/prometheus_logger.ex:8 lib/block_scout_web/views/layout_view.ex:174 +lib/explorer/smart_contract/publisher_worker.ex:6 apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: Function microseconds_time/1 has no local return apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: The call 'Elixir.System':convert_time_unit(__@1::any(),'native','microseconds') breaks the contract (integer(),time_unit() | 'native',time_unit() | 'native') -> integer() apps/block_scout_web/lib/block_scout_web/views/layout_view.ex:174: The call 'Elixir.Poison.Parser':'parse!'(any(),#{'keys':='atoms!'}) will never return since the success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []),[{atom(),_}]) -> 'false' | 'nil' | 'true' | binary() | ['false' | 'nil' | 'true' | binary() | [any()] | number() | map()] | number() | map() and the contract is (iodata(),'Elixir.Keyword':t()) -> t() -lib/explorer/smart_contract/publisher_worker.ex:6' From 7628b90060a66c7a439dac5ae2b421719d3628fa Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 11 Jul 2019 14:00:19 +0300 Subject: [PATCH 15/30] add CHANGELOG entry --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90943c1405..ba512c44d6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,8 +19,8 @@ - [#2302](https://github.com/poanetwork/blockscout/pull/2302) - fix names for xDai source - [#2289](https://github.com/poanetwork/blockscout/pull/2289) - Optional websockets for dev environment - [#2307](https://github.com/poanetwork/blockscout/pull/2307) - add GoJoy to README - - [#2293](https://github.com/poanetwork/blockscout/pull/2293) - remove request idle timeout configuration +- [#2255](https://github.com/poanetwork/blockscout/pull/2255) - bump elixir version to 1.9.0 ## 2.0.1-beta From d54021cbfb841dd48507b2e04dde103372ab3dcb Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 11 Jul 2019 17:04:25 +0300 Subject: [PATCH 16/30] fix CR issue --- .../lib/ethereum_jsonrpc/rolling_window.ex | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex index 0f83568f33..d761560315 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex @@ -209,18 +209,20 @@ defmodule EthereumJSONRPC.RollingWindow do @doc """ Display the raw contents of all windows for a given key. """ - @spec inspect(table :: atom, key :: term()) :: nonempty_list(non_neg_integer) + @spec inspect(table :: atom, key :: term()) :: nonempty_list(non_neg_integer) || [] def inspect(table, key) do - if :ets.whereis(table) == :undefined do - [] - else - case :ets.lookup(table, key) do - [{_, current_window, windows}] -> - [current_window | windows] - - _ -> - [] - end + case :ets.whereis(table) do + :undefined -> + [] + + tid -> + case :ets.lookup(tid, key) do + [{_, current_window, windows}] -> + [current_window | windows] + + _ -> + [] + end end end end From b04d8472e6bba14084d23399dfbb1f297ebb904e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 11 Jul 2019 17:13:20 +0300 Subject: [PATCH 17/30] fix typespec --- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex index d761560315..c1de043499 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/rolling_window.ex @@ -209,7 +209,7 @@ defmodule EthereumJSONRPC.RollingWindow do @doc """ Display the raw contents of all windows for a given key. """ - @spec inspect(table :: atom, key :: term()) :: nonempty_list(non_neg_integer) || [] + @spec inspect(table :: atom, key :: term()) :: nonempty_list(non_neg_integer) | [] def inspect(table, key) do case :ets.whereis(table) do :undefined -> From ba4a59be7c06480d5f95eefa98b3936fd76bdaf1 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 15 Jul 2019 14:18:37 +0300 Subject: [PATCH 18/30] fix dialyzer --- .dialyzer-ignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.dialyzer-ignore b/.dialyzer-ignore index 9fd534f745..de105bbd51 100644 --- a/.dialyzer-ignore +++ b/.dialyzer-ignore @@ -4,7 +4,7 @@ apps/ethereum_jsonrpc/lib/ethereum_jsonrpc.ex:400: Function timestamp_to_datetime/1 has no local return lib/block_scout_web/views/layout_view.ex:174: The call 'Elixir.Poison.Parser':'parse!'(any(),#{'keys':='atoms!'}) will never return since the success typing is (binary() | maybe_improper_list(binary() | maybe_improper_list(any(),binary() | []) | byte(),binary() | []),[{atom(),_}]) -> 'false' | 'nil' | 'true' | binary() | ['false' | 'nil' | 'true' | binary() | [any()] | number() | map()] | number() | map() and the contract is (iodata(),'Elixir.Keyword':t()) -> t() lib/explorer/repo/prometheus_logger.ex:8 -lib/block_scout_web/views/layout_view.ex:174 +lib/block_scout_web/views/layout_view.ex:175 lib/explorer/smart_contract/publisher_worker.ex:6 apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: Function microseconds_time/1 has no local return apps/explorer/lib/explorer/repo/prometheus_logger.ex:8: The call 'Elixir.System':convert_time_unit(__@1::any(),'native','microseconds') breaks the contract (integer(),time_unit() | 'native',time_unit() | 'native') -> integer() From eff839f1c4f215cd9aa3c87d607bb1c8ca676dde Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 15 Jul 2019 15:53:55 +0300 Subject: [PATCH 19/30] add default evm version to smart contract verification --- .../new.html.eex | 2 +- apps/explorer/config/config.exs | 2 +- apps/explorer/priv/compile_solc.js | 25 +++++++++++-------- .../solidity/code_compiler_test.exs | 20 +++++++++++++++ 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex index fd93b0af2b..e73e1434f0 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract_verification/new.html.eex @@ -50,7 +50,7 @@
<%= label :evm_version, :evm_version, gettext("EVM Version") %>
- <%= select f, :evm_version, @evm_versions, class: "form-control border-rounded", selected: "petersburg", "aria-describedby": "evm-version-help-block" %> + <%= select f, :evm_version, @evm_versions, class: "form-control border-rounded", selected: "default", "aria-describedby": "evm-version-help-block" %>
The EVM version the contract is written for. If the bytecode does not match the version, we try to verify using the latest EVM version. EVM version details.
diff --git a/apps/explorer/config/config.exs b/apps/explorer/config/config.exs index 65528753eb..defd5ae9e5 100644 --- a/apps/explorer/config/config.exs +++ b/apps/explorer/config/config.exs @@ -12,7 +12,7 @@ config :explorer, token_functions_reader_max_retries: 3, allowed_evm_versions: System.get_env("ALLOWED_EVM_VERSIONS") || - "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg", + "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg,default", include_uncles_in_average_block_time: if(System.get_env("UNCLES_IN_AVERAGE_BLOCK_TIME") == "false", do: false, else: true), healthy_blocks_period: System.get_env("HEALTHY_BLOCKS_PERIOD") || :timer.minutes(5) diff --git a/apps/explorer/priv/compile_solc.js b/apps/explorer/priv/compile_solc.js index 99048d9ffd..e6ba69c300 100755 --- a/apps/explorer/priv/compile_solc.js +++ b/apps/explorer/priv/compile_solc.js @@ -16,15 +16,7 @@ var solc = solc.setupMethods(compilerSnapshot); var fs = require('fs'); var sourceCode = fs.readFileSync(sourceCodePath, 'utf8'); -const input = { - language: 'Solidity', - sources: { - [newContractName]: { - content: sourceCode - } - }, - settings: { - evmVersion: evmVersion, +var settings = { optimizer: { enabled: optimize == '1', runs: optimizationRuns @@ -37,7 +29,20 @@ const input = { '*': ['*'] } } - } +} + +if (evmVersion !== 'default') { + settings = Object.assign(settings, {evmVersion: evmVersion}) +} + +const input = { + language: 'Solidity', + sources: { + [newContractName]: { + content: sourceCode + } + }, + settings: settings } diff --git a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs index d1c1d04b45..29674274ca 100644 --- a/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs +++ b/apps/explorer/test/explorer/smart_contract/solidity/code_compiler_test.exs @@ -53,6 +53,26 @@ defmodule Explorer.SmartContract.Solidity.CodeCompilerTest do }} = response end + test "compiles smart contract with default evm version", %{contract_code_info: contract_code_info} do + optimize = true + + response = + CodeCompiler.run( + name: contract_code_info.name, + compiler_version: contract_code_info.version, + code: contract_code_info.source_code, + optimize: optimize, + evm_version: "default" + ) + + assert {:ok, + %{ + "abi" => _, + "bytecode" => _, + "name" => _ + }} = response + end + test "compiles code with external libraries" do Enum.each(@compiler_tests, fn compiler_test -> compiler_version = compiler_test["compiler_version"] From aec8b8fccde5982f212e1e477ad224690b5de7d8 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 15 Jul 2019 15:58:32 +0300 Subject: [PATCH 20/30] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7a8a58beef..1399ca1fc7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ ## Current ### Features +- [#2360](https://github.com/poanetwork/blockscout/pull/2360) - add default evm version to smart contract verification - [#2294](https://github.com/poanetwork/blockscout/pull/2294) - add healthy block period checking endpoint ### Fixes From 14826824ad1dcd85793a1824f9a80e168a8dc58c Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 16 Jul 2019 16:16:50 +0300 Subject: [PATCH 21/30] add two columns of smart contract info --- .../templates/address_contract/index.html.eex | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex index 32f77425ca..f8da0a9c4f 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex @@ -23,12 +23,18 @@ <%= if BlockScoutWeb.AddressView.smart_contract_verified?(@address) do %>
-
<%= gettext "Contract name:" %>
-
<%= @address.smart_contract.name %>
+
<%= gettext "Contract name:" %>
+
<%= @address.smart_contract.name %>
+
<%= gettext "Optimization enabled" %>
+
<%= format_optimization_text(@address.smart_contract.optimization) %>
-
<%= gettext "Compiler version" %>
-
<%= @address.smart_contract.compiler_version %>
+
<%= gettext "Compiler version" %>
+
<%= @address.smart_contract.compiler_version %>
+ <%= if @address.smart_contract.optimization && @address.smart_contract.optimization_runs do %> +
<%= gettext "Optimization runs" %>
+
<%= @address.smart_contract.optimization_runs %>
+ <% end %>
<%= if @address.smart_contract.evm_version do %>
@@ -36,16 +42,6 @@
<%= @address.smart_contract.evm_version %>
<% end %> -
-
<%= gettext "Optimization enabled" %>
-
<%= format_optimization_text(@address.smart_contract.optimization) %>
-
- <%= if @address.smart_contract.optimization && @address.smart_contract.optimization_runs do %> -
-
<%= gettext "Optimization runs" %>
-
<%= @address.smart_contract.optimization_runs %>
-
- <% end %> <%= if @address.smart_contract.constructor_arguments do %>
<%= gettext "Constructor arguments" %>
From 199556c43f80484e935907ebb380a151c91ea0f2 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 17 Jul 2019 10:32:03 +0300 Subject: [PATCH 22/30] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 32 +++++++++---------- .../priv/gettext/en/LC_MESSAGES/default.po | 32 +++++++++---------- 2 files changed, 32 insertions(+), 32 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 8217a39d9c..508bfa45ec 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -230,7 +230,7 @@ msgid "Compiler" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:30 +#: lib/block_scout_web/templates/address_contract/index.html.eex:32 msgid "Compiler version" msgstr "" @@ -258,7 +258,7 @@ msgid "Connection Lost, click to load newer validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:71 +#: lib/block_scout_web/templates/address_contract/index.html.eex:67 msgid "Contract ABI" msgstr "" @@ -296,7 +296,7 @@ msgid "Contract name:" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:59 +#: lib/block_scout_web/templates/address_contract/index.html.eex:55 msgid "Contract source code" msgstr "" @@ -577,7 +577,7 @@ msgid "OUT" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:40 +#: lib/block_scout_web/templates/address_contract/index.html.eex:28 msgid "Optimization enabled" msgstr "" @@ -1405,17 +1405,17 @@ msgid "Support" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:73 +#: lib/block_scout_web/templates/address_contract/index.html.eex:69 msgid "Copy ABI" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:89 +#: lib/block_scout_web/templates/address_contract/index.html.eex:85 msgid "Copy Contract Creation Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:61 +#: lib/block_scout_web/templates/address_contract/index.html.eex:57 msgid "Copy Source Code" msgstr "" @@ -1487,7 +1487,7 @@ msgid "Search by address, token symbol name, transaction hash, or block number" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:35 +#: lib/block_scout_web/templates/address_contract/index.html.eex:41 #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:51 msgid "EVM Version" msgstr "" @@ -1518,7 +1518,7 @@ msgid "Decompiler version" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:45 +#: lib/block_scout_web/templates/address_contract/index.html.eex:35 #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:83 msgid "Optimization runs" msgstr "" @@ -1585,27 +1585,27 @@ msgid "Block Details" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:101 +#: lib/block_scout_web/templates/address_contract/index.html.eex:97 msgid "Contract Byte Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:87 +#: lib/block_scout_web/templates/address_contract/index.html.eex:83 msgid "Contract Creation Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:93 +#: lib/block_scout_web/templates/address_contract/index.html.eex:89 msgid "Contracts that self destruct in their constructors have no contract code published and cannot be verified." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:103 +#: lib/block_scout_web/templates/address_contract/index.html.eex:99 msgid "Copy Contract Byte Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:94 +#: lib/block_scout_web/templates/address_contract/index.html.eex:90 msgid "Displaying the init data provided of the creating transaction." msgstr "" @@ -1754,7 +1754,7 @@ msgid "Change Network" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:51 +#: lib/block_scout_web/templates/address_contract/index.html.eex:47 msgid "Constructor arguments" msgstr "" @@ -1769,7 +1769,7 @@ msgid "ERC-721 " msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:116 +#: lib/block_scout_web/templates/address_contract/index.html.eex:112 msgid "External libraries" msgstr "" 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 b58c06af59..26eb57164a 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 @@ -230,7 +230,7 @@ msgid "Compiler" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:30 +#: lib/block_scout_web/templates/address_contract/index.html.eex:32 msgid "Compiler version" msgstr "" @@ -258,7 +258,7 @@ msgid "Connection Lost, click to load newer validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:71 +#: lib/block_scout_web/templates/address_contract/index.html.eex:67 msgid "Contract ABI" msgstr "" @@ -296,7 +296,7 @@ msgid "Contract name:" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:59 +#: lib/block_scout_web/templates/address_contract/index.html.eex:55 msgid "Contract source code" msgstr "" @@ -577,7 +577,7 @@ msgid "OUT" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:40 +#: lib/block_scout_web/templates/address_contract/index.html.eex:28 msgid "Optimization enabled" msgstr "" @@ -1405,17 +1405,17 @@ msgid "Support" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:73 +#: lib/block_scout_web/templates/address_contract/index.html.eex:69 msgid "Copy ABI" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:89 +#: lib/block_scout_web/templates/address_contract/index.html.eex:85 msgid "Copy Contract Creation Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:61 +#: lib/block_scout_web/templates/address_contract/index.html.eex:57 msgid "Copy Source Code" msgstr "" @@ -1487,7 +1487,7 @@ msgid "Search by address, token symbol name, transaction hash, or block number" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:35 +#: lib/block_scout_web/templates/address_contract/index.html.eex:41 #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:51 msgid "EVM Version" msgstr "" @@ -1518,7 +1518,7 @@ msgid "Decompiler version" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:45 +#: lib/block_scout_web/templates/address_contract/index.html.eex:35 #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:83 msgid "Optimization runs" msgstr "" @@ -1585,27 +1585,27 @@ msgid "Block Details" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:101 +#: lib/block_scout_web/templates/address_contract/index.html.eex:97 msgid "Contract Byte Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:87 +#: lib/block_scout_web/templates/address_contract/index.html.eex:83 msgid "Contract Creation Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:93 +#: lib/block_scout_web/templates/address_contract/index.html.eex:89 msgid "Contracts that self destruct in their constructors have no contract code published and cannot be verified." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:103 +#: lib/block_scout_web/templates/address_contract/index.html.eex:99 msgid "Copy Contract Byte Code" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:94 +#: lib/block_scout_web/templates/address_contract/index.html.eex:90 msgid "Displaying the init data provided of the creating transaction." msgstr "" @@ -1754,7 +1754,7 @@ msgid "Change Network" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:51 +#: lib/block_scout_web/templates/address_contract/index.html.eex:47 msgid "Constructor arguments" msgstr "" @@ -1769,7 +1769,7 @@ msgid "ERC-721 " msgstr "" #, elixir-format -#: lib/block_scout_web/templates/address_contract/index.html.eex:116 +#: lib/block_scout_web/templates/address_contract/index.html.eex:112 msgid "External libraries" msgstr "" From 522d2c4a8373d7f5e3e7794811aa32bfc92a3789 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 17 Jul 2019 11:08:18 +0300 Subject: [PATCH 23/30] fix html columns --- .../templates/address_contract/index.html.eex | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex index f8da0a9c4f..dd0f6b7d20 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/address_contract/index.html.eex @@ -23,17 +23,17 @@ <%= if BlockScoutWeb.AddressView.smart_contract_verified?(@address) do %>
-
<%= gettext "Contract name:" %>
-
<%= @address.smart_contract.name %>
-
<%= gettext "Optimization enabled" %>
-
<%= format_optimization_text(@address.smart_contract.optimization) %>
+
<%= gettext "Contract name:" %>
+
<%= @address.smart_contract.name %>
+
<%= gettext "Optimization enabled" %>
+
<%= format_optimization_text(@address.smart_contract.optimization) %>
-
<%= gettext "Compiler version" %>
-
<%= @address.smart_contract.compiler_version %>
+
<%= gettext "Compiler version" %>
+
<%= @address.smart_contract.compiler_version %>
<%= if @address.smart_contract.optimization && @address.smart_contract.optimization_runs do %> -
<%= gettext "Optimization runs" %>
-
<%= @address.smart_contract.optimization_runs %>
+
<%= gettext "Optimization runs" %>
+
<%= @address.smart_contract.optimization_runs %>
<% end %>
<%= if @address.smart_contract.evm_version do %> From 433e29f6851a1dc94824ff6309a9cc3b7afa38b8 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 17 Jul 2019 11:09:04 +0300 Subject: [PATCH 24/30] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cd9165b22..e4b4e45dee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - [#2294](https://github.com/poanetwork/blockscout/pull/2294) - add healthy block period checking endpoint ### Fixes +- [#2368](https://github.com/poanetwork/blockscout/pull/2368) - add two columns of smart contract info - [#2346](https://github.com/poanetwork/blockscout/pull/2346) - Avoid fetching internal transactions of blocks that still need refetching - [#2350](https://github.com/poanetwork/blockscout/pull/2350) - fix invalid User agent headers - [#2345](https://github.com/poanetwork/blockscout/pull/2345) - do not override existing market records From 6615e8593c36d789b0b73e0f76b1dde7b0d19b9e Mon Sep 17 00:00:00 2001 From: pasqu4le Date: Wed, 17 Jul 2019 15:20:14 +0200 Subject: [PATCH 25/30] Update created_contract_code_indexed_at on transaction import conflict Problem: a transaction created_contract_code_indexed_at gets ignored during a conflicting update, so it is not updated. In particular it is not reset to NULL and this has been source of errors. Solution: add it as a field to check and update during an import with conflict. --- CHANGELOG.md | 1 + .../chain/import/runner/transactions.ex | 4 +- .../chain/import/runner/transactions_test.exs | 50 +++++++++++++++++++ 3 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 apps/explorer/test/explorer/chain/import/runner/transactions_test.exs diff --git a/CHANGELOG.md b/CHANGELOG.md index 7cd9165b22..484ebcdcb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,7 @@ - [#2294](https://github.com/poanetwork/blockscout/pull/2294) - add healthy block period checking endpoint ### Fixes +- [#2375](https://github.com/poanetwork/blockscout/pull/2375) - Update created_contract_code_indexed_at on transaction import conflict - [#2346](https://github.com/poanetwork/blockscout/pull/2346) - Avoid fetching internal transactions of blocks that still need refetching - [#2350](https://github.com/poanetwork/blockscout/pull/2350) - fix invalid User agent headers - [#2345](https://github.com/poanetwork/blockscout/pull/2345) - do not override existing market records diff --git a/apps/explorer/lib/explorer/chain/import/runner/transactions.ex b/apps/explorer/lib/explorer/chain/import/runner/transactions.ex index 2c36d7c7e5..570d934218 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/transactions.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/transactions.ex @@ -105,6 +105,7 @@ defmodule Explorer.Chain.Import.Runner.Transactions do old_block_hash: transaction.block_hash, block_number: fragment("EXCLUDED.block_number"), created_contract_address_hash: fragment("EXCLUDED.created_contract_address_hash"), + created_contract_code_indexed_at: fragment("EXCLUDED.created_contract_code_indexed_at"), cumulative_gas_used: fragment("EXCLUDED.cumulative_gas_used"), error: fragment("EXCLUDED.error"), from_address_hash: fragment("EXCLUDED.from_address_hash"), @@ -128,10 +129,11 @@ defmodule Explorer.Chain.Import.Runner.Transactions do ], where: fragment( - "(EXCLUDED.block_hash, EXCLUDED.block_number, EXCLUDED.created_contract_address_hash, EXCLUDED.cumulative_gas_used, EXCLUDED.cumulative_gas_used, EXCLUDED.from_address_hash, EXCLUDED.gas, EXCLUDED.gas_price, EXCLUDED.gas_used, EXCLUDED.index, EXCLUDED.internal_transactions_indexed_at, EXCLUDED.input, EXCLUDED.nonce, EXCLUDED.r, EXCLUDED.s, EXCLUDED.status, EXCLUDED.to_address_hash, EXCLUDED.v, EXCLUDED.value) IS DISTINCT FROM (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", + "(EXCLUDED.block_hash, EXCLUDED.block_number, EXCLUDED.created_contract_address_hash, EXCLUDED.created_contract_code_indexed_at, EXCLUDED.cumulative_gas_used, EXCLUDED.cumulative_gas_used, EXCLUDED.from_address_hash, EXCLUDED.gas, EXCLUDED.gas_price, EXCLUDED.gas_used, EXCLUDED.index, EXCLUDED.internal_transactions_indexed_at, EXCLUDED.input, EXCLUDED.nonce, EXCLUDED.r, EXCLUDED.s, EXCLUDED.status, EXCLUDED.to_address_hash, EXCLUDED.v, EXCLUDED.value) IS DISTINCT FROM (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", transaction.block_hash, transaction.block_number, transaction.created_contract_address_hash, + transaction.created_contract_code_indexed_at, transaction.cumulative_gas_used, transaction.cumulative_gas_used, transaction.from_address_hash, diff --git a/apps/explorer/test/explorer/chain/import/runner/transactions_test.exs b/apps/explorer/test/explorer/chain/import/runner/transactions_test.exs new file mode 100644 index 0000000000..2bfea8750b --- /dev/null +++ b/apps/explorer/test/explorer/chain/import/runner/transactions_test.exs @@ -0,0 +1,50 @@ +defmodule Explorer.Chain.Import.Runner.TransactionsTest do + use Explorer.DataCase + + alias Ecto.Multi + alias Explorer.Chain.{Address, Transaction} + alias Explorer.Chain.Import.Runner.Transactions + + describe "run/1" do + test "transaction's created_contract_code_indexed_at is modified on update" do + %Address{hash: address_hash} = insert(:address) + + transaction = + insert(:transaction, + created_contract_address_hash: address_hash, + created_contract_code_indexed_at: DateTime.utc_now() + ) + + assert not is_nil(transaction.created_contract_code_indexed_at) + + non_indexed_transaction_params = %{ + from_address_hash: transaction.from_address.hash, + gas: transaction.gas, + gas_price: transaction.gas_price, + hash: transaction.hash, + input: transaction.input, + nonce: transaction.nonce, + r: transaction.r, + s: transaction.s, + to_address_hash: transaction.to_address.hash, + v: transaction.v, + value: transaction.value, + created_contract_address_hash: address_hash, + created_contract_code_indexed_at: nil + } + + assert {:ok, _} = run_transactions([non_indexed_transaction_params]) + + assert is_nil(Repo.get(Transaction, transaction.hash).created_contract_code_indexed_at) + end + end + + defp run_transactions(changes_list) when is_list(changes_list) do + Multi.new() + |> Transactions.run(changes_list, %{ + timeout: :infinity, + timestamps: %{inserted_at: DateTime.utc_now(), updated_at: DateTime.utc_now()} + }) + |> Repo.transaction() + end +end From d62d1e07ae9a7e4e8ba3c2ba437993096785602d Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 18 Jul 2019 00:42:52 +0300 Subject: [PATCH 26/30] Remove unused css, remove moment.js localization files except EN --- CHANGELOG.md | 1 + .../block_scout_web/assets/css/components/_footer.scss | 4 ---- .../assets/css/components/_network-selector.scss | 10 ---------- apps/block_scout_web/assets/webpack.config.js | 4 +++- 4 files changed, 4 insertions(+), 15 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9c5933961e..fb5372ba77 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ - [#2294](https://github.com/poanetwork/blockscout/pull/2294) - add healthy block period checking endpoint ### Fixes +- [#2378](https://github.com/poanetwork/blockscout/pull/2378) - Page performance: exclude moment.js localization files except EN, remove unused css - [#2375](https://github.com/poanetwork/blockscout/pull/2375) - Update created_contract_code_indexed_at on transaction import conflict - [#2346](https://github.com/poanetwork/blockscout/pull/2346) - Avoid fetching internal transactions of blocks that still need refetching - [#2350](https://github.com/poanetwork/blockscout/pull/2350) - fix invalid User agent headers diff --git a/apps/block_scout_web/assets/css/components/_footer.scss b/apps/block_scout_web/assets/css/components/_footer.scss index be1c10d44a..f2eae03c3f 100644 --- a/apps/block_scout_web/assets/css/components/_footer.scss +++ b/apps/block_scout_web/assets/css/components/_footer.scss @@ -61,10 +61,6 @@ $footer-logo-width: auto !default; } } -.footer-info { - padding-top: 1em; -} - .footer-link { color: $footer-link-color; diff --git a/apps/block_scout_web/assets/css/components/_network-selector.scss b/apps/block_scout_web/assets/css/components/_network-selector.scss index 8c433f28c3..e8b5f72e78 100644 --- a/apps/block_scout_web/assets/css/components/_network-selector.scss +++ b/apps/block_scout_web/assets/css/components/_network-selector.scss @@ -287,16 +287,6 @@ $network-selector-item-icon-dimensions: 30px !default; } } -.network-selector-load-more-container { - flex-shrink: 1; - padding: 0 $network-selector-horizontal-padding; - - .btn-network-selector-load-more { - @include btn-line($btn-network-selector-load-more-background, $btn-network-selector-load-more-color); - width: 100%; - } -} - .network-selector-item-favorite { align-items: center; cursor: pointer; diff --git a/apps/block_scout_web/assets/webpack.config.js b/apps/block_scout_web/assets/webpack.config.js index 63c796d3f7..08a2f410e7 100644 --- a/apps/block_scout_web/assets/webpack.config.js +++ b/apps/block_scout_web/assets/webpack.config.js @@ -1,6 +1,7 @@ const path = require('path'); const ExtractTextPlugin = require('extract-text-webpack-plugin'); const CopyWebpackPlugin = require('copy-webpack-plugin'); +const { ContextReplacementPlugin } = require('webpack') const glob = require("glob"); function transpileViewScript(file) { @@ -74,7 +75,8 @@ const appJs = }, plugins: [ new ExtractTextPlugin('../css/app.css'), - new CopyWebpackPlugin([{ from: 'static/', to: '../' }]) + new CopyWebpackPlugin([{ from: 'static/', to: '../' }]), + new ContextReplacementPlugin(/moment[\/\\]locale$/, /en/) ] } From 345d0247af3cd095462aef9459cc2db28b86763e Mon Sep 17 00:00:00 2001 From: saneery Date: Thu, 18 Jul 2019 11:50:19 +0300 Subject: [PATCH 27/30] Disable network selector when is empty --- .../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 f152ec6bf9..f965f20e0c 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 @@ -82,7 +82,7 @@