Merge pull request #5443 from blockscout/vb-revert-reason-geth-2

Geth: display tx revert reason
pull/5450/head
Victor Baranov 3 years ago committed by GitHub
commit 6a918892f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      .dialyzer-ignore
  2. 1
      CHANGELOG.md
  3. 8
      apps/block_scout_web/lib/block_scout_web/controllers/api/rpc/transaction_controller.ex
  4. 2
      apps/block_scout_web/lib/block_scout_web/templates/transaction/overview.html.eex
  5. 13
      apps/explorer/lib/explorer/chain.ex
  6. 2
      apps/explorer/lib/explorer/chain/gas.ex

@ -18,7 +18,6 @@ lib/phoenix/router.ex:324
lib/phoenix/router.ex:402
lib/block_scout_web/views/layout_view.ex:145: The call 'Elixir.Poison.Parser':'parse!'
lib/block_scout_web/views/layout_view.ex:237: The call 'Elixir.Poison.Parser':'parse!'
lib/block_scout_web/controllers/api/rpc/transaction_controller.ex:22
lib/explorer/smart_contract/reader.ex:435
lib/indexer/fetcher/token_total_supply_on_demand.ex:16
lib/explorer/exchange_rates/source.ex:110

@ -6,6 +6,7 @@
- [#5268](https://github.com/blockscout/blockscout/pull/5268) - Contract names display improvement
### Fixes
- [#5443](https://github.com/blockscout/blockscout/pull/5443) - Geth: display tx revert reason
- [#5416](https://github.com/blockscout/blockscout/pull/5416) - Fix getsourcecode for EOA addresses
- [#5411](https://github.com/blockscout/blockscout/pull/5411) - Fix character_not_in_repertoire error for tx revert reason
- [#5410](https://github.com/blockscout/blockscout/pull/5410) - Handle exited realtime fetcher

@ -17,12 +17,8 @@ defmodule BlockScoutWeb.API.RPC.TransactionController do
{logs, next_page} = split_list_by_page(logs)
transaction_updated =
if error == "Reverted" do
if revert_reason == nil do
%Transaction{transaction | revert_reason: Chain.fetch_tx_revert_reason(transaction)}
else
transaction
end
if (error == "Reverted" || error == "execution reverted") && !revert_reason do
%Transaction{transaction | revert_reason: Chain.fetch_tx_revert_reason(transaction)}
else
transaction
end

@ -121,7 +121,7 @@
</dd>
</dl>
<!-- Revert reason -->
<%= if status == {:error, "Reverted"} do %>
<%= if status == {:error, "Reverted"} || status == {:error, "execution reverted"} do %>
<dl class="row">
<dt class="col-sm-3 col-lg-2 text-muted">
<%= render BlockScoutWeb.CommonComponentsView, "_i_tooltip_2.html",

@ -93,6 +93,8 @@ defmodule Explorer.Chain do
@revert_msg_prefix_2 "revert: "
@revert_msg_prefix_3 "reverted "
@revert_msg_prefix_4 "Reverted "
# Geth-like node
@revert_msg_prefix_5 "execution reverted: "
# keccak256("Error(string)")
@revert_error_method_id "08c379a0"
@ -3655,16 +3657,20 @@ defmodule Explorer.Chain do
Wei.hex_format(value)
)
data =
revert_reason =
case EthereumJSONRPC.json_rpc(req, json_rpc_named_arguments) do
{:error, %{data: data}} ->
data
{:error, %{message: message}} ->
message
_ ->
""
end
formatted_revert_reason = data |> format_revert_reason_message() |> (&if(String.valid?(&1), do: &1, else: data)).()
formatted_revert_reason =
revert_reason |> format_revert_reason_message() |> (&if(String.valid?(&1), do: &1, else: revert_reason)).()
if byte_size(formatted_revert_reason) > 0 do
transaction
@ -3689,6 +3695,9 @@ defmodule Explorer.Chain do
@revert_msg_prefix_4 <> rest ->
extract_revert_reason_message_wrapper(rest)
@revert_msg_prefix_5 <> rest ->
extract_revert_reason_message_wrapper(rest)
revert_reason_full ->
revert_reason_full
end

@ -6,5 +6,5 @@ defmodule Explorer.Chain.Gas do
"""
@typedoc @moduledoc
@type t :: non_neg_integer()
@type t :: false | nil | %Decimal{:coef => non_neg_integer(), :exp => integer(), :sign => -1 | 1}
end

Loading…
Cancel
Save