From 343a9bd083729196c73a1d8faea8315be678b289 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Mon, 25 Feb 2019 10:08:56 -0500 Subject: [PATCH 1/3] feat: allow decoding input as utf-8 --- apps/block_scout_web/assets/js/app.js | 1 + .../js/lib/transaction_input_dropdown.js | 10 ++++ .../templates/transaction/overview.html.eex | 30 +++++++++-- .../block_scout_web/views/transaction_view.ex | 3 ++ apps/block_scout_web/priv/gettext/default.pot | 49 +++++++++++------- .../priv/gettext/en/LC_MESSAGES/default.po | 51 +++++++++++-------- 6 files changed, 101 insertions(+), 43 deletions(-) create mode 100644 apps/block_scout_web/assets/js/lib/transaction_input_dropdown.js diff --git a/apps/block_scout_web/assets/js/app.js b/apps/block_scout_web/assets/js/app.js index f00b84c17c98..e01a7fcd7fd9 100644 --- a/apps/block_scout_web/assets/js/app.js +++ b/apps/block_scout_web/assets/js/app.js @@ -46,6 +46,7 @@ import './lib/stop_propagation' import './lib/token_balance_dropdown' import './lib/token_balance_dropdown_search' import './lib/token_transfers_toggle' +import './lib/transaction_input_dropdown' import './lib/async_listing_load' import './lib/tooltip' import './lib/try_api' diff --git a/apps/block_scout_web/assets/js/lib/transaction_input_dropdown.js b/apps/block_scout_web/assets/js/lib/transaction_input_dropdown.js new file mode 100644 index 000000000000..2c8d21d7a46a --- /dev/null +++ b/apps/block_scout_web/assets/js/lib/transaction_input_dropdown.js @@ -0,0 +1,10 @@ +import $ from 'jquery' + +$('.tx-input-dropdown').click(function (e) { + var el = $(e.currentTarget) + var target = $(el.attr('data-target')) + + target.show() + target.siblings('.transaction-input').hide() + $('#tx-input-decoding-button').text(el.text()) +}) diff --git a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex index a22dabc755b3..9acb212994e8 100644 --- a/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex +++ b/apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex @@ -93,15 +93,37 @@
<%= gettext "Raw Input" %>
-
+
+
+
<%= @transaction.input %>
+
+
+ + +
diff --git a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex index dd9a988b8338..14a20481b86b 100644 --- a/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex +++ b/apps/block_scout_web/lib/block_scout_web/views/transaction_view.ex @@ -91,6 +91,9 @@ defmodule BlockScoutWeb.TransactionView do def contract_creation?(_), do: false + # def utf8_encode() do + # end + def fee(%Transaction{} = transaction) do {_, value} = Chain.fee(transaction, :wei) value diff --git a/apps/block_scout_web/priv/gettext/default.pot b/apps/block_scout_web/priv/gettext/default.pot index 114e00bf53a0..ae553639bc38 100644 --- a/apps/block_scout_web/priv/gettext/default.pot +++ b/apps/block_scout_web/priv/gettext/default.pot @@ -49,7 +49,7 @@ msgid "%{subnetwork} Explorer - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:118 +#: lib/block_scout_web/views/transaction_view.ex:121 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -278,12 +278,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:195 +#: lib/block_scout_web/views/transaction_view.ex:198 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:194 +#: lib/block_scout_web/views/transaction_view.ex:197 msgid "Contract Creation" msgstr "" @@ -377,12 +377,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:122 +#: lib/block_scout_web/views/transaction_view.ex:125 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:120 +#: lib/block_scout_web/views/transaction_view.ex:123 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -392,7 +392,7 @@ msgstr "" #: lib/block_scout_web/templates/layout/app.html.eex:51 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:19 #: lib/block_scout_web/templates/transaction/_tile.html.eex:26 -#: lib/block_scout_web/templates/transaction/overview.html.eex:118 +#: lib/block_scout_web/templates/transaction/overview.html.eex:140 #: lib/block_scout_web/views/wei_helpers.ex:72 msgid "Ether" msgstr "" @@ -431,7 +431,7 @@ msgid "GET" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:131 +#: lib/block_scout_web/templates/transaction/overview.html.eex:153 msgid "Gas" msgstr "" @@ -495,7 +495,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:270 -#: lib/block_scout_web/views/transaction_view.ex:248 +#: lib/block_scout_web/views/transaction_view.ex:251 msgid "Internal Transactions" msgstr "" @@ -513,7 +513,7 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:143 +#: lib/block_scout_web/templates/transaction/overview.html.eex:165 msgid "Limit" msgstr "" @@ -521,7 +521,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:249 +#: lib/block_scout_web/views/transaction_view.ex:252 msgid "Logs" msgstr "" @@ -533,7 +533,7 @@ msgid "Market Cap" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:109 +#: lib/block_scout_web/views/transaction_view.ex:112 msgid "Max of" msgstr "" @@ -662,8 +662,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/transaction/overview.html.eex:55 -#: lib/block_scout_web/views/transaction_view.ex:117 -#: lib/block_scout_web/views/transaction_view.ex:151 +#: lib/block_scout_web/views/transaction_view.ex:120 +#: lib/block_scout_web/views/transaction_view.ex:154 msgid "Pending" msgstr "" @@ -768,7 +768,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 -#: lib/block_scout_web/views/transaction_view.ex:119 +#: lib/block_scout_web/views/transaction_view.ex:122 msgid "Success" msgstr "" @@ -879,7 +879,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:193 +#: lib/block_scout_web/views/transaction_view.ex:196 msgid "Token Transfer" msgstr "" @@ -891,7 +891,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:247 +#: lib/block_scout_web/views/transaction_view.ex:250 msgid "Token Transfers" msgstr "" @@ -932,7 +932,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:196 +#: lib/block_scout_web/views/transaction_view.ex:199 msgid "Transaction" msgstr "" @@ -999,7 +999,7 @@ msgid "Unique Token" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:136 +#: lib/block_scout_web/templates/transaction/overview.html.eex:158 msgid "Used" msgstr "" @@ -1020,7 +1020,7 @@ msgid "Validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:118 +#: lib/block_scout_web/templates/transaction/overview.html.eex:140 msgid "Value" msgstr "" @@ -1642,3 +1642,14 @@ msgstr "" #: lib/block_scout_web/templates/transaction/overview.html.eex:85 msgid "Transaction Speed" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/overview.html.eex:116 +#: lib/block_scout_web/templates/transaction/overview.html.eex:121 +msgid "Hex (Default)" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/overview.html.eex:125 +msgid "UTF-8" +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 d0102005474d..31ed957db22e 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 @@ -49,7 +49,7 @@ msgid "%{subnetwork} Explorer - BlockScout" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:118 +#: lib/block_scout_web/views/transaction_view.ex:121 msgid "(Awaiting internal transactions for status)" msgstr "" @@ -278,12 +278,12 @@ msgid "Contract Address Pending" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:195 +#: lib/block_scout_web/views/transaction_view.ex:198 msgid "Contract Call" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:194 +#: lib/block_scout_web/views/transaction_view.ex:197 msgid "Contract Creation" msgstr "" @@ -377,12 +377,12 @@ msgid "Error trying to fetch balances." msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:122 +#: lib/block_scout_web/views/transaction_view.ex:125 msgid "Error: %{reason}" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:120 +#: lib/block_scout_web/views/transaction_view.ex:123 msgid "Error: (Awaiting internal transactions for reason)" msgstr "" @@ -392,7 +392,7 @@ msgstr "" #: lib/block_scout_web/templates/layout/app.html.eex:51 #: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:19 #: lib/block_scout_web/templates/transaction/_tile.html.eex:26 -#: lib/block_scout_web/templates/transaction/overview.html.eex:118 +#: lib/block_scout_web/templates/transaction/overview.html.eex:140 #: lib/block_scout_web/views/wei_helpers.ex:72 msgid "Ether" msgstr "POA" @@ -431,7 +431,7 @@ msgid "GET" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:131 +#: lib/block_scout_web/templates/transaction/overview.html.eex:153 msgid "Gas" msgstr "" @@ -495,7 +495,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:43 #: lib/block_scout_web/templates/transaction_internal_transaction/index.html.eex:10 #: lib/block_scout_web/views/address_view.ex:270 -#: lib/block_scout_web/views/transaction_view.ex:248 +#: lib/block_scout_web/views/transaction_view.ex:251 msgid "Internal Transactions" msgstr "" @@ -513,7 +513,7 @@ msgid "Less than" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:143 +#: lib/block_scout_web/templates/transaction/overview.html.eex:165 msgid "Limit" msgstr "" @@ -521,7 +521,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:21 #: lib/block_scout_web/templates/transaction/_tabs.html.eex:48 #: lib/block_scout_web/templates/transaction_log/index.html.eex:10 -#: lib/block_scout_web/views/transaction_view.ex:249 +#: lib/block_scout_web/views/transaction_view.ex:252 msgid "Logs" msgstr "" @@ -533,7 +533,7 @@ msgid "Market Cap" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:109 +#: lib/block_scout_web/views/transaction_view.ex:112 msgid "Max of" msgstr "" @@ -662,8 +662,8 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/layout/_topnav.html.eex:44 #: lib/block_scout_web/templates/transaction/overview.html.eex:55 -#: lib/block_scout_web/views/transaction_view.ex:117 -#: lib/block_scout_web/views/transaction_view.ex:151 +#: lib/block_scout_web/views/transaction_view.ex:120 +#: lib/block_scout_web/views/transaction_view.ex:154 msgid "Pending" msgstr "" @@ -768,7 +768,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/transaction/_emission_reward_tile.html.eex:8 -#: lib/block_scout_web/views/transaction_view.ex:119 +#: lib/block_scout_web/views/transaction_view.ex:122 msgid "Success" msgstr "" @@ -879,7 +879,7 @@ msgstr "" #, elixir-format #: lib/block_scout_web/templates/tokens/transfer/_token_transfer.html.eex:4 #: lib/block_scout_web/templates/transaction_token_transfer/_token_transfer.html.eex:4 -#: lib/block_scout_web/views/transaction_view.ex:193 +#: lib/block_scout_web/views/transaction_view.ex:196 msgid "Token Transfer" msgstr "" @@ -891,7 +891,7 @@ msgstr "" #: lib/block_scout_web/templates/transaction/_tabs.html.eex:36 #: lib/block_scout_web/templates/transaction_token_transfer/index.html.eex:10 #: lib/block_scout_web/views/tokens/overview_view.ex:35 -#: lib/block_scout_web/views/transaction_view.ex:247 +#: lib/block_scout_web/views/transaction_view.ex:250 msgid "Token Transfers" msgstr "" @@ -932,7 +932,7 @@ msgid "Total transactions" msgstr "" #, elixir-format -#: lib/block_scout_web/views/transaction_view.ex:196 +#: lib/block_scout_web/views/transaction_view.ex:199 msgid "Transaction" msgstr "" @@ -999,7 +999,7 @@ msgid "Unique Token" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:136 +#: lib/block_scout_web/templates/transaction/overview.html.eex:158 msgid "Used" msgstr "" @@ -1020,7 +1020,7 @@ msgid "Validations" msgstr "" #, elixir-format -#: lib/block_scout_web/templates/transaction/overview.html.eex:118 +#: lib/block_scout_web/templates/transaction/overview.html.eex:140 msgid "Value" msgstr "" @@ -1638,7 +1638,18 @@ msgstr "" msgid "Transactions Sent" msgstr "" -#, elixir-format, fuzzy +#, elixir-format #: lib/block_scout_web/templates/transaction/overview.html.eex:85 msgid "Transaction Speed" msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/overview.html.eex:116 +#: lib/block_scout_web/templates/transaction/overview.html.eex:121 +msgid "Hex (Default)" +msgstr "" + +#, elixir-format +#: lib/block_scout_web/templates/transaction/overview.html.eex:125 +msgid "UTF-8" +msgstr "" From 47032c064e805c94364efbf5a36e4c0dc3fe2892 Mon Sep 17 00:00:00 2001 From: zachdaniel Date: Tue, 19 Feb 2019 14:42:54 -0500 Subject: [PATCH 2/3] feat: optimize/rework `init` for replaced transactions fetcher --- apps/explorer/lib/explorer/chain.ex | 63 +++++++++++++ .../chain/import/runner/transactions.ex | 2 +- .../indexer/replaced_transaction/fetcher.ex | 26 +++++- .../replaced_transaction/fetcher_test.exs | 89 +++++++++++++++++++ 4 files changed, 175 insertions(+), 5 deletions(-) diff --git a/apps/explorer/lib/explorer/chain.ex b/apps/explorer/lib/explorer/chain.ex index 2f6e2f071be1..cd7b970a86d1 100644 --- a/apps/explorer/lib/explorer/chain.ex +++ b/apps/explorer/lib/explorer/chain.ex @@ -11,6 +11,7 @@ defmodule Explorer.Chain do order_by: 2, order_by: 3, preload: 2, + select: 2, subquery: 1, union_all: 2, where: 2, @@ -1271,6 +1272,37 @@ defmodule Explorer.Chain do Repo.stream_reduce(query, initial, reducer) end + @spec stream_pending_transactions( + fields :: [ + :block_hash + | :internal_transactions_indexed_at + | :created_contract_code_indexed_at + | :from_address_hash + | :gas + | :gas_price + | :hash + | :index + | :input + | :nonce + | :r + | :s + | :to_address_hash + | :v + | :value + ], + initial :: accumulator, + reducer :: (entry :: term(), accumulator -> accumulator) + ) :: {:ok, accumulator} + when accumulator: term() + def stream_pending_transactions(fields, initial, reducer) when is_function(reducer, 2) do + query = + Transaction + |> pending_transactions_query() + |> select(^fields) + + Repo.stream_reduce(query, initial, reducer) + end + @doc """ Returns a stream of all `t:Explorer.Chain.Block.t/0` `hash`es that are marked as unfetched in `t:Explorer.Chain.Block.SecondDegreeRelation.t/0`. @@ -2265,6 +2297,37 @@ defmodule Explorer.Chain do |> Repo.all() end + @spec find_and_update_replaced_transactions([ + %{ + required(:nonce) => non_neg_integer, + required(:from_address_hash) => Hash.Address.t(), + required(:hash) => Hash.t() + } + ]) :: {integer(), nil | [term()]} + def find_and_update_replaced_transactions(transactions, timeout \\ :infinity) do + query = + Enum.reduce(transactions, Transaction, fn %{hash: hash, nonce: nonce, from_address_hash: from_address_hash}, + query -> + from(t in query, + or_where: + t.nonce == ^nonce and t.from_address_hash == ^from_address_hash and t.hash != ^hash and + not is_nil(t.block_number) + ) + end) + + hashes = Enum.map(transactions, & &1.hash) + + transactions_to_update = + from(pending in Transaction, + join: duplicate in subquery(query), + on: duplicate.nonce == pending.nonce, + on: duplicate.from_address_hash == pending.from_address_hash, + where: pending.hash in ^hashes + ) + + Repo.update_all(transactions_to_update, [set: [error: "dropped/replaced", status: :error]], timeout: timeout) + end + @spec update_replaced_transactions([ %{ required(:nonce) => non_neg_integer, diff --git a/apps/explorer/lib/explorer/chain/import/runner/transactions.ex b/apps/explorer/lib/explorer/chain/import/runner/transactions.ex index e155a84e23f9..f652309c4d0e 100644 --- a/apps/explorer/lib/explorer/chain/import/runner/transactions.ex +++ b/apps/explorer/lib/explorer/chain/import/runner/transactions.ex @@ -86,7 +86,7 @@ defmodule Explorer.Chain.Import.Runner.Transactions do conflict_target: :hash, on_conflict: on_conflict, for: Transaction, - returning: ~w(block_number index hash internal_transactions_indexed_at)a, + returning: ~w(block_number index hash internal_transactions_indexed_at block_hash nonce from_address_hash)a, timeout: timeout, timestamps: timestamps ) diff --git a/apps/indexer/lib/indexer/replaced_transaction/fetcher.ex b/apps/indexer/lib/indexer/replaced_transaction/fetcher.ex index 9a647e51b939..803c0f275ac4 100644 --- a/apps/indexer/lib/indexer/replaced_transaction/fetcher.ex +++ b/apps/indexer/lib/indexer/replaced_transaction/fetcher.ex @@ -53,12 +53,12 @@ defmodule Indexer.ReplacedTransaction.Fetcher do @impl BufferedTask def init(initial, reducer, _) do {:ok, final} = - Chain.stream_mined_transactions( - [:block_hash, :nonce, :from_address_hash], + [:block_hash, :nonce, :from_address_hash, :hash] + |> Chain.stream_pending_transactions( initial, fn transaction_fields, acc -> transaction_fields - |> entry() + |> pending_entry() |> reducer.(acc) end ) @@ -75,6 +75,10 @@ defmodule Indexer.ReplacedTransaction.Fetcher do {block_hash_bytes, nonce, from_address_hash_bytes} end + defp pending_entry(%{hash: %Hash{bytes: hash}, nonce: nonce, from_address_hash: %Hash{bytes: from_address_hash_bytes}}) do + {:pending, nonce, from_address_hash_bytes, hash} + end + defp params({block_hash_bytes, nonce, from_address_hash_bytes}) when is_integer(nonce) do {:ok, from_address_hash} = Hash.Address.cast(from_address_hash_bytes) @@ -83,6 +87,10 @@ defmodule Indexer.ReplacedTransaction.Fetcher do %{nonce: nonce, from_address_hash: from_address_hash, block_hash: block_hash} end + defp pending_params({:pending, nonce, from_address_hash, hash}) do + %{nonce: nonce, from_address_hash: from_address_hash, hash: hash} + end + @impl BufferedTask @decorate trace( name: "fetch", @@ -94,7 +102,17 @@ defmodule Indexer.ReplacedTransaction.Fetcher do Logger.debug("fetching replaced transactions for transactions") try do - entries + {pending, realtime} = + entries + |> Enum.split_with(fn entry -> + match?({:pending, _, _, _}, entry) + end) + + pending + |> Enum.map(&pending_params/1) + |> Chain.find_and_update_replaced_transactions() + + realtime |> Enum.map(¶ms/1) |> Chain.update_replaced_transactions() diff --git a/apps/indexer/test/indexer/replaced_transaction/fetcher_test.exs b/apps/indexer/test/indexer/replaced_transaction/fetcher_test.exs index 925aacd9df0f..8b2b61b80eed 100644 --- a/apps/indexer/test/indexer/replaced_transaction/fetcher_test.exs +++ b/apps/indexer/test/indexer/replaced_transaction/fetcher_test.exs @@ -95,6 +95,95 @@ defmodule Indexer.ReplacedTransaction.FetcherTest do assert %Transaction{error: nil, status: nil} = Repo.one!(from(t in Transaction, where: t.hash == ^second_replaced_transaction_hash)) end + + test "updates a replaced transaction on init" do + replaced_transaction_hash = "0x2a263224a95275d77bc30a7e131bc64d948777946a790c0915ab293791fbcb61" + + address = insert(:address, hash: "0xb7cffe2ac19b9d5705a24cbe14fef5663af905a6") + + insert(:transaction, + from_address: address, + nonce: 1, + block_hash: nil, + index: nil, + block_number: nil, + hash: replaced_transaction_hash + ) + + mined_transaction_hash = "0x1a263224a95275d77bc30a7e131bc64d948777946a790c0915ab293791fbcb61" + block = insert(:block) + + mined_transaction = + insert(:transaction, + from_address: address, + nonce: 1, + index: 0, + block_hash: block.hash, + block_number: block.number, + cumulative_gas_used: 1, + gas_used: 1, + hash: mined_transaction_hash + ) + + second_mined_transaction_hash = "0x3a263224a95275d77bc30a7e131bc64d948777946a790c0915ab293791fbcb61" + second_block = insert(:block) + + insert(:transaction, + from_address: address, + nonce: 1, + index: 0, + block_hash: second_block.hash, + block_number: second_block.number, + cumulative_gas_used: 1, + gas_used: 1, + hash: second_mined_transaction_hash + ) + + second_replaced_transaction_hash = "0x7a263224a95275d77bc30a7e131bc64d948777946a790c0915ab293791fbcb61" + second_address = insert(:address, hash: "0xc7cffe2ac19b9d5705a24cbe14fef5663af905a6") + + insert(:transaction, + from_address: second_address, + nonce: 1, + block_hash: nil, + index: nil, + block_number: nil, + hash: second_replaced_transaction_hash + ) + + insert(:transaction, + from_address: mined_transaction.from_address, + nonce: mined_transaction.nonce + ) + |> with_block(block) + + ReplacedTransaction.Supervisor.Case.start_supervised!() + + # assert :ok = + # ReplacedTransaction.Fetcher.async_fetch([ + # %{ + # block_hash: mined_transaction.block_hash, + # nonce: mined_transaction.nonce, + # from_address_hash: mined_transaction.from_address_hash + # } + # ]) + + found_replaced_transaction = + wait(fn -> + Repo.one!(from(t in Transaction, where: t.hash == ^replaced_transaction_hash and t.status == ^:error)) + end) + + assert found_replaced_transaction.error == "dropped/replaced" + + assert %Transaction{error: nil, status: nil} = + Repo.one!(from(t in Transaction, where: t.hash == ^mined_transaction_hash)) + + assert %Transaction{error: nil, status: nil} = + Repo.one!(from(t in Transaction, where: t.hash == ^second_mined_transaction_hash)) + + assert %Transaction{error: nil, status: nil} = + Repo.one!(from(t in Transaction, where: t.hash == ^second_replaced_transaction_hash)) + end end defp wait(producer) do From a41e071475023d5e485bb2b894aec0acea7ff72b Mon Sep 17 00:00:00 2001 From: Andrew Gross Date: Tue, 26 Feb 2019 12:16:21 -0700 Subject: [PATCH 3/3] heading change --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ada17f8f1b73..15124e8cb2bb 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ Currently available block explorers (i.e. Etherscan and Etherchain) are closed s * [Rinkeby Testnet](https://blockscout.com/eth/rinkeby) * [Ethereum Classic](https://blockscout.com/etc/mainnet) -#### Private Sidechains +#### Additional Chains Utilizing BlockScout * [Oasis Labs](https://blockexplorer.oasiscloud.io/) * [Fuse Network](https://explorer.fuse.io/)