8000 LidoOracle: new interface and pushing principles · Issue #129 · lidofinance/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
LidoOracle: new interface and pushing principles #129
Closed
@ongrid

Description

@ongrid

Base branch: lip_3_oracle

  • ReportInterval will be replaced to just epochIds (the same IDs as beacon chain states have for clarity). Method setReportIntervalDuration and event ReportIntervalDurationChanged, REPORT_INTERVAL_DURATION are deprecated and to be removed.
  • The last state pushed to lido now called lastPushedEpochId instead of lastFinalizedReportInterval
  • The accept reportBeacon transactions from oracles if lastPushedEpochId < _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) and getCurrentReportableEpochID() (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 require finalisation. The quorum-related logic should be renamed to _isQuorumReached(uint256 _epochId). pushBeacon and updating lastPushedEpochId 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 {
        
    }
}

Solves: #110, Related: #4, Cosmetic: #71, #87, #119

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

    0