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

fix: complete withdrawals #962

Closed
wants to merge 2 commits into from

Conversation

8sunyuan
Copy link
Collaborator

Decided on removing numToComplete interface and this PR also fixes some broken tests.

Also fixes a race condition bug where a staker's withdrawal is still slashable in the same block that the withdrawal is completable, leading to possible race conditions. The regression test test_getQueuedWithdrawals_SlashAfterWithdrawalCompletion on the view function found this and passes as a result of the fix.

@@ -6619,6 +6539,8 @@ contract DelegationManagerUnitTests_completeQueuedWithdrawal is DelegationManage
strategyMock,
depositSharesPerWithdrawal
);
withdrawal.nonce = nonce;
nonce += 1;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Note: this was needed because it was looping over creating queuedWithdrawalParams but each one was having a nonce of 0 from reading directly off the contract. I overwrite this value here since the expectation is that the withdrawals are queued in order with nonces from 0-3 inclusive

Copy link
Contributor

@0xClandestine 0xClandestine left a comment

Choose a reason for hiding this comment

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

one nit, ci is failing too

// if the completion block is in the future, simply read current slashing factors
// still possible however for the slashing factors to change before the withdrawal is completable
// and the shares withdrawn to be less
if (completableBlock > uint32(block.number)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: could be a ternary (no biggie tho)

@0xClandestine
Copy link
Contributor

one nit, ci is failing too

noticed it's also failing upstream, can fix if needed

Copy link
Collaborator

@ypatil12 ypatil12 left a comment

Choose a reason for hiding this comment

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

Can we simplify this PR?

if (completableBlock > uint32(block.number)) {
slashingFactors =
_getSlashingFactors({staker: staker, operator: operator, strategies: withdrawals[i].strategies});
// Read slashing factors at the completable block
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we remove these from this PR

@ypatil12
Copy link
Collaborator

Closing in favor of #965

@ypatil12 ypatil12 closed this Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants