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: add params to disable script #254

Merged
merged 1 commit into from
Aug 23, 2024
Merged

Conversation

beer-1
Copy link
Member

@beer-1 beer-1 commented Aug 22, 2024

Description

Closes: #XXXX


Author Checklist

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.

I have...

  • included the correct type prefix in the PR title, you can find examples of the prefixes below:
  • confirmed ! in the type prefix if API or client breaking change
  • targeted the correct branch
  • provided a link to the relevant issue or specification
  • reviewed "Files changed" and left comments if necessary
  • included the necessary unit and integration tests
  • updated the relevant documentation or specification, including comments for documenting Go code
  • confirmed all CI checks have passed

Reviewers Checklist

All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.

I have...

  • confirmed the correct type prefix in the PR title
  • confirmed all author checklist items have been addressed
  • reviewed state machine logic, API design and naming, documentation is accurate, tests and test coverage

@beer-1 beer-1 requested a review from a team as a code owner August 22, 2024 14:05
@beer-1 beer-1 self-assigned this Aug 22, 2024
Copy link

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Manifest Files

Copy link

coderabbitai bot commented Aug 22, 2024

Walkthrough

Walkthrough

The changes introduce a new Vesting structure in the governance module and modifications to the Params and RawParams structures to include a ScriptEnabled boolean flag. The Script method in the MsgServer now checks if script execution is enabled, while various files have been updated to manage script execution parameters, including error handling for disabled scripts. The updates enhance functionality across the governance and move modules.

Changes

Files Change Summary
api/initia/gov/v1/gov.pulsar.go Added Vesting structure and updates to Params for handling vesting information; updated reflection methods and protobuf definitions.
api/initia/move/v1/types.pulsar.go Changed list structure from _Params_4_list to _Params_5_list; added ScriptEnabled boolean field to Params and RawParams.
proto/initia/move/v1/types.proto Added script_enabled boolean field to Params and RawParams; changed the index of allowed_publishers.
x/move/keeper/msg_server.go Modified Script method to include a check for script execution status; changed context parameter name.
x/move/keeper/msg_server_test.go Added Test_ScriptDisabled to test behavior when script functionality is disabled.
x/move/keeper/params.go Introduced ScriptEnabled method to the Keeper struct for retrieving script execution status.
x/move/types/errors.go Added new error constant ErrScriptDisabled for scenarios where script execution is not permitted.
x/move/types/params.go Introduced DefaultScriptEnabled constant; updated DefaultParams function to include this new parameter.

Sequence Diagram(s)

sequenceDiagram
    participant MsgServer
    participant Params
    participant Keeper
    participant User

    User->>MsgServer: Request Script Execution
    MsgServer->>Keeper: Check ScriptEnabled
    Keeper-->>MsgServer: Return ScriptEnabled status
    alt Script Enabled
        MsgServer->>User: Execute Script
    else Script Disabled
        MsgServer->>User: Return ErrScriptDisabled
    end
Loading

🐇 In fields of code so bright and new,
A vesting structure hops into view.
With scripts now toggled, oh what a sight,
Governance dances with all its might!
Errors caught, like carrots held tight,
In this code garden, everything feels right! 🌼


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

codecov bot commented Aug 22, 2024

Codecov Report

Attention: Patch coverage is 62.50000% with 6 lines in your changes missing coverage. Please review.

Project coverage is 40.62%. Comparing base (6e1f68e) to head (126ff07).
Report is 1 commits behind head on main.

Files Patch % Lines
x/move/keeper/msg_server.go 57.14% 1 Missing and 2 partials ⚠️
x/move/keeper/params.go 50.00% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main     #254   +/-   ##
=======================================
  Coverage   40.61%   40.62%           
=======================================
  Files         264      264           
  Lines       25082    25096   +14     
=======================================
+ Hits        10187    10195    +8     
- Misses      13326    13329    +3     
- Partials     1569     1572    +3     
Files Coverage Δ
x/move/types/params.go 75.60% <100.00%> (+0.92%) ⬆️
x/move/keeper/msg_server.go 45.05% <57.14%> (-0.08%) ⬇️
x/move/keeper/params.go 44.06% <50.00%> (+0.67%) ⬆️

Copy link

@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 6e1f68e and 126ff07.

Files ignored due to path filters (2)
  • client/docs/swagger-ui/swagger.yaml is excluded by !**/*.yaml
  • x/move/types/types.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (8)
  • api/initia/gov/v1/gov.pulsar.go (25 hunks)
  • api/initia/move/v1/types.pulsar.go (31 hunks)
  • proto/initia/move/v1/types.proto (2 hunks)
  • x/move/keeper/msg_server.go (1 hunks)
  • x/move/keeper/msg_server_test.go (1 hunks)
  • x/move/keeper/params.go (1 hunks)
  • x/move/types/errors.go (1 hunks)
  • x/move/types/params.go (4 hunks)
Additional comments not posted (25)
x/move/types/errors.go (1)

51-52: New error constant ErrScriptDisabled added.

The addition of ErrScriptDisabled is consistent with the existing error handling pattern and enhances error management by providing a specific error for disabled script execution.

x/move/keeper/params.go (1)

51-59: New method ScriptEnabled added to Keeper.

The ScriptEnabled method is well-implemented, providing functionality to check if script execution is enabled. It includes proper error handling for parameter retrieval.

x/move/types/params.go (4)

17-18: New constant DefaultScriptEnabled added.

The addition of DefaultScriptEnabled with a value of true enhances configuration options and is integrated seamlessly into the default parameters.


39-39: Integration of ScriptEnabled into DefaultParams.

The ScriptEnabled field is correctly included in the DefaultParams function, ensuring it is part of the default parameter set.


79-79: Propagation of ScriptEnabled in ToRaw method.

The ScriptEnabled field is correctly propagated in the ToRaw method, maintaining consistency in parameter conversion.


90-90: Propagation of ScriptEnabled in ToParams method.

The ScriptEnabled field is correctly propagated in the ToParams method, ensuring consistent handling in parameter conversion.

proto/initia/move/v1/types.proto (2)

33-34: Addition of script_enabled field.

The script_enabled field is added to both Params and RawParams messages to control script execution. This change aligns with the PR's objective to introduce parameters for disabling scripts. Ensure that this field is correctly handled in all relevant parts of the codebase.

Also applies to: 60-61


38-38: Reordering of fields in Params.

The allowed_publishers field index has been updated from 4 to 5. Ensure that this change does not affect backward compatibility with existing serialized data.

Run the following script to verify the usage of Params and ensure compatibility:

x/move/keeper/msg_server_test.go (1)

69-82: Addition of Test_ScriptDisabled.

The test function Test_ScriptDisabled effectively verifies the behavior when script execution is disabled. This enhances test coverage and ensures robustness.

x/move/keeper/msg_server.go (2)

140-145: Script execution check in Script method.

The addition of a check to determine if script execution is enabled enhances the robustness of the method by ensuring that scripts are only executed when allowed.


140-140: Context parameter name change.

The change from context to ctx for the parameter name is a good practice to avoid shadowing the built-in context package and aligns with Go conventions.

api/initia/gov/v1/gov.pulsar.go (9)

243-243: Addition of fd_Params_vesting is appropriate.

The declaration of the field descriptor for the new Vesting field in the Params struct is necessary for its management.


268-268: Initialization of fd_Params_vesting is correct.

The field descriptor for the Vesting field is properly initialized in the init() function.


450-455: Update to Range method is appropriate.

Including the Vesting field in the Range method ensures consistent handling of all fields in the Params struct.


509-510: Update to Has method is correct.

The method now checks for the presence of the Vesting field, consistent with other fields in the Params struct.


565-566: Update to Clear method is appropriate.

The method now clears the Vesting field, maintaining consistency with other fields in the Params struct.


652-654: Update to Get method is correct.

The method now retrieves the value of the Vesting field, consistent with other fields in the Params struct.


721-722: Update to Set method is appropriate.

The method now sets the value of the Vesting field, maintaining consistency with other fields in the Params struct.


787-791: Update to Mutable method is correct.

The method now provides a mutable reference to the Vesting field, consistent with other fields in the Params struct.


873-875: Update to NewField method is appropriate.

The method now returns a new value for the Vesting field, maintaining consistency with other fields in the Params struct.

api/initia/move/v1/types.pulsar.go (5)

19-59: LGTM: Version increment for _Params_5_list.

The changes from _Params_4_list to _Params_5_list are straightforward and correctly handle list operations.


Line range hint 433-489: LGTM: Serialization updates for ScriptEnabled field.

The ProtoMethods functions correctly handle the serialization and deserialization of the ScriptEnabled field.

Also applies to: 1082-1123


657-675: LGTM: Unmarshalling updates for ScriptEnabled field.

The Unmarshal functions correctly parse the ScriptEnabled field.

Also applies to: 1290-1309


Line range hint 68-348: LGTM: Addition of ScriptEnabled field in Params.

The ScriptEnabled field is consistently handled across methods in the Params struct.

However, ensure that the usage of ScriptEnabled is correctly integrated across the codebase.

Run the following script to verify the usage of ScriptEnabled:

Verification successful

Verification Successful: ScriptEnabled is consistently integrated across the codebase.

The ScriptEnabled field is well-represented in various parts of the codebase, including parameter management, message handling, and tests. This suggests that the integration is thorough and consistent.

  • Files with ScriptEnabled references:
    • x/move/keeper/params.go
    • x/move/keeper/msg_server.go
    • x/move/keeper/msg_server_test.go
    • x/move/types/params.go
    • x/move/types/types.pb.go
    • api/initia/move/v1/types.pulsar.go
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `ScriptEnabled` in the codebase.

# Test: Search for the usage of `ScriptEnabled`. Expect: Consistent usage across the codebase.
rg --type go 'ScriptEnabled'

Length of output: 4065


Line range hint 748-1000: LGTM: Addition of ScriptEnabled field in RawParams.

The ScriptEnabled field is consistently handled across methods in the RawParams struct.

However, ensure that the usage of ScriptEnabled is correctly integrated across the codebase.

Run the following script to verify the usage of ScriptEnabled:

Verification successful

Verified: Consistent usage of ScriptEnabled across the codebase.

The ScriptEnabled field is consistently integrated and used across various files and contexts, including protobuf definitions, comparisons, and function implementations.

  • Files and contexts:
    • x/move/types/types.pb.go: Field definition and usage in comparisons.
    • x/move/keeper/msg_server_test.go: Test case assignments.
    • x/move/keeper/msg_server.go: Function calls.
    • x/move/keeper/params.go: Function definitions and returns.
    • api/initia/move/v1/types.pulsar.go: Multiple method implementations and accessors.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify all references to `ScriptEnabled` in the codebase.

# Test: Search for the usage of `ScriptEnabled`. Expect: Consistent usage across the codebase.
rg --type go 'ScriptEnabled'

Length of output: 4065

@beer-1 beer-1 merged commit cfafc11 into main Aug 23, 2024
10 checks passed
@beer-1 beer-1 deleted the feat/add-script-enabled-params branch August 23, 2024 04:56
This was referenced Sep 23, 2024
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.

1 participant