Refactor and optimize Staking DApp

pull/3745/head
POA 4 years ago
parent 7212895ddb
commit 5d0a55854c
  1. 2
      .dialyzer-ignore
  2. 204
      apps/explorer/lib/explorer/staking/contract_state.ex
  3. 190
      apps/explorer/lib/explorer/staking/stake_snapshotting.ex
  4. 286
      apps/explorer/test/explorer/staking/contract_state_test.exs

@ -25,4 +25,4 @@ lib/explorer/exchange_rates/source.ex:113
lib/explorer/smart_contract/verifier.ex:89
lib/block_scout_web/templates/address_contract/index.html.eex:123
lib/explorer/staking/stake_snapshotting.ex:15: Function do_snapshotting/7 has no local return
lib/explorer/staking/stake_snapshotting.ex:207
lib/explorer/staking/stake_snapshotting.ex:147

@ -443,14 +443,14 @@ defmodule Explorer.Staking.ContractState do
global_responses.inactive_pools
)
%{
pool_staking_responses: pool_staking_responses,
pool_mining_responses: pool_mining_responses,
staker_responses: staker_responses
} = get_responses(pools, block_number, contracts, abi)
# read pool info from the contracts by its staking address
pool_staking_responses = get_pool_staking_responses(pools, block_number, contracts, abi)
# to keep sort order when using `perform_grouped_requests` (see below)
pool_ids = Enum.map(pool_staking_responses, fn {pool_id, _} -> pool_id end)
# read pool info from the contracts by its mining address
pool_mining_responses = get_pool_mining_responses(pools, pool_staking_responses, block_number, contracts, abi)
# read info of each staker from the contracts
staker_responses = get_staker_responses(pool_staking_responses, block_number, contracts, abi)
# call `BlockReward.validatorShare` function for each pool
# to get validator's reward share of the pool (needed for the `Delegators` list in UI)
@ -458,7 +458,6 @@ defmodule Explorer.Staking.ContractState do
get_candidate_reward_responses(
pool_staking_responses,
global_responses,
pool_ids,
contracts,
abi,
block_number
@ -466,11 +465,10 @@ defmodule Explorer.Staking.ContractState do
# call `BlockReward.delegatorShare` function for each delegator
# to get their reward share of the pool (needed for the `Delegators` list in UI)
delegator_responses = get_delegator_responses(staker_responses)
delegator_reward_responses =
get_delegator_reward_responses(
delegator_responses,
staker_responses
|> get_delegator_responses()
|> get_delegator_reward_responses(
pool_staking_responses,
global_responses,
contracts,
@ -609,63 +607,43 @@ defmodule Explorer.Staking.ContractState do
|> Map.new(fn {mining_address, resp} -> {mining_address, address_string_to_bytes(resp.staking_address).bytes} end)
end
defp get_responses(pools, block_number, contracts, abi) do
# read pool info from the contracts by its staking address
pool_staking_responses =
pools
|> Enum.map(&ContractReader.pool_staking_requests(&1, block_number))
|> ContractReader.perform_grouped_requests(pools, contracts, abi)
# read pool info from the contracts by its mining address
pool_mining_responses =
pools
|> Enum.map(&ContractReader.pool_mining_requests(pool_staking_responses[&1].mining_address_hash, block_number))
|> ContractReader.perform_grouped_requests(pools, contracts, abi)
# get a flat list of all stakers in the form of {pool_id, pool_staking_address, staker_address, is_active}
stakers =
Enum.flat_map(pool_staking_responses, fn {pool_id, resp} ->
[{pool_id, resp.staking_address_hash, resp.staking_address_hash, true}] ++
Enum.map(resp.active_delegators, &{pool_id, resp.staking_address_hash, &1, true}) ++
Enum.map(resp.inactive_delegators, &{pool_id, resp.staking_address_hash, &1, false})
end)
# read info of each staker from the contracts
staker_responses =
stakers
|> Enum.map(fn {pool_id, pool_staking_address, staker_address, _is_active} ->
ContractReader.staker_requests(pool_id, pool_staking_address, staker_address, block_number)
end)
|> ContractReader.perform_grouped_requests(stakers, contracts, abi)
%{
pool_staking_responses: pool_staking_responses,
pool_mining_responses: pool_mining_responses,
staker_responses: staker_responses
}
end
defp get_candidate_reward_responses(
pool_staking_responses,
global_responses,
pool_ids,
contracts,
abi,
block_number
) do
pool_staking_responses
|> Enum.map(fn {_pool_id, resp} ->
ContractReader.validator_reward_request(
[
global_responses.epoch_number,
resp.self_staked_amount,
resp.total_staked_amount,
1000_000
],
block_number
)
# to keep sort order when using `perform_grouped_requests` (see below)
pool_ids = Enum.map(pool_staking_responses, fn {pool_id, _} -> pool_id end)
requests =
pool_staking_responses
|> Enum.map(fn {_pool_id, resp} ->
ContractReader.validator_reward_request(
[
global_responses.epoch_number,
resp.self_staked_amount,
resp.total_staked_amount,
1000_000
],
block_number
)
end)
chunk_size = 100
chunks = 0..trunc(ceil(Enum.count(pool_ids) / chunk_size) - 1)
Enum.reduce(chunks, %{}, fn i, acc ->
pool_ids_slice = Enum.slice(pool_ids, i * chunk_size, chunk_size)
responses =
requests
|> Enum.slice(i * chunk_size, chunk_size)
|> ContractReader.perform_grouped_requests(pool_ids_slice, contracts, abi)
Map.merge(acc, responses)
end)
|> ContractReader.perform_grouped_requests(pool_ids, contracts, abi)
end
defp get_delegator_responses(staker_responses) do
@ -690,22 +668,36 @@ defmodule Explorer.Staking.ContractState do
# to keep sort order when using `perform_grouped_requests` (see below)
delegator_keys = Enum.map(delegator_responses, fn {key, _} -> key end)
delegator_responses
|> Enum.map(fn {{pool_id, _pool_staking_address, _staker_address, _is_active}, resp} ->
staking_resp = pool_staking_responses[pool_id]
requests =
delegator_responses
|> Enum.map(fn {{pool_id, _pool_staking_address, _staker_address, _is_active}, resp} ->
staking_resp = pool_staking_responses[pool_id]
ContractReader.delegator_reward_request(
[
global_responses.epoch_number,
resp.stake_amount,
staking_resp.self_staked_amount,
staking_resp.total_staked_amount,
1000_000
],
block_number
)
end)
ContractReader.delegator_reward_request(
[
global_responses.epoch_number,
resp.stake_amount,
staking_resp.self_staked_amount,
staking_resp.total_staked_amount,
1000_000
],
block_number
)
chunk_size = 100
chunks = 0..trunc(ceil(Enum.count(delegator_keys) / chunk_size) - 1)
Enum.reduce(chunks, %{}, fn i, acc ->
delegator_keys_slice = Enum.slice(delegator_keys, i * chunk_size, chunk_size)
responses =
requests
|> Enum.slice(i * chunk_size, chunk_size)
|> ContractReader.perform_grouped_requests(delegator_keys_slice, contracts, abi)
Map.merge(acc, responses)
end)
|> ContractReader.perform_grouped_requests(delegator_keys, contracts, abi)
end
defp get_delegator_entries(staker_responses, delegator_reward_responses) do
@ -726,6 +718,68 @@ defmodule Explorer.Staking.ContractState do
end)
end
defp get_pool_mining_responses(pools, pool_staking_responses, block_number, contracts, abi) do
# we split batch requests by chunks
chunk_size = 80
chunks = 0..trunc(ceil(Enum.count(pools) / chunk_size) - 1)
Enum.reduce(chunks, %{}, fn i, acc ->
pools_slice = Enum.slice(pools, i * chunk_size, chunk_size)
responses =
pools_slice
|> Enum.map(&ContractReader.pool_mining_requests(pool_staking_responses[&1].mining_address_hash, block_number))
|> ContractReader.perform_grouped_requests(pools_slice, contracts, abi)
Map.merge(acc, responses)
end)
end
defp get_pool_staking_responses(pools, block_number, contracts, abi) do
# we split batch requests by chunks
chunk_size = 20
chunks = 0..trunc(ceil(Enum.count(pools) / chunk_size) - 1)
Enum.reduce(chunks, %{}, fn i, acc ->
pools_slice = Enum.slice(pools, i * chunk_size, chunk_size)
responses =
pools_slice
|> Enum.map(&ContractReader.pool_staking_requests(&1, block_number))
|> ContractReader.perform_grouped_requests(pools_slice, contracts, abi)
Map.merge(acc, responses)
end)
end
defp get_staker_responses(pool_staking_responses, block_number, contracts, abi) do
# get a flat list of all stakers in the form of {pool_id, pool_staking_address, staker_address, is_active}
stakers =
pool_staking_responses
|> Enum.flat_map(fn {pool_id, resp} ->
[{pool_id, resp.staking_address_hash, resp.staking_address_hash, true}] ++
Enum.map(resp.active_delegators, &{pool_id, resp.staking_address_hash, &1, true}) ++
Enum.map(resp.inactive_delegators, &{pool_id, resp.staking_address_hash, &1, false})
end)
# we split batch requests by chunks
chunk_size = 100
chunks = 0..trunc(ceil(Enum.count(stakers) / chunk_size) - 1)
Enum.reduce(chunks, %{}, fn i, acc ->
stakers_slice = Enum.slice(stakers, i * chunk_size, chunk_size)
responses =
stakers_slice
|> Enum.map(fn {pool_id, pool_staking_address, staker_address, _is_active} ->
ContractReader.staker_requests(pool_id, pool_staking_address, staker_address, block_number)
end)
|> ContractReader.perform_grouped_requests(stakers_slice, contracts, abi)
Map.merge(acc, responses)
end)
end
defp get_validator_min_reward_percent(epoch_number, block_number, contracts, abi) do
ContractReader.perform_requests(
ContractReader.validator_min_reward_percent_request(epoch_number, block_number),

@ -48,33 +48,27 @@ defmodule Explorer.Staking.StakeSnapshotting do
|> Enum.map(fn pool_id ->
case Map.fetch(cached_pool_staking_responses, pool_id) do
{:ok, resp} ->
Map.merge(
resp,
ContractReader.perform_requests(
snapshotted_pool_amounts_requests(pool_id, resp.staking_address_hash, block_number),
contracts,
abi
)
)
snapshotted_pool_amounts_requests(pool_id, resp.staking_address_hash, block_number)
:error ->
pool_staking_address = id_to_staking_address[pool_id]
Map.merge(
%{
staking_address_hash: pool_staking_address
},
ContractReader.perform_requests(
ContractReader.active_delegators_request(pool_id, block_number) ++
snapshotted_pool_amounts_requests(pool_id, pool_staking_address, block_number),
contracts,
abi
)
)
ContractReader.active_delegators_request(pool_id, block_number) ++
snapshotted_pool_amounts_requests(pool_id, pool_staking_address, block_number)
end
end)
|> Enum.zip(pool_ids)
|> Map.new(fn {key, val} -> {val, key} end)
|> ContractReader.perform_grouped_requests(pool_ids, contracts, abi)
|> Map.new(fn {pool_id, resp} ->
{pool_id,
case Map.fetch(cached_pool_staking_responses, pool_id) do
{:ok, cached_resp} ->
Map.merge(cached_resp, resp)
:error ->
pool_staking_address = id_to_staking_address[pool_id]
Map.merge(%{staking_address_hash: pool_staking_address}, resp)
end}
end)
# get a flat list of all stakers of each validator
# in the form of {pool_id, pool_staking_address, staker_address}
@ -85,73 +79,19 @@ defmodule Explorer.Staking.StakeSnapshotting do
end)
# read info about each staker from the contracts
staker_responses =
stakers
|> Enum.map(fn {pool_id, pool_staking_address, staker_address} ->
ContractReader.perform_requests(
snapshotted_staker_amount_request(
pool_id,
pool_staking_address,
staker_address,
block_number
),
contracts,
abi
)
end)
|> Enum.zip(stakers)
|> Map.new(fn {key, val} -> {val, key} end)
# to keep sort order when using `perform_grouped_requests` (see below)
pool_staking_keys = Enum.map(pool_staking_responses, fn {key, _} -> key end)
staker_responses = get_staker_responses(stakers, block_number, contracts, abi)
# call `BlockReward.validatorShare` function for each pool
# to get validator's reward share of the pool (needed for the `Delegators` list in UI)
validator_reward_responses =
pool_staking_responses
|> Enum.map(fn {_pool_id, resp} ->
ContractReader.validator_reward_request(
[
epoch_number,
resp.snapshotted_self_staked_amount,
resp.snapshotted_total_staked_amount,
1000_000
],
block_number
)
end)
|> ContractReader.perform_grouped_requests(pool_staking_keys, contracts, abi)
get_validator_reward_responses(pool_staking_responses, epoch_number, block_number, contracts, abi)
# call `BlockReward.delegatorShare` function for each delegator
# to get their reward share of the pool (needed for the `Delegators` list in UI)
delegator_responses =
Enum.reduce(staker_responses, %{}, fn {{_pool_id, pool_staking_address, staker_address} = key, value}, acc ->
if pool_staking_address != staker_address do
Map.put(acc, key, value)
else
acc
end
end)
delegator_keys = Enum.map(delegator_responses, fn {key, _} -> key end)
delegator_reward_responses =
delegator_responses
|> Enum.map(fn {{pool_id, _pool_staking_address, _staker_address}, resp} ->
staking_resp = pool_staking_responses[pool_id]
ContractReader.delegator_reward_request(
[
epoch_number,
resp.snapshotted_stake_amount,
staking_resp.snapshotted_self_staked_amount,
staking_resp.snapshotted_total_staked_amount,
1000_000
],
block_number
)
end)
|> ContractReader.perform_grouped_requests(delegator_keys, contracts, abi)
staker_responses
|> get_delegator_responses()
|> get_delegator_reward_responses(pool_staking_responses, epoch_number, block_number, contracts, abi)
# form entries for updating the `staking_pools` table in DB
pool_entries =
@ -224,6 +164,96 @@ defmodule Explorer.Staking.StakeSnapshotting do
defp address_bytes_to_string(hash), do: "0x" <> Base.encode16(hash, case: :lower)
defp get_delegator_responses(staker_responses) do
Enum.reduce(staker_responses, %{}, fn {{_pool_id, pool_staking_address, staker_address} = key, value}, acc ->
if pool_staking_address != staker_address do
Map.put(acc, key, value)
else
acc
end
end)
end
defp get_delegator_reward_responses(
delegator_responses,
pool_staking_responses,
epoch_number,
block_number,
contracts,
abi
) do
delegator_keys = Enum.map(delegator_responses, fn {key, _} -> key end)
delegator_requests =
delegator_responses
|> Enum.map(fn {{pool_id, _pool_staking_address, _staker_address}, resp} ->
staking_resp = pool_staking_responses[pool_id]
ContractReader.delegator_reward_request(
[
epoch_number,
resp.snapshotted_stake_amount,
staking_resp.snapshotted_self_staked_amount,
staking_resp.snapshotted_total_staked_amount,
1000_000
],
block_number
)
end)
chunk_size = 100
chunks = 0..trunc(ceil(Enum.count(delegator_keys) / chunk_size) - 1)
Enum.reduce(chunks, %{}, fn i, acc ->
delegator_keys_slice = Enum.slice(delegator_keys, i * chunk_size, chunk_size)
responses =
delegator_requests
|> Enum.slice(i * chunk_size, chunk_size)
|> ContractReader.perform_grouped_requests(delegator_keys_slice, contracts, abi)
Map.merge(acc, responses)
end)
end
defp get_staker_responses(stakers, block_number, contracts, abi) do
# we split batch requests by chunks
chunk_size = 100
chunks = 0..trunc(ceil(Enum.count(stakers) / chunk_size) - 1)
Enum.reduce(chunks, %{}, fn i, acc ->
stakers_slice = Enum.slice(stakers, i * chunk_size, chunk_size)
responses =
stakers_slice
|> Enum.map(fn {pool_id, pool_staking_address, staker_address} ->
snapshotted_staker_amount_request(pool_id, pool_staking_address, staker_address, block_number)
end)
|> ContractReader.perform_grouped_requests(stakers_slice, contracts, abi)
Map.merge(acc, responses)
end)
end
defp get_validator_reward_responses(pool_staking_responses, epoch_number, block_number, contracts, abi) do
# to keep sort order when using `perform_grouped_requests` (see below)
pool_ids = Enum.map(pool_staking_responses, fn {pool_id, _} -> pool_id end)
pool_staking_responses
|> Enum.map(fn {_pool_id, resp} ->
ContractReader.validator_reward_request(
[
epoch_number,
resp.snapshotted_self_staked_amount,
resp.snapshotted_total_staked_amount,
1000_000
],
block_number
)
end)
|> ContractReader.perform_grouped_requests(pool_ids, contracts, abi)
end
defp snapshotted_pool_amounts_requests(pool_id, pool_staking_address, block_number) do
[
# 2a8f6ecd = keccak256(stakeAmountTotal(uint256))

@ -260,7 +260,7 @@ defmodule Explorer.Staking.ContractStateTest do
end
)
# get_responses, ContractReader.pool_staking_requests
# get_pool_staking_responses
expect(
EthereumJSONRPC.Mox,
:json_rpc,
@ -374,7 +374,7 @@ defmodule Explorer.Staking.ContractStateTest do
end
)
# get_responses, ContractReader.pool_mining_requests
# get_pool_mining_responses
expect(
EthereumJSONRPC.Mox,
:json_rpc,
@ -476,7 +476,7 @@ defmodule Explorer.Staking.ContractStateTest do
end
)
# get_responses, ContractReader.staker_requests
# get_staker_responses
expect(
EthereumJSONRPC.Mox,
:json_rpc,
@ -722,7 +722,7 @@ defmodule Explorer.Staking.ContractStateTest do
end
)
# invoke do_start_snapshotting()
# start_snapshotting
## get_mining_to_staking_address
expect(
@ -745,285 +745,67 @@ defmodule Explorer.Staking.ContractStateTest do
end
)
## 1 snapshotted_pool_amounts_requests
## snapshotted_pool_amounts_requests
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 2
assert length(requests) == 4 * 2
{:ok,
format_responses([
# StakingAuRa.stakeAmountTotal
# 1.1 StakingAuRa.stakeAmountTotal
"0x0000000000000000000000000000000000000000000000000000000000000000",
# 1.2 StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000000000000000000",
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000000000000000000"
])}
end
)
## 2 snapshotted_pool_amounts_requests
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 2
{:ok,
format_responses([
# StakingAuRa.stakeAmountTotal
# 2.1 StakingAuRa.stakeAmountTotal
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000",
# 2.2 StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000",
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000"
])}
end
)
## 3 snapshotted_pool_amounts_requests
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 2
{:ok,
format_responses([
# StakingAuRa.stakeAmountTotal
# 3.1 StakingAuRa.stakeAmountTotal
"0x00000000000000000000000000000000000000000000000098a7d9b8314c0000",
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000"
])}
end
)
## 4 snapshotted_pool_amounts_requests
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 2
# 3.2 StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000",
{:ok,
format_responses([
# StakingAuRa.stakeAmountTotal
# 4.1 StakingAuRa.stakeAmountTotal
"0x00000000000000000000000000000000000000000000000029a2241af62c0000",
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000"
])}
end
)
## 1 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000000000000000000"
])}
end
)
## 2 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000"
])}
end
)
## 3 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## 4 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000"
])}
end
)
## 5 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
# 4.2 StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000"
])}
end
)
## 6 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## 7 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## 8 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## 9 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## 10 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## 11 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## 12 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## 13 snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## 14 snapshotted_staker_amount_request
## get_staker_responses, snapshotted_staker_amount_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
fn requests, _opts ->
assert length(requests) == 1
assert length(requests) == 14
{:ok,
format_responses([
# StakingAuRa.stakeAmount
"0x0000000000000000000000000000000000000000000000000000000000000000",
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000",
"0x0000000000000000000000000000000000000000000000001bc16d674ec80000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000",
"0x0000000000000000000000000000000000000000000000000de0b6b3a7640000"
])}
end
)
## ContractReader.validator_reward_request
## get_validator_reward_responses, validator_reward_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,
@ -1044,7 +826,7 @@ defmodule Explorer.Staking.ContractStateTest do
end
)
## ContractReader.delegator_reward_request
## get_delegator_reward_responses, delegator_reward_request
expect(
EthereumJSONRPC.Mox,
:json_rpc,

Loading…
Cancel
Save