-
Notifications
You must be signed in to change notification settings - Fork 254
Fix missing share price for de-registered operators #3661
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
Conversation
🛡️ Immunefi PR ReviewsThanks for submitting this PR for review! We’ve assigned 6 code reviewer(s) to take a look. They’ll provide feedback here as soon as possible. This review is based on the current state of your pull request. If you make changes after the review starts, they won’t be reflected here. To ensure the review includes your latest updates, you’ll need to open a new pull request. |
4f85096
to
9248e56
Compare
…ards but not in next operator set
9248e56
to
76c1547
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, and thank you for the tests.
My comment isn't blocking, feel free to fix it in a separate PR.
@@ -60,11 +64,22 @@ pub(crate) fn do_finalize_domain_current_epoch<T: Config>( | |||
}) | |||
} | |||
|
|||
/// Result holding after `operator_take_reward_tax_and_stake` | |||
pub(crate) struct OperatorTakeRewardTaxResult { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually in Rust, structs named Result have an Ok and Error case. A better name here would be:
pub(crate) struct OperatorTakeRewardTaxResult { | |
pub(crate) struct OperatorTakeRewardTaxOutcome { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The PR looks straightforward with the introduction to new storage mechanism for validators. We verified that this doesn't break any functionality and with detailed description of the changes.
- Oxrudrapratap
How de-registration of operator works?
Operator sends a de-registration extrinsics and status is moved to DeRegistered with ability to unlock funds after specified withdrawal period. After this no more deposits, withdrawals, and unlocking of already initiated withdrawals is accepted. Once the withdrawal period is complete, each nominator can submit
unlock_nominator
to get their funds back. Operator is also removed from the next_operator set.How Operator rewards are distributed?
Once a domain ER is confirmed, we note the rewards for operators who submitted that ER and distribute any rewards from that ER to these operators. If the operator is slashed or queued to be slashed, then that operator will not receive these rewards and instead deposited to treasury else they will be give these rewards.
How Epoch is transitioned?
When epoch is complete, protocol transitions given domain to next epoch. Before doing that, it accounts for all the deposits, withdrawals submitted to this operator during the epoch and finalizes them.
If the operator has set any nomination tax percentage then portion of rewards given to operator during the epoch are given to the operator and rest is distributed pro-rate to each nominator of the operator. Now when operator has non-zero tax-amount, protocol automatically deposit that tax-amount to operator as a new deposit.
During the epoch transition, if any operators in the next_operator set has any non-zero deposits or withdrawals, protocol calculates the share price for convert deposits into shares and withdrawals into Ai3.
What happened on taurus?
Seems like operator-8 have de-registered at epoch
23285
but they got a reward at epoch23299
.So during the epoch transition, operator 8 had a non-zero tax amount and protocol deposited that tax-amount to operator as a new deposit.
Unfortunately, share price for operator 8 is not calculated since they are not in next_operator set as they have de-registered previously even though they had a new deposit done by the protocol.
Later coming to epoch
23347
, operator 8 received another reward and had a non-zero tax amount. When depositing this new tax-amount reward for operator 8, protocol tried to convert previous deposit from23299
but failed to convert to shares since there was no share price.Due to this, epoch was never transitioned and all the bundles being submitted are failing.
Fix
This PR handles two things
Code contributor checklist: