-
-
Notifications
You must be signed in to change notification settings - Fork 436
chore: review epbs state transition changes (part 2) #8660
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -155,7 +155,7 @@ export function getExpectedWithdrawals( | |
| ? allBuilderPendingWithdrawals[i] | ||
| : stateGloas.builderPendingWithdrawals.getReadonly(i); | ||
|
|
||
| if (withdrawal.withdrawableEpoch > epoch || withdrawals.length === MAX_WITHDRAWALS_PER_PAYLOAD) { | ||
| if (withdrawal.withdrawableEpoch > epoch || withdrawals.length + 1 === MAX_WITHDRAWALS_PER_PAYLOAD) { | ||
| break; | ||
| } | ||
|
|
||
|
|
@@ -173,14 +173,16 @@ export function getExpectedWithdrawals( | |
| balance - MIN_ACTIVATION_BALANCE < withdrawal.amount ? balance - MIN_ACTIVATION_BALANCE : withdrawal.amount; | ||
| } | ||
|
|
||
| withdrawals.push({ | ||
| index: withdrawalIndex, | ||
| validatorIndex: withdrawal.builderIndex, | ||
| address: withdrawal.feeRecipient, | ||
| amount: BigInt(withdrawableBalance), | ||
| }); | ||
| withdrawalIndex++; | ||
| withdrawnBalances.set(withdrawal.builderIndex, totalWithdrawn + withdrawableBalance); | ||
| if (withdrawableBalance > 0) { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am surprised spec test didn't catch this bug |
||
| withdrawals.push({ | ||
| index: withdrawalIndex, | ||
| validatorIndex: withdrawal.builderIndex, | ||
| address: withdrawal.feeRecipient, | ||
| amount: BigInt(withdrawableBalance), | ||
| }); | ||
| withdrawalIndex++; | ||
| withdrawnBalances.set(withdrawal.builderIndex, totalWithdrawn + withdrawableBalance); | ||
| } | ||
| } | ||
| processedBuilderWithdrawalsCount++; | ||
| } | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,7 +63,6 @@ export function isMergeTransitionBlock(state: BeaconStateExecutions, body: bella | |
| * Merge is complete when the state includes execution layer data: | ||
| * state.latestExecutionPayloadHeader NOT EMPTY | ||
| */ | ||
| // TODO GLOAS: See if we need to update this for gloas | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should just remove the merge transition code, it's probably simpler than making it somehow work with gloas
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. created #8661 to track it |
||
| export function isMergeTransitionComplete(state: BeaconStateExecutions): boolean { | ||
| if (!isCapellaStateType(state)) { | ||
| return !ssz.bellatrix.ExecutionPayloadHeader.equals( | ||
|
|
||
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.
This loop condition appears to have an off-by-one error. The check
withdrawals.length + 1 === MAX_WITHDRAWALS_PER_PAYLOADwill cause the loop to break whenwithdrawals.lengthisMAX_WITHDRAWALS_PER_PAYLOAD - 1, resulting in one less withdrawal being processed than the maximum allowed.For example, if
MAX_WITHDRAWALS_PER_PAYLOADis 16 andwithdrawals.lengthbecomes 15, this condition15 + 1 === 16will be true, and the loop will break, leaving only 15 withdrawals in the list instead of the maximum of 16.The condition should probably be
withdrawals.length >= MAX_WITHDRAWALS_PER_PAYLOADto allow the list to be filled up to its maximum capacity. This is also consistent with the check used later in this function.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.
that's same as the spec here
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.
I am surprised spec test didn't catch this bug