-
Notifications
You must be signed in to change notification settings - Fork 90
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
feat(ssz): convert forkdata to peters lib #1763
Conversation
WalkthroughThe changes enhance the Changes
Poem
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 as PR comments)
Additionally, you can add CodeRabbit Configuration File (
|
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: 0
Outside diff range comments (1)
mod/consensus-types/pkg/types/fork_data_test.go (1)
[!TIP]
Codebase VerificationReinstate or Verify Test for
GetTree
MethodThe
GetTree
method is still in active use across the codebase. The removal of theTestForkData_GetTree
function might have been an oversight. Please verify the necessity of this test and consider reinstating it to ensure theGetTree
functionality is adequately tested.
- Files with
GetTree
usage:
mod/da/pkg/types/sidecar.ssz.go
mod/da/pkg/types/sidecars.ssz.go
mod/engine-primitives/pkg/engine-primitives/withdrawal_ssz_test.go
mod/da/pkg/types/sidecar_test.go
mod/engine-primitives/pkg/engine-primitives/withdrawal.ssz.go
mod/consensus-types/pkg/types/block_denebplus.ssz.go
mod/consensus-types/pkg/types/body_deneb.ssz.go
mod/consensus-types/pkg/types/eth1data_test.go
mod/consensus-types/pkg/types/payload.ssz.go
mod/consensus-types/pkg/types/block_deneb.ssz.go
mod/consensus-types/pkg/types/validator_test.go
mod/consensus-types/pkg/types/slashing_info.ssz.go
mod/consensus-types/pkg/types/slashing_info_test.go
mod/consensus-types/pkg/types/deposit.ssz.go
mod/consensus-types/pkg/types/payload_header.ssz.go
mod/consensus-types/pkg/types/header.ssz.go
mod/consensus-types/pkg/types/header_test.go
mod/consensus-types/pkg/types/body_denebplus.ssz.go
mod/consensus-types/pkg/types/deposit_message_test.go
mod/consensus-types/pkg/types/payload_header_test.go
mod/consensus-types/pkg/types/body_test.go
mod/consensus-types/pkg/types/validator.ssz.go
mod/consensus-types/pkg/types/fork.ssz.go
mod/consensus-types/pkg/types/block_test.go
mod/consensus-types/pkg/types/block_denebplus_test.go
mod/consensus-types/pkg/types/attestation_data_test.go
mod/consensus-types/pkg/types/fork_test.go
mod/consensus-types/pkg/types/eth1data.ssz.go
mod/consensus-types/pkg/types/deposit_test.go
mod/consensus-types/pkg/state/deneb/deneb.ssz.go
mod/consensus-types/pkg/types/body_denebplus_test.go
mod/consensus-types/pkg/types/attestation_data.ssz.go
mod/consensus-types/pkg/types/payload_test.go
mod/consensus-types/pkg/state/deneb/deneb_test.go
mod/cli/pkg/commands/genesis/types/validators.ssz.go
mod/consensus-types/pkg/types/deposit_message.ssz.go
Analysis chain
Line range hint
1-1
:
Verify the necessity of theGetTree
method.The removal of the
TestForkData_GetTree
function suggests that theGetTree
method might be deprecated or integrated into another method. Ensure that theGetTree
functionality is no longer needed or has been appropriately refactored.Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Verify the usage of the `GetTree` method in the codebase. # Test: Search for the method usage. Expect: No occurrences of the `GetTree` method. rg --type go -A 5 $'GetTree'Length of output: 20790
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (2)
- mod/consensus-types/pkg/types/fork_data.go (2 hunks)
- mod/consensus-types/pkg/types/fork_data_test.go (1 hunks)
Additional comments not posted (6)
mod/consensus-types/pkg/types/fork_data.go (6)
59-63
: LGTM!The
SizeSSZ
method correctly returns the fixed size of 36 bytes for theForkData
object in SSZ encoding.
65-69
: LGTM!The
DefineSSZ
method correctly establishes the SSZ encoding for theCurrentVersion
andGenesisValidatorsRoot
fields.
71-74
: LGTM!The
HashTreeRoot
method correctly computes the SSZ hash tree root of theForkData
object usingssz.HashSequential
.
76-80
: LGTM!The
MarshalSSZTo
method correctly marshals theForkData
object to SSZ format into the provided buffer usingssz.EncodeToBytes
.
82-86
: LGTM!The
MarshalSSZ
method correctly creates a new buffer based on the size determined bySizeSSZ
and marshals the data into it usingMarshalSSZTo
.
88-91
: LGTM!The
UnmarshalSSZ
method correctly unmarshals theForkData
object from SSZ format usingssz.DecodeFromBytes
.
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: 0
Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Files selected for processing (2)
- mod/consensus-types/pkg/types/fork_data.go (2 hunks)
- mod/consensus-types/pkg/types/fork_data_test.go (4 hunks)
Additional comments not posted (9)
mod/consensus-types/pkg/types/fork_data_test.go (3)
24-24
: Acknowledgment: Added import forio
package.The
io
package is added to handle error assertions in the test cases.
53-53
: Update error assertion inTestForkData_Unmarshal
.The error assertion has been updated to check for
io.ErrUnexpectedEOF
, aligning with the expected error handling during unmarshalling.
64-64
: Update size assertion inTestForkData_SizeSSZ
.The size assertion has been updated to compare the size as a
uint32
, enhancing type safety and clarity.mod/consensus-types/pkg/types/fork_data.go (6)
27-27
: Acknowledgment: Added import forssz
package.The
ssz
package is added to support the new SSZ encoding and decoding methods for theForkData
struct.
58-62
: Acknowledgment: AddedSizeSSZ
method.The
SizeSSZ
method returns a fixed size of 36 bytes for theForkData
object in SSZ encoding, providing a clear indication of the size required for serialization.
64-68
: Acknowledgment: AddedDefineSSZ
method.The
DefineSSZ
method establishes the SSZ encoding for theForkData
fields, ensuring correct serialization.
70-73
: Acknowledgment: AddedHashTreeRoot
method.The
HashTreeRoot
method computes the SSZ hash tree root for theForkData
object, crucial for cryptographic operations and data integrity.
75-85
: Acknowledgment: AddedMarshalSSZTo
andMarshalSSZ
methods.The
MarshalSSZTo
andMarshalSSZ
methods manage the serialization of theForkData
object into SSZ format, providing flexibility in how the data can be serialized.
87-90
: Acknowledgment: AddedUnmarshalSSZ
method.The
UnmarshalSSZ
method handles deserialization from an SSZ format byte buffer, completing the round-trip capability of theForkData
struct.
Summary by CodeRabbit
New Features
ForkData
struct with new methods for SSZ encoding and decoding, improving compliance with Ethereum 2.0 specifications.SizeSSZ
,DefineSSZ
,HashTreeRoot
,MarshalSSZTo
,MarshalSSZ
, andUnmarshalSSZ
.Bug Fixes
ForkData
struct.GetTree
method, streamlining the test suite.