Initial draft of stake delegation without fees and penalties.#39
Open
nikita-fuchs wants to merge 1 commit intoaeternity:masterfrom
Open
Initial draft of stake delegation without fees and penalties.#39nikita-fuchs wants to merge 1 commit intoaeternity:masterfrom
nikita-fuchs wants to merge 1 commit intoaeternity:masterfrom
Conversation
hanssv
reviewed
Nov 26, 2024
| ### **Contextual constraints** | ||
| The above delegation logic assumes the following requirements to the `main staking logic` to be met: | ||
|
|
||
| 1. On any adjustment of a staker's amount, who registered as a `delegatee`, `update_delegatees_stake()` is called to keep the delegation logic's book-keeping in sync with the amount of funds staked by stakers in the `main staking logic`. By checking if the Caller is a `delegatee`, all delegatee's calls to adjust their stake shall be forwarded *to the delegation logic* (as for example the direct withdrawal from the staker's total stake in the `main staking logic` would withdraw also the funds *delegated* to him). The delegation logic has means of adjusting the staked amount in the `main staking logic` in accordance to the changes in its book keeping, according stubs are included in the current code. |
Member
There was a problem hiding this comment.
This is not settled, but we are leaning towards the main staking contract not knowing if the logic behind a StakingValidator is a single entity or a delegatee backed by several delegates.
| The above delegation logic assumes the following requirements to the `main staking logic` to be met: | ||
|
|
||
| 1. On any adjustment of a staker's amount, who registered as a `delegatee`, `update_delegatees_stake()` is called to keep the delegation logic's book-keeping in sync with the amount of funds staked by stakers in the `main staking logic`. By checking if the Caller is a `delegatee`, all delegatee's calls to adjust their stake shall be forwarded *to the delegation logic* (as for example the direct withdrawal from the staker's total stake in the `main staking logic` would withdraw also the funds *delegated* to him). The delegation logic has means of adjusting the staked amount in the `main staking logic` in accordance to the changes in its book keeping, according stubs are included in the current code. | ||
| 3. It is assumed there is some function in the `main staking logic` that is called by the block producer every time he produces a block. (Current information: There is supposedly a function called `step()` to which this applies). |
Member
There was a problem hiding this comment.
We will not do this on a block-by-block basis...
|
|
||
| 1. On any adjustment of a staker's amount, who registered as a `delegatee`, `update_delegatees_stake()` is called to keep the delegation logic's book-keeping in sync with the amount of funds staked by stakers in the `main staking logic`. By checking if the Caller is a `delegatee`, all delegatee's calls to adjust their stake shall be forwarded *to the delegation logic* (as for example the direct withdrawal from the staker's total stake in the `main staking logic` would withdraw also the funds *delegated* to him). The delegation logic has means of adjusting the staked amount in the `main staking logic` in accordance to the changes in its book keeping, according stubs are included in the current code. | ||
| 3. It is assumed there is some function in the `main staking logic` that is called by the block producer every time he produces a block. (Current information: There is supposedly a function called `step()` to which this applies). | ||
| 4. It is assumed that rewards for blocks produced by stakers that registered as `delegatee`s remain in the contract of the `main staking logic`, from which the eligible parties can withdraw them utilizing the delegation logic's `withdraw_rewards()`. |
Member
There was a problem hiding this comment.
This is one way a delegatee/validator might organize his/her "pool" other variants are feasible too, right?
| 1. On any adjustment of a staker's amount, who registered as a `delegatee`, `update_delegatees_stake()` is called to keep the delegation logic's book-keeping in sync with the amount of funds staked by stakers in the `main staking logic`. By checking if the Caller is a `delegatee`, all delegatee's calls to adjust their stake shall be forwarded *to the delegation logic* (as for example the direct withdrawal from the staker's total stake in the `main staking logic` would withdraw also the funds *delegated* to him). The delegation logic has means of adjusting the staked amount in the `main staking logic` in accordance to the changes in its book keeping, according stubs are included in the current code. | ||
| 3. It is assumed there is some function in the `main staking logic` that is called by the block producer every time he produces a block. (Current information: There is supposedly a function called `step()` to which this applies). | ||
| 4. It is assumed that rewards for blocks produced by stakers that registered as `delegatee`s remain in the contract of the `main staking logic`, from which the eligible parties can withdraw them utilizing the delegation logic's `withdraw_rewards()`. | ||
| 5. Every time a block was produced, the `split_reward()` function is to be called (presumably in the function referenced in 3.) . This is safe, because `split_reward()` immediately returns, if the caller is not a registered `delegatee`. It is assumed, that in this call, the earned block reward is `Call.value`. If that is not the case, the delegation logic can easily be adjusted to reference this value from somewhere else which is accessible to the contract. |
Member
There was a problem hiding this comment.
At the end of an epoch - and with some (1 epoch?) delay - rewards are distributed. The StakingValidator interface allows a callback to be registered; this function will be called with information of rewards during the given epoch.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@hanssv would you be so kind to copy-paste your comments over to here?
This is a new version of PR #38