From 156bd82649f6c64b6063fa21fc07ed48f30ebb25 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 25 Jun 2019 12:53:51 +0300 Subject: [PATCH 01/11] fix rsk total_supply --- apps/explorer/lib/explorer/chain/supply/rsk.ex | 11 ++++------- .../test/explorer/chain/supply/rsk_test.exs | 13 +++++++++++++ 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/supply/rsk.ex b/apps/explorer/lib/explorer/chain/supply/rsk.ex index 09a02252a2..ec55c94e95 100644 --- a/apps/explorer/lib/explorer/chain/supply/rsk.ex +++ b/apps/explorer/lib/explorer/chain/supply/rsk.ex @@ -9,11 +9,12 @@ defmodule Explorer.Chain.Supply.RSK do alias Explorer.Chain.Address.CoinBalance alias Explorer.Chain.{Block, Wei} - alias Explorer.ExchangeRates.Token - alias Explorer.{Market, Repo} + alias Explorer.Repo def market_cap(exchange_rate) do - circulating() * exchange_rate.usd_value + ether = Wei.to(circulating(), :ether) + + Decimal.mult(ether, exchange_rate.usd_value) end @doc "Equivalent to getting the circulating value " @@ -96,8 +97,4 @@ defmodule Explorer.Chain.Supply.RSK do def total do 21_000_000 end - - def exchange_rate do - Market.get_exchange_rate(Explorer.coin()) || Token.null() - end end diff --git a/apps/explorer/test/explorer/chain/supply/rsk_test.exs b/apps/explorer/test/explorer/chain/supply/rsk_test.exs index 40aa0a831b..db87fd3e2b 100644 --- a/apps/explorer/test/explorer/chain/supply/rsk_test.exs +++ b/apps/explorer/test/explorer/chain/supply/rsk_test.exs @@ -3,6 +3,7 @@ defmodule Explorer.Chain.Supply.RSKTest do alias Explorer.Chain.Supply.RSK alias Explorer.Chain.Wei + alias Explorer.ExchangeRates.Token @coin_address "0x0000000000000000000000000000000001000006" @@ -15,6 +16,18 @@ defmodule Explorer.Chain.Supply.RSKTest do assert RSK.total() == 21_000_000 end + describe "market_cap/1" do + test "calculates market_cap" do + address = insert(:address, hash: @coin_address) + insert(:block, number: 0) + insert(:fetched_balance, value: 10_000_000_000_000_000_000, address_hash: address.hash, block_number: 0) + + exchange_rate = %{Token.null() | usd_value: Decimal.new(10)} + + assert RSK.market_cap(exchange_rate) == Decimal.new(100) + end + end + describe "circulating/0" do test "with no balance" do assert RSK.circulating() == wei!(0) From 651ce9790eab181ee6751fa4d077aad5a9c01b37 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 25 Jun 2019 12:55:40 +0300 Subject: [PATCH 02/11] add CHANGELOG entry --- CHANGELOG.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b671d7539..aa181456a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,7 +44,8 @@ - [#2173](https://github.com/poanetwork/blockscout/pull/2173) - handle correctly empty transactions - [#2174](https://github.com/poanetwork/blockscout/pull/2174) - fix reward channel joining - [#2186](https://github.com/poanetwork/blockscout/pull/2186) - fix net version test -- [#2167](https://github.com/poanetwork/blockscout/pull/2168) - feat: document eth rpc api mimicking endpoints +- [#2167](https://github.com/poanetwork/blockscout/pull/2168) - feat: document eth rpc api mimicking endpoints +- [#2237](https://github.com/poanetwork/blockscout/pull/2237) - fix rsk total_supply ### Chore - [#2127](https://github.com/poanetwork/blockscout/pull/2127) - use previouse chromedriver version From 9f3e8eec89197404100516722dcff60501caddfc Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 27 Jun 2019 12:12:18 +0300 Subject: [PATCH 03/11] fix rsk marketcap --- apps/explorer/lib/explorer/chain/supply/rsk.ex | 5 ++++- apps/explorer/test/explorer/chain/supply/rsk_test.exs | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/supply/rsk.ex b/apps/explorer/lib/explorer/chain/supply/rsk.ex index ec55c94e95..365eaf3685 100644 --- a/apps/explorer/lib/explorer/chain/supply/rsk.ex +++ b/apps/explorer/lib/explorer/chain/supply/rsk.ex @@ -12,7 +12,10 @@ defmodule Explorer.Chain.Supply.RSK do alias Explorer.Repo def market_cap(exchange_rate) do - ether = Wei.to(circulating(), :ether) + ether = + circulating() + |> Wei.to(:ether) + |> Decimal.div(Decimal.new(1_000)) Decimal.mult(ether, exchange_rate.usd_value) end diff --git a/apps/explorer/test/explorer/chain/supply/rsk_test.exs b/apps/explorer/test/explorer/chain/supply/rsk_test.exs index db87fd3e2b..b8a1e7f705 100644 --- a/apps/explorer/test/explorer/chain/supply/rsk_test.exs +++ b/apps/explorer/test/explorer/chain/supply/rsk_test.exs @@ -20,7 +20,7 @@ defmodule Explorer.Chain.Supply.RSKTest do test "calculates market_cap" do address = insert(:address, hash: @coin_address) insert(:block, number: 0) - insert(:fetched_balance, value: 10_000_000_000_000_000_000, address_hash: address.hash, block_number: 0) + insert(:fetched_balance, value: 10_000_000_000_000_000_000_000, address_hash: address.hash, block_number: 0) exchange_rate = %{Token.null() | usd_value: Decimal.new(10)} From eaed589d5d5971dca21a871dde37c68b46da3930 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Thu, 27 Jun 2019 12:36:06 +0300 Subject: [PATCH 04/11] increase by 2 decimals --- apps/explorer/lib/explorer/chain/supply/rsk.ex | 2 +- apps/explorer/test/explorer/chain/supply/rsk_test.exs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/supply/rsk.ex b/apps/explorer/lib/explorer/chain/supply/rsk.ex index 365eaf3685..6cefb9814f 100644 --- a/apps/explorer/lib/explorer/chain/supply/rsk.ex +++ b/apps/explorer/lib/explorer/chain/supply/rsk.ex @@ -15,7 +15,7 @@ defmodule Explorer.Chain.Supply.RSK do ether = circulating() |> Wei.to(:ether) - |> Decimal.div(Decimal.new(1_000)) + |> Decimal.div(Decimal.new(100_000)) Decimal.mult(ether, exchange_rate.usd_value) end diff --git a/apps/explorer/test/explorer/chain/supply/rsk_test.exs b/apps/explorer/test/explorer/chain/supply/rsk_test.exs index b8a1e7f705..b3b87b7d49 100644 --- a/apps/explorer/test/explorer/chain/supply/rsk_test.exs +++ b/apps/explorer/test/explorer/chain/supply/rsk_test.exs @@ -20,7 +20,7 @@ defmodule Explorer.Chain.Supply.RSKTest do test "calculates market_cap" do address = insert(:address, hash: @coin_address) insert(:block, number: 0) - insert(:fetched_balance, value: 10_000_000_000_000_000_000_000, address_hash: address.hash, block_number: 0) + insert(:fetched_balance, value: 1_000_000_000_000_000_000_000_000, address_hash: address.hash, block_number: 0) exchange_rate = %{Token.null() | usd_value: Decimal.new(10)} From cd7227e8df9c9e079e0e6629c1ef26b4978defc9 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 12:38:42 +0300 Subject: [PATCH 05/11] fix circulating value --- apps/explorer/lib/explorer/application.ex | 13 ++-- .../explorer/lib/explorer/chain/supply/rsk.ex | 71 ++++++++++++++----- .../test/explorer/chain/supply/rsk_test.exs | 37 +++------- 3 files changed, 71 insertions(+), 50 deletions(-) diff --git a/apps/explorer/lib/explorer/application.ex b/apps/explorer/lib/explorer/application.ex index 724e4f41a1..4c2e9f79ba 100644 --- a/apps/explorer/lib/explorer/application.ex +++ b/apps/explorer/lib/explorer/application.ex @@ -7,6 +7,7 @@ defmodule Explorer.Application do alias Explorer.Admin alias Explorer.Chain.{BlockCountCache, BlockNumberCache, BlocksCache, NetVersionCache, TransactionCountCache} + alias Explorer.Chain.Supply.RSK alias Explorer.Market.MarketHistoryCache alias Explorer.Repo.PrometheusLogger @@ -34,7 +35,8 @@ defmodule Explorer.Application do {BlockCountCache, []}, con_cache_child_spec(BlocksCache.cache_name()), con_cache_child_spec(NetVersionCache.cache_name()), - con_cache_child_spec(MarketHistoryCache.cache_name()) + con_cache_child_spec(MarketHistoryCache.cache_name()), + con_cache_child_spec(RSK.cache_name(), ttl_check_interval: :timer.minutes(1), global_ttl: :timer.minutes(30)) ] children = base_children ++ configurable_children() @@ -83,14 +85,13 @@ defmodule Explorer.Application do ] end - defp con_cache_child_spec(name) do + defp con_cache_child_spec(name, params \\ [ttl_check_interval: false]) do + params = Keyword.put(params, :name, name) + Supervisor.child_spec( { ConCache, - [ - name: name, - ttl_check_interval: false - ] + params }, id: {ConCache, name} ) diff --git a/apps/explorer/lib/explorer/chain/supply/rsk.ex b/apps/explorer/lib/explorer/chain/supply/rsk.ex index 6cefb9814f..7d6fa87312 100644 --- a/apps/explorer/lib/explorer/chain/supply/rsk.ex +++ b/apps/explorer/lib/explorer/chain/supply/rsk.ex @@ -6,18 +6,20 @@ defmodule Explorer.Chain.Supply.RSK do use Explorer.Chain.Supply import Ecto.Query, only: [from: 2] + import EthereumJSONRPC, only: [integer_to_quantity: 1] + alias EthereumJSONRPC.FetchedBalances alias Explorer.Chain.Address.CoinBalance - alias Explorer.Chain.{Block, Wei} + alias Explorer.Chain.{Block, BlockNumberCache, Wei} alias Explorer.Repo + @cache_name :rsk_balance + @balance_key :balance + def market_cap(exchange_rate) do - ether = - circulating() - |> Wei.to(:ether) - |> Decimal.div(Decimal.new(100_000)) + btc = circulating() - Decimal.mult(ether, exchange_rate.usd_value) + Decimal.mult(btc, exchange_rate.usd_value) end @doc "Equivalent to getting the circulating value " @@ -78,18 +80,51 @@ defmodule Explorer.Chain.Supply.RSK do end def circulating do - query = - from(balance in CoinBalance, - join: block in Block, - on: block.number == balance.block_number, - where: block.consensus == true, - where: balance.address_hash == ^"0x0000000000000000000000000000000001000006", - order_by: [desc: block.timestamp], - limit: 1, - select: balance.value - ) + value = ConCache.get(@cache_name, @balance_key) + + if is_nil(value) do + updated_value = fetch_circulating_value() + + ConCache.put(@cache_name, @balance_key, updated_value) + + updated_value + else + value + end + end - Repo.one(query) || wei!(0) + def cache_name, do: @cache_name + + defp fetch_circulating_value do + max_number = BlockNumberCache.max_number() + + params = [ + %{block_quantity: integer_to_quantity(max_number), hash_data: "0x0000000000000000000000000000000001000006"} + ] + + json_rpc_named_argumens = Application.get_env(:explorer, :json_rpc_named_arguments) + + case EthereumJSONRPC.fetch_balances(params, json_rpc_named_argumens) do + {:ok, + %FetchedBalances{ + errors: [], + params_list: [ + %{ + address_hash: "0x0000000000000000000000000000000001000006", + value: value + } + ] + }} -> + sub = + value + |> Decimal.new() + |> Decimal.div(Decimal.new(1_000_000_000_000_000_000)) + + Decimal.sub(total(), sub) + + _ -> + Decimal.new(0) + end end defp wei!(value) do @@ -98,6 +133,6 @@ defmodule Explorer.Chain.Supply.RSK do end def total do - 21_000_000 + Decimal.new(21_000_000) end end diff --git a/apps/explorer/test/explorer/chain/supply/rsk_test.exs b/apps/explorer/test/explorer/chain/supply/rsk_test.exs index b3b87b7d49..d22ed8fc02 100644 --- a/apps/explorer/test/explorer/chain/supply/rsk_test.exs +++ b/apps/explorer/test/explorer/chain/supply/rsk_test.exs @@ -1,45 +1,30 @@ defmodule Explorer.Chain.Supply.RSKTest do use Explorer.DataCase + import Mox + alias Explorer.Chain.Supply.RSK alias Explorer.Chain.Wei alias Explorer.ExchangeRates.Token @coin_address "0x0000000000000000000000000000000001000006" - defp wei!(value) do - {:ok, wei} = Wei.cast(value) - wei - end - test "total is 21_000_000" do - assert RSK.total() == 21_000_000 + assert Decimal.equal?(RSK.total(), Decimal.new(21_000_000)) end describe "market_cap/1" do + @tag :no_parity + @tag :no_geth test "calculates market_cap" do - address = insert(:address, hash: @coin_address) - insert(:block, number: 0) - insert(:fetched_balance, value: 1_000_000_000_000_000_000_000_000, address_hash: address.hash, block_number: 0) + EthereumJSONRPC.Mox + |> expect(:json_rpc, fn [%{id: id, method: "eth_getBalance"}], _options -> + {:ok, [%{id: id, result: "20999999999900000000000000"}]} + end) - exchange_rate = %{Token.null() | usd_value: Decimal.new(10)} - - assert RSK.market_cap(exchange_rate) == Decimal.new(100) - end - end - - describe "circulating/0" do - test "with no balance" do - assert RSK.circulating() == wei!(0) - end - - test "with a balance" do - address = insert(:address, hash: @coin_address) - insert(:block, number: 0) - - insert(:fetched_balance, value: 10, address_hash: address.hash, block_number: 0) + exchange_rate = %{Token.null() | usd_value: Decimal.new(1_000_000)} - assert RSK.circulating() == wei!(10) + assert Decimal.equal?(RSK.market_cap(exchange_rate), Decimal.new(100.0000)) end end From 181d0b6f252ea2938cb2371356a8276e3ace8f9e Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 12:39:38 +0300 Subject: [PATCH 06/11] add rescue clause --- apps/explorer/lib/explorer/chain/supply/rsk.ex | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/explorer/lib/explorer/chain/supply/rsk.ex b/apps/explorer/lib/explorer/chain/supply/rsk.ex index 7d6fa87312..305ff50429 100644 --- a/apps/explorer/lib/explorer/chain/supply/rsk.ex +++ b/apps/explorer/lib/explorer/chain/supply/rsk.ex @@ -125,6 +125,8 @@ defmodule Explorer.Chain.Supply.RSK do _ -> Decimal.new(0) end + rescue + _ -> Decimal.new(0) end defp wei!(value) do From c3997a1d8a9a191decc898ef4a7c8ad5bed18f63 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Mon, 1 Jul 2019 14:24:01 +0300 Subject: [PATCH 07/11] fix supply for days --- .../explorer/lib/explorer/chain/supply/rsk.ex | 4 +-- .../test/explorer/chain/supply/rsk_test.exs | 31 +++++++++---------- 2 files changed, 17 insertions(+), 18 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/supply/rsk.ex b/apps/explorer/lib/explorer/chain/supply/rsk.ex index 305ff50429..37d04598ff 100644 --- a/apps/explorer/lib/explorer/chain/supply/rsk.ex +++ b/apps/explorer/lib/explorer/chain/supply/rsk.ex @@ -68,10 +68,10 @@ defmodule Explorer.Chain.Supply.RSK do case Map.get(by_day, date) do nil -> - {Map.put(days, date, last), last} + {Map.put(days, date, Decimal.sub(total(), last)), last} value -> - {Map.put(days, date, value.value), value.value} + {Map.put(days, date, Decimal.sub(total(), value.value)), value.value} end end) |> elem(0) diff --git a/apps/explorer/test/explorer/chain/supply/rsk_test.exs b/apps/explorer/test/explorer/chain/supply/rsk_test.exs index d22ed8fc02..9504ce5df4 100644 --- a/apps/explorer/test/explorer/chain/supply/rsk_test.exs +++ b/apps/explorer/test/explorer/chain/supply/rsk_test.exs @@ -4,7 +4,6 @@ defmodule Explorer.Chain.Supply.RSKTest do import Mox alias Explorer.Chain.Supply.RSK - alias Explorer.Chain.Wei alias Explorer.ExchangeRates.Token @coin_address "0x0000000000000000000000000000000001000006" @@ -45,9 +44,9 @@ defmodule Explorer.Chain.Supply.RSKTest do assert RSK.supply_for_days(2) == {:ok, %{ - date(now, days: -2) => dec(0), - date(now, days: -1) => dec(0), - date(now) => dec(0) + date(now, days: -2) => dec(21_000_000), + date(now, days: -1) => dec(21_000_000), + date(now) => dec(21_000_000) }} end @@ -62,9 +61,9 @@ defmodule Explorer.Chain.Supply.RSKTest do assert RSK.supply_for_days(2) == {:ok, %{ - date(now, days: -2) => dec(10), - date(now, days: -1) => dec(10), - date(now) => dec(10) + date(now, days: -2) => dec(20_999_990), + date(now, days: -1) => dec(20_999_990), + date(now) => dec(20_999_990) }} end @@ -82,9 +81,9 @@ defmodule Explorer.Chain.Supply.RSKTest do assert RSK.supply_for_days(2) == {:ok, %{ - date(now, days: -2) => dec(10), - date(now, days: -1) => dec(20), - date(now) => dec(20) + date(now, days: -2) => dec(20_999_990), + date(now, days: -1) => dec(20_999_980), + date(now) => dec(20_999_980) }} end @@ -105,9 +104,9 @@ defmodule Explorer.Chain.Supply.RSKTest do assert RSK.supply_for_days(2) == {:ok, %{ - date(now, days: -2) => dec(10), - date(now, days: -1) => dec(20), - date(now) => dec(20) + date(now, days: -2) => dec(20_999_990), + date(now, days: -1) => dec(20_999_980), + date(now) => dec(20_999_980) }} end @@ -128,9 +127,9 @@ defmodule Explorer.Chain.Supply.RSKTest do assert RSK.supply_for_days(2) == {:ok, %{ - date(now, days: -2) => dec(10), - date(now, days: -1) => dec(20), - date(now) => dec(30) + date(now, days: -2) => dec(20_999_990), + date(now, days: -1) => dec(20_999_980), + date(now) => dec(20_999_970) }} end end From dd6c27ff9fd2c3364a8e4eb062f2e914edf4eac5 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Tue, 2 Jul 2019 10:54:44 +0300 Subject: [PATCH 08/11] fix value conversion --- .../explorer/lib/explorer/chain/supply/rsk.ex | 31 ++++++++++++------- .../test/explorer/chain/supply/rsk_test.exs | 21 +++++++------ 2 files changed, 30 insertions(+), 22 deletions(-) diff --git a/apps/explorer/lib/explorer/chain/supply/rsk.ex b/apps/explorer/lib/explorer/chain/supply/rsk.ex index 37d04598ff..bc4171e45f 100644 --- a/apps/explorer/lib/explorer/chain/supply/rsk.ex +++ b/apps/explorer/lib/explorer/chain/supply/rsk.ex @@ -66,13 +66,16 @@ defmodule Explorer.Chain.Supply.RSK do |> Timex.shift(days: i) |> Timex.to_date() - case Map.get(by_day, date) do - nil -> - {Map.put(days, date, Decimal.sub(total(), last)), last} + cur_value = + case Map.get(by_day, date) do + nil -> + last - value -> - {Map.put(days, date, Decimal.sub(total(), value.value)), value.value} - end + value -> + value.value + end + + {Map.put(days, date, calculate_value(cur_value)), cur_value} end) |> elem(0) @@ -115,12 +118,7 @@ defmodule Explorer.Chain.Supply.RSK do } ] }} -> - sub = - value - |> Decimal.new() - |> Decimal.div(Decimal.new(1_000_000_000_000_000_000)) - - Decimal.sub(total(), sub) + calculate_value(value) _ -> Decimal.new(0) @@ -137,4 +135,13 @@ defmodule Explorer.Chain.Supply.RSK do def total do Decimal.new(21_000_000) end + + defp calculate_value(val) do + sub = + val + |> Decimal.new() + |> Decimal.div(Decimal.new(1_000_000_000_000_000_000)) + + Decimal.sub(total(), sub) + end end diff --git a/apps/explorer/test/explorer/chain/supply/rsk_test.exs b/apps/explorer/test/explorer/chain/supply/rsk_test.exs index 9504ce5df4..71d3a530bb 100644 --- a/apps/explorer/test/explorer/chain/supply/rsk_test.exs +++ b/apps/explorer/test/explorer/chain/supply/rsk_test.exs @@ -7,6 +7,7 @@ defmodule Explorer.Chain.Supply.RSKTest do alias Explorer.ExchangeRates.Token @coin_address "0x0000000000000000000000000000000001000006" + @mult 1_000_000_000_000_000_000 test "total is 21_000_000" do assert Decimal.equal?(RSK.total(), Decimal.new(21_000_000)) @@ -56,7 +57,7 @@ defmodule Explorer.Chain.Supply.RSKTest do insert(:block, number: 0, timestamp: Timex.shift(now, days: -10)) - insert(:fetched_balance, value: 10, address_hash: address.hash, block_number: 0) + insert(:fetched_balance, value: 10 * @mult, address_hash: address.hash, block_number: 0) assert RSK.supply_for_days(2) == {:ok, @@ -74,9 +75,9 @@ defmodule Explorer.Chain.Supply.RSKTest do insert(:block, number: 0, timestamp: Timex.shift(now, days: -10)) insert(:block, number: 1, timestamp: Timex.shift(now, days: -1)) - insert(:fetched_balance, value: 10, address_hash: address.hash, block_number: 0) + insert(:fetched_balance, value: 10 * @mult, address_hash: address.hash, block_number: 0) - insert(:fetched_balance, value: 20, address_hash: address.hash, block_number: 1) + insert(:fetched_balance, value: 20 * @mult, address_hash: address.hash, block_number: 1) assert RSK.supply_for_days(2) == {:ok, @@ -95,11 +96,11 @@ defmodule Explorer.Chain.Supply.RSKTest do insert(:block, number: 1, timestamp: Timex.shift(now, days: -2)) insert(:block, number: 2, timestamp: Timex.shift(now, days: -1)) - insert(:fetched_balance, value: 5, address_hash: address.hash, block_number: 0) + insert(:fetched_balance, value: 5 * @mult, address_hash: address.hash, block_number: 0) - insert(:fetched_balance, value: 10, address_hash: address.hash, block_number: 1) + insert(:fetched_balance, value: 10 * @mult, address_hash: address.hash, block_number: 1) - insert(:fetched_balance, value: 20, address_hash: address.hash, block_number: 2) + insert(:fetched_balance, value: 20 * @mult, address_hash: address.hash, block_number: 2) assert RSK.supply_for_days(2) == {:ok, @@ -119,10 +120,10 @@ defmodule Explorer.Chain.Supply.RSKTest do insert(:block, number: 2, timestamp: Timex.shift(now, days: -1)) insert(:block, number: 3, timestamp: now) - insert(:fetched_balance, value: 5, address_hash: address.hash, block_number: 0) - insert(:fetched_balance, value: 10, address_hash: address.hash, block_number: 1) - insert(:fetched_balance, value: 20, address_hash: address.hash, block_number: 2) - insert(:fetched_balance, value: 30, address_hash: address.hash, block_number: 3) + insert(:fetched_balance, value: 5 * @mult, address_hash: address.hash, block_number: 0) + insert(:fetched_balance, value: 10 * @mult, address_hash: address.hash, block_number: 1) + insert(:fetched_balance, value: 20 * @mult, address_hash: address.hash, block_number: 2) + insert(:fetched_balance, value: 30 * @mult, address_hash: address.hash, block_number: 3) assert RSK.supply_for_days(2) == {:ok, From 9e31ab6b13ee5e84c28661d2644e13a655de8e93 Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 3 Jul 2019 11:06:32 +0300 Subject: [PATCH 09/11] handle empty availablesupply in web scokets --- apps/block_scout_web/assets/js/pages/chain.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/block_scout_web/assets/js/pages/chain.js b/apps/block_scout_web/assets/js/pages/chain.js index 00f92523ec..f4cd0e6628 100644 --- a/apps/block_scout_web/assets/js/pages/chain.js +++ b/apps/block_scout_web/assets/js/pages/chain.js @@ -142,7 +142,7 @@ const elements = { chart = createMarketHistoryChart($el[0]) }, render ($el, state, oldState) { - if (!chart || (oldState.availableSupply === state.availableSupply && oldState.marketHistoryData === state.marketHistoryData)) return + if (!chart || (oldState.availableSupply === state.availableSupply && oldState.marketHistoryData === state.marketHistoryData) || !state.availableSupply) return chart.update(state.availableSupply, state.marketHistoryData) } }, From 247a22dbdde207a20b45bdc4794aaef73d4c616c Mon Sep 17 00:00:00 2001 From: Ayrat Badykov Date: Wed, 3 Jul 2019 13:11:53 +0300 Subject: [PATCH 10/11] mix format --- apps/explorer/lib/explorer/application.ex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/explorer/lib/explorer/application.ex b/apps/explorer/lib/explorer/application.ex index d87ce09854..5a6aa1795b 100644 --- a/apps/explorer/lib/explorer/application.ex +++ b/apps/explorer/lib/explorer/application.ex @@ -15,8 +15,8 @@ defmodule Explorer.Application do TransactionCountCache, TransactionsCache } - alias Explorer.Chain.Supply.RSK + alias Explorer.Chain.Supply.RSK alias Explorer.Market.MarketHistoryCache alias Explorer.Repo.PrometheusLogger From 23d6b2aa103780bc1bccf251d71b2c6b1405e566 Mon Sep 17 00:00:00 2001 From: Victor Baranov Date: Wed, 3 Jul 2019 16:06:19 +0300 Subject: [PATCH 11/11] Update CHANGELOG.md Bump version --- CHANGELOG.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e15b08af0c..ede02ddea1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,14 @@ ## Current + +### Features + +### Fixes + +### Chore + + +## 2.0.1-beta + ### Features - [#2283](https://github.com/poanetwork/blockscout/pull/2283) - Add transactions cache - [#2182](https://github.com/poanetwork/blockscout/pull/2182) - add market history cache @@ -81,8 +91,6 @@ - [#2118](https://github.com/poanetwork/blockscout/pull/2118) - show only the last decompiled contract - [#2256](https://github.com/poanetwork/blockscout/pull/2256) - use the latest version of chromedriver -### Chore - ## 2.0.0-beta ### Features