-
Notifications
You must be signed in to change notification settings - Fork 585
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: move initialization logic to light client module method #6037
Conversation
WalkthroughWalkthroughThe recent changes involve refactoring the Solo Machine light client within the IBC framework. The Changes
Assessment against linked issues
Related issues
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 as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
also looking for opinions on #5974 (comment) |
@@ -67,19 +65,6 @@ func (cs ClientState) Validate() error { | |||
return cs.ConsensusState.ValidateBasic() | |||
} | |||
|
|||
// Initialize checks that the initial consensus state is equal to the latest consensus state of the initial client and | |||
// sets the client state in the provided client store. | |||
func (cs ClientState) Initialize(_ sdk.Context, cdc codec.BinaryCodec, clientStore storetypes.KVStore, consState exported.ConsensusState) error { |
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.
changelog?
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 guess it doesn't hurt. Also, even though the migration docs already mention that the interface function has been removed, maybe it's worth adding a separate section in the migration docs to document that this function has also been removed from the concrete type.
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (4)
- modules/light-clients/06-solomachine/client_state.go (2 hunks)
- modules/light-clients/06-solomachine/client_state_test.go (2 hunks)
- modules/light-clients/06-solomachine/light_client_module.go (2 hunks)
- modules/light-clients/06-solomachine/light_client_module_test.go (2 hunks)
Additional comments: 11
modules/light-clients/06-solomachine/light_client_module_test.go (2)
- 8-8: The addition of the
ibctm
package import is noted. Ensure that this import is utilized within the test cases, particularly for creating instances ofibctm.ConsensusState
used in the test scenarios.- 17-77: The
TestInitialize
function tests various scenarios for initializing the solo machine client state with different consensus states. Here are some observations and suggestions:
- The use of table-driven tests is a good practice for covering multiple scenarios efficiently.
- The test setup and execution logic are clear and well-structured.
- The use of
reflect.DeepEqual
for comparing expected and actual consensus states in the test cases would enhance the robustness of the tests.Consider adding a test case to cover the scenario where the initialization succeeds but with a warning or minor issue that doesn't block the client state's initialization. This could help ensure the resilience of the initialization logic under less-than-ideal conditions.
Overall, the test function is well-implemented and follows good testing practices.
modules/light-clients/06-solomachine/client_state.go (1)
- 1-1: The removal of the
Initialize
function fromclient_state.go
is in line with the PR's objective to refactor the initialization logic into theLightClientModule
. Ensure that all references to theInitialize
function have been updated or removed accordingly across the codebase to prevent any broken dependencies or compilation errors.modules/light-clients/06-solomachine/light_client_module.go (1)
- 61-69: The
Initialize
function correctly implements the logic to compareclientState.ConsensusState
withconsensusState
usingreflect.DeepEqual
. This is a critical check to ensure that the consensus state matches the client state during the initialization phase. Here are some observations and suggestions:
- The use of
reflect.DeepEqual
for deep comparison is appropriate in this context, as it ensures that the two consensus states are identical in all respects.- Ensure that the error message provided when the consensus states do not match is clear and informative, helping developers understand the nature of the mismatch.
- Consider adding logging or metrics around this initialization process to aid in debugging and monitoring the initialization of solo machine clients in production environments.
Overall, the implementation of the
Initialize
function aligns with the PR's objectives and follows best practices for ensuring the integrity of the initialization process.modules/light-clients/06-solomachine/client_state_test.go (7)
- 8-15: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [1-1]
The removal of imports
ibctm
andhost
suggests that dependencies on these packages were eliminated due to the refactor. Ensure that this change does not leave unused variables or functions that were specifically tied to these imports.
- 8-15: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [12-22]
The
TestStatus
function correctly tests the client state's status both when active and when frozen. This test remains relevant and well-implemented.
- 8-15: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [24-70]
The
TestClientStateValidateBasic
function provides comprehensive coverage of the basic validation scenarios for the solo machine client state. It's well-structured and adheres to best practices for testing.
- 90-95: > 📝 NOTE
This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [72-287]
The
TestVerifyMembership
function thoroughly tests the verification of membership across a variety of scenarios. This is crucial for ensuring the integrity and correctness of the solo machine client state.
- 8-15: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [289-308]
The
TestSignBytesMarshalling
function correctly tests the marshalling behavior of sign bytes, ensuring that nil and empty array data are treated equivalently. This is an important aspect of the serialization logic.
- 8-15: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [310-409]
The
TestVerifyNonMembership
function provides comprehensive testing for the verification of non-membership across various scenarios. This ensures the solo machine client state accurately recognizes non-existent memberships.
- 8-15: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [411-441]
The
TestGetTimestampAtHeight
function tests the retrieval of timestamps at specific heights, a fundamental aspect of the solo machine client state's functionality. It's well-implemented and relevant.
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (1)
- modules/light-clients/06-solomachine/light_client_module_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- modules/light-clients/06-solomachine/light_client_module_test.go
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.
Looks perfectly fine to me. I would still add a note in the migration docs.
modules/light-clients/06-solomachine/light_client_module_test.go
Outdated
Show resolved
Hide resolved
Co-authored-by: Carlos Rodriguez <[email protected]>
Will add changelog before merge. After merge will also make similar changes for other small functions in solomachine and we can leave that PR open until discussed! |
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (1)
- modules/light-clients/06-solomachine/light_client_module_test.go (2 hunks)
Files skipped from review as they are similar to previous changes (1)
- modules/light-clients/06-solomachine/light_client_module_test.go
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.
Changes look good to me, happy to merge this with or without the changelog (can happen in a follow up)
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.
LGTM
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (1)
- docs/docs/05-migrations/13-v8-to-v9.md (1 hunks)
Additional comments: 9
docs/docs/05-migrations/13-v8-to-v9.md (9)
- 80-89: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [10-10]
Near line 10, there's a possible spelling mistake found in the context "...tions for migrating to a new version of ibc-go. There are four sections based on the...". However, upon review, this appears to be a false positive, as "ibc-go" is correctly spelled and relevant in this context.
- 80-89: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [19-19]
The note about "ibc-go supports golang semantic versioning" is crucial for users to understand the importance of updating imports on major version releases. This is correctly placed and well-worded for clarity.
- 80-89: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [29-30]
In the section detailing API removals for IBC Apps, it's mentioned that various interfaces and their functions have been removed, urging users to use concrete types instead. This change is significant and well-documented, providing clear guidance for users on how to adapt their applications.
- 80-89: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [41-42]
The deprecation notice for certain testing package functions and the introduction of new functions is an important change that's well-highlighted. It's crucial for developers to transition to the new functions to ensure compatibility with future versions.
- 80-89: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [46-46]
The replacement of
mock.PV
withcmttypes.MockPV
is a specific change that could impact testing setups. The documentation provides a direct link to the new type, which is helpful for developers looking to make the necessary adjustments.
- 80-89: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [58-62]
The removal of various functions from the
ClientState
interface, includingInitialize
,Status
,GetLatestHeight
, etc., is a major change for IBC Light Clients. The documentation clearly outlines these removals and suggests that light client developers implement theLightClientModule
interface instead. This guidance is crucial for maintaining functionality and compatibility with ibc-go v9.
- 85-85: The specific change regarding the
Initialize
function in06-solomachine
being moved to theLightClientModule
interface is well-documented. This change is part of the broader effort to streamline the initialization process and enhance maintainability.- 89-89: The removal of the
IterateConsensusMetadata
function in07-tendermint
is noted without additional context. Given the nature of migration documentation, it would be beneficial to briefly explain the reason behind this removal or its impact, if significant.Consider providing a brief explanation or context for the removal of the
IterateConsensusMetadata
function to help users understand its impact on their implementations.
- 80-89: > 📝 NOTE
This review was outside the diff hunks, and no overlapping diff hunk was found. Original lines [93-94]
The changes in
08-wasm
, including the removal of theExportMetadataMsg
struct and theZeroCustomFields
interface function, are significant for developers working with wasm light clients. The documentation clearly states these removals, which is essential for developers to update their contracts accordingly.
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.
Review Status
Actionable comments generated: 0
Configuration used: .coderabbit.yml
Files selected for processing (1)
- CHANGELOG.md (1 hunks)
Additional comments: 1
CHANGELOG.md (1)
- 45-45: The summary provided in the CHANGELOG.md accurately reflects the changes made in the codebase regarding the
Initialize
function's relocation. The description is clear and concise.
Quality Gate passed for 'ibc-go'Issues Measures |
Description
closes: #5974
Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.
docs/
).godoc
comments.Files changed
in the GitHub PR explorer.SonarCloud Report
in the comment section below once CI passes.Summary by CodeRabbit