diff --git a/apps/explorer/lib/explorer/staking/contract_reader.ex b/apps/explorer/lib/explorer/staking/contract_reader.ex index d2e70fc2cb..88f241846f 100644 --- a/apps/explorer/lib/explorer/staking/contract_reader.ex +++ b/apps/explorer/lib/explorer/staking/contract_reader.ex @@ -20,8 +20,8 @@ defmodule Explorer.Staking.ContractReader do pools_likelihood: {:staking, "getPoolsLikelihood", []}, validators: {:validator_set, "getValidators", []}, unremovable_validator: {:validator_set, "unremovableValidator", []}, - pending_validators: {:validator_set, "getPendingValidators", []}, - be_finalized_validators: {:validator_set, "validatorsToBeFinalized", []}, + # pending_validators: {:validator_set, "getPendingValidators", []}, + # be_finalized_validators: {:validator_set, "validatorsToBeFinalized", []}, validator_set_apply_block: {:validator_set, "validatorSetApplyBlock", []} ] end diff --git a/apps/explorer/lib/explorer/staking/contract_state.ex b/apps/explorer/lib/explorer/staking/contract_state.ex index 31f1315ced..18a2125d0d 100644 --- a/apps/explorer/lib/explorer/staking/contract_state.ex +++ b/apps/explorer/lib/explorer/staking/contract_state.ex @@ -7,6 +7,8 @@ defmodule Explorer.Staking.ContractState do use GenServer + require Logger + alias Explorer.Chain alias Explorer.Chain.Events.{Publisher, Subscriber} alias Explorer.SmartContract.Reader @@ -118,8 +120,6 @@ defmodule Explorer.Staking.ContractState do end defp fetch_state(contracts, abi, block_number) do - previous_epoch = get(:epoch_number, 0) - global_responses = ContractReader.perform_requests(ContractReader.global_requests(), contracts, abi) token = get_token(global_responses.token_contract_address) @@ -268,11 +268,11 @@ defmodule Explorer.Staking.ContractState do timeout: :infinity }) - if previous_epoch && previous_epoch != 0 && previous_epoch != global_responses.epoch_number do + if global_responses.epoch_start_block == block_number + 1 do with( true <- :ets.insert(@table_name, is_snapshotted: false), {:ok, _} <- - StakeSnapshotting.start_snapshoting( + StakeSnapshotting.start_snapshotting( %{contracts: contracts, abi: abi, global_responses: global_responses}, block_number ) diff --git a/apps/explorer/lib/explorer/staking/stake_snapshotting.ex b/apps/explorer/lib/explorer/staking/stake_snapshotting.ex index 63557c5363..e75b27a4da 100644 --- a/apps/explorer/lib/explorer/staking/stake_snapshotting.ex +++ b/apps/explorer/lib/explorer/staking/stake_snapshotting.ex @@ -7,22 +7,24 @@ defmodule Explorer.Staking.StakeSnapshotting do import Ecto.Query, only: [from: 2] + require Logger + alias Explorer.Chain alias Explorer.Chain.{StakingPool, StakingPoolsDelegator} alias Explorer.SmartContract.Reader alias Explorer.Staking.ContractReader - def start_snapshoting(%{contracts: contracts, abi: abi, global_responses: global_responses}, block_number) do + def start_snapshotting(%{contracts: contracts, abi: abi, global_responses: global_responses}, block_number) do %{ - "getPendingValidators" => {:ok, [pending_validators_mining_addresses]}, - "validatorsToBeFinalized" => {:ok, [be_finalized_validators_mining_addresses]} + "getPendingValidators" => {:ok, [pending_validators]}, + "validatorsToBeFinalized" => {:ok, [to_be_finalized_validators]} } = Reader.query_contract(contracts.validator_set, abi, %{ "getPendingValidators" => [], "validatorsToBeFinalized" => [] }) - pool_mining_addresses = Enum.uniq(pending_validators_mining_addresses ++ be_finalized_validators_mining_addresses) + pool_mining_addresses = Enum.uniq(pending_validators ++ to_be_finalized_validators) pool_staking_addresses = pool_mining_addresses diff --git a/apps/explorer/priv/contracts_abi/posdao/ValidatorSetAuRa.json b/apps/explorer/priv/contracts_abi/posdao/ValidatorSetAuRa.json index fcfd9237bc..7906f27317 100644 --- a/apps/explorer/priv/contracts_abi/posdao/ValidatorSetAuRa.json +++ b/apps/explorer/priv/contracts_abi/posdao/ValidatorSetAuRa.json @@ -557,7 +557,7 @@ "name": "getPendingValidators", "outputs": [ { - "name": "_miningAddress", + "name": "", "type": "address[]" } ], @@ -571,7 +571,7 @@ "name": "validatorsToBeFinalized", "outputs": [ { - "name": "_miningAddress", + "name": "miningAddresses", "type": "address[]" } ],