Closed
Description
Base branch: lip_3_oracle
ReportInterval
will be replaced to justepochId
s (the same IDs as beacon chain states have for clarity). MethodsetReportIntervalDuration
and eventReportIntervalDurationChanged
,REPORT_INTERVAL_DURATION
are deprecated and to be removed.- The last state pushed to lido now called
lastPushedEpochId
instead oflastFinalizedReportInterval
- The accept
reportBeacon
transactions from oracles iflastPushedEpochId < _epochId <= getCurrentReportableEpochID()
, revert if not. - To gather reports for different epochs they should be stored in the map instead of
currentlyAggregatedReportInterval
flat variables.
map gatheredReports[_epochId] = { Report, contrinutionBitmask }
- To save gas, reports are tightly packed in the
Report
struct
struct Report {
uint128 beaconValidators;
uint128 beaconBalance;
}
-
remove
getLatestData
since it doesn't make any sense. -
Implement beaconSpec struct (oracle daemons take configuration from it). Implemented as public variable and its setter
// 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;
function setBeaconSpec(uint64 slotsPerEpoch, uint64 secondsPerSlot, uint64 genesisTime) public {
// Some require for sanity checks here
beaconSpec.slotsPerEpoch = slotsPerEpoch;
beaconSpec.secondsPerSlot = secondsPerSlot;
beaconSpec.genesisTime = genesisTime;
}
- Implement public/external getters for oracle daemons:
getCurrentReportableEpoch
(define public vs external) andgetCurrentReportableEpochID()
(define external vs internal)
// 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);
}
- Cosmetic: more clear naming on quorum-related methods, see list of cosmetic issues below
- Cosmetic:
_tryFinalize
is a bad name for new implementation since it doesn't requirefinalisation
. The quorum-related logic should be renamed to_isQuorumReached(uint256 _epochId)
.pushBeacon
and updatinglastPushedEpochId
can be called on the same level. - Cosmetic: all the introduced and refactored entities should have doxygens
- Unit tests (integration tests will probably conflict with Lido pushBeacon with _beaconValidators amount for proper reward calculation #128)
- Update Aragon's UI spec, deploy and check it by eyes. Suldin will help if needed.
Reference: Lido's interface:
contract Lido {
// called by the oracle contract
function pushBeacon(uint128 _beaconValidators, uint256 _beaconBalance) external {
}
}