Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

LIP-3 Oracle interface and reward algorithm for v0.2.x #153

Merged
merged 23 commits into from
Nov 22, 2020
Merged

Conversation

ongrid
Copy link
Contributor

@ongrid ongrid commented Nov 18, 2020

Resolves #110 - funds "in process" (from deposit submission until it gets processed and added to the beacon state's validators list) got treated like a decrease, the behavior was equal to slashing and lead to significant drops in stETH supply.

The new implementation counts the number of deposited validators as the funds get teposited on stake, so there is no time gap when funds are not accounted. Until the oracle can see the validator, it's assumed to have 32 ETH balance.

Spec: LIP-3

Note: full-cycle integration tests need to re-calculate and double-check all the numbers, made a separate task for this #152

closes #128
closes #129
closes #87
closes #4

@ongrid ongrid added the enhancement New feature or request label Nov 18, 2020
@ongrid ongrid added this to the RC2 milestone Nov 18, 2020
@ongrid ongrid self-assigned this Nov 18, 2020
@ongrid ongrid requested a review from skozin November 18, 2020 10:56
Copy link
Member

@skozin skozin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The renaming will break the UI code in apps/*/app and https://github.com/lidofinance/widget, they should be updated, too, as a part of this.

contracts/0.4.24/Lido.sol Outdated Show resolved Hide resolved
contracts/0.4.24/Lido.sol Outdated Show resolved Hide resolved
contracts/0.4.24/Lido.sol Outdated Show resolved Hide resolved
contracts/0.4.24/template/LidoTemplate.sol Outdated Show resolved Hide resolved
@vshvsh
Copy link
Contributor

vshvsh commented Nov 18, 2020

Checked the rewards calculation and distribution part and it works as we want it. Can't really check the implementation or style so I'm not blocking from there.

ongrid added a commit that referenced this pull request Nov 19, 2020
* epochsPerFrame
* slotsPerEpoch
* secondsPerSlot
* genesisTime

New semantics and default values are used in `deploy-lido-dao.js`
which in turn called by `yarn run deploy:dao`.

Reason: PR #153 review
Copy link
Member

@skozin skozin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK; right now I'm deploying this to test in Görli/Pyrmont setup but don't want to block merging


UPD: I've prepared a couple of PRs, please take a look at #163, #164, and #165.

contracts/0.4.24/oracle/LidoOracle.sol Outdated Show resolved Hide resolved
ongrid added a commit that referenced this pull request Nov 22, 2020
* epochsPerFrame
* slotsPerEpoch
* secondsPerSlot
* genesisTime

New semantics and default values are used in `deploy-lido-dao.js`
which in turn called by `yarn run deploy:dao`.

Reason: PR #153 review
@ongrid ongrid requested a review from skozin November 22, 2020 19:16
ongrid added a commit that referenced this pull request Nov 22, 2020
* epochsPerFrame
* slotsPerEpoch
* secondsPerSlot
* genesisTime

New semantics and default values are used in `deploy-lido-dao.js`
which in turn called by `yarn run deploy:dao`.

Reason: PR #153 review
ongrid and others added 9 commits November 23, 2020 02:31
* New pushBeacon func now gets amount of validators visible on beacon
* _getTransientBalance() - calculations based on number of validators
* Amount of validators visible on beacon now come from the oracle.
* Increment number of deposited validators (not sum balance) on deposit.
* Reimplement getTotelControlledEther to getTotalPooledEther() #71
* RewardBase calculator and store removed from Lido scope
* The rewards calculated in runtime in pushBeacon, no state modification
* Remove epoch-awareness from Lido (Oracle still epoch-aware)
* Rename remoteEther2 to beaconBalance #71
* Rename totalControlledEther to totalPooledEther
* Rename getEther2Stat getBeaconStat

Related: #110
* Add PushableMock contract
* Add pushBeacon unittests
Related:  #110, #4
* Title description
* initialize() doxygen
* fallback and submit, _submit
* depositBufferedEther, _depositBufferedEther
* setOracle
* setDepositIterationLimit
* pushBeacon
* getBufferedEther
* getTotalPooledEther
* getToken
* getOracle
* setToken
* setValidatorRegistrationContract
* _setOperators
* _setDepositIterationLimit
* _ETH2Deposit, _stake, _submitted
* distributeRewards
* _getTransientBalance
* Improve PushableMock contract
* Extend pushBeacon unittests
Related:  #110, #4
Extend pushBeacon unittests to cover different cases/combinations
of depositedValidators/beaconValidators/beaconBalances

Related:  #110, #4
@skozin
Copy link
Member

skozin commented Nov 22, 2020

rebased to fix lido -> depool artifacts in e2e full flow test

t.is(await lidoHelper.getTotalControlledEther(), usersDeposits, 'Total controlled ether in Lido')
t.is(await ether2Stat.deposited, usersDeposits, 'Check that the ether2 stat is changed correctly')
t.is(await lidoHelper.getTotalPooledEther(), usersDeposits, 'Total pooled ether in Lido')
t.is(await ether2Stat.depositedValidators, usersDeposits, 'Check that the ether2 stat is changed correctly')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is clearly broken since we're comparing the number of deposits with their amount, but let's fix E2E in a separate PR.

@skozin skozin merged commit 4cc5813 into master Nov 22, 2020
@skozin skozin deleted the lip_3_oracle branch November 22, 2020 23:56
@skozin skozin mentioned this pull request Nov 23, 2020
krogla pushed a commit that referenced this pull request Jan 26, 2021
* epochsPerFrame
* slotsPerEpoch
* secondsPerSlot
* genesisTime

New semantics and default values are used in `deploy-lido-dao.js`
which in turn called by `yarn run deploy:dao`.

Reason: PR #153 review
dechjo pushed a commit to dechjo/lido-dao that referenced this pull request Jan 26, 2021
* epochsPerFrame
* slotsPerEpoch
* secondsPerSlot
* genesisTime

New semantics and default values are used in `deploy-lido-dao.js`
which in turn called by `yarn run deploy:dao`.

Reason: PR lidofinance#153 review
dechjo pushed a commit to dechjo/lido-dao that referenced this pull request Jan 26, 2021
LIP-3 Oracle interface and reward algorithm for v0.2.x
tamtamchik pushed a commit that referenced this pull request Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment