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

Check for churn period seconds to pass when delegator ends #625

Merged
merged 7 commits into from
Oct 24, 2024

Conversation

geoff-vball
Copy link
Contributor

Why this should be merged

Makes delegators wait at least churnPeriodSeconds to reclaim their stake in the case that their validator ended early. If the validator has not ended, the delegator must still wait minStakeDuration, where minStakeDuration >= churnPeriodSeconds. This prevents the delegator from potentially staking multiple times in the same churn period.

How this was tested

Unit tests

How is this documented

Comments

Copy link
Contributor

@bernard-avalabs bernard-avalabs left a comment

Choose a reason for hiding this comment

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

Looks good to me. Just a quick question about the extra check in completeEndDelegation.

@@ -691,6 +697,11 @@ abstract contract PoSValidatorManager is
revert InvalidDelegatorStatus(delegator.status);
}

// Check that minimum stake duration has passed.
if (block.timestamp < delegator.startedAt + $._minimumStakeDuration) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this check necessary given that we know the delegator is in PendingRemoved state?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops. I didn't actually mean to add this check here. Thanks!

Comment on lines 602 to 606
// To prevent churn tracker abuse, check that one full churn period has passed,
// so a delegator may not stake twice in the same churn period.
if (block.timestamp < delegator.startedAt + _getChurnPeriodSeconds()) {
revert MinStakeDurationNotPassed(uint64(block.timestamp));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this check should actually be moved into _completeEndDelegation itself. Currently I think there is still a corner case where _completeEndDelegation could be called from completeDelegatorRegistration prior to a churn period elapsing if the validator completed prior the delegation registration being completed.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Otherwise, we could also just add the similar check in that case, but feels more robust and less error prone to include it in a single place within _completeEndDelegation (possibly with the downside of doing a redundant check in certain cases).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh yep, you're right

@geoff-vball geoff-vball merged commit 93920df into validator-manager Oct 24, 2024
14 checks passed
@michaelkaplan13 michaelkaplan13 deleted the delegator-must-wait-churn-period branch October 24, 2024 20:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants