Merge branch 'master' into ab-add-new-fields-for-contract-verification

pull/2235/head
Ayrat Badykov 5 years ago committed by GitHub
commit cce65b54a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      CHANGELOG.md
  2. 20
      README.md
  3. 9
      apps/block_scout_web/assets/js/pages/address/logs.js
  4. 13
      apps/block_scout_web/lib/block_scout_web/templates/address_internal_transaction/index.html.eex
  5. 4
      apps/block_scout_web/lib/block_scout_web/templates/address_logs/index.html.eex
  6. 13
      apps/block_scout_web/lib/block_scout_web/templates/tokens/transfer/index.html.eex
  7. 2
      apps/block_scout_web/priv/gettext/default.pot
  8. 54
      apps/block_scout_web/priv/gettext/en/LC_MESSAGES/default.po
  9. 4
      apps/explorer/config/config.exs
  10. 14
      apps/explorer/lib/explorer/counters/average_block_time.ex
  11. 1
      apps/explorer/mix.exs
  12. 31
      apps/explorer/test/explorer/counters/average_block_time_test.exs
  13. 5
      apps/indexer/lib/indexer/fetcher/token_balance.ex
  14. 35
      apps/indexer/test/indexer/fetcher/token_balance_test.exs
  15. 1
      docs/_sidebar.md
  16. 2
      docs/env-variables.md
  17. 9
      docs/index.html
  18. 20
      docs/projects.md

@ -9,6 +9,7 @@
- [#2235](https://github.com/poanetwork/blockscout/pull/2235) - save and show additional validation fields to smart contract - [#2235](https://github.com/poanetwork/blockscout/pull/2235) - save and show additional validation fields to smart contract
- [#2190](https://github.com/poanetwork/blockscout/pull/2190) - show all token transfers - [#2190](https://github.com/poanetwork/blockscout/pull/2190) - show all token transfers
- [#2193](https://github.com/poanetwork/blockscout/pull/2193) - feat: add BLOCKSCOUT_HOST, and use it in API docs - [#2193](https://github.com/poanetwork/blockscout/pull/2193) - feat: add BLOCKSCOUT_HOST, and use it in API docs
- [#2266](https://github.com/poanetwork/blockscout/pull/2266) - allow excluding uncles from average block time calculation
### Fixes ### Fixes
- [#2263](https://github.com/poanetwork/blockscout/pull/2263) - added an ability to close network selector on outside click - [#2263](https://github.com/poanetwork/blockscout/pull/2263) - added an ability to close network selector on outside click
@ -56,6 +57,10 @@
- [#2167](https://github.com/poanetwork/blockscout/pull/2167) - feat: document eth rpc api mimicking endpoints - [#2167](https://github.com/poanetwork/blockscout/pull/2167) - feat: document eth rpc api mimicking endpoints
- [#2225](https://github.com/poanetwork/blockscout/pull/2225) - fix metadata decoding in Solidity 0.5.9 smart contract verification - [#2225](https://github.com/poanetwork/blockscout/pull/2225) - fix metadata decoding in Solidity 0.5.9 smart contract verification
- [#2204](https://github.com/poanetwork/blockscout/pull/2204) - fix large contract verification - [#2204](https://github.com/poanetwork/blockscout/pull/2204) - fix large contract verification
- [#2247](https://github.com/poanetwork/blockscout/pull/2247) - hide logs search if there are no logs
- [#2248](https://github.com/poanetwork/blockscout/pull/2248) - sort block after query execution for average block time
- [#2270](https://github.com/poanetwork/blockscout/pull/2270) - Remove duplicate params in `Indexer.Fetcher.TokenBalance`
- [#2268](https://github.com/poanetwork/blockscout/pull/2268) - remove not existing assigns in html code
### Chore ### Chore
- [#2127](https://github.com/poanetwork/blockscout/pull/2127) - use previouse chromedriver version - [#2127](https://github.com/poanetwork/blockscout/pull/2127) - use previouse chromedriver version

@ -26,6 +26,25 @@ BlockScout is an Elixir application that allows users to search transactions, vi
Currently available full-featured block explorers (Etherscan, Etherchain, Blockchair) are closed systems which are not independently verifiable. As Ethereum sidechains continue to proliferate in both private and public settings, transparent, open-source tools are needed to analyze and validate transactions. Currently available full-featured block explorers (Etherscan, Etherchain, Blockchair) are closed systems which are not independently verifiable. As Ethereum sidechains continue to proliferate in both private and public settings, transparent, open-source tools are needed to analyze and validate transactions.
## Supported Projects
| **Hosted Mainnets** | **Hosted Testnets** | **Additional Chains using BlockScout** |
|--------------------------------------------------------|-------------------------------------------------------|----------------------------------------------------|
| [Aerum](https://blockscout.com/aerum/mainnet) | [Goerli Testnet](https://blockscout.com/eth/goerli) | [ARTIS](https://explorer.sigma1.artis.network) |
| [Callisto](https://blockscout.com/callisto/mainnet) | [Kovan Testnet](https://blockscout.com/eth/kovan) | [Ether-1](https://blocks.ether1.wattpool.net/) |
| [Ethereum Classic](https://blockscout.com/etc/mainnet) | [POA Sokol Testnet](https://blockscout.com/poa/sokol) | [Fuse Network](https://explorer.fuse.io/) |
| [Ethereum Mainnet](https://blockscout.com/eth/mainnet) | [Rinkeby Testnet](https://blockscout.com/eth/rinkeby) | [Oasis Labs](https://blockexplorer.oasiscloud.io/) |
| [POA Core Network](https://blockscout.com/poa/core) | [Ropsten Testnet](https://blockscout.com/eth/ropsten) | [Petrichor](https://explorer.petrachor.com/) |
| [RSK](https://blockscout.com/rsk/mainnet) | | [PIRL](http://pirl.es/) |
| [xDai Chain](https://blockscout.com/poa/dai) | | [SafeChain](https://explorer.safechain.io) |
| | | [SpringChain](https://explorer.springrole.com/) |
| | | [Kotti Testnet](https://kottiexplorer.ethernode.io/) |
| | | [Loom](http://plasma-blockexplorer.dappchains.com/) |
| | | [Tenda](https://tenda.network) |
Current BlockScout versions for hosted projects are available [on the forum](https://forum.poa.network/t/deployed-instances-on-blockscout-com/1938).
## Getting Started ## Getting Started
See the [project documentation](https://poanetwork.github.io/blockscout) for instructions: See the [project documentation](https://poanetwork.github.io/blockscout) for instructions:
@ -35,6 +54,7 @@ See the [project documentation](https://poanetwork.github.io/blockscout) for ins
- [ENV variables](https://poanetwork.github.io/blockscout/#/env-variables) - [ENV variables](https://poanetwork.github.io/blockscout/#/env-variables)
- [Configuration options](https://poanetwork.github.io/blockscout/#/dev-env) - [Configuration options](https://poanetwork.github.io/blockscout/#/dev-env)
## Acknowledgements ## Acknowledgements
We would like to thank the [EthPrize foundation](http://ethprize.io/) for their funding support. We would like to thank the [EthPrize foundation](http://ethprize.io/) for their funding support.

@ -40,6 +40,15 @@ const elements = {
return $el.hide() return $el.hide()
} }
return $el.show()
}
},
'[data-search]': {
render ($el, state) {
if (state.emptyResponse) {
return $el.hide()
}
return $el.show() return $el.show()
} }
} }

@ -67,17 +67,8 @@
</div> </div>
<div data-items></div> <div data-items></div>
<!--<div class="transaction-bottom-panel"> <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
<div class="download-all-transactions">
Download <a class="download-all-transactions-link" href=<%= address_transaction_path(@conn, :token_transfers_csv, %{"address_id" => to_string(@address.hash)}) %>><%= gettext("CSV") %></span>
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="16">
<path fill="#333333" fill-rule="evenodd" d="M13 16H1c-.999 0-1-1-1-1V1s-.004-1 1-1h6l7 7v8s-.032 1-1 1zm-1-8c0-.99-1-1-1-1H8s-1 .001-1-1V3c0-.999-1-1-1-1H2v12h10V8z"/>
</svg>
</a>
</div>-->
<%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
<!--</div>-->
</div> </div>
</div> </div>

@ -7,8 +7,8 @@
<div class="card-body" data-async-load data-async-listing="<%= @current_path %>"> <div class="card-body" data-async-load data-async-listing="<%= @current_path %>">
<h2 class="card-title"><%= gettext "Logs" %></h2> <h2 class="card-title"><%= gettext "Logs" %></h2>
<div class="logs-topbar"> <div class="logs-topbar">
<div class="logs-search"> <div data-search class="logs-search">
<input data-search-field class="logs-search-input" type='text' placeholder=<%= gettext("Topic") %> id='search-text-input' /> <input data-search-field class="logs-search-input" type='text' placeholder=<%= gettext("Topic") %> id='search-text-input' />
<button data-cancel-search-button class="logs-search-btn-cancel" type="button">x</button> <button data-cancel-search-button class="logs-search-btn-cancel" type="button">x</button>
<button data-search-button class="logs-search-btn" type="button"><%= gettext("Search") %></button> <button data-search-button class="logs-search-btn" type="button"><%= gettext("Search") %></button>

@ -27,17 +27,8 @@
</div> </div>
<div data-items></div> <div data-items></div>
<!--<div class="transaction-bottom-panel"> <%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
<div class="download-all-transactions">
Download <a class="download-all-transactions-link" href=<%= address_transaction_path(@conn, :token_transfers_csv, %{"address_id" => to_string(@address.hash)}) %>><%= gettext("CSV") %></span>
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="16">
<path fill="#333333" fill-rule="evenodd" d="M13 16H1c-.999 0-1-1-1-1V1s-.004-1 1-1h6l7 7v8s-.032 1-1 1zm-1-8c0-.99-1-1-1-1H8s-1 .001-1-1V3c0-.999-1-1-1-1H2v12h10V8z"/>
</svg>
</a>
</div>-->
<%= render BlockScoutWeb.CommonComponentsView, "_pagination_container.html", position: "bottom", cur_page_number: "1", show_pagination_limit: true, data_next_page_button: true, data_prev_page_button: true %>
<!--</div>-->
</div> </div>
</div> </div>

@ -1798,4 +1798,4 @@ msgstr ""
#, elixir-format #, elixir-format
#: lib/block_scout_web/templates/layout/_network_selector.html.eex:23 #: lib/block_scout_web/templates/layout/_network_selector.html.eex:23
msgid "Testnet" msgid "Testnet"
msgstr "" msgstr ""

@ -1742,60 +1742,6 @@ msgstr ""
msgid "here." msgid "here."
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_internal_transaction/index.html.eex:73
#: lib/block_scout_web/templates/address_token/index.html.eex:26
#: lib/block_scout_web/templates/address_transaction/index.html.eex:72
#: lib/block_scout_web/templates/tokens/transfer/index.html.eex:33
msgid "CSV"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_network_selector.html.eex:11 #: lib/block_scout_web/templates/layout/_network_selector.html.eex:11
msgid "Change Network" msgid "Change Network"
msgstr "" msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:51
msgid "Constructor arguments"
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:44
msgid "ERC-20 "
msgstr ""
#, elixir-format
#: lib/block_scout_web/views/transaction_view.ex:45
msgid "ERC-721 "
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/address_contract/index.html.eex:58
msgid "External libraries"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_network_selector.html.eex:24
msgid "Favorites"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_network_selector.html.eex:12
msgid "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore."
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_network_selector.html.eex:22
msgid "Mainnet"
msgstr ""
#, elixir-format, fuzzy
#: lib/block_scout_web/templates/layout/_network_selector.html.eex:18
msgid "Search network"
msgstr ""
#, elixir-format
#: lib/block_scout_web/templates/layout/_network_selector.html.eex:23
msgid "Testnet"
msgstr ""

@ -12,7 +12,9 @@ config :explorer,
token_functions_reader_max_retries: 3, token_functions_reader_max_retries: 3,
allowed_evm_versions: allowed_evm_versions:
System.get_env("ALLOWED_EVM_VERSIONS") || System.get_env("ALLOWED_EVM_VERSIONS") ||
"homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg" "homestead,tangerineWhistle,spuriousDragon,byzantium,constantinople,petersburg",
include_uncles_in_average_block_time:
if(System.get_env("UNCLES_IN_AVERAGE_BLOCK_TIME") == "false", do: false, else: true)
config :explorer, Explorer.Counters.AverageBlockTime, enabled: true config :explorer, Explorer.Counters.AverageBlockTime, enabled: true

@ -66,13 +66,23 @@ defmodule Explorer.Counters.AverageBlockTime do
from(block in Block, from(block in Block,
limit: 100, limit: 100,
offset: 0, offset: 0,
order_by: [desc: block.number, desc: block.timestamp], order_by: [desc: block.number],
select: {block.number, block.timestamp} select: {block.number, block.timestamp}
) )
query =
if Application.get_env(:explorer, :include_uncles_in_average_block_time) do
timestamps_query
else
from(block in timestamps_query,
where: block.consensus == true
)
end
timestamps = timestamps =
timestamps_query query
|> Repo.all() |> Repo.all()
|> Enum.sort_by(fn {_, timestamp} -> timestamp end, &>=/2)
|> Enum.map(fn {number, timestamp} -> |> Enum.map(fn {number, timestamp} ->
{number, DateTime.to_unix(timestamp, :millisecond)} {number, DateTime.to_unix(timestamp, :millisecond)}
end) end)

@ -92,7 +92,6 @@ defmodule Explorer.Mixfile do
{:math, "~> 0.3.0"}, {:math, "~> 0.3.0"},
{:mock, "~> 0.3.0", only: [:test], runtime: false}, {:mock, "~> 0.3.0", only: [:test], runtime: false},
{:mox, "~> 0.4", only: [:test]}, {:mox, "~> 0.4", only: [:test]},
{:nimble_csv, "~> 0.6.0"},
{:poison, "~> 3.1"}, {:poison, "~> 3.1"},
{:nimble_csv, "~> 0.6.0"}, {:nimble_csv, "~> 0.6.0"},
{:postgrex, ">= 0.0.0"}, {:postgrex, ">= 0.0.0"},

@ -11,6 +11,8 @@ defmodule Explorer.Counters.AverageBlockTimeTest do
start_supervised!(AverageBlockTime) start_supervised!(AverageBlockTime)
Application.put_env(:explorer, AverageBlockTime, enabled: true) Application.put_env(:explorer, AverageBlockTime, enabled: true)
Application.put_env(:explorer, :include_uncles_in_average_block_time, true)
on_exit(fn -> on_exit(fn ->
Application.put_env(:explorer, AverageBlockTime, enabled: false) Application.put_env(:explorer, AverageBlockTime, enabled: false)
end) end)
@ -43,6 +45,35 @@ defmodule Explorer.Counters.AverageBlockTimeTest do
assert AverageBlockTime.average_block_time() == Timex.Duration.parse!("PT3S") assert AverageBlockTime.average_block_time() == Timex.Duration.parse!("PT3S")
end end
test "excludes uncles if include_uncles_in_average_block_time is set to false" do
block_number = 99_999_999
Application.put_env(:explorer, :include_uncles_in_average_block_time, false)
first_timestamp = Timex.now()
insert(:block, number: block_number, consensus: true, timestamp: Timex.shift(first_timestamp, seconds: 3))
insert(:block, number: block_number, consensus: false, timestamp: Timex.shift(first_timestamp, seconds: 4))
insert(:block, number: block_number + 1, consensus: true, timestamp: Timex.shift(first_timestamp, seconds: 5))
AverageBlockTime.refresh()
assert AverageBlockTime.average_block_time() == Timex.Duration.parse!("PT2S")
end
test "excludes uncles if include_uncles_in_average_block_time is set to true" do
block_number = 99_999_999
first_timestamp = Timex.now()
insert(:block, number: block_number, consensus: true, timestamp: Timex.shift(first_timestamp, seconds: 3))
insert(:block, number: block_number, consensus: false, timestamp: Timex.shift(first_timestamp, seconds: 4))
insert(:block, number: block_number + 1, consensus: true, timestamp: Timex.shift(first_timestamp, seconds: 5))
AverageBlockTime.refresh()
assert AverageBlockTime.average_block_time() == Timex.Duration.parse!("PT1S")
end
test "when there are no uncles sorts by block number" do test "when there are no uncles sorts by block number" do
block_number = 99_999_999 block_number = 99_999_999

@ -93,7 +93,10 @@ defmodule Indexer.Fetcher.TokenBalance do
end end
def fetch_from_blockchain(params_list) do def fetch_from_blockchain(params_list) do
retryable_params_list = Enum.filter(params_list, &(&1.retries_count <= @max_retries)) retryable_params_list =
params_list
|> Enum.filter(&(&1.retries_count <= @max_retries))
|> Enum.uniq_by(&Map.take(&1, [:token_contract_address_hash, :address_hash, :block_number]))
Logger.metadata(count: Enum.count(retryable_params_list)) Logger.metadata(count: Enum.count(retryable_params_list))

@ -111,6 +111,41 @@ defmodule Indexer.Fetcher.TokenBalanceTest do
assert TokenBalance.run(token_balances, nil) == :ok assert TokenBalance.run(token_balances, nil) == :ok
end end
test "fetches duplicate params only once" do
%Address.TokenBalance{
address_hash: %Hash{bytes: address_hash_bytes} = address_hash,
token_contract_address_hash: %Hash{bytes: token_contract_address_hash_bytes},
block_number: block_number
} = insert(:token_balance, value_fetched_at: nil, value: nil)
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn [%{id: id, method: "eth_call", params: [%{data: _, to: _}, _]}], _options ->
{:ok,
[
%{
id: id,
jsonrpc: "2.0",
result: "0x00000000000000000000000000000000000000000000d3c21bcecceda1000000"
}
]}
end
)
assert TokenBalance.run(
[
{address_hash_bytes, token_contract_address_hash_bytes, block_number, 0},
{address_hash_bytes, token_contract_address_hash_bytes, block_number, 0}
],
nil
) == :ok
assert 1 =
from(tb in Address.TokenBalance, where: tb.address_hash == ^address_hash)
|> Explorer.Repo.aggregate(:count, :id)
end
end end
describe "import_token_balances/1" do describe "import_token_balances/1" do

@ -3,7 +3,6 @@
- About BlockScout - About BlockScout
- [About](about.md) - [About](about.md)
- [Projects Using BlockScout](projects.md)
- [Umbrella Project Organization](umbrella.md) - [Umbrella Project Organization](umbrella.md)
- Installation & Configuration - Installation & Configuration

@ -1,6 +1,6 @@
# BlockScout Env Variables # BlockScout Env Variables
Below is a table outlining the environment variables utilized by BlockScout. Below is a table outlining the environment variables utilized by BlockScout.
| Variable | Required | Description | Default | Version | | Variable | Required | Description | Default | Version |

@ -6,12 +6,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="description" content="Description"> <meta name="description" content="Description">
<meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"> <meta name="viewport" content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/docsify-themeable@0/dist/css/theme-simple.css"> <link rel="stylesheet" href="//unpkg.com/docsify/themes/buble.css">
<style> <style>
:root { nav.app-nav li ul {
/* Reduce the font size */ min-width: 100px;
--base-font-size: 16px;
} }
</style> </style>
@ -32,7 +30,6 @@
</script> </script>
<script src="//unpkg.com/docsify/lib/docsify.min.js"></script> <script src="//unpkg.com/docsify/lib/docsify.min.js"></script>
<script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script> <script src="//unpkg.com/docsify/lib/plugins/search.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/docsify-themeable@0"></script>
<script src="https://unpkg.com/docsify-plugin-flexible-alerts"></script> <script src="https://unpkg.com/docsify-plugin-flexible-alerts"></script>
</body> </body>
</html> </html>

@ -1,20 +0,0 @@
<!-- projects.md -->
### Supported Projects
| **Hosted Mainnets** | **Hosted Testnets** | **Additional Chains using BlockScout** |
|--------------------------------------------------------|-------------------------------------------------------|----------------------------------------------------|
| [Aerum](https://blockscout.com/aerum/mainnet) | [Goerli Testnet](https://blockscout.com/eth/goerli) | [ARTIS](https://explorer.sigma1.artis.network) |
| [Callisto](https://blockscout.com/callisto/mainnet) | [Kovan Testnet](https://blockscout.com/eth/kovan) | [Ether-1](https://blocks.ether1.wattpool.net/) |
| [Ethereum Classic](https://blockscout.com/etc/mainnet) | [POA Sokol Testnet](https://blockscout.com/poa/sokol) | [Fuse Network](https://explorer.fuse.io/) |
| [Ethereum Mainnet](https://blockscout.com/eth/mainnet) | [Rinkeby Testnet](https://blockscout.com/eth/rinkeby) | [Oasis Labs](https://blockexplorer.oasiscloud.io/) |
| [POA Core Network](https://blockscout.com/poa/core) | [Ropsten Testnet](https://blockscout.com/eth/ropsten) | [Petrichor](https://explorer.petrachor.com/) |
| [RSK](https://blockscout.com/rsk/mainnet) | | [PIRL](http://pirl.es/) |
| [xDai Chain](https://blockscout.com/poa/dai) | | [SafeChain](https://explorer.safechain.io) |
| | | [SpringChain](https://explorer.springrole.com/) |
| | | [Kotti Testnet](https://kottiexplorer.ethernode.io/) |
| | | [Loom](http://plasma-blockexplorer.dappchains.com/) |
| | | [Tenda](https://tenda.network) |
Current BlockScout versions for hosted projects are available [on the forum](https://forum.poa.network/t/deployed-instances-on-blockscout-com/1938).
Loading…
Cancel
Save