-
-
Notifications
You must be signed in to change notification settings - Fork 317
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: commit pending partial withdrawals after adding new entry #7375
base: unstable
Are you sure you want to change the base?
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #7375 +/- ##
============================================
- Coverage 48.62% 48.62% -0.01%
============================================
Files 603 603
Lines 40516 40517 +1
Branches 2071 2071
============================================
Hits 19700 19700
- Misses 20778 20779 +1
Partials 38 38 |
Performance Report✔️ no performance regression detected 🚀🚀 Significant benchmark improvement detected
Full benchmark results
|
@@ -76,6 +76,7 @@ export function processWithdrawalRequest( | |||
withdrawableEpoch, | |||
}); | |||
state.pendingPartialWithdrawals.push(pendingPartialWithdrawal); | |||
state.pendingPartialWithdrawals.commit(); |
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.
can we commit once across multiple withdrawal requests?
eg:
for (...) {
processWithdrawalRequest(...);
}
state.pendingPartialWithdrawals.commit();
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 problem is that we need to commit before we call getPendingBalanceToWithdraw
const pendingBalanceToWithdraw = getPendingBalanceToWithdraw(state, validatorIndex); |
since this calls getAllReadonly
.getAllReadonly() |
I am sure there is a better solution for this
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.
so if we don't commit after we push the first withdrawal request the issue happens
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.
@nflaig calling commit()
at the middle of state transition is not great but this is a limitation at ssz side, we should be able to get all items without calling commit()
call state.pendingPartialWithdrawals.getAllReadonly()
at the start of processWithdrawalRequest
then modify getPendingBalanceToWithdraw
let total = 0;
for (let i = 0; i < state.pendingPartialWithdrawals.length; i++) {
const item = state.pendingPartialWithdrawals.get(i);
if (item.validatorIndex === validatorIndex) {
total += Number(item.amount);
}
return total;
}
performance should be the same, a unit test should help
putting as draft for now until more testing is done |
Fixes
devnet-5
issuewhich happened when processing block with two withdrawal requests.
See discord for more context.