-
Notifications
You must be signed in to change notification settings - Fork 202
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: enable wasm light clients on IBC (08-wasm) #2068
Conversation
df922a1
to
f975eac
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2068 +/- ##
==========================================
- Coverage 64.58% 64.56% -0.03%
==========================================
Files 271 271
Lines 21237 21279 +42
==========================================
+ Hits 13716 13738 +22
- Misses 6574 6587 +13
- Partials 947 954 +7
|
f975eac
to
cddf453
Compare
55d6412
to
b0fbe1f
Compare
WalkthroughThe pull request introduces significant updates to the Nibiru EVM codebase, focusing on the integration of the IBC Wasm light client module. Key changes include bug fixes, new features, refactoring, and enhanced testing. The Changes
Assessment against linked issues
Possibly related PRs
Suggested reviewers
Poem
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
🪧 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 (
|
b0fbe1f
to
8fb0340
Compare
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: 3
🧹 Outside diff range and nitpick comments (6)
app/upgrades/v1_2_0/constants.go (1)
Based on the search results, I can now generate the final response since I have clear evidence of how IBC-related migrations are handled in the codebase.
The upgrade handler needs to be updated to enable Wasm client type in IBC params
Looking at the v2_1_0 upgrade handler, which is specifically focused on Wasm light clients, it performs necessary IBC-specific migrations by updating the allowed client types. Your handler should follow the same pattern:
params := clientKeeper.GetParams(ctx) params.AllowedClients = append(params.AllowedClients, ibcwasmtypes.Wasm) clientKeeper.SetParams(ctx, params)This ensures that the Wasm client type is properly registered with IBC after the upgrade.
🔗 Analysis chain
Line range hint
17-21
: Verify the upgrade handler's minimal implementation.While the upgrade handler has been modified to accept the
clientKeeper
parameter, it's not utilizing it for any IBC-specific migrations. Given that this PR is specifically about enabling Wasm light clients on IBC:
- The handler might need to perform IBC-specific migrations or validations
- Consider if any Wasm-related state migrations are required
Let's check if other upgrade handlers in the codebase perform IBC-specific migrations:
Consider whether you need to:
- Initialize any Wasm-specific state
- Migrate existing light client data
- Set up default parameters for the Wasm light client module
Would you like assistance in implementing these potential requirements?
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for IBC-related migrations in other upgrade handlers rg -A 10 "CreateUpgradeHandler.*clientKeeper" app/upgrades/Length of output: 3880
app/upgrades/v1_4_0/constants.go (1)
Based on the search results, I can now generate the final response as we have clear evidence of how Wasm-related migrations are handled in the codebase, particularly from the v2_1_0 upgrade handler.
Wasm client type needs to be added to allowed clients list during upgrade
The upgrade handler should update the IBC client parameters to include the Wasm client type, similar to how it's done in v2_1_0:
params := clientKeeper.GetParams(ctx) params.AllowedClients = append(params.AllowedClients, ibcwasmtypes.Wasm) clientKeeper.SetParams(ctx, params)This ensures that Wasm light clients can be created after the upgrade.
🔗 Analysis chain
Line range hint
17-21
: Verify if Wasm-related migrations are needed.While the
clientKeeper
parameter has been added to the upgrade handler, it's not being utilized in the implementation. Given that this PR aims to enable Wasm light clients, consider if any Wasm-specific migrations should be performed during this upgrade.🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Description: Check for any Wasm-related migrations in other upgrade handlers # or migration files that might serve as examples # Look for Wasm-related migrations in other upgrade handlers echo "Checking for Wasm-related migrations in other upgrade handlers..." rg -l "wasm" app/upgrades/ # Look for migration-related files echo "Checking for migration files..." fd -t f "migrations?" app/upgrades/ # Look for IBC client migrations echo "Checking for IBC client migrations..." rg -A 5 "clientKeeper" app/upgrades/Length of output: 3649
app/upgrades.go (1)
31-31
: Enhancement: IBC Client Keeper integration looks goodThe addition of
app.ibcKeeper.ClientKeeper
to the upgrade handler is well-aligned with the objective of enabling Wasm light clients on IBC. This change provides the necessary access to IBC client functionality during upgrades.Consider documenting the following in your upgrade guide:
- The impact of this change on existing IBC connections
- Any necessary steps for validators during the upgrade
- The process for verifying Wasm client functionality post-upgrade
app/keepers/all_keepers.go (1)
72-72
: LGTM! Consider documenting keeper responsibilities.The WasmClientKeeper field is correctly positioned with other WASM-related keepers and follows the established pattern.
Consider adding a documentation comment above the field to clarify:
- Its role in IBC light client verification
- Its relationship with the existing WasmKeeper
- Any specific initialization requirements
Example:
+ // WasmClientKeeper handles IBC light client verification using WebAssembly modules. + // It works alongside WasmKeeper but focuses specifically on IBC client operations. WasmClientKeeper ibcwasmkeeper.KeeperCHANGELOG.md (2)
177-177
: Enhance the changelog entry for IBC Wasm light clients.The current entry
feat: enable wasm light clients on IBC (08-wasm)
could be expanded to provide more context about this significant change. Consider adding details about:
- The purpose and benefits of enabling Wasm light clients
- Any configuration or setup requirements
- Impact on existing IBC functionality
- Any migration steps needed
Example:
-feat: enable wasm light clients on IBC (08-wasm) +feat: enable wasm light clients on IBC (08-wasm) + - Adds support for WebAssembly-based light clients in IBC to enable trust-minimized cross-chain communication + - Implements IBC client interface for Wasm light clients following 08-wasm specifications + - Allows deployment and modification of light clients across chains + - Required for the upcoming Euclid Protocol launch on 40-50 testnets
Line range hint
1-24
: Maintain consistent changelog formatting and detail level.The changelog structure is good but could benefit from more consistency:
Each breaking change should include:
- What changed
- Why it changed
- Migration impact
- Required actions
Use consistent formatting:
- Start entries with change type (feat/fix/refactor)
- Include PR number in consistent format
- Add descriptive summaries beyond PR titles
Example format:
- feat(module): description of new feature (#PR) - Details about what changed - Impact on existing functionality - Required actions for users
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
⛔ Files ignored due to path filters (1)
go.sum
is excluded by!**/*.sum
📒 Files selected for processing (13)
CHANGELOG.md
(1 hunks)app/app.go
(3 hunks)app/keepers.go
(11 hunks)app/keepers/all_keepers.go
(2 hunks)app/upgrades.go
(2 hunks)app/upgrades/types.go
(1 hunks)app/upgrades/v1_1_0/constants.go
(2 hunks)app/upgrades/v1_2_0/constants.go
(2 hunks)app/upgrades/v1_3_0/constants.go
(2 hunks)app/upgrades/v1_4_0/constants.go
(2 hunks)app/upgrades/v2_1_0/constants.go
(1 hunks)cmd/nibid/cmd/init.go
(3 hunks)go.mod
(2 hunks)
🔇 Additional comments (32)
app/upgrades/types.go (2)
7-8
: LGTM: Clean import addition for IBC client keeper.
The import of clientkeeper
from IBC-Go v7 is properly structured and aligns with the requirements for Wasm light client support.
14-14
: Verify all upgrade handlers are updated for the breaking change.
The addition of clientkeeper.Keeper
parameter to CreateUpgradeHandler
is a breaking change that requires updates to all existing upgrade handlers.
Let's verify all upgrade handlers have been properly updated:
✅ Verification successful
All upgrade handlers have been properly updated with the clientkeeper.Keeper parameter
Based on the search results, all upgrade handlers in the codebase have been updated to include the clientkeeper.Keeper
parameter:
- app/upgrades/v1_1_0/constants.go
- app/upgrades/v1_2_0/constants.go
- app/upgrades/v1_3_0/constants.go
- app/upgrades/v1_4_0/constants.go
- app/upgrades/v2_1_0/constants.go
Each handler follows the new signature pattern and accepts all three parameters: *module.Manager
, module.Configurator
, and clientkeeper.Keeper
.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check all upgrade handlers for the new parameter pattern
# Expected: All CreateUpgradeHandler implementations should use clientkeeper.Keeper
# Search for CreateUpgradeHandler implementations
ast-grep --pattern 'CreateUpgradeHandler := func($_, $_, $_) types.UpgradeHandler'
# Also check for any potentially missed handlers
rg -A 5 "CreateUpgradeHandler.*func.*UpgradeHandler"
Length of output: 3335
app/upgrades/v1_2_0/constants.go (1)
8-8
: LGTM: Import addition aligns with the new clientKeeper parameter.
The addition of the clientkeeper
import from ibc-go/v7
is necessary for the new parameter type in the upgrade handler.
app/upgrades/v1_4_0/constants.go (1)
8-8
: LGTM: Import addition is appropriate.
The addition of the clientkeeper import from ibc-go v7 aligns with the PR's objective of enabling Wasm light clients.
app/upgrades/v1_1_0/constants.go (2)
8-8
: LGTM: Import added correctly
The import for clientkeeper
from ibc-go v7 is properly added to support the new parameter.
Line range hint 18-22
: Verify: Handler might be missing Wasm client initialization
The clientKeeper
parameter is added but not utilized in the upgrade handler. Given that this PR aims to enable Wasm light clients on IBC, the handler should potentially include initialization or migration logic for Wasm clients.
Let's check other upgrade handlers for similar patterns:
Consider whether this upgrade handler should:
- Initialize any Wasm client-specific parameters
- Migrate existing client states
- Set up any required Wasm client configurations
Would you like assistance in implementing the Wasm client initialization logic?
app/upgrades/v2_1_0/constants.go (4)
1-12
: LGTM: Imports are well-organized and necessary.
All required dependencies are properly imported for the upgrade functionality.
14-14
: LGTM: Version constant follows semantic versioning.
The upgrade name follows the standard format and matches the intended version.
28-30
: LGTM: Store upgrades correctly configured.
The store upgrades configuration properly adds the Wasm module to support the new functionality.
23-23
: Verify error handling for SetParams.
The SetParams
call could potentially return an error that should be handled before proceeding with migrations.
app/upgrades.go (2)
13-13
: LGTM: Import follows consistent pattern
The import for the new v2.1.0 upgrade package follows the established pattern and semantic versioning convention.
21-21
: Verify upgrade version compatibility
The addition of v2.1.0 upgrade follows the correct sequence and pattern. Given this upgrade's importance for the Euclid Protocol launch across multiple testnets, let's verify the upgrade configuration.
✅ Verification successful
Let me gather more information about the upgrade configuration and its dependencies.
Upgrade version v2.1.0 is properly configured and compatible
The verification confirms:
- Correct version sequence: v1.1.0 → v1.2.0 → v1.3.0 → v1.4.0 → v2.1.0
- Proper upgrade handler implementation that adds wasm client type to IBC params
- No version conflicts or inconsistencies in the codebase
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify upgrade configuration and dependencies
# Check upgrade name consistency
echo "Verifying upgrade name consistency..."
rg -l "v2\.1\.0" --type go
# Check for any potential version conflicts or dependencies
echo "Checking for version references..."
rg "UpgradeName.*2\.1\.0" --type go -A 5
Length of output: 802
Script:
#!/bin/bash
# Check the upgrade sequence and dependencies
# Check previous upgrade version
echo "Checking previous upgrade version..."
rg "UpgradeName.*1\.4\.0" --type go -A 5
# List all upgrade versions in chronological order
echo "Listing all upgrade versions..."
fd -e go -e md . app/upgrades/ -x rg -l "UpgradeName.*=.*v[0-9]+\.[0-9]+\.[0-9]+"
# Check upgrade handler implementation
echo "Checking upgrade handler implementation..."
ast-grep --pattern 'func($_, $_, $_) upgradetypes.UpgradeHandler {
$$$
}'
Length of output: 6432
app/upgrades/v1_3_0/constants.go (2)
Line range hint 26-63
: Missing Wasm light client initialization in upgrade handler.
The upgrade handler initializes the ICA module but doesn't include any initialization for Wasm light clients. According to the PR objectives, this upgrade should enable Wasm light clients on IBC.
Let's check if Wasm light client initialization exists elsewhere:
#!/bin/bash
# Search for Wasm-related initializations or configurations
rg -l "wasm" --type go
# Search specifically for IBC Wasm client setup
ast-grep --pattern 'func($_) {
$$$
wasm$_
$$$
}'
Consider adding the following to the upgrade handler:
- Initialize Wasm light client parameters
- Register any required Wasm client types
- Set up necessary state migrations for Wasm client support
Would you like assistance in implementing these changes?
26-26
:
Unused parameter clientKeeper
in CreateUpgradeHandler.
The clientKeeper
parameter is added to the function signature but is not utilized within the upgrade handler. This suggests incomplete implementation of the Wasm light client functionality.
Let's verify if other upgrade handlers use this parameter:
app/keepers/all_keepers.go (1)
13-13
: LGTM! Verify keeper initialization.
The import statement is correctly added and follows the standard Go conventions.
Let's verify the keeper initialization and usage:
✅ Verification successful
Keeper initialization and dependencies verified successfully
The verification shows that:
- WasmKeeper is properly initialized before WasmClientKeeper
- WasmClientKeeper is correctly initialized with the shared WasmVM instance
- Both keepers are properly integrated into the app's dependency chain
- No initialization conflicts or dependency issues found
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Verify the initialization of WasmClientKeeper and its dependencies
# Test 1: Check keeper initialization
rg -A 10 "WasmClientKeeper.*=.*ibcwasmkeeper\.NewKeeper"
# Test 2: Check for any potential conflicts with existing Wasm keeper
rg "WasmKeeper.*=.*wasmkeeper\.NewKeeper"
Length of output: 620
Script:
#!/bin/bash
# Let's verify the initialization order and dependencies
# Check if WasmKeeper is initialized before WasmClientKeeper
rg -B 10 -A 10 "WasmKeeper.*=.*wasmkeeper\.NewKeeper" app/keepers.go
# Check if there are any other references to these keepers
rg "WasmClientKeeper|WasmKeeper" --type go
Length of output: 3129
cmd/nibid/cmd/init.go (2)
11-11
: LGTM: Required imports for IBC Wasm integration.
The new imports are correctly versioned and necessary for enabling the Wasm light client functionality.
Also applies to: 30-31
136-140
: Verify security implications of enabling Wasm clients.
While the implementation correctly adds Wasm to the allowed clients list, this is a significant security change that requires careful consideration:
- Enabling Wasm clients allows arbitrary light client implementations to be deployed.
- This change only affects newly initialized chains.
Let's verify the upgrade handling for existing chains:
Consider adding:
- Documentation comments explaining the security implications
- Validation of Wasm client configurations during runtime
- Explicit error handling for IBC state modifications
go.mod (2)
17-17
: LGTM: IBC-Go version update
The update to github.com/cosmos/ibc-go/v7 v7.4.0
aligns with the PR objective of enabling Wasm light clients.
60-60
: Verify compatibility with development version of Wasm light client module
The Wasm light client module is pinned to a development version (v0.3.2-0.20240730185603-13c071f0b34d
). While this might be necessary for early integration, it could pose stability risks.
Let's verify the compatibility between the IBC-Go and Wasm light client versions:
✅ Verification successful
Let me gather more information about the specific version compatibility and usage.
Let me check one more aspect to understand the integration better.
Development version of Wasm light client module appears stable and properly integrated
Based on the evidence gathered:
- The Wasm light client module is properly initialized using
ibcwasmkeeper.NewKeeperWithVM
with appropriate parameters - The feature was intentionally added as shown in CHANGELOG.md: "feat: enable wasm light clients on IBC (08-wasm)"
- The module is used alongside IBC-Go v7.4.0, which is a stable release
- The development version (v0.3.2-0.20240730185603-13c071f0b34d) appears to be a pre-release that's been specifically integrated and tested with the codebase
While it's a development version, the integration appears intentional and properly configured. The stability risk is mitigated by the proper initialization and its use alongside a stable IBC-Go version.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Description: Check if the Wasm light client module is compatible with IBC-Go v7.4.0
# Test 1: Check if the module version is referenced in IBC-Go's go.mod
rg -A 5 "github.com/cosmos/ibc-go/modules/light-clients/08-wasm"
# Test 2: Look for any compatibility notes or requirements
fd -t f "README.md" | xargs rg -i "compatibility|requirement|version"
Length of output: 4239
Script:
#!/bin/bash
# Check for version constraints and usage in the codebase
# Look for version constraints in go.mod
rg "github.com/cosmos/ibc-go/v7" go.mod -A 2
# Check for Wasm light client initialization and configuration
ast-grep --pattern 'ibcwasmkeeper.NewKeeper($_)'
# Look for any upgrade handlers or migration code related to Wasm light client
fd -t f "upgrades" | xargs rg -i "wasm.*light.*client"
# Check for any specific version requirements or constraints in docs
fd -t f ".md" | xargs rg -i "wasm.*light.*client|ibc.*version"
Length of output: 416
Script:
#!/bin/bash
# Check for specific configuration and initialization of the Wasm light client
# Look for Wasm light client configuration in app setup
rg -A 10 "ibcwasmkeeper.NewKeeper"
# Check for any specific commit references or version constraints
rg -A 3 "13c071f0b34d"
# Look for any specific configuration or parameters in the app initialization
rg "RegisterWasmLightClient"
Length of output: 1380
CHANGELOG.md (1)
Line range hint 25-35
: LGTM on versioning structure!
The changelog follows semantic versioning best practices with:
- Clear version numbers (MAJOR.MINOR.PATCH)
- Release dates included
- Proper separation of unreleased changes
- Well-organized sections for different types of changes
app/app.go (2)
13-15
: Imports added are appropriate
The new import statements for cmtos
, cmtproto
, and ibcwasmkeeper
are necessary for the added IBC WASM functionalities.
246-249
: 🛠️ Refactor suggestion
Improve error handling in snapshot extension registration
When registering snapshot extensions, it's beneficial to provide specific error messages for easier debugging. Currently, if an error occurs, the message is generic and doesn't specify which snapshotter failed to register.
Consider modifying the error handling to include the actual error and specify which extension failed:
if err := snapshotManager.RegisterExtensions(
wasmkeeper.NewWasmSnapshotter(
app.CommitMultiStore(),
&app.WasmKeeper,
),
ibcwasmkeeper.NewWasmSnapshotter(
app.CommitMultiStore(),
&app.WasmClientKeeper,
),
); err != nil {
- panic("failed to add wasm snapshot extension.")
+ panic(fmt.Sprintf("failed to register snapshot extensions: %v", err))
}
This change will output the specific error encountered during registration.
Likely invalid or redundant comment.
app/keepers.go (10)
7-8
: Correctly imported ibcwasm packages
The import statements for ibcwasm
and ibcwasmkeeper
are correctly added to support the IBC Wasm light client functionality.
21-21
: Added necessary import for wasmvm package
The import of the wasmvm
package is correctly added, which is essential for interacting with the WASM virtual machine.
90-90
: Imported ibcwasmtypes package
The ibcwasmtypes
package is correctly imported, providing necessary type definitions for the IBC Wasm light client.
202-202
: Added ibcwasm StoreKey to store keys
The ibcwasmtypes.StoreKey
is correctly added to the list of store keys in initStoreKeys()
, which is necessary for proper state management of the IBC Wasm module.
460-466
: Initialized WASM VM instance for reuse
The WASM VM is initialized outside the keeper using wasmvm.NewVM
, allowing it to be reused in both the WasmKeeper
and WasmClientKeeper
. The parameters passed are appropriate, and handling the error with a panic is acceptable in this initialization context.
485-486
: Configured WasmKeeper with the shared WASM VM
The WasmKeeper
is correctly configured to use the shared wasmVM
instance by appending wasmkeeper.WithWasmEngine(wasmVM)
to the options. This ensures consistency and efficient resource utilization.
488-494
: Initialized WasmClientKeeper with the shared WASM VM
The WasmClientKeeper
is properly initialized using ibcwasmkeeper.NewKeeperWithVM
, reusing the shared wasmVM
instance. The parameters provided, including appCodec
, keys
, ClientKeeper
, and GRPCQueryRouter
, are appropriate.
658-658
: Included ibcwasm module in application modules
The ibcwasm
module is correctly included in the list of application modules through ibcwasm.NewAppModule(app.WasmClientKeeper)
, enabling its functionalities within the application.
730-730
: Added ibcwasm module to ordered module names
The ibcwasmtypes.ModuleName
is appropriately added to the orderedModuleNames
list, ensuring the correct initialization order and integration with begin and end block hooks.
837-837
: Included ibcwasm AppModuleBasic in ModuleBasicManager
The ibcwasm.AppModuleBasic{}
is correctly added to the ModuleBasicManager
, registering the basic functionality of the IBC Wasm module and ensuring proper module setup.
Purpose / Abstract
Summary by CodeRabbit
New Features
v2.1.0
.Bug Fixes
Refactor
Tests
Documentation