-
Notifications
You must be signed in to change notification settings - Fork 122
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
chore(state-transition): Dropped unused code #2144
Conversation
WalkthroughThe changes in this pull request involve significant modifications to the state processing logic within the Ethereum 2.0 framework. Key alterations include the removal of several methods related to attestation deltas, rewards, penalties, and slashing events from the Changes
Possibly related PRs
Suggested labels
Suggested reviewers
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 @@
## main #2144 +/- ##
==========================================
+ Coverage 26.24% 26.43% +0.18%
==========================================
Files 360 359 -1
Lines 16241 16128 -113
Branches 12 12
==========================================
Hits 4263 4263
+ Misses 11709 11596 -113
Partials 269 269
|
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: 2
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (2)
mod/state-transition/pkg/core/state_processor.go
(1 hunks)mod/state-transition/pkg/core/state_processor_slashing.go
(0 hunks)
💤 Files with no reviewable changes (1)
- mod/state-transition/pkg/core/state_processor_slashing.go
// TODO: implement processRewardsAndPenalties | ||
// TODO: implement processSlashingsReset |
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.
🧹 Nitpick (assertive)
Document the rationale for removing these functions
The TODOs indicate that processRewardsAndPenalties
and processSlashingsReset
functionality will need to be reimplemented. Consider adding more context in the TODO comments about:
- When these functions will be reimplemented (e.g., "TODO: implement when slashing is integrated")
- Any specific requirements or dependencies needed for reimplementation
- // TODO: implement processRewardsAndPenalties
- // TODO: implement processSlashingsReset
+ // TODO(slashing): Implement processRewardsAndPenalties when slashing is integrated
+ // TODO(slashing): Implement processSlashingsReset when slashing is integrated
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
// TODO: implement processRewardsAndPenalties | |
// TODO: implement processSlashingsReset | |
// TODO(slashing): Implement processRewardsAndPenalties when slashing is integrated | |
// TODO(slashing): Implement processSlashingsReset when slashing is integrated |
) (transition.ValidatorUpdates, error) { | ||
if err := sp.processRewardsAndPenalties(st); err != nil { | ||
return nil, err | ||
} | ||
if err := sp.processSlashingsReset(st); err != nil { | ||
return nil, err | ||
} | ||
// TODO: implement processRewardsAndPenalties | ||
// TODO: implement processSlashingsReset | ||
if err := sp.processRandaoMixesReset(st); err != nil { | ||
return nil, err | ||
} |
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.
🧹 Nitpick (assertive)
💡 Codebase verification
Based on the search results, I can now generate the final response:
Slashing functionality is still integral to the codebase
The removal of these TODOs requires careful consideration as slashing is deeply integrated in the system:
-
Core slashing interfaces and types are defined and used throughout:
mod/consensus-types/pkg/types/validator.go
defines slashing-related validator statesmod/storage/pkg/beacondb/slashing.go
implements slashing storagemod/node-core/pkg/components/interfaces.go
defines slashing-related interfacesexamples/berad/pkg/state-transition/state_processor_slashing.go
contains reference implementation
-
The codebase maintains slashing-related state:
- Validator slashing status tracking
- Slashing history storage
- Total slashing amounts
Rather than removing these TODOs, they should be implemented to maintain consistency with the rest of the system's slashing capabilities.
🔗 Analysis chain
Consider architectural implications of removing slashing functionality
The removal of slashing-related code (processRewardsAndPenalties, processSlashingsReset) has architectural implications:
- Ensure that no other parts of the system depend on these removed functionalities
- Consider adding validation to prevent slashable behaviors until slashing is reimplemented
- Document the temporary limitations in the system's documentation
Let's verify if there are any remaining references to the removed functionality:
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for references to removed slashing-related functions
echo "Searching for references to removed functions..."
rg "processRewardsAndPenalties|processSlashingsReset|getAttestationDeltas|processProposerSlashing|processSlashings|processSlash"
# Search for any remaining slashing-related code
echo "Searching for slashing-related code..."
rg -i "slash|penalty|reward|attestation.*delta"
Length of output: 41797
// TODO: implement this function forreal | ||
validators, err := st.GetValidators() | ||
if err != nil { | ||
return nil, nil, err | ||
} | ||
placeholder := make([]math.Gwei, len(validators)) | ||
return placeholder, placeholder, nil |
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.
we load the full validator list to do absolutely nothing with it. Better avoid this until we explicitly handle slashing
]) processRewardsAndPenalties( | ||
st BeaconStateT, | ||
) error { | ||
slot, err := st.GetSlot() |
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.
with getAttestationDeltas gone, this is pointless
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 would prefer to keep the code if it matches the Ethereum 2.0 specification and just mark it with some convention-defined comment, but I can confirm that – apart from the examples/berad
module – it's not used anymore.
//nolint:lll | ||
func (sp *StateProcessor[ | ||
_, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _, | ||
]) getAttestationDeltas( |
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.
Still used by the examples/berad
module.
Provided by examples/berad/pkg/state-transition/state_processor.go
row 458.
Called in examples/berad/pkg/state-transition/state_processor.go
row 488.
//nolint:lll | ||
func (sp *StateProcessor[ | ||
_, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _, | ||
]) processRewardsAndPenalties( |
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.
Still used by the examples/berad
module.
Provided by examples/berad/pkg/state-transition/state_processor.go
row 476.
Called in examples/berad/pkg/state-transition/state_processor.go
row 338.
//nolint:lll | ||
func (sp *StateProcessor[ | ||
_, _, _, BeaconStateT, _, _, _, _, _, _, _, _, _, _, _, _, _, | ||
]) processSlashingsReset( |
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.
Still used by the examples/berad
module.
Provided by examples/berad/pkg/state-transition/state_processor_slashing.go
row 29.
Called in examples/berad/pkg/state-transition/state_processor.go
row 340.
@dezzeus ok, keeping code as is |
This is simple code to implement (straight from Eth 2.0 specs) but it's not active.
Keeping this in gives no advantages and make marginally harder to read code.
Will reimplement once we have slashing in
Summary by CodeRabbit
New Features
Bug Fixes
Chores