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

eip7251: Bugfix and more withdrawal tests #3979

Merged
merged 2 commits into from
Oct 30, 2024

Conversation

mkalinin
Copy link
Collaborator

Follow up to #3943 with more withdrawal tests and yet another bugfix.
The PR does also proposes to rename partial_withdrawals_count to processed_partial_withdrawals_count and withdrawals test helper refactor.

The fix

The balance withdrawn upon request, i.e. by processing a pending partial withdrawal, wasn’t taken into account for the sweep. Potential outcome is a validator being considered partially withdrawable while it has no excess balance and effectively is not partially withdrawable.

The proposed fix is simply to check if validator index is already presented in the withdrawals and deduct the already withdrawn balance from the balance considered by the sweep.

Copy link
Member

@jtraglia jtraglia left a comment

Choose a reason for hiding this comment

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

Thanks for this! It looks really good.

  • The name processed_partial_withdrawals_count makes sense 👍
  • Good catch on the bug, the fix looks correct to me.
  • The new tests are nice. I see no issues here, just a few questions.

Copy link
Member

@ppopth ppopth left a comment

Choose a reason for hiding this comment

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

The idea looks good to me

balance = state.balances[validator_index]
# [Modified in Electra:EIP7251]
partially_withdrawn_balance = sum(
withdrawal.amount for withdrawal in withdrawals if withdrawal.validator_index == validator_index)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alternatively, it could iterate over withdrawals[:effective_partial_withdrawals_count] which contains partial withdrawals included during the current run. In cases when there are no withdrawal requests eligible for processing this computation will be a noop. But we can also leave the existing computation in the spec for simplicity and defer possible optimisation to the implementations

Copy link
Member

@ppopth ppopth Oct 18, 2024

Choose a reason for hiding this comment

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

What is effective_partial_withdrawals_count? I cannot find its definition.

Copy link
Member

Choose a reason for hiding this comment

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

@ppopth I think he meant processed_partial_withdrawals_count, the newly renamed variable.

Copy link
Collaborator Author

@mkalinin mkalinin Oct 19, 2024

Choose a reason for hiding this comment

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

effective_partial_withdrawals_count = len(withdrawals) computed before the sweep. processed_partial_withdrawals_count may be greater than that number due to skipped partial withdrawals

Copy link
Member

Choose a reason for hiding this comment

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

That makes sense then.

Co-authored-by: Justin Traglia <[email protected]>
@jtraglia jtraglia merged commit c060147 into ethereum:dev Oct 30, 2024
25 checks passed
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.

4 participants