Skip to content
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

Tung/add wasm client wasmvm v2.0.0 #168

Merged

Conversation

tungleanh0902
Copy link
Contributor

@tungleanh0902 tungleanh0902 commented Mar 14, 2024

Closes: #122

This pull request implements the WASM light client with wasmvm v2.0.0-rc2. Close dublicate pull request #153

Summary by CodeRabbit

  • New Features
    • Integrated WebAssembly (WASM) functionality for enhanced smart contract capabilities.
    • Implemented a multi-stage build process for the application, optimizing deployment efficiency.
  • Refactor
    • Updated the initialization process and registration of modules to accommodate new WASM features.
  • Chores
    • Adjusted the local node start-up script for improved execution path accuracy.

Copy link
Contributor

coderabbitai bot commented Mar 14, 2024

Important

Auto Review Skipped

Review was skipped due to path filters

Files ignored due to path filters (2)
  • go.mod is excluded by: !**/*.mod
  • go.sum is excluded by: !**/*.sum

Walkthrough

This update introduces a multi-stage Docker build for a Golang application, enhancing the project with wasm functionality for improved performance and flexibility. Key changes include the integration of the ibc wasm client, adjustments in keeper initialization, and updates to script commands for starting local nodes, ensuring the application is lightweight and efficient.

Changes

Files Change Summary
Dockerfile Introduced a multi-stage build process for efficiency and security.
app/app.go, app/upgrades.go Integrated wasm functionality, added Wasm08Keeper, updated keepers initialization, and included wasm migrations.
scripts/start_local_node.sh Modified the command to adjust the executable path for starting a local node.

Assessment against linked issues

Objective Addressed Explanation
Wasm Light Client Integration (#122)

Poem

In the code's vast garden, a rabbit hops around,
Weaving wasm threads, where light clients are found.
With Docker's embrace and Alpine's light touch,
The binary blooms, not weighing much.
🐰💻✨
Through the digital meadow, under the moon's soft glow,
CodeRabbit leaps, making the blockchain flow.

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?

Share

Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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: 3

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between 6d0c170 and 5d4287f.
Files ignored due to path filters (2)
  • go.mod is excluded by: !**/*.mod
  • go.sum is excluded by: !**/*.sum
Files selected for processing (4)
  • Dockerfile (1 hunks)
  • app/app.go (14 hunks)
  • app/upgrades.go (2 hunks)
  • scripts/start_local_node.sh (1 hunks)
Check Runs (1)
lint completed (5)
  • app/app.go: 38-38: SA1019: "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" is deprecated: The legacy v1beta1 gov types maintained in this file are deprecated and will be removed in a future release. Please use MsgIBCSoftwareUpgrade and MsgRecoverClient in favour of the legacy v1beta1 gov proposal types. (staticcheck)
  • app/upgrades.go: 10-10: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmWasm/wasmd) --custom-order (gci)
  • app/upgrades.go: 23-23: File is not gci-ed with --skip-generated -s standard -s default -s prefix(cosmossdk.io) -s prefix(github.com/cosmos/cosmos-sdk) -s prefix(github.com/CosmWasm/wasmd) --custom-order (gci)
Additional comments: 16
Dockerfile (7)
  • 1-1: The base image golang:1.21-alpine3.18 is a good choice for building Go applications, providing a balance between size and the necessary build tools. However, ensure that this version aligns with the project's compatibility requirements.
  • 3-7: Using build arguments LIBWASM_VERSION and LIBWASM_CHECKSUM with subsequent checks ensures that the build process is parameterized and secure. This approach allows for flexibility and verification of the wasmvm library version being used.
  • 9-9: Adding necessary build dependencies is crucial for the compilation process. However, consider documenting why each package is needed, especially for less obvious ones like libusb-dev, to improve maintainability.
  • 20-23: Copying local directories (internal, testing, modules) and the LICENSE file before running go mod download is a good practice to ensure that any local overrides are respected. This step is crucial for builds that depend on local modules not yet available in remote repositories.
  • 28-30: Setting the working directory to /go/modules/light-clients/08-wasm before running go mod download is specific to the project structure. Ensure that this path accurately reflects the location of the Go module that needs to be built.
  • 32-32: The build command is comprehensive, including various build tags and linker flags to optimize the binary. Ensure that all flags and build tags (netgo, ledger, muslc) are necessary and correctly configured for the project's requirements.
  • 34-38: Switching to a lightweight alpine:3.18 image for the final stage and copying the built binary is a good practice for optimizing the image size. Ensure that the runtime dependencies of the binary (if any) are satisfied by the Alpine image.
scripts/start_local_node.sh (3)
  • 5-5: The definition of EVED with the --home flag is a good practice for specifying the home directory. Ensure that the EVE_HOME path is correctly set and that the eved executable path is accurate.
  • 5-5: The script appears to be well-structured and follows good practices for initializing and configuring a local node. However, ensure that the eved command and its flags are up-to-date with the latest version of the software being used.
  • 5-5: The commented-out section at the end of the script related to starting the daemon, adding a governator, and bringing the daemon back to the foreground suggests that this part of the script is either under development or optional. Consider clarifying its purpose or removing it if it's no longer needed.
app/upgrades.go (1)
  • 10-11: The addition of imports for v2 "github.com/CosmWasm/wasmd/x/wasm/migrations/v2" and wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" is crucial for supporting WASM migrations and types. Ensure that these imports are used within the file and that their versions are compatible with the rest of the project.
app/app.go (5)
  • 12-22: The addition of imports related to WASM functionality, including wasmvm, wasm08, wasm08keeper, and wasm08types, is crucial for integrating wasmvm v2.0.0-rc2. These imports enable the application to utilize the latest WASM light client capabilities and contract handling.
  • 153-157: The introduction of the ContractMemoryLimit constant is a significant change. It sets a memory limit for each contract execution, ensuring that all nodes run with the same limit and thus maintain consistency across the network. This is a critical parameter for managing resource usage in contract execution.
  • 248-248: The inclusion of a new Wasm08Keeper entity is a key part of integrating wasmvm v2.0.0-rc2. This keeper is essential for managing the lifecycle and execution of WASM contracts under the new version, ensuring that the application can effectively utilize the enhanced capabilities of wasmvm.
  • 506-513: Creating a new WASM VM instance with wasmvm.NewVM is a critical step in integrating wasmvm v2.0.0-rc2. The configuration, including the directory for WASM binaries, capabilities, memory limit, and other parameters, is essential for the proper functioning of WASM contracts within the application. This setup ensures that the application is equipped to handle WASM contracts with the updated wasmvm version.
  • 528-535: The initialization of Wasm08Keeper with NewKeeperWithVM is an important change. It configures the keeper with the newly created WASM VM instance, enabling the application to manage and execute WASM contracts using the latest wasmvm version. This adjustment is crucial for leveraging the enhanced capabilities of wasmvm v2.0.0-rc2.

app/app.go Outdated
@@ -31,7 +35,7 @@
ibctransferkeeper "github.com/cosmos/ibc-go/v8/modules/apps/transfer/keeper"
ibctransfertypes "github.com/cosmos/ibc-go/v8/modules/apps/transfer/types"
ibc "github.com/cosmos/ibc-go/v8/modules/core"
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types" //nolint:staticcheck
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The import github.com/cosmos/ibc-go/v8/modules/core/02-client/types is marked as deprecated. It's recommended to use MsgIBCSoftwareUpgrade and MsgRecoverClient in favor of the legacy v1beta1 gov proposal types to ensure future compatibility and leverage the latest IBC functionalities.

- import ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
+ // Consider replacing deprecated types with their updated counterparts

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.

Suggested change
ibcclienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
// Consider replacing deprecated types with their updated counterparts

Comment on lines +14 to +16
ADD https://github.com/CosmWasm/wasmvm/releases/download/${LIBWASM_VERSION}/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.x86_64.a
RUN sha256sum /lib/libwasmvm_muslc.x86_64.a | grep ${LIBWASM_CHECKSUM}
RUN cp /lib/libwasmvm_muslc.x86_64.a /lib/libwasmvm_muslc.a
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Downloading and verifying the libwasmvm_muslc.x86_64.a library directly from GitHub ensures that the specific version of wasmvm is used. This is a secure practice as it uses checksum verification. However, consider handling potential download failures or checksum mismatches more gracefully.

app/upgrades.go Outdated
Comment on lines 10 to 11
v2 "github.com/CosmWasm/wasmd/x/wasm/migrations/v2"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The file's import order does not follow the Go conventions, which typically group standard library imports separately from third-party packages. Consider reordering the imports to improve readability and maintainability.

import (
	"fmt"

	"github.com/eve-network/eve/app/upgrades"
	upgradetypes "cosmossdk.io/x/upgrade/types"
+	v2 "github.com/CosmWasm/wasmd/x/wasm/migrations/v2"
+	wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"

	"github.com/cosmos/cosmos-sdk/baseapp"
	authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
	banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
	crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
	distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
	govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
	govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
	minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
	paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
	paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
	slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
	stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

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.

Suggested change
v2 "github.com/CosmWasm/wasmd/x/wasm/migrations/v2"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
import (
"fmt"
"github.com/eve-network/eve/app/upgrades"
upgradetypes "cosmossdk.io/x/upgrade/types"
v2 "github.com/CosmWasm/wasmd/x/wasm/migrations/v2"
wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types"
"github.com/cosmos/cosmos-sdk/baseapp"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
crisistypes "github.com/cosmos/cosmos-sdk/x/crisis/types"
distrtypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
govv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
minttypes "github.com/cosmos/cosmos-sdk/x/mint/types"
paramskeeper "github.com/cosmos/cosmos-sdk/x/params/keeper"
paramstypes "github.com/cosmos/cosmos-sdk/x/params/types"
slashingtypes "github.com/cosmos/cosmos-sdk/x/slashing/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

Copy link
Contributor

@coderabbitai coderabbitai bot left a 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 UI

Commits Files that changed from the base of the PR and between 5d4287f and 677f258.
Files selected for processing (1)
  • app/app.go (13 hunks)
Files skipped from review as they are similar to previous changes (1)
  • app/app.go

Copy link
Collaborator

@hoank101 hoank101 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hoank101 hoank101 merged commit 5c3a2f1 into eve-network:main Mar 14, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Wasm Light Client Integration
2 participants