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

feat(rollapp): add vm type to rollapp registration #1040

Merged
merged 7 commits into from
Aug 7, 2024

Conversation

zale144
Copy link
Contributor

@zale144 zale144 commented Aug 6, 2024

Description


Closes #1036

All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow-up issues.

PR review checkboxes:

I have...

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Targeted PR against the correct branch
  • included the correct type prefix in the PR title
  • Linked to the GitHub issue with discussion and accepted design
  • Targets only one GitHub issue
  • Wrote unit and integration tests
  • Wrote relevant migration scripts if necessary
  • All CI checks have passed
  • Added relevant godoc comments
  • Updated the scripts for local run, e.g genesis_config_commands.sh if the PR changes parameters
  • Add an issue in the e2e-tests repo if necessary

SDK Checklist

  • Import/Export Genesis
  • Registered Invariants
  • Registered Events
  • Updated openapi.yaml
  • No usage of go map
  • No usage of time.Now()
  • Used fixed point arithmetic and not float arithmetic
  • Avoid panicking in Begin/End block as much as possible
  • No unexpected math Overflow
  • Used sendCoin and not SendCoins
  • Out-of-block compute is bounded
  • No serialized ID at the end of store keys
  • UInt to byte conversion should use BigEndian

Full security checklist here

----;

For Reviewer:

  • Confirmed the correct type prefix in the PR title
  • Reviewers assigned
  • Confirmed all author checklist items have been addressed

---;

After reviewer approval:

  • In case the PR targets the main branch, PR should not be squash merge in order to keep meaningful git history.
  • In case the PR targets a release branch, PR must be rebased.

Summary by CodeRabbit

  • New Features

    • Introduced a new VMType field to enhance Rollapp functionality, allowing specific configurations based on virtual machine types such as EVM and WASM.
    • Updated command-line interfaces to include a required vm-type argument for creating Rollapps, improving clarity and specificity.
  • Bug Fixes

    • Corrected the usage string for the proposer address in the command interface to reduce user confusion.
  • Documentation

    • Enhanced changelog to reflect recent changes and their impacts on Rollapp functionalities.

@zale144 zale144 self-assigned this Aug 6, 2024
@zale144 zale144 requested a review from a team as a code owner August 6, 2024 10:12
Copy link
Contributor

coderabbitai bot commented Aug 6, 2024

Walkthrough

The changes introduce a VMType field to enhance the Rollapp functionality, allowing for the specification of virtual machine types (EVM, WASM). This update improves configuration capabilities and maintains better validation, ensuring that rollapps can be effectively managed within the system. The modifications span various files, impacting structures, functions, and error handling to accommodate this new field.

Changes

Files Change Summary
CHANGELOG.md Added VMType field to Rollapp functionality documentation.
app/apptesting/test_suite.go, x/incentives/client/cli/query_test.go, x/incentives/keeper/suite_test.go Added VmType to struct initialization in respective methods.
app/upgrades/v4/upgrade.go, proto/dymensionxyz/dymension/rollapp/tx.proto Updated methods to include VmType in rollapp creation and upgrades.
ibctesting/utils_test.go, x/rollapp/client/cli/tx_create_rollapp.go Modified methods to accept and handle new vm_type parameter.
proto/dymensionxyz/dymension/rollapp/rollapp.proto Introduced VMType enum and added vm_type field to Rollapp message.
x/rollapp/types/errors.go Introduced ErrInvalidVMType for handling invalid VM types.
x/rollapp/types/message_create_rollapp.go, x/rollapp/types/message_create_rollapp_test.go Updated message creation logic to support new vmType parameter and validation in tests.
x/rollapp/keeper/msg_server_create_rollapp_test.go, x/rollapp/keeper/msg_server_update_rollapp_test.go Added VmType to test instances for rollapp creation and updates.
x/rollapp/types/rollapp.go Updated NewRollapp to include vmType parameter and validation logic for it.
x/rollapp/client/cli/tx_submit_fraud_proposal.go Corrected usage string for proposer address in command.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant CLI
    participant Rollapp
    participant Validator
    participant ErrorHandler

    User->>CLI: Create Rollapp with vm-type
    CLI->>Rollapp: Initialize with vmType
    Rollapp->>Validator: Validate vmType
    Validator-->>Rollapp: Valid
    Rollapp-->>CLI: Rollapp created
    CLI-->>User: Success response

    User->>CLI: Create Rollapp with invalid vm-type
    CLI->>Rollapp: Initialize with vmType
    Rollapp->>Validator: Validate vmType
    Validator-->>Rollapp: Invalid
    Rollapp->>ErrorHandler: Handle ErrInvalidVMType
    ErrorHandler-->>CLI: Error response
    CLI-->>User: Error response
Loading

Assessment against linked issues

Objective Addressed Explanation
Include VM type in Rollapp registration (#1036)
Ensure enum is updatable via governance proposals (#1036) No explicit implementation found.
Validate sequencer fields based on VM type (#1036)

🐰 "In fields of code with hop and bounce,
A VM type now makes us pounce!
With changes grand, we leap in glee,
Configuring rollapps, oh so free!
For EVM or WASM, we now decide,
In our coding burrow, we'll take pride!" 🐇


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 testing code 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 testing code 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 testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

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 an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • 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/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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.

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
ibctesting/utils_test.go (1)

130-130: Update function calls to match the new signature.

Several instances of createRollapp in the test files still use the old signature. These need to be updated to include the new rollappType parameter.

  • x/rollapp/keeper/msg_server_create_rollapp_test.go
    • Line 1: suite.createRollapp(nil)
  • ibctesting/genesis_transfer_test.go
    • Line 1: s.createRollapp(false, nil)
  • ibctesting/transfers_enabled_test.go
    • Line 1: s.createRollapp(false, nil)

Please update these instances to match the new function signature.

Analysis chain

LGTM! But verify the function usage in the codebase.

The code changes are approved.

However, ensure that all function calls to createRollapp match the new signature.


Verify the function usage in the codebase with the new signature.

The initial search results show multiple instances of createRollapp and related functions. To ensure all calls match the new signature, we need to inspect the parameters passed in each call.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all function calls to `createRollapp` match the new signature.

# Test: Search for the function usage. Expect: Only occurrences of the new signature.
rg --type go -A 5 $'createRollapp'

Length of output: 6631


Script:

#!/bin/bash
# Description: Extract full context of createRollapp function calls to verify parameters.

# Search for createRollapp function calls and include more context lines to see the parameters.
rg --type go -A 10 $'createRollapp'

Length of output: 10728

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 16ddee6 and 3e2fc04.

Files ignored due to path filters (2)
  • x/rollapp/types/rollapp.pb.go is excluded by !**/*.pb.go
  • x/rollapp/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (16)
  • CHANGELOG.md (1 hunks)
  • app/apptesting/test_suite.go (1 hunks)
  • app/upgrades/v4/upgrade.go (1 hunks)
  • ibctesting/utils_test.go (1 hunks)
  • proto/dymensionxyz/dymension/rollapp/rollapp.proto (1 hunks)
  • proto/dymensionxyz/dymension/rollapp/tx.proto (1 hunks)
  • x/incentives/client/cli/query_test.go (1 hunks)
  • x/incentives/keeper/suite_test.go (1 hunks)
  • x/rollapp/client/cli/tx_create_rollapp.go (3 hunks)
  • x/rollapp/client/cli/tx_submit_fraud_proposal.go (1 hunks)
  • x/rollapp/keeper/msg_server_create_rollapp_test.go (11 hunks)
  • x/rollapp/keeper/msg_server_update_rollapp_test.go (4 hunks)
  • x/rollapp/types/errors.go (1 hunks)
  • x/rollapp/types/message_create_rollapp.go (3 hunks)
  • x/rollapp/types/message_create_rollapp_test.go (3 hunks)
  • x/rollapp/types/rollapp.go (3 hunks)
Files skipped from review due to trivial changes (1)
  • x/rollapp/client/cli/tx_submit_fraud_proposal.go
Additional context used
GitHub Check: build
x/rollapp/types/rollapp.go

[failure] 35-35:
undefined: types

GitHub Check: Analyze
x/rollapp/types/rollapp.go

[failure] 35-35:
undefined: types

Additional comments not posted (34)
x/rollapp/types/message_create_rollapp.go (2)

18-18: LGTM! The new parameter vmType is correctly integrated.

The function signature and the struct initialization are correctly updated to include the new vmType parameter.

Also applies to: 28-28


62-62: LGTM! The new field VmType is correctly integrated into the GetRollapp method.

The method now correctly includes msg.VmType in its return values.

x/rollapp/client/cli/tx_create_rollapp.go (5)

17-17: LGTM! The command usage is correctly updated to include the new argument vm-type.

The command usage now correctly reflects the new required argument.


19-19: LGTM! The command example is correctly updated to include the new argument vm-type.

The command example now correctly reflects the new required argument.


20-20: LGTM! The command arguments are correctly updated to include the new argument vm-type.

The command arguments now correctly reflect the new required argument.


25-27: LGTM! The VM type validation is correctly implemented.

The VM type is validated against a predefined set of values and an error is returned if the provided vm-type is invalid.


57-57: LGTM! The message creation logic is correctly updated to include the new argument vm-type.

The message creation logic now correctly reflects the new required argument.

proto/dymensionxyz/dymension/rollapp/rollapp.proto (3)

56-60: LGTM! The new enumeration VMType is correctly defined.

The new enumeration defines three possible values: Unspecified, EVM, and WASM.


61-62: LGTM! The new field vm_type is correctly added to the Rollapp message.

The new field is properly integrated into the message.


64-64: LGTM! The field tag update for sealed is correctly implemented.

The field sealed has been moved to a new tag to accommodate the new vm_type field.

proto/dymensionxyz/dymension/rollapp/tx.proto (1)

41-42: Addition of vm_type field to MsgCreateRollapp

The addition of the vm_type field enhances the MsgCreateRollapp message by allowing the specification of the rollapp machine type, which can be either EVM or WASM. This change is consistent with the PR objectives and improves the flexibility of rollapp configurations.

Ensure that the vm_type field is properly validated and utilized in the rollapp creation logic.

x/incentives/client/cli/query_test.go (1)

41-41: Addition of VmType field to CreateDefaultRollapp

The addition of the VmType field in the CreateDefaultRollapp method ensures that the rollapp being created will utilize the EVM type. This change is consistent with the PR objectives and improves the specificity of rollapp configurations.

Ensure that the VmType field is properly validated and utilized in the rollapp creation logic.

x/rollapp/types/errors.go (1)

45-45: Addition of ErrInvalidVMType error variable

The addition of the ErrInvalidVMType error variable enhances the error handling capabilities by specifically addressing issues related to invalid VM types. This change is consistent with the PR objectives and improves feedback for developers and users.

Ensure that this error is properly used in the rollapp creation and validation logic.

app/apptesting/test_suite.go (1)

49-49: LGTM! Verify the usage of the new VmType field.

The VmType field is correctly added and initialized to rollapptypes.Rollapp_EVM.

Ensure that the usage of the new VmType field is consistent throughout the codebase.

Verification successful

The VmType field is consistently used throughout the codebase.

The search results indicate that the VmType field is correctly integrated and utilized in various parts of the codebase, including tests and protobuf definitions.

  • x/incentives/keeper/suite_test.go
  • x/rollapp/types/message_create_rollapp_test.go
  • x/rollapp/types/rollapp.pb.go
  • x/rollapp/types/message_create_rollapp.go
  • x/rollapp/types/rollapp.go
  • x/rollapp/types/tx.pb.go
  • x/incentives/client/cli/query_test.go
  • x/rollapp/keeper/msg_server_update_rollapp_test.go
  • x/rollapp/keeper/msg_server_create_rollapp_test.go
  • app/upgrades/v4/upgrade.go
  • app/apptesting/test_suite.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of the new `VmType` field.

# Test: Search for the `VmType` field usage. Expect: Consistent usage of the new field.
rg --type go 'VmType'

Length of output: 3748

x/rollapp/types/rollapp.go (2)

24-24: Add the vmType parameter to the NewRollapp function.

The vmType parameter is correctly added to the function signature.


86-89: LGTM! The validation logic for the VmType field is correctly implemented.

The ValidateBasic method now includes validation for the VmType field.

x/rollapp/types/message_create_rollapp_test.go (3)

30-30: LGTM! The VmType field is correctly added to the test case.

The VmType field is correctly added and initialized to Rollapp_EVM in the "valid - full features" test case.


74-74: LGTM! The VmType field is correctly added to the test case.

The VmType field is correctly added and initialized to Rollapp_EVM in the "valid address" test case.


160-160: LGTM! The VmType field is correctly added to the test case.

The VmType field is correctly added and initialized to Rollapp_EVM in the "invalid metadata: invalid logo data uri" test case.

app/upgrades/v4/upgrade.go (1)

150-151: LGTM! But verify the handling of the VmType field in the codebase.

The addition of the VmType field aligns with the PR objectives. Ensure that the new field is properly handled in the rest of the codebase.

Verification successful

The VmType field is properly integrated and handled across the codebase.

The addition of the VmType field aligns with the PR objectives, and its usage is consistent in various parts of the codebase, including protobuf definitions, message creation, validation, and tests.

  • The placeholder value rollapptypes.Rollapp_EVM is used consistently, but ensure it is appropriate for all contexts or consider making it dynamic if needed.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the `VmType` field in the codebase.

# Test: Search for the usage of the `VmType` field. Expect: Proper handling in the codebase.
rg --type go -A 5 $'VmType'

Length of output: 16305

x/incentives/keeper/suite_test.go (1)

219-219: LGTM! But verify the handling of the VmType field in the codebase.

The addition of the VmType field aligns with the PR objectives. Ensure that the new field is properly handled in the rest of the codebase.

x/rollapp/keeper/msg_server_update_rollapp_test.go (3)

46-46: LGTM! But verify the handling of the VmType field in the codebase.

The addition of the VmType field aligns with the PR objectives. Ensure that the new field is properly handled in the rest of the codebase.

Verification successful

LGTM! The VmType field is properly handled in the codebase.

The VmType field is integrated into various parts of the codebase, including protobuf definitions, message creation, and testing, indicating that it is well-supported and correctly handled.

  • Files and locations confirming proper handling:
    • x/rollapp/types/tx.pb.go
    • x/rollapp/types/rollapp.go
    • x/rollapp/types/message_create_rollapp.go
    • x/rollapp/keeper/msg_server_update_rollapp_test.go
    • x/rollapp/keeper/msg_server_create_rollapp_test.go
    • app/upgrades/v4/upgrade.go
    • app/apptesting/test_suite.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the `VmType` field in the codebase.

# Test: Search for the usage of the `VmType` field. Expect: Proper handling in the codebase.
rg --type go -A 5 $'VmType'

Length of output: 16305


181-181: LGTM! But verify the handling of the VmType field in the codebase.

The addition of the VmType field aligns with the PR objectives. Ensure that the new field is properly handled in the rest of the codebase.

Verification successful

LGTM! The VmType field is properly handled in the codebase.

The addition of the VmType field aligns with the PR objectives and is correctly integrated into the protobuf messages, validation logic, and test cases.

  • Files and locations:
    • x/rollapp/types/tx.pb.go
    • x/rollapp/types/message_create_rollapp_test.go
    • x/rollapp/types/rollapp.go
    • x/rollapp/types/message_create_rollapp.go
    • x/rollapp/types/rollapp.pb.go
    • x/rollapp/keeper/msg_server_update_rollapp_test.go
    • x/rollapp/keeper/msg_server_create_rollapp_test.go
    • x/incentives/keeper/suite_test.go
    • x/incentives/client/cli/query_test.go
    • app/upgrades/v4/upgrade.go
    • app/apptesting/test_suite.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the `VmType` field in the codebase.

# Test: Search for the usage of the `VmType` field. Expect: Proper handling in the codebase.
rg --type go -A 5 $'VmType'

Length of output: 16305


121-121: LGTM! But verify the handling of the VmType field in the codebase.

The addition of the VmType field aligns with the PR objectives. Ensure that the new field is properly handled in the rest of the codebase.

Verification successful

The VmType field appears to be properly handled in the codebase.

The field is integrated into various parts of the code, including message creation, validation, and protobuf serialization/deserialization, indicating thorough handling.

  • Files and contexts where VmType is handled:
    • x/rollapp/types/rollapp.go
    • x/rollapp/types/message_create_rollapp.go
    • x/rollapp/types/tx.pb.go
    • x/rollapp/types/rollapp.pb.go
    • Various test files
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the handling of the `VmType` field in the codebase.

# Test: Search for the usage of the `VmType` field. Expect: Proper handling in the codebase.
rg --type go -A 5 $'VmType'

Length of output: 16305

x/rollapp/keeper/msg_server_create_rollapp_test.go (9)

36-36: LGTM!

The inclusion of the VmType field enhances the test by specifying the VM type for the rollapp.


58-58: LGTM!

The inclusion of the VmType field enhances the test by specifying the VM type for the rollapp.


70-70: LGTM!

The inclusion of the VmType field enhances the test by specifying the VM type for the rollapp.


133-133: LGTM!

The inclusion of the VmType field enhances the test by specifying the VM type for the rollapp.


199-199: LGTM!

The inclusion of the VmType field enhances the test by specifying the VM type for the rollapp.


260-260: LGTM!

The inclusion of the VmType field enhances the test by specifying the VM type for the rollapp.


278-278: LGTM!

The inclusion of the VmType field enhances the test by specifying the VM type for the rollapp.


322-322: LGTM!

The inclusion of the VmType field enhances the test by specifying the VM type for the rollapp.


350-350: LGTM!

The inclusion of the VmType field enhances the test by specifying the VM type for the rollapp.

CHANGELOG.md (1)

46-46: LGTM!

The inclusion of the VMType field in the changelog is consistent with the PR objectives and provides necessary information to users and developers.

x/rollapp/types/rollapp.go Outdated Show resolved Hide resolved
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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3e2fc04 and 1b7d37c.

Files ignored due to path filters (1)
  • x/rollapp/types/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (1)
  • proto/dymensionxyz/dymension/rollapp/tx.proto (1 hunks)
Files skipped from review as they are similar to previous changes (1)
  • proto/dymensionxyz/dymension/rollapp/tx.proto

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.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 1b7d37c and 90760ae.

Files selected for processing (2)
  • x/rollapp/types/message_create_rollapp_test.go (12 hunks)
  • x/rollapp/types/rollapp.go (3 hunks)
Files skipped from review as they are similar to previous changes (2)
  • x/rollapp/types/message_create_rollapp_test.go
  • x/rollapp/types/rollapp.go

mtsitrin
mtsitrin previously approved these changes Aug 7, 2024
@@ -12,25 +14,30 @@ import (

func CmdCreateRollapp() *cobra.Command {
Copy link
Contributor

Choose a reason for hiding this comment

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

@zale144 I guess it's better to add long description with possible fields and expected values

x/rollapp/types/rollapp.go Show resolved Hide resolved
omritoptix
omritoptix previously approved these changes Aug 7, 2024
@omritoptix
Copy link
Contributor

no need for adding manual entry to changelog as it will collide with the automated process

@omritoptix omritoptix changed the title feat(rollapp): Add vm type to rollapp registration feat(rollapp): add vm type to rollapp registration Aug 7, 2024
@zale144 zale144 dismissed stale reviews from omritoptix and mtsitrin via d2765d1 August 7, 2024 08:52
@omritoptix omritoptix merged commit 2a8d639 into main Aug 7, 2024
6 checks passed
@omritoptix omritoptix deleted the zale144/1036-add-vm-type-to-rollapp-registration branch August 7, 2024 09:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

include vm type in the rollapp registration
3 participants