-
Notifications
You must be signed in to change notification settings - Fork 117
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
perf(state-transition): reduce amount of withdrawals processed #2110
base: main
Are you sure you want to change the base?
Conversation
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the WalkthroughThe changes in this pull request focus on the Changes
Possibly related PRs
Suggested reviewers
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## state-transition-add-UTs #2110 +/- ##
============================================================
+ Coverage 24.82% 26.41% +1.59%
============================================================
Files 357 357
Lines 16071 16075 +4
Branches 12 12
============================================================
+ Hits 3990 4247 +257
+ Misses 11886 11560 -326
- Partials 195 268 +73
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
- mod/state-transition/pkg/core/state/statedb.go (1 hunks)
🔇 Additional comments (1)
mod/state-transition/pkg/core/state/statedb.go (1)
246-262
: LGTM! Performance optimization achieved.The changes successfully optimize withdrawal processing by:
- Eliminating unnecessary intermediate variables
- Reducing memory allocations
- Only processing withdrawals for eligible validators (fully or partially withdrawable)
This aligns well with the PR objective of reducing the amount of withdrawals processed.
Signed-off-by: nidhi-singh02 <[email protected]>
This reverts commit 099716d.
Signed-off-by: nidhi-singh02 <[email protected]>
Signed-off-by: nidhi-singh02 <[email protected]>
Timestamp: 10, | ||
ExtraData: []byte("testing"), | ||
Transactions: [][]byte{}, | ||
Withdrawals: []*engineprimitives.Withdrawal{}, // no withdrawals |
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 is the point of the test here, which is different from the base branch here: the list of withdrawals is empty instead of containing two withdrawals with zero amount.
2778c79
to
09eee8e
Compare
// TODO: hack to avoid failure of EL checks on withdrawals | ||
if p.Withdrawals == nil { | ||
p.Withdrawals = make([]*engineprimitives.Withdrawal, 0) | ||
} |
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.
post Shangai an EL explicitly check that Withdrawals are not nil (instead empty slices are fine).
Currently BeaconKit duly builds a block with Withdrawals set to empty slice (if not withdrawals are available) but as soon as the block is returned by CometBFT for verification, the SSZ decoding sets the empty slice to nil.
This code change solves the issue.
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.
makes sense!
No need to process for withdrawal validators that are not fully or partially withdrawable
Note: this PR (and those built on top) seems to break once we update erigon from 2.60.1 to 2.60.9.
Geth seems to give the following error:
Note: keep on investigating with @dezzeus. It looks like withdrawals are duly set to an empty slice when the block is built, but as soon as the block is returned from consensus to middleware for verification, the slice is nil. SSZ serialization seems to be responsible for this. Investigation ongoing
Investigation ongoing
Note: found a solution: expliciting make Withdrawals slice when SSZ unmarshalling.