Merge branch 'master' into ab-oprimize-inventory-query

pull/2635/head
Ayrat Badykov 5 years ago committed by GitHub
commit 001aeaba92
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      CHANGELOG.md
  2. 1
      apps/block_scout_web/assets/css/_images-preload.scss
  3. 3
      apps/block_scout_web/assets/css/components/_network-selector.scss
  4. BIN
      apps/block_scout_web/assets/static/images/network-selector-icons/lukso-l14-testnet.png
  5. 116
      apps/ethereum_jsonrpc/test/ethereum_jsonrpc/rolling_window_test.exs
  6. 7
      apps/explorer/lib/explorer/chain.ex
  7. 26
      apps/explorer/test/explorer/chain_test.exs
  8. 98
      docs/env-variables.md

@ -8,6 +8,8 @@
### Fixes
- [#2635](https://github.com/poanetwork/blockscout/pull/2635) - optimize ERC721 inventory query
- [#2623](https://github.com/poanetwork/blockscout/pull/2623) - fix a blinking test
- [#2616](https://github.com/poanetwork/blockscout/pull/2616) - deduplicate coin history records by delta
- [#2613](https://github.com/poanetwork/blockscout/pull/2613) - fix getminedblocks rpc endpoint
- [#2592](https://github.com/poanetwork/blockscout/pull/2592) - process new metadata format for whisper
- [#2572](https://github.com/poanetwork/blockscout/pull/2572) - Ease non-critical css
@ -19,10 +21,12 @@
- [#2538](https://github.com/poanetwork/blockscout/pull/2538) - fetch the last not empty coin balance records
### Chore
- [#2634](https://github.com/poanetwork/blockscout/pull/2634) - add Lukso to networks dropdown
- [#2611](https://github.com/poanetwork/blockscout/pull/2611) - fix js dependency vulnerabilities
- [#2617](https://github.com/poanetwork/blockscout/pull/2617) - skip cache update if there are no blocks inserted
- [#2594](https://github.com/poanetwork/blockscout/pull/2594) - do not start genesis data fetching periodically
- [#2590](https://github.com/poanetwork/blockscout/pull/2590) - restore backward compatablity with old releases
- [#2577](https://github.com/poanetwork/blockscout/pull/2577) - Need recompile column in the env vars table
- [#2574](https://github.com/poanetwork/blockscout/pull/2574) - limit request body in json rpc error
- [#2566](https://github.com/poanetwork/blockscout/pull/2566) - upgrade absinthe phoenix

@ -12,4 +12,5 @@ body:after {
url(/images/network-selector-icons/rsk-mainnet.png)
url(/images/network-selector-icons/ropsten-testnet.png)
url(/images/network-selector-icons/xdai-chain.png)
url(/images/network-selector-icons/lukso-l14-testnet.png)
};

@ -277,6 +277,9 @@ $network-selector-item-icon-dimensions: 30px !default;
&-xdai-chain {
background-image: url(/images/network-selector-icons/xdai-chain.png)
}
&-lukso-l14-testnet {
background-image: url(/images/network-selector-icons/lukso-l14-testnet.png)
}
}
.network-selector-item-title {

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

@ -1,27 +1,8 @@
defmodule EthereumJSONRPC.RollingWindowTest do
use ExUnit.Case,
# The same named process is used for all tests and they use the same key in the table, so they would interfere
async: false
use ExUnit.Case, async: true
alias EthereumJSONRPC.RollingWindow
@table :table
setup do
# We set `window_length` to a large time frame so that we can sweep manually to simulate
# time passing
{:ok, pid} =
RollingWindow.start_link([table: @table, duration: :timer.minutes(120), window_count: 3], name: RollingWindow)
on_exit(fn -> Process.exit(pid, :normal) end)
:ok
end
defp sweep do
GenServer.call(RollingWindow, :sweep)
end
test "start_link/2" do
assert {:ok, _} = RollingWindow.start_link(table: :test_table, duration: 5, window_count: 1)
end
@ -29,7 +10,7 @@ defmodule EthereumJSONRPC.RollingWindowTest do
describe "init/1" do
test "raises when duration isn't evenly divisble by window_count" do
assert_raise ArgumentError, ~r"evenly divisible", fn ->
RollingWindow.init(table: @table, duration: :timer.seconds(2), window_count: 3)
RollingWindow.init(table: :init_test_table, duration: :timer.seconds(2), window_count: 3)
end
end
@ -40,61 +21,85 @@ defmodule EthereumJSONRPC.RollingWindowTest do
end
test "when no increments have happened, inspect returns an empty list" do
assert RollingWindow.inspect(@table, :foobar) == []
table = :no_increments_have_happened
start_rolling_window(table)
assert RollingWindow.inspect(table, :foobar) == []
end
test "when no increments have happened, count returns 0" do
assert RollingWindow.count(@table, :foobar) == 0
table = :no_increments_have_happened_empty_list
start_rolling_window(table)
assert RollingWindow.count(table, :foobar) == 0
end
test "when an increment has happened, inspect returns the count for that window" do
RollingWindow.inc(@table, :foobar)
table = :no_increments_have_happened_count
start_rolling_window(table)
assert RollingWindow.inspect(@table, :foobar) == [1]
RollingWindow.inc(table, :foobar)
assert RollingWindow.inspect(table, :foobar) == [1]
end
test "when an increment has happened, count returns the count for that window" do
RollingWindow.inc(@table, :foobar)
table = :no_increments_have_happened_count1
start_rolling_window(table)
RollingWindow.inc(table, :foobar)
assert RollingWindow.count(@table, :foobar) == 1
assert RollingWindow.count(table, :foobar) == 1
end
test "when an increment has happened in multiple windows, inspect returns the count for both windows" do
RollingWindow.inc(@table, :foobar)
sweep()
RollingWindow.inc(@table, :foobar)
table = :no_increments_have_happened_multiple_windows
start_rolling_window(table)
assert RollingWindow.inspect(@table, :foobar) == [1, 1]
RollingWindow.inc(table, :foobar)
sweep(table)
RollingWindow.inc(table, :foobar)
assert RollingWindow.inspect(table, :foobar) == [1, 1]
end
test "when an increment has happened in multiple windows, count returns the sum of both windows" do
RollingWindow.inc(@table, :foobar)
sweep()
RollingWindow.inc(@table, :foobar)
table = :no_increments_have_happened_multiple_windows1
start_rolling_window(table)
RollingWindow.inc(table, :foobar)
sweep(table)
RollingWindow.inc(table, :foobar)
assert RollingWindow.count(@table, :foobar) == 2
assert RollingWindow.count(table, :foobar) == 2
end
test "when an increment has happened, but has been swept <window_count> times, it no longer appears in inspect" do
RollingWindow.inc(@table, :foobar)
sweep()
sweep()
RollingWindow.inc(@table, :foobar)
sweep()
RollingWindow.inc(@table, :foobar)
assert RollingWindow.inspect(@table, :foobar) == [1, 1, 0]
table = :no_increments_have_happened_multiple_windows3
start_rolling_window(table)
RollingWindow.inc(table, :foobar)
sweep(table)
sweep(table)
RollingWindow.inc(table, :foobar)
sweep(table)
RollingWindow.inc(table, :foobar)
assert RollingWindow.inspect(table, :foobar) == [1, 1, 0]
end
test "when an increment has happened, but has been swept <window_count> times, it no longer is included in count" do
RollingWindow.inc(@table, :foobar)
sweep()
sweep()
RollingWindow.inc(@table, :foobar)
sweep()
RollingWindow.inc(@table, :foobar)
assert RollingWindow.count(@table, :foobar) == 2
table = :no_increments_have_happened_multiple_windows4
start_rolling_window(table)
RollingWindow.inc(table, :foobar)
sweep(table)
sweep(table)
RollingWindow.inc(table, :foobar)
sweep(table)
RollingWindow.inc(table, :foobar)
assert RollingWindow.count(table, :foobar) == 2
end
test "sweeping schedules another sweep" do
@ -102,4 +107,13 @@ defmodule EthereumJSONRPC.RollingWindowTest do
RollingWindow.handle_info(:sweep, state)
assert_receive(:sweep)
end
defp start_rolling_window(table_name) do
{:ok, _pid} =
RollingWindow.start_link([table: table_name, duration: :timer.minutes(120), window_count: 3], name: table_name)
end
defp sweep(name) do
GenServer.call(name, :sweep)
end
end

@ -2967,6 +2967,13 @@ defmodule Explorer.Chain do
|> CoinBalance.fetch_coin_balances(paging_options)
|> page_coin_balances(paging_options)
|> Repo.all()
|> Enum.dedup_by(fn record ->
if record.delta == Decimal.new(0) do
:dup
else
System.unique_integer()
end
end)
end
def get_coin_balance(address_hash, block_number) do

@ -4159,4 +4159,30 @@ defmodule Explorer.ChainTest do
assert Chain.staking_pools_count(:inactive) == 1
end
end
describe "address_to_coin_balances/2" do
test "deduplicates records by zero delta" do
address = insert(:address)
1..5
|> Enum.each(fn block_number ->
insert(:block, number: block_number)
insert(:fetched_balance, value: 1, block_number: block_number, address_hash: address.hash)
end)
insert(:block, number: 6)
insert(:fetched_balance, value: 2, block_number: 6, address_hash: address.hash)
assert [first, second, third] = Chain.address_to_coin_balances(address.hash, [])
assert first.block_number == 6
assert first.delta == Decimal.new(1)
assert second.block_number == 5
assert second.delta == Decimal.new(0)
assert third.block_number == 1
assert third.delta == Decimal.new(1)
end
end
end

@ -14,52 +14,54 @@ $ export NETWORK=POA
```
| Variable | Required | Description | Default | Version |
| --- | --- | --- | ---| --- |
| `NETWORK`| :white_check_mark: | Environment variable for the main EVM network such as Ethereum Network or POA Network | POA Network | all |
| `SUBNETWORK` | :white_check_mark: | Environment variable for the subnetwork such as Core or Sokol Network | Sokol Testnet | all |
| `NETWORK_ICON` | :white_check_mark: | Environment variable for the main network icon or testnet icon. Two options are `_test_network_icon.html` and `_network_icon.html` | `_test_network_icon.html` | all |
| `LOGO` | :white_check_mark: | Environment variable for the logo image location. The logo files names for different chains can be found [here](https://github.com/poanetwork/blockscout/tree/master/apps/block_scout_web/assets/static/images) | /images/blockscout_logo.svg | all |
| `ETHEREUM_JSONRPC_VARIANT` | :white_check_mark: | This environment variable is used to tell the application which RPC Client the node is using (i.e. Geth, Parity, or Ganache) | parity | all |
| `ETHEREUM_JSONRPC_HTTP_URL` | :white_check_mark: | The RPC endpoint used to fetch blocks, transactions, receipts, tokens. | localhost:8545 | all |
| `ETHEREUM_JSONRPC_TRACE_URL` | | The RPC endpoint specifically for the Geth/Parity client used by trace_block and trace_replayTransaction. This can be used to designate a tracing node. | localhost:8545 | all |
| `ETHEREUM_JSONRPC_WS_URL` | :white_check_mark: | The WebSockets RPC endpoint used to subscribe to the `newHeads` subscription alerting the indexer to fetch new blocks. | ws://localhost:8546 | all |
| `NETWORK_PATH` | | Used to set a network path other than what is displayed in the root directory. An example would be to add /eth/mainnet/ to the root directory. | (empty) | all |
| `SECRET_KEY_BASE` | :white_check_mark: | Use mix phx.gen.secret to generate a new Secret Key Base string to protect production assets. | (empty) | all |
| `CHECK_ORIGIN` | | Used to check the origin of requests when the origin header is present. It defaults to false. In case of true, it will check against the host value. | false | all |
| `PORT` | :white_check_mark: | Default port the application runs on is 4000 | 4000 | all |
| `COIN` | :white_check_mark: | The coin here is checked via the Coinmarketcap API to obtain USD prices on graphs and other areas of the UI | POA | all |
| `METADATA_CONTRACT` | | This environment variable is specifically used by POA Network to obtain Validators information to display in the UI. | (empty) | all |
| `VALIDATORS_CONTRACT` | | This environment variable is specifically used by POA Network to obtain the Emission Fund contract. | (empty) | all |
| `SUPPLY_MODULE` | | This environment variable is used by the xDai Chain in order to tell the application how to calculate the total supply of the chain. | false | all |
| `SOURCE_MODULE` | | This environment variable is used to calculate the exchange rate and is specifically used by the xDai Chain. | false | all |
| `DATABASE_URL` | | Production environment variable to define the Database endpoint. | (empty) | all |
| `POOL_SIZE` | | Production environment variable to define the number of database connections allowed. | 20 | all |
| `ECTO_USE_SSL` | | Production environment variable to use SSL on Ecto queries. | true | all |
| `DATADOG_HOST` | | Host configuration setting for [Datadog integration](https://docs.datadoghq.com/integrations/) | (empty) | all |
| `DATADOG_PORT` | | Port configuration setting for [Datadog integration](https://docs.datadoghq.com/integrations/). | (empty} | all |
| Variable | Required | Description | Default | Version | Need recompile |
| --- | --- | --- | ---| --- | --- |
| `NETWORK`| :white_check_mark: | Environment variable for the main EVM network such as Ethereum Network or POA Network | POA Network | all | |
| `SUBNETWORK` | :white_check_mark: | Environment variable for the subnetwork such as Core or Sokol Network | Sokol Testnet | all | |
| `NETWORK_ICON` | :white_check_mark: | Environment variable for the main network icon or testnet icon. Two options are `_test_network_icon.html` and `_network_icon.html` | `_test_network_icon.html` | all | |
| `LOGO` | :white_check_mark: | Environment variable for the logo image location. The logo files names for different chains can be found [here](https://github.com/poanetwork/blockscout/tree/master/apps/block_scout_web/assets/static/images) | /images/blockscout_logo.svg | all | |
| `ETHEREUM_JSONRPC_VARIANT` | :white_check_mark: | This environment variable is used to tell the application which RPC Client the node is using (i.e. Geth, Parity, or Ganache) | parity | all | |
| `ETHEREUM_JSONRPC_HTTP_URL` | :white_check_mark: | The RPC endpoint used to fetch blocks, transactions, receipts, tokens. | localhost:8545 | all | |
| `ETHEREUM_JSONRPC_TRACE_URL` | | The RPC endpoint specifically for the Geth/Parity client used by trace_block and trace_replayTransaction. This can be used to designate a tracing node. | localhost:8545 | all | |
| `ETHEREUM_JSONRPC_WS_URL` | :white_check_mark: | The WebSockets RPC endpoint used to subscribe to the `newHeads` subscription alerting the indexer to fetch new blocks. | ws://localhost:8546 | all | |
| `NETWORK_PATH` | | Used to set a network path other than what is displayed in the root directory. An example would be to add /eth/mainnet/ to the root directory. | (empty) | all | |
| `SECRET_KEY_BASE` | :white_check_mark: | Use mix phx.gen.secret to generate a new Secret Key Base string to protect production assets. | (empty) | all | |
| `CHECK_ORIGIN` | | Used to check the origin of requests when the origin header is present. It defaults to false. In case of true, it will check against the host value. | false | all | |
| `PORT` | :white_check_mark: | Default port the application runs on is 4000 | 4000 | all | |
| `COIN` | :white_check_mark: | The coin here is checked via the Coinmarketcap API to obtain USD prices on graphs and other areas of the UI | POA | all | |
| `METADATA_CONTRACT` | | This environment variable is specifically used by POA Network to obtain Validators information to display in the UI. | (empty) | all | |
| `VALIDATORS_CONTRACT` | | This environment variable is specifically used by POA Network to obtain the Emission Fund contract. | (empty) | all | |
| `SUPPLY_MODULE` | | This environment variable is used by the xDai Chain in order to tell the application how to calculate the total supply of the chain. | false | all | |
| `SOURCE_MODULE` | | This environment variable is used to calculate the exchange rate and is specifically used by the xDai Chain. | false | all | |
| `DATABASE_URL` | | Production environment variable to define the Database endpoint. | (empty) | all | |
| `POOL_SIZE` | | Production environment variable to define the number of database connections allowed. | 20 | all | |
| `ECTO_USE_SSL` | | Production environment variable to use SSL on Ecto queries. | true | all | |
| `DATADOG_HOST` | | Host configuration setting for [Datadog integration](https://docs.datadoghq.com/integrations/) | (empty) | all | |
| `DATADOG_PORT` | | Port configuration setting for [Datadog integration](https://docs.datadoghq.com/integrations/). | (empty} | all | |
| `SPANDEX_BATCH_SIZE` | | [Spandex](https://github.com/spandex-project/spandex) and Datadog configuration setting. | (empty) | all |
| `SPANDEX_SYNC_THRESHOLD` | | [Spandex](https://github.com/spandex-project/spandex) and Datadog configuration setting. | (empty) | all |
| `HEART_BEAT_TIMEOUT` | | Production environment variable to restart the application in the event of a crash. | 30 | all |
| `HEART_COMMAND` | | Production environment variable to restart the application in the event of a crash. | systemctl restart explorer.service | all |
| `BLOCKSCOUT_VERSION` | | Added to the footer to signify the current BlockScout version. | (empty) | v1.3.4+ |
| `RELEASE_LINK` | | The link to Blockscout release notes in the footer. | <u>https: //github.com/poanetwork/</u> <br /><u>blockscout/releases/</u> <br /> <u>tag/${BLOCKSCOUT_VERSION}</u> | v1.3.5+ |
| `ELIXIR_VERSION` | | Elixir version to install on the node before Blockscout deploy. | (empty) | all |
| `BLOCK_TRANSFORMER` | | Transformer for blocks: base or clique. | base | v1.3.4+ |
| `GRAPHIQL _TRANSACTION` | | Default transaction in query to GraphiQL. | (empty) | v1.3.4+ |
| `FIRST_BLOCK` | | The block number, where indexing begins from. | 0 | v1.3.8+ |
| `LAST_BLOCK` | | The block number, where indexing stops. | (empty) | v2.0.3+ |
| `TXS_COUNT_CACHE_PERIOD` | | Interval in seconds to restart the task, which calculates the total txs count. | 60 * 60 * 2 | v1.3.9+ |
| `ADDRESS_WITH_BALANCES` <br /> `_UPDATE_INTERVAL`| | Interval in seconds to restart the task, which calculates addresses with balances. | 30 * 60 | v1.3.9+ |
| `LINK_TO_OTHER_EXPLORERS` | | true/false. If true, links to other explorers are added in the footer | (empty) | v1.3.0+ |
| `COINMARKETCAP_PAGES` | | the number of pages on coinmarketcap to list in order to find token's price | 10 | v1.3.10+ |
| `CHAIN_SPEC_PATH` | | Chain specification path (absolute file system path or url) to import block emission reward ranges and genesis account balances from | (empty) | master |
| `SUPPORTED_CHAINS` | | Array of supported chains that displays in the footer and in the chains dropdown. This var was introduced in this PR [#1900](https://github.com/poanetwork/blockscout/pull/1900) and looks like an array of JSON objects. | (empty) | v2.0.0+ |
| `BLOCK_COUNT_CACHE_PERIOD ` | | time to live of cache in seconds. This var was introduced in [#1876](https://github.com/poanetwork/blockscout/pull/1876) | 600 | v2.0.0+ |
| `ALLOWED_EVM_VERSIONS ` | | the comma-separated list of allowed EVM versions for contracts verification. This var was introduced in [#1964](https://github.com/poanetwork/blockscout/pull/1964) | "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" | v2.0.0+ |
| `DISABLE_WEBAPP` | | If `true`, endpoints to webapp are hidden (compile-time) | `false` | v2.0.3+ |
| `DISABLE_READ_API` | | If `true`, read-only endpoints to API are hidden (compile-time) | `false` | v2.0.3+ |
| `DISABLE_WRITE_API` | | If `true`, write endpoints to API are hidden (compile-time) | `false` | v2.0.3+ |
| `DISABLE_INDEXER` | | If `true`, indexer application doesn't run | `false` | v2.0.3+ |
| `WEBAPP_URL` | | Link to web application instance, e.g. `http://host/path` | (empty) | v2.0.3+ |
| `API_URL` | | Link to API instance, e.g. `http://host/path` | (empty) | v2.0.3+ |
| `SPANDEX_SYNC_THRESHOLD` | | [Spandex](https://github.com/spandex-project/spandex) and Datadog configuration setting. | (empty) | all | |
| `HEART_BEAT_TIMEOUT` | | Production environment variable to restart the application in the event of a crash. | 30 | all | |
| `HEART_COMMAND` | | Production environment variable to restart the application in the event of a crash. | systemctl restart explorer.service | all | |
| `BLOCKSCOUT_VERSION` | | Added to the footer to signify the current BlockScout version. | (empty) | v1.3.4+ | |
| `RELEASE_LINK` | | The link to Blockscout release notes in the footer. | <u>https: //github.com/poanetwork/</u> <br /><u>blockscout/releases/</u> <br /> <u>tag/${BLOCKSCOUT_VERSION}</u> | v1.3.5+ | |
| `ELIXIR_VERSION` | | Elixir version to install on the node before Blockscout deploy. | (empty) | all | |
| `BLOCK_TRANSFORMER` | | Transformer for blocks: base or clique. | base | v1.3.4+ | |
| `GRAPHIQL_TRANSACTION` | | Default transaction in query to GraphiQL. | (empty) | v1.2.0+ | :white_check_mark: |
| `FIRST_BLOCK` | | The block number, where indexing begins from. | 0 | v1.3.8+ | |
| `LAST_BLOCK` | | The block number, where indexing stops. | (empty) | v2.0.3+ | |
| `TXS_COUNT_CACHE_PERIOD` | | Interval in seconds to restart the task, which calculates the total txs count. | 60 * 60 * 2 | v1.3.9+ | |
| `ADDRESS_WITH_BALANCES` <br /> `_UPDATE_INTERVAL`| | Interval in seconds to restart the task, which calculates addresses with balances. | 30 * 60 | v1.3.9+ | |
| `LINK_TO_OTHER_EXPLORERS` | | true/false. If true, links to other explorers are added in the footer | (empty) | v1.3.0+ | |
| `COINMARKETCAP_PAGES` | | the number of pages on coinmarketcap to list in order to find token's price | 10 | v1.3.10+ | |
| `SUPPORTED_CHAINS` | | Array of supported chains that displays in the footer and in the chains dropdown. This var was introduced in this PR [#1900](https://github.com/poanetwork/blockscout/pull/1900) and looks like an array of JSON objects. | (empty) | v2.0.0+ | |
| `BLOCK_COUNT_CACHE_PERIOD ` | | time to live of cache in seconds. This var was introduced in [#1876](https://github.com/poanetwork/blockscout/pull/1876) | 600 | v2.0.0+ | |
| `ALLOWED_EVM_VERSIONS ` | | the comma-separated list of allowed EVM versions for contracts verification. This var was introduced in [#1964](https://github.com/poanetwork/blockscout/pull/1964) | "homestead, tangerineWhistle, spuriousDragon, byzantium, constantinople, petersburg" | v2.0.0+ | |
| `AVERAGE_BLOCK_CACHE_PERIOD` | | Update of average block cache, in seconds | 30 minutes | v2.0.2+ |
| `MARKET_HISTORY_CACHE_PERIOD` | | Update of market history cache, in seconds | 6 hours | v2.0.2+ |
| `DISABLE_WEBAPP` | | If `true`, endpoints to webapp are hidden (compile-time) | `false` | v2.0.3+ | :white_check_mark: |
| `DISABLE_READ_API` | | If `true`, read-only endpoints to API are hidden (compile-time) | `false` | v2.0.3+ | :white_check_mark: |
| `DISABLE_WRITE_API` | | If `true`, write endpoints to API are hidden (compile-time) | `false` | v2.0.3+ | :white_check_mark: |
| `DISABLE_INDEXER` | | If `true`, indexer application doesn't run | `false` | v2.0.3+ | :white_check_mark: |
| `WEBAPP_URL` | | Link to web application instance, e.g. `http://host/path` | (empty) | v2.0.3+ | |
| `API_URL` | | Link to API instance, e.g. `http://host/path` | (empty) | v2.0.3+ | |
| `CHAIN_SPEC_PATH` | | Chain specification path (absolute file system path or url) to import block emission reward ranges and genesis account balances from | (empty) | master | |

Loading…
Cancel
Save