Oracled should calculate the number of beacon validators for currentReportableEpoch epoch for all the keys in SP registry. Need to double check if both LightHouse and Prysm give the same set of validators and same balance (=use the same beacon state).
Oracled should summarize all the balances of entire validators set (indep. of their statuses, that can be not 'Active').
Both numbers should be used in OracleContract.reportBeacon(uint256 _epochID, uint128 _beaconValidators, uint128 _beaconBalance), pushData deprecated.
Oracled doesn't calculate epoch/slot, it takes the epoch from the OracleContract.getCurrentReportableEpoch() so
MAINNET_SECONDS_PER_SLOT, MAINNET_SLOTS_PER_EPOCH, SECONDS_PER_SLOT, SLOTS_PER_EPOCH, EPOCH_DURATION, REPORT_INTERVAL_DURATION, GENESIS_TIME, REPORT_INTERVAL_SLOTS
Oracle should run in the endless loop (with pauses about several seconds per each iteration), no pre-calculated sleeps , await_time should be removed.
remove ts(epoch): - daemon should rely on timing from OracleContract.getCurrentReportableEpoch()
Remove all slot-related logic (except API constructor, it should receive slots_per_epoch from the OracleContract.beaconSpec().slotsPerPeoch). Other code should use just epochs for simplicity reasons.
ReportIntervals are deprecated
Remove determining actual, before_*, and last slots/epochs, just take from OracleContract.getCurrentReportableEpoch()
Add additional check before building tx - OracleContract.lastPushedEpochId() should be less then OracleContract.getCurrentReportableEpoch().epochId
Related oracle interface
contract LidoOracle {
// timing parameters of Beacon Chain specification (may be overriden by corresponding setter)
// See https://github.com/ethereum/eth2.0-specs/blob/dev/specs/phase0/beacon-chain.md
struct BeaconSpec {
uint64 slotsPerEpoch = 32; // SLOTS_PER_EPOCH
uint64 secondsPerSlot = 12; // SECONDS_PER_SLOT
// The genesis expected to happen on Dec 1, 2020, 12pm UTC
// But the exact time depends on actual staking and will be known post factum
uint64 genesisTime = 1606824000;
}
BeaconSpec public beaconSpec;
uint256 lastPushedEpochId;
function setBeaconSpec(uint64 slotsPerEpoch, uint64 secondsPerSlot, uint64 genesisTime) public {
// Some require for sanity checks here
beaconSpec.slotsPerEpoch = slotsPerEpoch;
beaconSpec.secondsPerSlot = secondsPerSlot;
beaconSpec.genesisTime = genesisTime;
}
// Returns the current reportable epoch object with its timestamp boundaries.
// Used by oracle daemons
function getCurrentReportableEpoch() public {
epochId = getCurrentEpochID();
// Use SafeMath here
startTimestamp = epochId * beaconSpec.secondsPerSlot * beaconSpec.slotsPerEpoch
endTimestamp = (epochId + 1) * beaconSpec.secondsPerSlot * beaconSpec.slotsPerEpoch - 1
}
// Returns the current epochId
function getCurrentReportableEpochID() internal {
// Switch to safeMath
return(block.timestamp / beaconSpec.secondsPerSlot / beaconSpec.slotsPerEpoch);
}
// instead of pushData. Called by Oracle Daemons
function reportBeacon(uint256 _epoch, uint128 _beaconValidators, uint128 _beaconBalance) public {
require(_epoch > lastPushedEpochId);
require(_epoch <= getCurrentEpochID());
report = Report(beaconValidators: _beaconValidators, beaconBalance: _beaconBalance});
// add event just for mock debugging
}
}
Everything is either DONE or moved to separate, more specific issues.
Oracled should calculate the number of beacon validators for currentReportableEpoch epoch for all the keys in SP registry. (DONE in pyrmont, improved in daemon_v2, planned to release in v0.2)
Need to double check if both LightHouse and Prysm give the same set of validators and same balance (=use the same beacon state). continues in #42, lido-dao#197 and lido-dao#198
Both numbers should be used in OracleContract.reportBeacon(uint256 _epochID, uint128 _beaconValidators, uint128 _beaconBalance), pushData deprecated. (DONE in pyrmont, improved in daemon_v2, planned to release in v0.2)
Oracled doesn't calculate epoch/slot, it takes the epoch from the OracleContract.getCurrentReportableEpoch() - (DONE in pyrmont, improved in daemon_v2, planned to release in v0.2)
Oracle should run in the endless loop (with pauses about several seconds per each iteration), no pre-calculated sleeps , await_time should be removed. - (DONE then introduced back with pyrmont hotfix, to be improved in v0.2 release, See #21 )
remove ts(epoch): - daemon should rely on timing from OracleContract.getCurrentReportableEpoch() - DONE
Remove all slot-related logic (except API constructor, it should receive slots_per_epoch from the OracleContract.beaconSpec().slotsPerPeoch). Other code should use just epochs for simplicity reasons. (DONE in pyrmont, improved in daemon_v2, planned to release in v0.2)
ReportIntervals are deprecated - (DONE in pyrmont, improved in daemon_v2, planned to release in v0.2)
Remove determining actual, before_*, and last slots/epochs, just take from OracleContract.getCurrentReportableEpoch() - (DONE in pyrmont, improved in daemon_v2, planned to release in v0.2)
Add additional check before building tx - OracleContract.lastPushedEpochId() should be less then OracleContract.getCurrentReportableEpoch().epochId - (DONE in pyrmont, checks by calling composed tx locally)
balances
of entire validators set (indep. of their statuses, that can be not 'Active').OracleContract.reportBeacon(uint256 _epochID, uint128 _beaconValidators, uint128 _beaconBalance)
,pushData
deprecated.OracleContract.getCurrentReportableEpoch()
soMAINNET_SECONDS_PER_SLOT
,MAINNET_SLOTS_PER_EPOCH
,SECONDS_PER_SLOT
,SLOTS_PER_EPOCH
,EPOCH_DURATION
,REPORT_INTERVAL_DURATION
,GENESIS_TIME
,REPORT_INTERVAL_SLOTS
await_time
should be removed.ts(epoch):
- daemon should rely on timing fromOracleContract.getCurrentReportableEpoch()
slots_per_epoch
from theOracleContract.beaconSpec().slotsPerPeoch
). Other code should use justepochs
for simplicity reasons.OracleContract.getCurrentReportableEpoch()
OracleContract.lastPushedEpochId()
should be less thenOracleContract.getCurrentReportableEpoch().epochId
Related oracle interface