From 7259efb7c2cff4086f60e63b5b3e291bbfe908aa Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Jul 2019 12:48:12 +0300 Subject: [PATCH 01/24] add create2 support to tracer --- .../lib/ethereum_jsonrpc/geth/tracer.ex | 6 ++++-- .../geth/debug_traceTransaction/tracer.js | 19 ++++++++++++++++++- .../chain/internal_transaction/type.ex | 15 +++++++++++++-- 3 files changed, 35 insertions(+), 5 deletions(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/tracer.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/tracer.ex index 6545250b4a..cbc43fa71d 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/tracer.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/tracer.ex @@ -113,6 +113,7 @@ defmodule EthereumJSONRPC.Geth.Tracer do end defp op(%{"op" => "CREATE"} = log, ctx), do: create_op(log, ctx) + defp op(%{"op" => "CREATE2"} = log, ctx), do: create_op(log, ctx, "create2") defp op(%{"op" => "SELFDESTRUCT"} = log, ctx), do: self_destruct_op(log, ctx) defp op(%{"op" => "CALL"} = log, ctx), do: call_op(log, "call", ctx) defp op(%{"op" => "CALLCODE"} = log, ctx), do: call_op(log, "callcode", ctx) @@ -155,7 +156,8 @@ defmodule EthereumJSONRPC.Geth.Tracer do defp create_op( %{"stack" => log_stack, "memory" => log_memory}, - %{depth: stack_depth, stack: stack, trace_address: trace_address, calls: calls} = ctx + %{depth: stack_depth, stack: stack, trace_address: trace_address, calls: calls} = ctx, + type \\ "create" ) do [value, input_offset, input_length | _] = Enum.reverse(log_stack) @@ -165,7 +167,7 @@ defmodule EthereumJSONRPC.Geth.Tracer do |> String.slice(quantity_to_integer("0x" <> input_offset) * 2, quantity_to_integer("0x" <> input_length) * 2) call = %{ - "type" => "create", + "type" => type, "from" => nil, "traceAddress" => Enum.reverse(trace_address), "init" => "0x" <> init, diff --git a/apps/ethereum_jsonrpc/priv/js/ethereum_jsonrpc/geth/debug_traceTransaction/tracer.js b/apps/ethereum_jsonrpc/priv/js/ethereum_jsonrpc/geth/debug_traceTransaction/tracer.js index 15db7d8ff9..5b8a7470d1 100644 --- a/apps/ethereum_jsonrpc/priv/js/ethereum_jsonrpc/geth/debug_traceTransaction/tracer.js +++ b/apps/ethereum_jsonrpc/priv/js/ethereum_jsonrpc/geth/debug_traceTransaction/tracer.js @@ -91,6 +91,9 @@ case 'CREATE': this.createOp(log); break; + case 'CREATE2': + this.create2Op(log); + break; case 'SELFDESTRUCT': this.selfDestructOp(log, db); break; @@ -162,6 +165,21 @@ this.callStack.push(call); }, + create2Op(log) { + const inputOffset = log.stack.peek(1).valueOf(); + const inputLength = log.stack.peek(2).valueOf(); + const inputEnd = inputOffset + inputLength; + const stackValue = log.stack.peek(0); + + const call = { + type: 'create2', + from: toHex(log.contract.getAddress()), + init: toHex(log.memory.slice(inputOffset, inputEnd)), + valueBigInt: bigInt(stackValue.toString(10)) + }; + this.callStack.push(call); + }, + selfDestructOp(log, db) { const contractAddress = log.contract.getAddress(); @@ -422,4 +440,3 @@ call.gasUsed = '0x' + gasUsedBigInt.toString(16); } } - diff --git a/apps/explorer/lib/explorer/chain/internal_transaction/type.ex b/apps/explorer/lib/explorer/chain/internal_transaction/type.ex index 4133dcf45f..c462e601d5 100644 --- a/apps/explorer/lib/explorer/chain/internal_transaction/type.ex +++ b/apps/explorer/lib/explorer/chain/internal_transaction/type.ex @@ -11,7 +11,7 @@ defmodule Explorer.Chain.InternalTransaction.Type do * `:reward` * `:selfdestruct` """ - @type t :: :call | :create | :reward | :selfdestruct + @type t :: :call | :create | :create2 | :reward | :selfdestruct @doc """ Casts `term` to `t:t/0` @@ -22,6 +22,8 @@ defmodule Explorer.Chain.InternalTransaction.Type do {:ok, :call} iex> Explorer.Chain.InternalTransaction.Type.cast(:create) {:ok, :create} + iex> Explorer.Chain.InternalTransaction.Type.cast(:create2) + {:ok, :create2} iex> Explorer.Chain.InternalTransaction.Type.cast(:reward) {:ok, :reward} iex> Explorer.Chain.InternalTransaction.Type.cast(:selfdestruct) @@ -33,6 +35,8 @@ defmodule Explorer.Chain.InternalTransaction.Type do {:ok, :call} iex> Explorer.Chain.InternalTransaction.Type.cast("create") {:ok, :create} + iex> Explorer.Chain.InternalTransaction.Type.cast("create2") + {:ok, :create2} iex> Explorer.Chain.InternalTransaction.Type.cast("reward") {:ok, :reward} iex> Explorer.Chain.InternalTransaction.Type.cast("selfdestruct") @@ -53,9 +57,10 @@ defmodule Explorer.Chain.InternalTransaction.Type do """ @impl Ecto.Type @spec cast(term()) :: {:ok, t()} | :error - def cast(t) when t in ~w(call create selfdestruct reward)a, do: {:ok, t} + def cast(t) when t in ~w(call create create2 selfdestruct reward)a, do: {:ok, t} def cast("call"), do: {:ok, :call} def cast("create"), do: {:ok, :create} + def cast("create2"), do: {:ok, :create} def cast("reward"), do: {:ok, :reward} def cast("selfdestruct"), do: {:ok, :selfdestruct} def cast(_), do: :error @@ -67,6 +72,8 @@ defmodule Explorer.Chain.InternalTransaction.Type do {:ok, "call"} iex> Explorer.Chain.InternalTransaction.Type.dump(:create) {:ok, "create"} + iex> Explorer.Chain.InternalTransaction.Type.dump(:create2) + {:ok, "create2"} iex> Explorer.Chain.InternalTransaction.Type.dump(:reward) {:ok, "reward"} iex> Explorer.Chain.InternalTransaction.Type.dump(:selfdestruct) @@ -87,6 +94,7 @@ defmodule Explorer.Chain.InternalTransaction.Type do @spec dump(term()) :: {:ok, String.t()} | :error def dump(:call), do: {:ok, "call"} def dump(:create), do: {:ok, "create"} + def dump(:create2), do: {:ok, "create2"} def dump(:reward), do: {:ok, "reward"} def dump(:selfdestruct), do: {:ok, "selfdestruct"} def dump(_), do: :error @@ -98,6 +106,8 @@ defmodule Explorer.Chain.InternalTransaction.Type do {:ok, :call} iex> Explorer.Chain.InternalTransaction.Type.load("create") {:ok, :create} + iex> Explorer.Chain.InternalTransaction.Type.load("create2") + {:ok, :create2} iex> Explorer.Chain.InternalTransaction.Type.load("reward") {:ok, :reward} iex> Explorer.Chain.InternalTransaction.Type.load("selfdestruct") @@ -118,6 +128,7 @@ defmodule Explorer.Chain.InternalTransaction.Type do @spec load(term()) :: {:ok, t()} | :error def load("call"), do: {:ok, :call} def load("create"), do: {:ok, :create} + def load("create2"), do: {:ok, :create2} def load("reward"), do: {:ok, :reward} def load("selfdestruct"), do: {:ok, :selfdestruct} # deprecated From 900fda45a28dc70f652b088c6bfcf3b5e7938c39 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Jul 2019 13:09:46 +0300 Subject: [PATCH 02/24] fix test --- apps/explorer/lib/explorer/chain/internal_transaction/type.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/chain/internal_transaction/type.ex b/apps/explorer/lib/explorer/chain/internal_transaction/type.ex index c462e601d5..0a13587afe 100644 --- a/apps/explorer/lib/explorer/chain/internal_transaction/type.ex +++ b/apps/explorer/lib/explorer/chain/internal_transaction/type.ex @@ -60,7 +60,7 @@ defmodule Explorer.Chain.InternalTransaction.Type do def cast(t) when t in ~w(call create create2 selfdestruct reward)a, do: {:ok, t} def cast("call"), do: {:ok, :call} def cast("create"), do: {:ok, :create} - def cast("create2"), do: {:ok, :create} + def cast("create2"), do: {:ok, :create2} def cast("reward"), do: {:ok, :reward} def cast("selfdestruct"), do: {:ok, :selfdestruct} def cast(_), do: :error From 6a94113ad7018f622aa3b68bf26478045eb998c7 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Jul 2019 15:14:36 +0300 Subject: [PATCH 03/24] fix tracer --- .../lib/ethereum_jsonrpc/geth/call.ex | 10 ++++----- .../geth/debug_traceTransaction/tracer.js | 21 ++++++++++++++++++- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex index 1555ea6c8f..8d23302cef 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex @@ -426,13 +426,13 @@ defmodule EthereumJSONRPC.Geth.Call do "transactionHash" => transaction_hash, "index" => index, "traceAddress" => trace_address, - "type" => "create" = type, + "type" => type, "from" => from_address_hash, "error" => error, "gas" => gas, "init" => init, "value" => value - }) do + }) when type in ~w(create create2) do %{ block_number: block_number, transaction_index: transaction_index, @@ -454,7 +454,7 @@ defmodule EthereumJSONRPC.Geth.Call do "transactionHash" => transaction_hash, "index" => index, "traceAddress" => trace_address, - "type" => "create", + "type" => type, "from" => from_address_hash, "createdContractAddressHash" => created_contract_address_hash, "gas" => gas, @@ -462,14 +462,14 @@ defmodule EthereumJSONRPC.Geth.Call do "init" => init, "createdContractCode" => created_contract_code, "value" => value - }) do + }) when type in ~w(create create2) do %{ block_number: block_number, transaction_index: transaction_index, transaction_hash: transaction_hash, index: index, trace_address: trace_address, - type: "create", + type: type, from_address_hash: from_address_hash, gas: gas, gas_used: gas_used, diff --git a/apps/ethereum_jsonrpc/priv/js/ethereum_jsonrpc/geth/debug_traceTransaction/tracer.js b/apps/ethereum_jsonrpc/priv/js/ethereum_jsonrpc/geth/debug_traceTransaction/tracer.js index 5b8a7470d1..5c3c98f871 100644 --- a/apps/ethereum_jsonrpc/priv/js/ethereum_jsonrpc/geth/debug_traceTransaction/tracer.js +++ b/apps/ethereum_jsonrpc/priv/js/ethereum_jsonrpc/geth/debug_traceTransaction/tracer.js @@ -130,7 +130,7 @@ const ret = log.stack.peek(0); if (!ret.equals(0)) { - if (call.type === 'create') { + if (call.type === 'create' || call.type === 'create2') { call.createdContractAddressHash = toHex(toAddress(ret.toString(16))); call.createdContractCode = toHex(db.getCode(toAddress(ret.toString(16)))); } else { @@ -261,6 +261,9 @@ case 'CREATE': result = this.ctxToCreate(ctx, db); break; + case 'CREATE2': + result = this.ctxToCreate2(ctx, db); + break; } return result; @@ -310,6 +313,22 @@ return result; }, + ctxToCreate2(ctx, db) { + const result = { + type: 'create2', + from: toHex(ctx.from), + init: toHex(ctx.input), + valueBigInt: bigInt(ctx.value.toString(10)), + gasBigInt: bigInt(ctx.gas), + gasUsedBigInt: bigInt(ctx.gasUsed) + }; + + this.putBottomChildCalls(result); + this.putErrorOrCreatedContract(result, ctx, db); + + return result; + }, + putBottomChildCalls(result) { const bottomCall = this.bottomCall(); const bottomChildCalls = bottomCall.calls; From 043986e608b371504f6f321c46353478d0b32734 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Jul 2019 15:17:37 +0300 Subject: [PATCH 04/24] mix format --- apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex index 8d23302cef..c83b157324 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/geth/call.ex @@ -432,7 +432,8 @@ defmodule EthereumJSONRPC.Geth.Call do "gas" => gas, "init" => init, "value" => value - }) when type in ~w(create create2) do + }) + when type in ~w(create create2) do %{ block_number: block_number, transaction_index: transaction_index, @@ -462,7 +463,8 @@ defmodule EthereumJSONRPC.Geth.Call do "init" => init, "createdContractCode" => created_contract_code, "value" => value - }) when type in ~w(create create2) do + }) + when type in ~w(create create2) do %{ block_number: block_number, transaction_index: transaction_index, From 36b2be6cf19dd80c8d5b9a8e89800beebd1e7d32 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Jul 2019 15:20:44 +0300 Subject: [PATCH 05/24] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b9c8934f3d..c1ac9a4dd1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - [#2294](https://github.com/poanetwork/blockscout/pull/2294) - add healthy block period checking endpoint ### Fixes +- [#2388](https://github.com/poanetwork/blockscout/pull/2388) - add create2 support to geth's js tracer - [#2378](https://github.com/poanetwork/blockscout/pull/2378) - Page performance: exclude moment.js localization files except EN, remove unused css - [#2368](https://github.com/poanetwork/blockscout/pull/2368) - add two columns of smart contract info - [#2375](https://github.com/poanetwork/blockscout/pull/2375) - Update created_contract_code_indexed_at on transaction import conflict From 9c682071a794cfeee01707a9f0041fbbbe8d7207 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Fri, 19 Jul 2019 16:59:53 +0300 Subject: [PATCH 06/24] fix create2 changeset --- apps/explorer/lib/explorer/chain/internal_transaction.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/chain/internal_transaction.ex b/apps/explorer/lib/explorer/chain/internal_transaction.ex index 1231677a57..52a5245b84 100644 --- a/apps/explorer/lib/explorer/chain/internal_transaction.ex +++ b/apps/explorer/lib/explorer/chain/internal_transaction.ex @@ -392,7 +392,7 @@ defmodule Explorer.Chain.InternalTransaction do @create_required_fields ~w(from_address_hash gas index init trace_address transaction_hash value)a @create_allowed_fields @create_optional_fields ++ @create_required_fields - defp type_changeset(changeset, attrs, :create) do + defp type_changeset(changeset, attrs, type) when type in [:create, :create2] do changeset |> cast(attrs, @create_allowed_fields) |> validate_required(@create_required_fields) From 8858424b837020ae86db5a470859ed11430c3592 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 22 Jul 2019 17:15:39 +0300 Subject: [PATCH 07/24] add create2 to view --- .../lib/block_scout_web/views/internal_transaction_view.ex | 1 + 1 file changed, 1 insertion(+) diff --git a/apps/block_scout_web/lib/block_scout_web/views/internal_transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/internal_transaction_view.ex index fe12f04302..46252f72ce 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/internal_transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/internal_transaction_view.ex @@ -23,6 +23,7 @@ defmodule BlockScoutWeb.InternalTransactionView do def type(%InternalTransaction{type: :call, call_type: :delegatecall}), do: gettext("Delegate Call") def type(%InternalTransaction{type: :call, call_type: :staticcall}), do: gettext("Static Call") def type(%InternalTransaction{type: :create}), do: gettext("Create") + def type(%InternalTransaction{type: :create2}), do: gettext("Create2") def type(%InternalTransaction{type: :selfdestruct}), do: gettext("Self-Destruct") def type(%InternalTransaction{type: :reward}), do: gettext("Reward") end From 81ca80bdc9fab6d42eb49194eaeb4f57715e9157 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 22 Jul 2019 17:19:19 +0300 Subject: [PATCH 08/24] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 9 +++++++-- .../priv/gettext/en/LC_MESSAGES/default.po | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 61d7465f49..61556744c7 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -1041,12 +1041,12 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/_tile.html.eex:47 #: lib/block_scout_web/templates/chain/_block.html.eex:23 -#: lib/block_scout_web/views/internal_transaction_view.ex:27 +#: lib/block_scout_web/views/internal_transaction_view.ex:28 msgid "Reward" msgstr "" #, elixir-format -#: lib/block_scout_web/views/internal_transaction_view.ex:26 +#: lib/block_scout_web/views/internal_transaction_view.ex:27 msgid "Self-Destruct" msgstr "" @@ -1804,3 +1804,8 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:4 msgid "Connection Lost" msgstr "" + +#, elixir-format +#: lib/block_scout_web/views/internal_transaction_view.ex:26 +msgid "Create2" +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 5333eb95aa..6157316c1b 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 @@ -1041,12 +1041,12 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/_tile.html.eex:47 #: lib/block_scout_web/templates/chain/_block.html.eex:23 -#: lib/block_scout_web/views/internal_transaction_view.ex:27 +#: lib/block_scout_web/views/internal_transaction_view.ex:28 msgid "Reward" msgstr "" #, elixir-format -#: lib/block_scout_web/views/internal_transaction_view.ex:26 +#: lib/block_scout_web/views/internal_transaction_view.ex:27 msgid "Self-Destruct" msgstr "" @@ -1804,3 +1804,8 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:4 msgid "Connection Lost" msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/views/internal_transaction_view.ex:26 +msgid "Create2" +msgstr "" From 1fa8b2f33b58d5d6c891db7eb1e9acb72a227747 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 22 Jul 2019 18:18:52 +0300 Subject: [PATCH 09/24] fix raw trace --- apps/explorer/lib/explorer/chain/internal_transaction.ex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/internal_transaction.ex b/apps/explorer/lib/explorer/chain/internal_transaction.ex index 52a5245b84..77f7d15da2 100644 --- a/apps/explorer/lib/explorer/chain/internal_transaction.ex +++ b/apps/explorer/lib/explorer/chain/internal_transaction.ex @@ -537,7 +537,7 @@ defmodule Explorer.Chain.InternalTransaction do |> put_raw_call_error_or_result(transaction) end - defp internal_transaction_to_raw(%{type: :create} = transaction) do + defp internal_transaction_to_raw(%{type: type} = transaction) when type in [:create, :create2] do %{ from_address_hash: from_address_hash, gas: gas, @@ -549,7 +549,7 @@ defmodule Explorer.Chain.InternalTransaction do action = %{"from" => from_address_hash, "gas" => gas, "init" => init, "value" => value} %{ - "type" => "create", + "type" => Atom.to_string(type), "action" => Action.to_raw(action), "traceAddress" => trace_address } From f8ff3a402b31eae0e3889df241fcb0e1ebf62790 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 23 Jul 2019 13:16:10 +0300 Subject: [PATCH 10/24] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 17 +++++++++++ .../priv/gettext/en/LC_MESSAGES/default.po | 28 +++++++++++++------ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 58800258f6..a65306f22e 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -1792,3 +1792,20 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:4 msgid "Connection Lost" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_contract/index.html.eex:53 +msgid "Constructor Arguments" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/views/internal_transaction_view.ex:26 +msgid "Create2" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/block/_tile.html.eex:47 +#: lib/block_scout_web/templates/chain/_block.html.eex:190 +#: lib/block_scout_web/views/internal_transaction_view.ex:28 +msgid "Reward" +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 fd933f2faf..7accba81c7 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 @@ -34,7 +34,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:21 -#: lib/block_scout_web/templates/chain/_block.html.eex:11 +#: lib/block_scout_web/templates/chain/_block.html.eex:178 msgid "%{count} Transactions" msgstr "" @@ -522,7 +522,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/_tile.html.eex:38 #: lib/block_scout_web/templates/block/overview.html.eex:121 -#: lib/block_scout_web/templates/chain/_block.html.eex:15 +#: lib/block_scout_web/templates/chain/_block.html.eex:182 msgid "Miner" msgstr "" @@ -1038,13 +1038,6 @@ msgstr "" msgid "Delegate Call" msgstr "" -#, elixir-format -#: lib/block_scout_web/templates/block/_tile.html.eex:47 -#: lib/block_scout_web/templates/chain/_block.html.eex:23 -#: lib/block_scout_web/views/internal_transaction_view.ex:28 -msgid "Reward" -msgstr "" - #, elixir-format #: lib/block_scout_web/views/internal_transaction_view.ex:27 msgid "Self-Destruct" @@ -1799,3 +1792,20 @@ msgstr "" #: lib/block_scout_web/templates/address_contract_verification/new.html.eex:4 msgid "Connection Lost" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_contract/index.html.eex:53 +msgid "Constructor Arguments" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/views/internal_transaction_view.ex:26 +msgid "Create2" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/block/_tile.html.eex:47 +#: lib/block_scout_web/templates/chain/_block.html.eex:190 +#: lib/block_scout_web/views/internal_transaction_view.ex:28 +msgid "Reward" +msgstr "" From a3f93167a1d0020d6f5e5f4eee08aebf426923ab Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 23 Jul 2019 15:11:29 +0300 Subject: [PATCH 11/24] remove outer tables for decoded data --- .../transaction/_decoded_input_body.html.eex | 88 ++++++++++--------- .../templates/transaction_log/_logs.html.eex | 74 ++++++++-------- apps/block_scout_web/priv/gettext/default.pot | 36 ++++---- .../priv/gettext/en/LC_MESSAGES/default.po | 42 ++++----- 4 files changed, 119 insertions(+), 121 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex index f009eeb2b3..9e68d7e1bd 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex @@ -1,4 +1,5 @@ -" class="table thead-light table-bordered table-responsive transaction-info-table"> +
+
" class="table thead-light table-bordered"> @@ -7,49 +8,52 @@ -
<%= gettext "Method Id" %> 0x<%= @method_id %>Call <%= @text %>
+ + <%= unless Enum.empty?(@mapping) do %> - " class="table thead-light table-bordered table-responsive"> - - - - - - - <%= for {name, type, value} <- @mapping do %> +
+
<%= gettext "Name" %><%= gettext "Type" %><%= gettext "Data" %>
" class="table thead-light table-bordered"> + + + + + - - - - + - <% end %> -
<%= gettext "Name" %><%= gettext "Type" %><%= gettext "Data" %>
- <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %> - <% :error -> %> - <%= nil %> - <% copy_text -> %> - - - - - - <% end %> - <%= name %><%= type %> - <%= case BlockScoutWeb.ABIEncodedValueView.value_html(type, value) do %> - <% :error -> %> -
- <%= gettext "Error rendering value" %> -
- <% value -> %> -
<%= value %>
+ <%= for {name, type, value} <- @mapping do %> +
+ <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %> + <% :error -> %> + <%= nil %> + <% copy_text -> %> + + + + + <% end %> - -
+ + <%= name %> + <%= type %> + + <%= case BlockScoutWeb.ABIEncodedValueView.value_html(type, value) do %> + <% :error -> %> +
+ <%= gettext "Error rendering value" %> +
+ <% value -> %> +
<%= value %>
+ <% end %> + + + <% end %> + + <% end %> 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 5a52821601..ff3e46d42a 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 @@ -39,43 +39,45 @@ <%= text %> - " class="table thead-light table-bordered table-responsive"> - - - - - - - - <%= for {name, type, indexed?, value} <- mapping do %> +
+
<%= gettext "Name" %><%= gettext "Type" %><%= gettext "Indexed?" %><%= gettext "Data" %>
" class="table thead-light table-bordered"> - - - - - - - <% end %> -
- <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %> - <% :error -> %> - <%= nil %> - <% copy_text -> %> - - - - - - <% end %> - <%= name %><%= type %><%= indexed? %> -
<%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
-
+ + <%= gettext "Name" %> + <%= gettext "Type" %> + <%= gettext "Indexed?" %> + <%= gettext "Data" %> + + <%= for {name, type, indexed?, value} <- mapping do %> + + + <%= case BlockScoutWeb.ABIEncodedValueView.copy_text(type, value) do %> + <% :error -> %> + <%= nil %> + <% copy_text -> %> + + + + + + <% end %> + + <%= name %> + <%= type %> + <%= indexed? %> + +
<%= BlockScoutWeb.ABIEncodedValueView.value_html(type, value) %>
+ + + <% end %> + + <% _ -> %> <%= nil %> <% end %> diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index ab62a2e888..58bb54922f 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -330,9 +330,9 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:44 -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:18 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:48 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:113 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:115 msgid "Data" msgstr "" @@ -556,8 +556,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:45 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:19 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:46 msgid "Name" msgstr "" @@ -827,7 +827,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:14 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:83 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:85 msgid "Topics" msgstr "" @@ -1139,18 +1139,18 @@ msgid "Decoded" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:48 msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:17 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:46 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 msgid "Type" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:3 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:4 msgid "Method Id" msgstr "" @@ -1160,12 +1160,8 @@ msgid "To see decoded input data, the contract must be verified." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:1 -msgid "Transaction Info" -msgstr "" - -#, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:13 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:2 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 msgid "Transaction Inputs" msgstr "" @@ -1187,13 +1183,13 @@ msgid "Failed to decode input data." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:46 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:49 msgid "Error rendering value" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:28 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:58 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59 msgid "Copy Value" msgstr "" @@ -1203,7 +1199,7 @@ msgid "Failed to decode log data." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:42 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:43 msgid "Log Data" 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 9d448b5a70..eb10bcaec4 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 @@ -34,7 +34,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:21 -#: lib/block_scout_web/templates/chain/_block.html.eex:11 +#: lib/block_scout_web/templates/chain/_block.html.eex:178 msgid "%{count} Transactions" msgstr "" @@ -330,9 +330,9 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:44 -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:18 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:48 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:113 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:115 msgid "Data" msgstr "" @@ -522,7 +522,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/_tile.html.eex:38 #: lib/block_scout_web/templates/block/overview.html.eex:121 -#: lib/block_scout_web/templates/chain/_block.html.eex:15 +#: lib/block_scout_web/templates/chain/_block.html.eex:182 msgid "Miner" msgstr "" @@ -556,8 +556,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:52 -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:45 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:19 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:46 msgid "Name" msgstr "" @@ -827,7 +827,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:14 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:83 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:85 msgid "Topics" msgstr "" @@ -1040,7 +1040,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/_tile.html.eex:47 -#: lib/block_scout_web/templates/chain/_block.html.eex:23 +#: lib/block_scout_web/templates/chain/_block.html.eex:190 #: lib/block_scout_web/views/internal_transaction_view.ex:27 msgid "Reward" msgstr "" @@ -1139,18 +1139,18 @@ msgid "Decoded" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:48 msgid "Indexed?" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:17 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:46 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 msgid "Type" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:3 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:4 msgid "Method Id" msgstr "" @@ -1160,12 +1160,8 @@ msgid "To see decoded input data, the contract must be verified." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:1 -msgid "Transaction Info" -msgstr "" - -#, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:13 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:2 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:16 msgid "Transaction Inputs" msgstr "" @@ -1187,13 +1183,13 @@ msgid "Failed to decode input data." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:46 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:49 msgid "Error rendering value" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:28 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:58 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59 msgid "Copy Value" msgstr "" @@ -1203,7 +1199,7 @@ msgid "Failed to decode log data." msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:42 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:43 msgid "Log Data" msgstr "" From 91bbb4a8b0faacf3a399408f2de7ed7c7a613a84 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 23 Jul 2019 15:15:30 +0300 Subject: [PATCH 12/24] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b333ba4ef9..361e08f066 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - [#2324](https://github.com/poanetwork/blockscout/pull/2324) - set timeout for loading message on the main page ### Fixes +- [#2413](https://github.com/poanetwork/blockscout/pull/2413) - remove outer tables for decoded data - [#2410](https://github.com/poanetwork/blockscout/pull/2410) - preload smart contract for logs decoding - [#2398](https://github.com/poanetwork/blockscout/pull/2398) - show only one decoded candidate - [#2395](https://github.com/poanetwork/blockscout/pull/2395) - new block loading animation From 5de1681e744f0dc7a3e753e9ac1e840c9fe2886f Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Jul 2019 11:32:44 +0300 Subject: [PATCH 13/24] fetch data from cache in healthy endpoint --- .../controllers/api/v1/health_controller.ex | 19 +++++++++++----- .../api/v1/health_controller_test.exs | 22 +++++++++++-------- 2 files changed, 27 insertions(+), 14 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/health_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/health_controller.ex index 957dc797be..1ca6bb53d4 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/health_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/health_controller.ex @@ -1,7 +1,7 @@ defmodule BlockScoutWeb.API.V1.HealthController do use BlockScoutWeb, :controller - alias Explorer.Chain + alias Explorer.{Chain, PagingOptions} def health(conn, _) do with {:ok, number, timestamp} <- Chain.last_block_status() do @@ -12,11 +12,20 @@ defmodule BlockScoutWeb.API.V1.HealthController do end def result(number, timestamp) do + latest_block_in_cache = + [ + paging_options: %PagingOptions{page_size: 1} + ] + |> Chain.list_blocks() + |> List.last() + %{ "healthy" => true, "data" => %{ - "latest_block_number" => to_string(number), - "latest_block_inserted_at" => to_string(timestamp) + "db_latest_block_number" => to_string(number), + "db_latest_block_inserted_at" => to_string(timestamp), + "cache_latest_block_number" => to_string(latest_block_in_cache.number), + "cache_latest_block_inserted_at" => to_string(latest_block_in_cache.timestamp) } } |> Jason.encode!() @@ -40,8 +49,8 @@ defmodule BlockScoutWeb.API.V1.HealthController do "error_description" => "There are no new blocks in the DB for the last 5 mins. Check the healthiness of Ethereum archive node or the Blockscout DB instance", "data" => %{ - "latest_block_number" => to_string(number), - "latest_block_inserted_at" => to_string(timestamp) + "db_latest_block_number" => to_string(number), + "db_latest_block_inserted_at" => to_string(timestamp) } } |> Jason.encode!() diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs index 41735f685a..6b9db74208 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs @@ -25,26 +25,30 @@ defmodule BlockScoutWeb.API.V1.HealthControllerTest do "error_description" => "There are no new blocks in the DB for the last 5 mins. Check the healthiness of Ethereum archive node or the Blockscout DB instance", "data" => %{ - "latest_block_number" => _, - "latest_block_inserted_at" => _ + "db_latest_block_number" => _, + "db_latest_block_inserted_at" => _ } } = Poison.decode!(request.resp_body) end test "returns ok when last block is not stale", %{conn: conn} do - insert(:block, consensus: true, timestamp: DateTime.utc_now()) + block1 = insert(:block, consensus: true, timestamp: DateTime.utc_now(), number: 2) + insert(:block, consensus: true, timestamp: DateTime.utc_now(), number: 1) request = get(conn, api_v1_health_path(conn, :health)) assert request.status == 200 + result = Poison.decode!(request.resp_body) + + assert result["healthy"] == true + assert %{ - "healthy" => true, - "data" => %{ - "latest_block_number" => _, - "latest_block_inserted_at" => _ - } - } = Poison.decode!(request.resp_body) + "db_latest_block_number" => to_string(block1.number), + "db_latest_block_inserted_at" => to_string(block1.timestamp), + "cache_latest_block_number" => to_string(block1.number), + "cache_latest_block_inserted_at" => to_string(block1.timestamp) + } == result["data"] end end end From ca6c67d6e9896d7ee053c1748ba2e96b526b5568 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Jul 2019 12:37:24 +0300 Subject: [PATCH 14/24] check cache status in chain module --- .../controllers/api/v1/health_controller.ex | 28 +++++------- .../api/v1/health_controller_test.exs | 44 +++++++++++++++++-- apps/explorer/lib/explorer/chain.ex | 41 ++++++++++++----- apps/explorer/test/explorer/chain_test.exs | 22 ++++++++-- 4 files changed, 98 insertions(+), 37 deletions(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/health_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/health_controller.ex index 1ca6bb53d4..1e65fa75ba 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/health_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/api/v1/health_controller.ex @@ -1,31 +1,25 @@ defmodule BlockScoutWeb.API.V1.HealthController do use BlockScoutWeb, :controller - alias Explorer.{Chain, PagingOptions} + alias Explorer.Chain def health(conn, _) do - with {:ok, number, timestamp} <- Chain.last_block_status() do - send_resp(conn, :ok, result(number, timestamp)) + with {:ok, number, timestamp} <- Chain.last_db_block_status(), + {:ok, cache_number, cache_timestamp} <- Chain.last_cache_block_status() do + send_resp(conn, :ok, result(number, timestamp, cache_number, cache_timestamp)) else status -> send_resp(conn, :internal_server_error, error(status)) end end - def result(number, timestamp) do - latest_block_in_cache = - [ - paging_options: %PagingOptions{page_size: 1} - ] - |> Chain.list_blocks() - |> List.last() - + def result(number, timestamp, cache_number, cache_timestamp) do %{ "healthy" => true, "data" => %{ - "db_latest_block_number" => to_string(number), - "db_latest_block_inserted_at" => to_string(timestamp), - "cache_latest_block_number" => to_string(latest_block_in_cache.number), - "cache_latest_block_inserted_at" => to_string(latest_block_in_cache.timestamp) + "latest_block_number" => to_string(number), + "latest_block_inserted_at" => to_string(timestamp), + "cache_latest_block_number" => to_string(cache_number), + "cache_latest_block_inserted_at" => to_string(cache_timestamp) } } |> Jason.encode!() @@ -49,8 +43,8 @@ defmodule BlockScoutWeb.API.V1.HealthController do "error_description" => "There are no new blocks in the DB for the last 5 mins. Check the healthiness of Ethereum archive node or the Blockscout DB instance", "data" => %{ - "db_latest_block_number" => to_string(number), - "db_latest_block_inserted_at" => to_string(timestamp) + "latest_block_number" => to_string(number), + "latest_block_inserted_at" => to_string(timestamp) } } |> Jason.encode!() diff --git a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs index 6b9db74208..19631ff746 100644 --- a/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs +++ b/apps/block_scout_web/test/block_scout_web/controllers/api/v1/health_controller_test.exs @@ -1,6 +1,15 @@ defmodule BlockScoutWeb.API.V1.HealthControllerTest do use BlockScoutWeb.ConnCase + alias Explorer.{Chain, PagingOptions} + + setup do + Supervisor.terminate_child(Explorer.Supervisor, {ConCache, Explorer.Chain.Cache.Blocks.cache_name()}) + Supervisor.restart_child(Explorer.Supervisor, {ConCache, Explorer.Chain.Cache.Blocks.cache_name()}) + + :ok + end + describe "GET last_block_status/0" do test "returns error when there are no blocks in db", %{conn: conn} do request = get(conn, api_v1_health_path(conn, :health)) @@ -25,8 +34,8 @@ defmodule BlockScoutWeb.API.V1.HealthControllerTest do "error_description" => "There are no new blocks in the DB for the last 5 mins. Check the healthiness of Ethereum archive node or the Blockscout DB instance", "data" => %{ - "db_latest_block_number" => _, - "db_latest_block_inserted_at" => _ + "latest_block_number" => _, + "latest_block_inserted_at" => _ } } = Poison.decode!(request.resp_body) end @@ -44,11 +53,38 @@ defmodule BlockScoutWeb.API.V1.HealthControllerTest do assert result["healthy"] == true assert %{ - "db_latest_block_number" => to_string(block1.number), - "db_latest_block_inserted_at" => to_string(block1.timestamp), + "latest_block_number" => to_string(block1.number), + "latest_block_inserted_at" => to_string(block1.timestamp), "cache_latest_block_number" => to_string(block1.number), "cache_latest_block_inserted_at" => to_string(block1.timestamp) } == result["data"] end end + + test "return error when cache is stale", %{conn: conn} do + stale_block = insert(:block, consensus: true, timestamp: Timex.shift(DateTime.utc_now(), hours: -50), number: 3) + state_block_hash = stale_block.hash + + assert [%{hash: ^state_block_hash}] = Chain.list_blocks(paging_options: %PagingOptions{page_size: 1}) + + insert(:block, consensus: true, timestamp: DateTime.utc_now(), number: 1) + + assert [%{hash: ^state_block_hash}] = Chain.list_blocks(paging_options: %PagingOptions{page_size: 1}) + + request = get(conn, api_v1_health_path(conn, :health)) + + assert request.status == 500 + + assert %{ + "healthy" => false, + "error_code" => 5001, + "error_title" => "blocks fetching is stuck", + "error_description" => + "There are no new blocks in the DB for the last 5 mins. Check the healthiness of Ethereum archive node or the Blockscout DB instance", + "data" => %{ + "latest_block_number" => _, + "latest_block_inserted_at" => _ + } + } = Poison.decode!(request.resp_body) + end end diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 0e01212c37..db545e1f9d 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -1818,7 +1818,7 @@ defmodule Explorer.Chain do Repo.one!(query) end - def last_block_status do + def last_db_block_status do query = from(block in Block, select: {block.number, block.timestamp}, @@ -1827,22 +1827,39 @@ defmodule Explorer.Chain do limit: 1 ) - case Repo.one(query) do - nil -> - {:error, :no_blocks} + query + |> Repo.one() + |> block_status() + end - {number, timestamp} -> - now = DateTime.utc_now() - last_block_period = DateTime.diff(now, timestamp, :millisecond) + def last_cache_block_status do + [ + paging_options: %PagingOptions{page_size: 1} + ] + |> list_blocks() + |> List.last() + |> case do + %{timestamp: timestamp, number: number} -> + block_status({number, timestamp}) - if last_block_period > Application.get_env(:explorer, :healthy_blocks_period) do - {:error, number, timestamp} - else - {:ok, number, timestamp} - end + _ -> + block_status(nil) end end + defp block_status({number, timestamp}) do + now = DateTime.utc_now() + last_block_period = DateTime.diff(now, timestamp, :millisecond) + + if last_block_period > Application.get_env(:explorer, :healthy_blocks_period) do + {:error, number, timestamp} + else + {:ok, number, timestamp} + end + end + + defp block_status(nil), do: {:error, :no_blocks} + @doc """ Calculates the ranges of missing consensus blocks in `range`. diff --git a/apps/explorer/test/explorer/chain_test.exs b/apps/explorer/test/explorer/chain_test.exs index 5ee506982b..234252dbe4 100644 --- a/apps/explorer/test/explorer/chain_test.exs +++ b/apps/explorer/test/explorer/chain_test.exs @@ -50,21 +50,35 @@ defmodule Explorer.ChainTest do end end - describe "last_block_status/0" do + describe "last_db_block_status/0" do test "return no_blocks errors if db is empty" do - assert {:error, :no_blocks} = Chain.last_block_status() + assert {:error, :no_blocks} = Chain.last_db_block_status() end test "returns {:ok, last_block_period} if block is in healthy period" do insert(:block, consensus: true) - assert {:ok, _, _} = Chain.last_block_status() + assert {:ok, _, _} = Chain.last_db_block_status() end test "return {:ok, last_block_period} if block is not in healthy period" do insert(:block, consensus: true, timestamp: Timex.shift(DateTime.utc_now(), hours: -50)) - assert {:error, _, _} = Chain.last_block_status() + assert {:error, _, _} = Chain.last_db_block_status() + end + end + + describe "last_cache_block_status/0" do + test "returns success if cache is not stale" do + insert(:block, consensus: true) + + assert {:ok, _, _} = Chain.last_cache_block_status() + end + + test "return error if cache is stale" do + insert(:block, consensus: true, timestamp: Timex.shift(DateTime.utc_now(), hours: -50)) + + assert {:error, _, _} = Chain.last_cache_block_status() end end From 41e68ca6bfa6a04aeae63a4f0462a604c0ea0f69 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Jul 2019 12:39:12 +0300 Subject: [PATCH 15/24] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f9f4f9a55..6cea007540 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ - [#2324](https://github.com/poanetwork/blockscout/pull/2324) - set timeout for loading message on the main page ### Fixes +- [#2420](https://github.com/poanetwork/blockscout/pull/2420) - fetch data from cache in healthy endpoint - [#2410](https://github.com/poanetwork/blockscout/pull/2410) - preload smart contract for logs decoding - [#2398](https://github.com/poanetwork/blockscout/pull/2398) - show only one decoded candidate - [#2395](https://github.com/poanetwork/blockscout/pull/2395) - new block loading animation From 6183eac5885b0d25149aac9de726e7eed5eda4df Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 24 Jul 2019 14:34:30 +0300 Subject: [PATCH 16/24] Fix hiding of loader for txs on the main page --- CHANGELOG.md | 1 + .../lib/block_scout_web/templates/chain/show.html.eex | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e35a980ec..404c89b1c2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ - [#2324](https://github.com/poanetwork/blockscout/pull/2324) - set timeout for loading message on the main page ### Fixes +- [#2421](https://github.com/poanetwork/blockscout/pull/2421) - Fix hiding of loader for txs on the main page - [#2416](https://github.com/poanetwork/blockscout/pull/2416) - Fix "page not found" handling in the router - [#2410](https://github.com/poanetwork/blockscout/pull/2410) - preload smart contract for logs decoding - [#2405](https://github.com/poanetwork/blockscout/pull/2405) - added templates for table loader and tile loader diff --git a/apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex index 69d1f8b6ed..53b21cb3fa 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/chain/show.html.eex @@ -117,7 +117,9 @@ <%= gettext "Something went wrong, click to retry." %> - <%= render BlockScoutWeb.CommonComponentsView, "_tile-loader.html" %> + From 433cec0d36b21a85f580e1c7e1fc2fc6d6cf838a Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Jul 2019 14:41:04 +0300 Subject: [PATCH 17/24] check if address_id is binary in token_transfers_csv endpoint --- .../controllers/address_transaction_controller.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex b/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex index f6d9b8a30f..1176e047f4 100644 --- a/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex +++ b/apps/block_scout_web/lib/block_scout_web/controllers/address_transaction_controller.ex @@ -110,7 +110,7 @@ defmodule BlockScoutWeb.AddressTransactionController do end end - def token_transfers_csv(conn, %{"address_id" => address_hash_string}) do + def token_transfers_csv(conn, %{"address_id" => address_hash_string}) when is_binary(address_hash_string) do with {:ok, address_hash} <- Chain.string_to_address_hash(address_hash_string), {:ok, address} <- Chain.hash_to_address(address_hash) do address From 6d1befa1a85cb620bd5947b433f9a23b55992547 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Jul 2019 14:44:15 +0300 Subject: [PATCH 18/24] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1f9f4f9a55..30c3dcb53f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -32,6 +32,7 @@ - [#2326](https://github.com/poanetwork/blockscout/pull/2326) - fix nested constructor arguments ### Chore +- [#2422](https://github.com/poanetwork/blockscout/pull/2422) - check if address_id is binary in token_transfers_csv endpoint - [#2418](https://github.com/poanetwork/blockscout/pull/2418) - Remove parentheses in market cap percentage - [#2401](https://github.com/poanetwork/blockscout/pull/2401) - add ENV vars to manage updating period of average block time and market history cache - [#2363](https://github.com/poanetwork/blockscout/pull/2363) - add parameters example for eth rpc From 1bbe5de02e7c86517ffa71e73d223a0d24b70bd3 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 24 Jul 2019 16:01:45 +0300 Subject: [PATCH 19/24] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 50 ++++++++++++++++- .../priv/gettext/en/LC_MESSAGES/default.po | 55 ++++++++++++++++--- 2 files changed, 94 insertions(+), 11 deletions(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index ebd02ec878..cd0ca56802 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -328,7 +328,6 @@ msgstr "" msgid "Curl" msgstr "" - #, elixir-format #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:53 #: lib/block_scout_web/templates/api_docs/_action_tile.html.eex:188 @@ -819,7 +818,6 @@ msgstr "" msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" - #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:67 msgid "Total Difficulty" @@ -1163,7 +1161,6 @@ msgstr "" msgid "Error rendering value" msgstr "" - #, elixir-format #: lib/block_scout_web/templates/address_coin_balance/index.html.eex:34 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:61 @@ -1761,3 +1758,50 @@ msgstr "" #: lib/block_scout_web/templates/address_contract/index.html.eex:53 msgid "Constructor Arguments" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:59 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59 +msgid "Copy Value" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:49 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:114 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:115 +msgid "Data" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:29 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:29 +msgid "Failed to decode log data." +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:48 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:48 +msgid "Indexed?" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:43 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:43 +msgid "Log Data" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:84 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:85 +msgid "Topics" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:47 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 +msgid "Type" +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 72948e50b3..466f678055 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 @@ -818,7 +818,6 @@ msgstr "" msgid "Top Accounts - %{subnetwork} Explorer" msgstr "" - #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:67 msgid "Total Difficulty" @@ -1163,13 +1162,6 @@ msgid "Error rendering value" msgstr "" "" -#, elixir-format -#: lib/block_scout_web/templates/address_logs/_logs.html.eex:29 -#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:29 -msgid "Failed to decode log data." -msgstr "" - - #, elixir-format #: lib/block_scout_web/templates/address_coin_balance/index.html.eex:34 #: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:61 @@ -1767,3 +1759,50 @@ msgstr "" #: lib/block_scout_web/templates/address_contract/index.html.eex:53 msgid "Constructor Arguments" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:59 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59 +msgid "Copy Value" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:49 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:114 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:115 +msgid "Data" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:29 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:29 +msgid "Failed to decode log data." +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:48 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:48 +msgid "Indexed?" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:43 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:43 +msgid "Log Data" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:84 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:85 +msgid "Topics" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:47 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 +msgid "Type" +msgstr "" From a30749cada2e0e1b218eb0d081a7331c0877bdfd Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 25 Jul 2019 10:28:36 +0300 Subject: [PATCH 20/24] fix gettext --- apps/block_scout_web/priv/gettext/default.pot | 58 ++++++++++++++++++ .../priv/gettext/en/LC_MESSAGES/default.po | 61 ++++++++++++++++++- 2 files changed, 118 insertions(+), 1 deletion(-) diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index aafa803ef7..cad9101f82 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -1752,3 +1752,61 @@ msgstr "" msgid "Constructor Arguments" msgstr "" +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:59 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59 +msgid "Copy Value" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/views/internal_transaction_view.ex:26 +msgid "Create2" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:49 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:114 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:115 +msgid "Data" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:29 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:29 +msgid "Failed to decode log data." +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:48 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:48 +msgid "Indexed?" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:43 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:43 +msgid "Log Data" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/block/_tile.html.eex:47 +#: lib/block_scout_web/templates/chain/_block.html.eex:190 +#: lib/block_scout_web/views/internal_transaction_view.ex:28 +msgid "Reward" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:84 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:85 +msgid "Topics" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:47 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 +msgid "Type" +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 a13692638f..95b36b9dab 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 @@ -1751,4 +1751,63 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/address_contract/index.html.eex:53 msgid "Constructor Arguments" -msgstr "" \ No newline at end of file +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:59 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:31 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:59 +msgid "Copy Value" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/views/internal_transaction_view.ex:26 +msgid "Create2" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:49 +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:114 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:49 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:115 +msgid "Data" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:29 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:29 +msgid "Failed to decode log data." +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:48 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:48 +msgid "Indexed?" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:43 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:43 +msgid "Log Data" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/block/_tile.html.eex:47 +#: lib/block_scout_web/templates/chain/_block.html.eex:190 +#: lib/block_scout_web/views/internal_transaction_view.ex:28 +msgid "Reward" +msgstr "" + +#, elixir-format, fuzzy +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:84 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:85 +msgid "Topics" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/address_logs/_logs.html.eex:47 +#: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:20 +#: lib/block_scout_web/templates/transaction_log/_logs.html.eex:47 +msgid "Type" +msgstr "" From e5b3ced87d58172d5deb5c944565d362dbe33fec Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 25 Jul 2019 13:42:01 +0300 Subject: [PATCH 21/24] bump timex --- apps/block_scout_web/mix.exs | 2 +- apps/ethereum_jsonrpc/mix.exs | 2 +- apps/explorer/mix.exs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/apps/block_scout_web/mix.exs b/apps/block_scout_web/mix.exs index e431d4ecf5..623aba2089 100644 --- a/apps/block_scout_web/mix.exs +++ b/apps/block_scout_web/mix.exs @@ -125,7 +125,7 @@ defmodule BlockScoutWeb.Mixfile do {:spandex_datadog, "~> 0.4.0"}, # `:spandex` tracing of `:phoenix` {:spandex_phoenix, "~> 0.3.1"}, - {:timex, "~> 3.4"}, + {:timex, "~> 3.6"}, {:wallaby, "~> 0.22", only: [:test], runtime: false}, # `:cowboy` `~> 2.0` and Phoenix 1.4 compatibility {:wobserver, "~> 0.2.0", github: "poanetwork/wobserver", branch: "support-https"}, diff --git a/apps/ethereum_jsonrpc/mix.exs b/apps/ethereum_jsonrpc/mix.exs index 7c2299c4a8..58dcff8fd5 100644 --- a/apps/ethereum_jsonrpc/mix.exs +++ b/apps/ethereum_jsonrpc/mix.exs @@ -82,7 +82,7 @@ defmodule EthereumJsonrpc.MixProject do # `:spandex` integration with Datadog {:spandex_datadog, "~> 0.4.0"}, # Convert unix timestamps in JSONRPC to DateTimes - {:timex, "~> 3.4"}, + {:timex, "~> 3.6"}, # Encode/decode function names and arguments {:ex_abi, "~> 0.1.18"}, # `:verify_fun` for `Socket.Web.connect` diff --git a/apps/explorer/mix.exs b/apps/explorer/mix.exs index 4956363cc4..b9b887f838 100644 --- a/apps/explorer/mix.exs +++ b/apps/explorer/mix.exs @@ -117,7 +117,7 @@ defmodule Explorer.Mixfile do # Attach `:prometheus_ecto` to `:ecto` {:telemetry, "~> 0.3.0"}, # `Timex.Duration` for `Explorer.Counters.AverageBlockTime.average_block_time/0` - {:timex, "~> 3.4"}, + {:timex, "~> 3.6"}, {:con_cache, "~> 0.13"} ] end From 62e5b43b67731fd6c5020c84be8bb4494a85a441 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 25 Jul 2019 13:44:40 +0300 Subject: [PATCH 22/24] add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 68005eba12..0c4e5c8c8a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,7 @@ - [#2326](https://github.com/poanetwork/blockscout/pull/2326) - fix nested constructor arguments ### Chore +- [#2434](https://github.com/poanetwork/blockscout/pull/2434) - get rid of timex warnings - [#2418](https://github.com/poanetwork/blockscout/pull/2418) - Remove parentheses in market cap percentage - [#2401](https://github.com/poanetwork/blockscout/pull/2401) - add ENV vars to manage updating period of average block time and market history cache - [#2363](https://github.com/poanetwork/blockscout/pull/2363) - add parameters example for eth rpc From 3b687a73daefd746922992499e72d7245b3abc0b Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 25 Jul 2019 16:18:36 +0300 Subject: [PATCH 23/24] Revert #2395 --- CHANGELOG.md | 1 - .../assets/css/components/_tile.scss | 3 + .../templates/chain/_block.html.eex | 167 ------------------ apps/block_scout_web/priv/gettext/default.pot | 6 +- .../priv/gettext/en/LC_MESSAGES/default.po | 14 +- 5 files changed, 13 insertions(+), 178 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15bbd44f20..dce2ac2a1d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,7 +20,6 @@ - [#2410](https://github.com/poanetwork/blockscout/pull/2410) - preload smart contract for logs decoding - [#2405](https://github.com/poanetwork/blockscout/pull/2405) - added templates for table loader and tile loader - [#2398](https://github.com/poanetwork/blockscout/pull/2398) - show only one decoded candidate -- [#2395](https://github.com/poanetwork/blockscout/pull/2395) - new block loading animation - [#2389](https://github.com/poanetwork/blockscout/pull/2389) - Reduce Lodash lib size (86% of lib methods are not used) - [#2388](https://github.com/poanetwork/blockscout/pull/2388) - add create2 support to geth's js tracer - [#2387](https://github.com/poanetwork/blockscout/pull/2387) - fix not existing keys in transaction json rpc diff --git a/apps/block_scout_web/assets/css/components/_tile.scss b/apps/block_scout_web/assets/css/components/_tile.scss index 501533ce05..e621e4fd6d 100644 --- a/apps/block_scout_web/assets/css/components/_tile.scss +++ b/apps/block_scout_web/assets/css/components/_tile.scss @@ -340,6 +340,9 @@ $tile-body-a-color: #5959d8 !default; padding-right: 6px; } } + .tile-type-block { + overflow: hidden; + } .row { @include media-breakpoint-down(lg) { margin-left: -6px; diff --git a/apps/block_scout_web/lib/block_scout_web/templates/chain/_block.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/chain/_block.html.eex index 729df59a3c..706d18ec47 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/chain/_block.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/chain/_block.html.eex @@ -1,172 +1,5 @@
-
-
- Block Validated, processing... -
-
-
-
- - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
-
-
- - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
-
-
- - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
- - - - - - - - - - - - - - - -
-
-
-
-
<%= link( @block, class: "tile-title", diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index cad9101f82..7047c6966a 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -34,7 +34,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:21 -#: lib/block_scout_web/templates/chain/_block.html.eex:178 +#: lib/block_scout_web/templates/chain/_block.html.eex:11 msgid "%{count} Transactions" msgstr "" @@ -514,7 +514,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/_tile.html.eex:38 #: lib/block_scout_web/templates/block/overview.html.eex:121 -#: lib/block_scout_web/templates/chain/_block.html.eex:182 +#: lib/block_scout_web/templates/chain/_block.html.eex:15 msgid "Miner" msgstr "" @@ -1793,7 +1793,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/_tile.html.eex:47 -#: lib/block_scout_web/templates/chain/_block.html.eex:190 +#: lib/block_scout_web/templates/chain/_block.html.eex:23 #: lib/block_scout_web/views/internal_transaction_view.ex:28 msgid "Reward" 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 95b36b9dab..76e3303bf9 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 @@ -34,7 +34,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/overview.html.eex:21 -#: lib/block_scout_web/templates/chain/_block.html.eex:178 +#: lib/block_scout_web/templates/chain/_block.html.eex:11 msgid "%{count} Transactions" msgstr "" @@ -514,7 +514,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/_tile.html.eex:38 #: lib/block_scout_web/templates/block/overview.html.eex:121 -#: lib/block_scout_web/templates/chain/_block.html.eex:182 +#: lib/block_scout_web/templates/chain/_block.html.eex:15 msgid "Miner" msgstr "" @@ -1760,12 +1760,12 @@ msgstr "" msgid "Copy Value" msgstr "" -#, elixir-format, fuzzy +#, elixir-format #: lib/block_scout_web/views/internal_transaction_view.ex:26 msgid "Create2" msgstr "" -#, elixir-format, fuzzy +#, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:49 #: lib/block_scout_web/templates/address_logs/_logs.html.eex:114 #: lib/block_scout_web/templates/transaction/_decoded_input_body.html.eex:21 @@ -1774,7 +1774,7 @@ msgstr "" msgid "Data" msgstr "" -#, elixir-format, fuzzy +#, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:29 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:29 msgid "Failed to decode log data." @@ -1794,12 +1794,12 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/block/_tile.html.eex:47 -#: lib/block_scout_web/templates/chain/_block.html.eex:190 +#: lib/block_scout_web/templates/chain/_block.html.eex:23 #: lib/block_scout_web/views/internal_transaction_view.ex:28 msgid "Reward" msgstr "" -#, elixir-format, fuzzy +#, elixir-format #: lib/block_scout_web/templates/address_logs/_logs.html.eex:84 #: lib/block_scout_web/templates/transaction_log/_logs.html.eex:85 msgid "Topics" From 6f6bdd52ccc1042608fce5303e1d4520dc3fa341 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Thu, 25 Jul 2019 18:53:57 +0300 Subject: [PATCH 24/24] bump version: 2.0.2 --- CHANGELOG.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index dce2ac2a1d..99588261ea 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ ## Current +### Features + +### Fixes + +### Chore + + +## 2.0.2-beta + ### Features - [#2412](https://github.com/poanetwork/blockscout/pull/2412) - dark theme - [#2399](https://github.com/poanetwork/blockscout/pull/2399) - decode verified smart contract's logs