Skip to content

Commit

Permalink
Merge branch 'master' into gs-jsonrpc-timeouts
Browse files Browse the repository at this point in the history
  • Loading branch information
vbaranov committed Mar 19, 2019
2 parents ab6111b + 2973766 commit 3f956a3
Show file tree
Hide file tree
Showing 20 changed files with 130 additions and 30 deletions.
47 changes: 47 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## Current

### Features

### Fixes


## 1.3.5-beta

### Features

- [#1560](https://github.com/poanetwork/blockscout/pull/1560) - Allow executing smart contract functions in arbitrarily sized batches
- [#1543](https://github.com/poanetwork/blockscout/pull/1543) - Use trace_replayBlockTransactions API for faster tracing
- [#1558](https://github.com/poanetwork/blockscout/pull/1558) - Allow searching by token symbol
- [#1551](https://github.com/poanetwork/blockscout/pull/1551) Exact date and time for Transaction details page
- [#1547](https://github.com/poanetwork/blockscout/pull/1547) - Verify smart contracts with evm versions
- [#1540](https://github.com/poanetwork/blockscout/pull/1540) - Fetch ERC721 token balances if sender is '0x0..0'
- [#1539](https://github.com/poanetwork/blockscout/pull/1539) - Add the link to release in the footer
- [#1519](https://github.com/poanetwork/blockscout/pull/1519) - Create contract methods
- [#1496](https://github.com/poanetwork/blockscout/pull/1496) - Remove dropped/replaced transactions in pending transactions list
- [#1492](https://github.com/poanetwork/blockscout/pull/1492) - Disable usd value for an empty exchange rate
- [#1466](https://github.com/poanetwork/blockscout/pull/1466) - Decoding candidates for unverified contracts

### Fixes
- [#1545](https://github.com/poanetwork/blockscout/pull/1545) - Fix scheduling of latest block polling in Realtime Fetcher
- [#1554](https://github.com/poanetwork/blockscout/pull/1554) - Encode integer parameters when calling smart contract functions
- [#1537](https://github.com/poanetwork/blockscout/pull/1537) - Fix test that depended on date
- [#1534](https://github.com/poanetwork/blockscout/pull/1534) - Render a nicer error when creator cannot be determined
- [#1527](https://github.com/poanetwork/blockscout/pull/1527) - Add index to value_fetched_at
- [#1518](https://github.com/poanetwork/blockscout/pull/1518) - Select only distinct failed transactions
- [#1516](https://github.com/poanetwork/blockscout/pull/1516) - Fix coin balance params reducer for pending transaction
- [#1511](https://github.com/poanetwork/blockscout/pull/1511) - Set correct log level for production
- [#1510](https://github.com/poanetwork/blockscout/pull/1510) - Fix test that fails every 1st day of the month
- [#1509](https://github.com/poanetwork/blockscout/pull/1509) - Add index to blocks' consensus
- [#1508](https://github.com/poanetwork/blockscout/pull/1508) - Remove duplicated indexes
- [#1505](https://github.com/poanetwork/blockscout/pull/1505) - Use https instead of ssh for absinthe libs
- [#1501](https://github.com/poanetwork/blockscout/pull/1501) - Constructor_arguments must be type `text`
- [#1498](https://github.com/poanetwork/blockscout/pull/1498) - Add index for created_contract_address_hash in transactions
- [#1493](https://github.com/poanetwork/blockscout/pull/1493) - Do not do work in process initialization
- [#1487](https://github.com/poanetwork/blockscout/pull/1487) - Limit geth sync to 128 blocks
- [#1484](https://github.com/poanetwork/blockscout/pull/1484) - Allow decoding input as utf-8
- [#1479](https://github.com/poanetwork/blockscout/pull/1479) - Remove smoothing from coin balance chart

### Chore
- [https://github.com/poanetwork/blockscout/pull/1532](https://github.com/poanetwork/blockscout/pull/1532) - Upgrade elixir to 1.8.1
- [https://github.com/poanetwork/blockscout/pull/1553](https://github.com/poanetwork/blockscout/pull/1553) - Dockerfile: remove 1.7.1 version pin FROM bitwalker/alpine-elixir-phoenix
- [https://github.com/poanetwork/blockscout/pull/1465](https://github.com/poanetwork/blockscout/pull/1465) - Resolve lodash security alert
1 change: 1 addition & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
4. Commit your changes (`git commit -am 'Add some feature'`)
5. Push to the branch (`git push origin my-new-feature`)
6. Create a new Pull Request
7. Update CHANGELOG.md with the link to PR and description of the changes

### General

Expand Down
3 changes: 2 additions & 1 deletion apps/block_scout_web/assets/js/lib/from_now.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ function tryUpdateAge (el) {
function updateAge (el, timestamp) {
let fromNow = timestamp.fromNow()
// show the exact time only for transaction details page. Otherwise, short entry
if (window.location.pathname.startsWith('/tx/')) {
const elInTile = el.hasAttribute('in-tile')
if (window.location.pathname.includes('/tx/') && !elInTile) {
const offset = moment().utcOffset() / 60
const sign = offset && Math.sign(offset) ? '+' : '-'
const formatDate = `MMMM-DD-YYYY hh:mm:ss A ${sign}${offset} UTC`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,13 @@
<h2 class="card-title text-white balance-card-title"><%= gettext "Balance" %></h2>
<div class="text-right">
<h3 class="text-white" data-test="address_balance"><%= balance(@address) %></h3>
<%= unless match?({:pending, _}, @coin_balance_status) do %>
<%= if !match?({:pending, _}, @coin_balance_status) && !empty_exchange_rate?(@exchange_rate) do %>
<span class="text-white text-faded">
<span class="current-balance-in-wei"
data-wei-value="<%= if @address.fetched_coin_balance, do: @address.fetched_coin_balance.value %>"
<% if !empty_exchange_rate?(@exchange_rate) do %>
data-usd-exchange-rate="<%= @exchange_rate.usd_value %>">
<% end %>
</spanc>
<% if !empty_exchange_rate?(@exchange_rate) do %>
<small>(@ <span data-usd-unit-price="<%= @exchange_rate.usd_value %>"></span>/<%= gettext("Ether") %>)</small>
<% end %>
<br>
</span>
<% end %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
to: block_path(BlockScoutWeb.Endpoint, :show, @internal_transaction.block_number)
) %>
</span>
<span class="mr-2 mr-md-0 order-2" data-from-now="<%= @internal_transaction.transaction.block.timestamp %>"></span>
<span class="mr-2 mr-md-0 order-2" in-tile data-from-now="<%= @internal_transaction.transaction.block.timestamp %>"></span>
<%= if assigns[:current_address] do %>
<span class="mr-2 mr-md-0 order-0 order-md-3">
<%= if assigns[:current_address].hash == @internal_transaction.from_address_hash do %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
<span class="mr-2 mr-md-0 order-1">
<%= @transaction |> block_number() |> BlockScoutWeb.RenderHelpers.render_partial() %>
</span>
<span class="mr-2 mr-md-0 order-2" data-from-now="<%= block_timestamp(@transaction) %>"></span>
<span class="mr-2 mr-md-0 order-2" in-tile data-from-now="<%= block_timestamp(@transaction) %>"></span>
<%= if from_or_to_address?(@transaction, assigns[:current_address]) do %>
<span class="mr-2 mr-md-0 order-0 order-md-3">
<%= if @transaction.from_address_hash == assigns[:current_address].hash do %>
Expand Down
6 changes: 3 additions & 3 deletions apps/block_scout_web/priv/gettext/default.pot
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ msgid "Enter the Solidity Contract Code below"
msgstr ""

#, elixir-format
#: lib/block_scout_web/templates/address/_balance_card.html.eex:32
#: lib/block_scout_web/templates/address/_balance_card.html.eex:28
msgid "Error trying to fetch balances."
msgstr ""

Expand All @@ -387,7 +387,7 @@ msgid "Error: (Awaiting internal transactions for reason)"
msgstr ""

#, elixir-format
#: lib/block_scout_web/templates/address/_balance_card.html.eex:16
#: lib/block_scout_web/templates/address/_balance_card.html.eex:13
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:16
#: lib/block_scout_web/templates/layout/app.html.eex:51
#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20
Expand All @@ -408,7 +408,7 @@ msgid "Execute"
msgstr ""

#, elixir-format
#: lib/block_scout_web/templates/address/_balance_card.html.eex:28
#: lib/block_scout_web/templates/address/_balance_card.html.eex:24
msgid "Fetching tokens..."
msgstr ""

Expand Down
6 changes: 3 additions & 3 deletions apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ msgid "Enter the Solidity Contract Code below"
msgstr ""

#, elixir-format
#: lib/block_scout_web/templates/address/_balance_card.html.eex:32
#: lib/block_scout_web/templates/address/_balance_card.html.eex:28
msgid "Error trying to fetch balances."
msgstr ""

Expand All @@ -387,7 +387,7 @@ msgid "Error: (Awaiting internal transactions for reason)"
msgstr ""

#, elixir-format
#: lib/block_scout_web/templates/address/_balance_card.html.eex:16
#: lib/block_scout_web/templates/address/_balance_card.html.eex:13
#: lib/block_scout_web/templates/internal_transaction/_tile.html.eex:16
#: lib/block_scout_web/templates/layout/app.html.eex:51
#: lib/block_scout_web/templates/transaction/_pending_tile.html.eex:20
Expand All @@ -408,7 +408,7 @@ msgid "Execute"
msgstr ""

#, elixir-format
#: lib/block_scout_web/templates/address/_balance_card.html.eex:28
#: lib/block_scout_web/templates/address/_balance_card.html.eex:24
msgid "Fetching tokens..."
msgstr ""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -487,29 +487,26 @@ defmodule BlockScoutWeb.ViewingAddressesTest do
|> AddressPage.visit_page(lincoln)
|> AddressPage.click_balance_dropdown_toggle()
|> AddressPage.fill_balance_dropdown_search("ato")
|> assert_has(AddressPage.token_balance(count: 1))
|> assert_has(AddressPage.token_type(count: 1))
|> assert_has(AddressPage.token_balance(count: 2))
|> assert_has(AddressPage.token_type(count: 2))
|> assert_has(AddressPage.token_type_count(type: "ERC-721", text: "1"))
|> assert_has(AddressPage.token_balance_counter("1"))
end

test "filter token balances by token symbol", %{session: session, lincoln: lincoln} do
session
|> AddressPage.visit_page(lincoln)
|> AddressPage.click_balance_dropdown_toggle()
|> AddressPage.fill_balance_dropdown_search("T2")
|> assert_has(AddressPage.token_balance(count: 1))
|> assert_has(AddressPage.token_type(count: 1))
|> assert_has(AddressPage.token_balance(count: 2))
|> assert_has(AddressPage.token_type(count: 2))
|> assert_has(AddressPage.token_type_count(type: "ERC-20", text: "1"))
|> assert_has(AddressPage.token_balance_counter("1"))
end

test "reset token balances filter when dropdown closes", %{session: session, lincoln: lincoln} do
session
|> AddressPage.visit_page(lincoln)
|> AddressPage.click_balance_dropdown_toggle()
|> AddressPage.fill_balance_dropdown_search("ato")
|> assert_has(AddressPage.token_balance_counter("1"))
|> AddressPage.click_outside_of_the_dropdown()
|> assert_has(AddressPage.token_balance_counter("2"))
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ defmodule BlockScoutWeb.Schema.Query.AddressTest do
"r" => to_string(transaction.r),
"s" => to_string(transaction.s),
"status" => nil,
"v" => transaction.v,
"v" => to_string(transaction.v),
"value" => to_string(transaction.value.value),
"from_address_hash" => to_string(transaction.from_address_hash),
"to_address_hash" => to_string(transaction.to_address_hash),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ defmodule BlockScoutWeb.Schema.Query.TransactionTest do
"r" => to_string(transaction.r),
"s" => to_string(transaction.s),
"status" => transaction.status |> to_string() |> String.upcase(),
"v" => transaction.v,
"v" => to_string(transaction.v),
"value" => to_string(transaction.value.value),
"from_address_hash" => to_string(transaction.from_address_hash),
"to_address_hash" => to_string(transaction.to_address_hash),
Expand Down
2 changes: 1 addition & 1 deletion apps/explorer/lib/explorer/chain/transaction.ex
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ defmodule Explorer.Chain.Transaction do
field(:r, :decimal)
field(:s, :decimal)
field(:status, Status)
field(:v, :integer)
field(:v, :decimal)
field(:value, Wei)

timestamps()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
defmodule Explorer.Repo.Migrations.ChangeTransactionsVColumnType do
use Ecto.Migration

def up do
alter table(:transactions) do
modify(:v, :numeric, precision: 100, null: false)
end
end

def down do
alter table(:transactions) do
modify(:v, :integer, null: false)
end
end
end
1 change: 1 addition & 0 deletions apps/indexer/config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ config :indexer,
memory_limit: 1 <<< 30

# config :indexer, Indexer.ReplacedTransaction.Supervisor, disabled?: true
# config :indexer, Indexer.Block.Reward.Supervisor, disabled?: true

config :indexer, Indexer.Tracer,
service: :indexer,
Expand Down
17 changes: 17 additions & 0 deletions apps/indexer/config/dev/parity.exs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,23 @@ config :indexer,
],
variant: EthereumJSONRPC.Parity
],
# Example configuration to override json_rpc_named_arguments for just the realtime block fetcher
# realtime_overrides: [
# json_rpc_named_arguments: [
# transport: EthereumJSONRPC.HTTP,
# transport_options: [
# http: EthereumJSONRPC.HTTP.HTTPoison,
# url: System.get_env("ETHEREUM_JSONRPC_REALTIME_HTTP_URL") || "http://localhost:8545",
# method_to_url: [
# eth_getBalance: System.get_env("ETHEREUM_JSONRPC_REALTIME_TRACE_URL") || "http://localhost:8545",
# trace_block: System.get_env("ETHEREUM_JSONRPC_REALTIME_TRACE_URL") || "http://localhost:8545",
# trace_replayTransaction: System.get_env("ETHEREUM_JSONRPC_REALTIME_TRACE_URL") || "http://localhost:8545"
# ],
# http_options: [recv_timeout: :timer.minutes(1), timeout: :timer.minutes(1), hackney: [pool: :ethereum_jsonrpc]]
# ],
# variant: EthereumJSONRPC.Parity
# ]
# ],
subscribe_named_arguments: [
transport: EthereumJSONRPC.WebSocket,
transport_options: [
Expand Down
2 changes: 2 additions & 0 deletions apps/indexer/lib/indexer/block/realtime/consensus_ensurer.ex
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ defmodule Indexer.Block.Realtime.ConsensusEnsurer do
alias Explorer.Chain.Hash
alias Indexer.Block.Realtime.Fetcher

def perform(_, number, _) when not is_integer(number) or number < 0, do: :ok

def perform(%Hash{byte_count: unquote(Hash.Full.byte_count())} = block_hash, number, block_fetcher) do
case Chain.hash_to_block(block_hash) do
{:ok, %{consensus: true} = _block} ->
Expand Down
7 changes: 6 additions & 1 deletion apps/indexer/lib/indexer/block/reward/fetcher.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ defmodule Indexer.Block.Reward.Fetcher do
alias Explorer.Chain.{Block, Wei}
alias Indexer.Address.CoinBalances
alias Indexer.{AddressExtraction, BufferedTask, CoinBalance, Tracer}
alias Indexer.Block.Reward.Supervisor, as: BlockRewardSupervisor

@behaviour BufferedTask

Expand All @@ -34,7 +35,11 @@ defmodule Indexer.Block.Reward.Fetcher do
"""
@spec async_fetch([Block.block_number()]) :: :ok
def async_fetch(block_numbers) when is_list(block_numbers) do
BufferedTask.buffer(__MODULE__, block_numbers)
if BlockRewardSupervisor.disabled?() do
:ok
else
BufferedTask.buffer(__MODULE__, block_numbers)
end
end

@doc false
Expand Down
10 changes: 9 additions & 1 deletion apps/indexer/lib/indexer/block/reward/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,15 @@ defmodule Indexer.Block.Reward.Supervisor do
end

def start_link(arguments, gen_server_options \\ []) do
Supervisor.start_link(__MODULE__, arguments, Keyword.put_new(gen_server_options, :name, __MODULE__))
if disabled?() do
:ignore
else
Supervisor.start_link(__MODULE__, arguments, Keyword.put_new(gen_server_options, :name, __MODULE__))
end
end

def disabled?() do
Application.get_env(:indexer, __MODULE__, [])[:disabled?] == true
end

@impl Supervisor
Expand Down
15 changes: 12 additions & 3 deletions apps/indexer/lib/indexer/block/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,23 @@ defmodule Indexer.Block.Supervisor do
%{
block_interval: block_interval,
json_rpc_named_arguments: json_rpc_named_arguments,
subscribe_named_arguments: subscribe_named_arguments
subscribe_named_arguments: subscribe_named_arguments,
realtime_overrides: realtime_overrides
} = named_arguments
) do
block_fetcher =
named_arguments
|> Map.drop(~w(block_interval memory_monitor subscribe_named_arguments)a)
|> Map.drop(~w(block_interval memory_monitor subscribe_named_arguments realtime_overrides)a)
|> Block.Fetcher.new()

realtime_block_fetcher =
named_arguments
|> Map.drop(~w(block_interval memory_monitor subscribe_named_arguments realtime_overrides)a)
|> Map.merge(Enum.into(realtime_overrides, %{}))
|> Block.Fetcher.new()

realtime_subscribe_named_arguments = realtime_overrides[:subscribe_named_arguments] || subscribe_named_arguments

memory_monitor = Map.get(named_arguments, :memory_monitor)

Supervisor.init(
Expand All @@ -38,7 +47,7 @@ defmodule Indexer.Block.Supervisor do
{InvalidConsensus.Supervisor, [[], [name: InvalidConsensus.Supervisor]]},
{Realtime.Supervisor,
[
%{block_fetcher: block_fetcher, subscribe_named_arguments: subscribe_named_arguments},
%{block_fetcher: realtime_block_fetcher, subscribe_named_arguments: realtime_subscribe_named_arguments},
[name: Realtime.Supervisor]
]},
{Uncle.Supervisor, [[block_fetcher: block_fetcher, memory_monitor: memory_monitor], [name: Uncle.Supervisor]]},
Expand Down
3 changes: 2 additions & 1 deletion apps/indexer/lib/indexer/shrinkable/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,11 @@ defmodule Indexer.Shrinkable.Supervisor do
|> Application.get_all_env()
|> Keyword.take(
~w(blocks_batch_size blocks_concurrency block_interval json_rpc_named_arguments receipts_batch_size
receipts_concurrency subscribe_named_arguments)a
receipts_concurrency subscribe_named_arguments realtime_overrides)a
)
|> Enum.into(%{})
|> Map.put(:memory_monitor, memory_monitor)
|> Map.put_new(:realtime_overrides, %{})

Supervisor.init(
[
Expand Down

0 comments on commit 3f956a3

Please sign in to comment.