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

x/intent: add unified MsgNewAction tx for creating new actions #321

Merged
merged 14 commits into from
Jun 5, 2024

Conversation

Pitasi
Copy link
Contributor

@Pitasi Pitasi commented May 27, 2024

closes #261

Big PR, sorry. I suggest reviewing this commit by commit.

  • I introduced the concept of IntentsRegistry. Basically, other modules such as x/warden are able to plug their logic to fetch the intent definition for their message types (e.g. MsgAddSpaceOwner will fetch the AdminIntent for the space)
  • I changed how Actions are executed. Instead of the user sending MsgAddSpaceOwner and the handler creating the right action for it, the user now sends a MsgNewAction that wraps a MsgAddSpaceOwner. The handler for MsgAddSpaceOwner is called by the authority of the x/intent module. This is also how x/gov works when executing any Msg after a proposal passes.

rationale: this has several benefits. First of all, we don't leak x/intent concepts such as "btl" (now renamed to TimeoutHeight) into other modules. Then, we also have a single point where Action are created and a single point where Action are executed, this will make it possible to implement things such as cronjobs.

Summary by CodeRabbit

  • New Features

    • Introduced a new RPC method to create actions.
    • Added new response messages for key management and space owner updates.
    • Implemented a registry for managing intents.
  • Improvements

    • Updated response messages for various actions to provide more specific feedback.
    • Enhanced error handling and validation for message signers.
    • Improved context setup for message handling.
  • Bug Fixes

    • Fixed issues related to incorrect signer validation for action messages.
  • Refactor

    • Renamed fields for clarity and consistency.
    • Simplified message server implementation by removing redundant handlers.

Copy link
Contributor

coderabbitai bot commented May 27, 2024

Walkthrough

Walkthrough

The recent changes introduce a new MsgNewAction transaction to the Warden protocol, allowing users to create actions generically. This reduces boilerplate code and enhances flexibility. Key modifications include the addition of new message types, changes to existing RPC methods, and updates to message handling logic to support the new transaction. The MsgActionCreated message has been removed, and various functions and structures have been updated to support the new timeout_height field and intent handling.

Changes

File(s) Change Summary
proto/warden/intent/action.proto Renamed btl to timeout_height in Action message; removed MsgActionCreated.
proto/warden/intent/tx.proto Added NewAction RPC method; defined MsgNewAction and MsgNewActionResponse.
proto/warden/warden/v1beta2/tx.proto Updated RPC methods to return specific response messages; renamed creator to authority.
warden/app/wasm-interop/custom_msg.go Added imports; updated message encoding logic; introduced MsgNewAction.
warden/testutil/keeper/intent.go Added intentRegistry initialization; updated keeper.NewKeeper call.
warden/testutil/keeper/warden.go Added intentAuthority initialization.
warden/x/intent/keeper/actions.go Updated ExecuteAction function; added new functions for message handling and validation.
warden/x/intent/module/module.go Added Router and IntentRegistry fields to ModuleInputs and ModuleOutputs.
warden/x/intent/types/action.go Removed NewMsgActionCreated function; updated NewApprover function.
warden/x/intent/types/codec.go Registered MsgNewAction.
warden/x/intent/types/errors.go Added ErrInvalidActionMsgSigner.
warden/x/intent/types/registry.go Introduced IntentsRegistry for managing intents.
warden/x/warden/keeper/intents.go Added functions for registering and handling intents.
warden/x/warden/keeper/keeper.go Added intentAuthority field; updated NewKeeper function; added GetIntentAuthority method.
warden/x/warden/keeper/msg_server.go Simplified NewMsgServerImpl function.
warden/x/warden/keeper/msg_server_add_space_owner.go Updated AddSpaceOwner function signature; added authority check.
warden/x/intent/keeper/keeper.go Added router and intentsRegistry fields to Keeper; updated NewKeeper function.

Sequence Diagram(s) (Beta)

sequenceDiagram
    participant User
    participant MsgService
    participant IntentKeeper
    participant Router
    participant ModuleAccount

    User->>MsgService: Send MsgNewAction
    MsgService->>IntentKeeper: Create Action
    IntentKeeper->>Router: Route Message
    Router->>ModuleAccount: Execute Message
    ModuleAccount-->>Router: Execution Result
    Router-->>IntentKeeper: Execution Result
    IntentKeeper-->>MsgService: Action Created
    MsgService-->>User: MsgNewActionResponse
Loading

Assessment against linked issues

Objective (Issue #261) Addressed Explanation
Add MsgNewAction transaction
Expose a generic MsgCreateAction
Ensure only x/intents module can execute these messages
Reduce duplicated boilerplate

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 Configration 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.

@Pitasi Pitasi force-pushed the msg-create-action branch 3 times, most recently from 527acef to 27b172a Compare May 31, 2024 15:33
@Pitasi Pitasi marked this pull request as ready for review May 31, 2024 15:43

This comment has been minimized.

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: 4

Outside diff range and nitpick comments (2)
warden/x/warden/types/v1beta2/errors.go (1)

13-13: Add documentation for ErrInvalidActionSigner.

It would be beneficial to add a comment explaining the specific scenarios where ErrInvalidActionSigner is expected to be used. This helps in maintaining clarity and ease of understanding for future developers.

warden/x/intent/types/errors.go (1)

13-13: Add documentation for ErrInvalidActionMsgSigner.

Consider adding a comment detailing the use cases for ErrInvalidActionMsgSigner. This will enhance code readability and help other developers understand the context in which this error should be thrown.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8a55029 and d190ed9.

Files ignored due to path filters (9)
  • api/warden/intent/action.pulsar.go is excluded by !api/**
  • api/warden/intent/tx.pulsar.go is excluded by !api/**
  • api/warden/intent/tx_grpc.pb.go is excluded by !**/*.pb.go, !api/**
  • api/warden/warden/v1beta2/tx.pulsar.go is excluded by !api/**
  • api/warden/warden/v1beta2/tx_grpc.pb.go is excluded by !**/*.pb.go, !api/**
  • go.sum is excluded by !**/*.sum
  • warden/x/intent/types/action.pb.go is excluded by !**/*.pb.go
  • warden/x/intent/types/tx.pb.go is excluded by !**/*.pb.go
  • warden/x/warden/types/v1beta2/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (27)
  • proto/warden/intent/action.proto (2 hunks)
  • proto/warden/intent/tx.proto (2 hunks)
  • proto/warden/warden/v1beta2/tx.proto (8 hunks)
  • warden/app/wasm-interop/custom_msg.go (3 hunks)
  • warden/testutil/keeper/intent.go (1 hunks)
  • warden/testutil/keeper/warden.go (3 hunks)
  • warden/x/intent/keeper/actions.go (5 hunks)
  • warden/x/intent/keeper/keeper.go (5 hunks)
  • warden/x/intent/keeper/msg_server_approve_action.go (1 hunks)
  • warden/x/intent/keeper/msg_server_new_action.go (1 hunks)
  • warden/x/intent/module/module.go (5 hunks)
  • warden/x/intent/types/action.go (1 hunks)
  • warden/x/intent/types/codec.go (1 hunks)
  • warden/x/intent/types/errors.go (1 hunks)
  • warden/x/intent/types/registry.go (1 hunks)
  • warden/x/warden/keeper/intents.go (1 hunks)
  • warden/x/warden/keeper/keeper.go (5 hunks)
  • warden/x/warden/keeper/msg_server.go (2 hunks)
  • warden/x/warden/keeper/msg_server_add_space_owner.go (1 hunks)
  • warden/x/warden/keeper/msg_server_new_key_request.go (3 hunks)
  • warden/x/warden/keeper/msg_server_new_signature_request.go (3 hunks)
  • warden/x/warden/keeper/msg_server_remove_space_owner.go (1 hunks)
  • warden/x/warden/keeper/msg_server_update_key.go (1 hunks)
  • warden/x/warden/keeper/msg_server_update_space.go (1 hunks)
  • warden/x/warden/module/module.go (2 hunks)
  • warden/x/warden/types/expected_keepers.go (1 hunks)
  • warden/x/warden/types/v1beta2/errors.go (1 hunks)
Files skipped from review due to trivial changes (2)
  • warden/x/intent/types/action.go
  • warden/x/warden/keeper/msg_server.go
Additional context used
Path-based instructions (22)
warden/x/warden/types/v1beta2/errors.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/types/errors.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_update_key.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_add_space_owner.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/types/codec.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_remove_space_owner.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/msg_server_new_action.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_update_space.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_new_key_request.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/msg_server_approve_action.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/types/expected_keepers.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/testutil/keeper/intent.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/app/wasm-interop/custom_msg.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_new_signature_request.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/testutil/keeper/warden.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/keeper.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/types/registry.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/keeper.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/intents.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/actions.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/module/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/module/module.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (34)
warden/x/warden/keeper/msg_server_add_space_owner.go (1)

9-9: Ensure robust error handling in AddSpaceOwner.

Similar to UpdateKey, the assertIntentAuthority function is crucial. Verify that it is implemented correctly and that all error paths are covered by unit tests.

warden/x/intent/types/codec.go (1)

12-12: Ensure MsgNewAction is properly registered.

The registration of MsgNewAction appears correct. However, ensure that all necessary fields and methods are implemented correctly in the message to avoid runtime issues.

warden/x/warden/keeper/msg_server_remove_space_owner.go (1)

10-10: Validate error handling in RemoveSpaceOwner.

The function assertIntentAuthority is used here as well. Confirm that it's correctly implemented and thoroughly tested to handle all error scenarios effectively.

warden/x/intent/keeper/msg_server_new_action.go (1)

11-31: Ensure proper error handling and context management in NewAction.

This function correctly unpacks the message, retrieves the intent, and handles errors appropriately. The use of fmt.Errorf to wrap errors helps in maintaining the stack trace which is good for debugging.

warden/x/warden/keeper/msg_server_update_space.go (1)

9-9: Ensure authority checks are robust in UpdateSpace.

The authority check at the beginning of the function is crucial for security. This check prevents unauthorized modifications to the space details.

warden/x/warden/keeper/msg_server_new_key_request.go (1)

Line range hint 10-39: Ensure authority checks and error handling are robust in NewKeyRequest.

The authority check at the beginning and the comprehensive error handling throughout the function ensure that the key request process is secure and errors are managed effectively.

warden/x/intent/keeper/msg_server_approve_action.go (1)

21-21: Ensure timeout handling is accurate in ApproveAction.

The handling of action timeouts is crucial for maintaining the integrity of actions. This implementation correctly updates the action status and manages the error if the action has timed out.

warden/x/warden/types/expected_keepers.go (1)

28-29: Ensure new methods in interfaces are correctly implemented.

The addition of GetActionCreator and IntentRegistry methods to the IntentKeeper interface is crucial for the new functionalities introduced in the protocol. Ensure these methods are implemented correctly in the concrete classes.

warden/testutil/keeper/intent.go (1)

35-44: Ensure test setup is robust in IntentKeeper.

The setup of the test environment for the IntentKeeper is comprehensive, including the initialization of intentRegistry and the configuration of the keeper. This setup ensures that the keeper can be tested effectively in isolation.

warden/app/wasm-interop/custom_msg.go (2)

10-10: Ensure the new import intenttypes is utilized effectively in the file.


37-55: The implementation of EncodeCustomMsg correctly encapsulates the new MsgNewAction logic. However, ensure that error handling is robust and that all possible error paths are considered.

Verification successful

The error handling in EncodeCustomMsg appears to be robust, covering critical points such as JSON unmarshalling and message creation.

  • Lines 37-55 in warden/app/wasm-interop/custom_msg.go handle errors appropriately.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify robust error handling in `EncodeCustomMsg`.

# Test: Search for error handling patterns. Expect: Comprehensive error checks.
rg --type go 'if err != nil' 'warden/app/wasm-interop/custom_msg.go'

Length of output: 103



Script:

#!/bin/bash
# Description: Inspect the specific lines where error checks occur in `custom_msg.go`.

# Extract lines containing 'if err != nil' and their surrounding context.
rg --type go --context 5 'if err != nil' warden/app/wasm-interop/custom_msg.go

Length of output: 691

warden/x/warden/keeper/msg_server_new_signature_request.go (1)

Line range hint 12-62: The implementation of NewSignatureRequest correctly handles authority checks and integrates with other keeper functions. Ensure that all external calls are properly error-handled.

Verification successful

The output indicates that error handling patterns (if err != nil) are present in the NewSignatureRequest function. This suggests that the function is handling errors for its external calls.

  • Lines 8-10: Error handling for k.assertIntentAuthority.
  • Lines 12-14: Error handling for k.KeysKeeper.Get.
  • Lines 16-18: Error handling for k.SpacesKeeper.Get.
  • Lines 20-22: Error handling for k.keychains.Get.
  • Lines 24-30: Error handling for k.bankKeeper.SendCoins.
  • Lines 34-36: Error handling for types.NewSignMethodHandler.
  • Lines 40-42: Error handling for k.cdc.UnpackAny.
  • Lines 44-46: Error handling for handler.Handle.

Given this comprehensive error handling, the implementation appears robust.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify proper error handling in external calls within `NewSignatureRequest`.

# Test: Search for error handling patterns. Expect: Comprehensive error checks.
rg --type go 'if err != nil' 'warden/x/warden/keeper/msg_server_new_signature_request.go'

Length of output: 209

warden/testutil/keeper/warden.go (1)

Line range hint 20-45: The initialization of intentAuthority in the test utility is correctly implemented. Ensure that this utility is consistently used across all relevant tests.

Verification successful

The intentAuthority is consistently used across the relevant test files through the WardenKeeper function.

  • warden/x/warden/keeper/query_params_test.go
  • warden/x/warden/keeper/query_keys_by_space_id_test.go
  • warden/x/warden/keeper/query_all_keys_test.go
  • warden/x/warden/keeper/params_test.go
  • warden/x/warden/keeper/msg_server_test.go
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify consistent usage of `intentAuthority` in tests.

# Test: Search for usage patterns of `intentAuthority`. Expect: Consistent usage across tests.
rg --type go 'intentAuthority' 'warden/testutil/keeper/'

Length of output: 219



Script:

#!/bin/bash
# Description: Verify usage of `WardenKeeper` function in test files.

# Test: Search for usage patterns of `WardenKeeper`. Expect: Consistent usage across tests.
rg --type go 'WardenKeeper' 'warden/testutil/keeper/' 'warden/x/warden/keeper/'

Length of output: 590

warden/x/intent/keeper/keeper.go (1)

Line range hint 11-103: The modifications to the Keeper struct, including the addition of router and intentsRegistry, are correctly implemented. The new IntentRegistry method provides a clean interface for accessing the intents registry.

Verification successful

The integration of router and intentsRegistry in the Keeper implementation appears to be correctly done. The search results show that these components are used appropriately within the keeper.go file and other related files.

  • router is used to handle messages in actions.go.
  • intentsRegistry is used to get intents in msg_server_new_action.go.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of `router` and `intentsRegistry` in the Keeper.

# Test: Search for usage patterns of `router` and `intentsRegistry`. Expect: Proper integration and usage.
rg --type go '(router|intentsRegistry)' 'warden/x/intent/keeper/'

Length of output: 711

proto/warden/intent/tx.proto (1)

Line range hint 22-69: The addition of the NewAction RPC method and the MsgNewAction message is correctly implemented. Ensure that these new definitions are properly integrated with the rest of the system.

Verification successful

The search results indicate that NewAction and MsgNewAction are referenced in various parts of the codebase, including service implementations and handlers. This suggests that the new definitions are integrated into the system.

  • warden/app/wasm-interop/custom_msg.go: Contains a reference to MsgNewAction.
  • warden/x/intent/types/codec.go: Registers MsgNewAction.
  • warden/x/intent/keeper/msg_server_new_action.go: Implements the NewAction method.
  • proto/warden/intent/tx.proto: Defines NewAction, MsgNewAction, and MsgNewActionResponse.
  • api/warden/intent/tx_grpc.pb.go: Contains gRPC method definitions for NewAction.

These references confirm that the new RPC method and message types are properly integrated into the system.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the integration of `NewAction` and `MsgNewAction` in the system.

# Test: Search for usage patterns of `NewAction` and `MsgNewAction`. Expect: Proper integration and usage.
rg --type proto '(NewAction|MsgNewAction)' 'proto/warden/intent/'

Length of output: 95



Script:

#!/bin/bash
# Description: Verify the integration of `NewAction` and `MsgNewAction` in the system.

# Find all .proto files and search for usage patterns of `NewAction` and `MsgNewAction`.
fd -e proto -x rg '(NewAction|MsgNewAction)' {}

Length of output: 205



Script:

#!/bin/bash
# Description: Verify the integration of `NewAction` and `MsgNewAction` in the system.

# Search for references to `NewAction` and `MsgNewAction` in the entire codebase.
rg 'NewAction|MsgNewAction'

Length of output: 26335

warden/x/intent/types/registry.go (6)

10-20: The IntentsRegistry struct is well-documented and clearly explains its purpose and usage. This is crucial for maintainability and understanding the codebase, especially for new developers.


31-40: The generic Register function enhances type safety by ensuring that the callback function accepts a sdk.Msg of the correct type. This is a good use of generics to enforce type constraints at compile time.


46-55: Similarly, the RegisterCtx function uses generics to ensure type safety for context-aware provider functions. This consistency in using generics for both context and non-context functions is commendable.


60-65: The NewIntentsRegistry function correctly initializes an IntentsRegistry with an empty map. This is a standard pattern for constructing new instances in Go, ensuring that the map is ready to use.


67-94: The Register and RegisterCtx methods include robust error handling by panicking when an invalid state is detected (e.g., empty typeUrl or nil function). This preemptive check prevents subtle bugs in runtime by enforcing correct usage patterns during development.


96-106: The Get method provides a clear error message when no provider is registered for a given sdk.Msg type. This explicit error handling is crucial for debugging and maintaining the registry.

warden/x/warden/keeper/keeper.go (2)

Line range hint 69-118: The constructor NewKeeper now includes intentAuthority as a parameter, which is validated similarly to authority. This consistency in validation is good practice. However, ensure that the intentAuthority is used correctly throughout the module to enforce intended security policies.


29-31: The addition of intentAuthority to the Keeper struct is a significant change. It's important to ensure that all uses of this new authority are properly audited to maintain security and correct access control.

Verification successful

The addition of intentAuthority to the Keeper struct has been properly integrated with access control measures. The assertIntentAuthority method in keeper.go ensures that the provided address matches the expected authority, maintaining security and correct access control.

  • warden/x/warden/keeper/keeper.go: Proper access control is enforced via the assertIntentAuthority method.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all uses of `intentAuthority` to ensure proper access control.

# Test: Search for the usage of `intentAuthority`. Expect: Proper checks before usage.
rg --type go $'intentAuthority'

Length of output: 793



Script:

#!/bin/bash
# Extract and review the context around each usage of `intentAuthority` to ensure proper access control.

# Extract 5 lines before and after each match for context
rg --type go --context 5 'intentAuthority'

Length of output: 5905

warden/x/warden/keeper/intents.go (2)

13-20: The RegisterIntents method correctly registers various intent handlers. This centralization of registration is good for maintainability and ensures that all intent handlers are registered in one place.


22-33: Each intent function is well-structured and handles errors appropriately by returning them up the call stack. This consistent error handling strategy helps in maintaining robustness and reliability of the module.

Also applies to: 35-46, 48-59, 61-98, 100-117, 119-130

proto/warden/warden/v1beta2/tx.proto (1)

28-33: The changes in the RPC method signatures and message structures, such as the addition of authority fields, align with the PR's objectives to centralize authority and enhance security. Ensure that these fields are used consistently and securely throughout the application.

Also applies to: 44-44, 51-51, 60-60, 64-64, 105-106, 114-115, 142-143, 162-163, 193-194, 202-203

warden/x/intent/keeper/actions.go (4)

72-104: The ExecuteAction function is critical as it executes actions based on the messages. The use of a cache context and proper error handling within this function are good practices. However, ensure that the error handling logic does not inadvertently suppress important errors that should be propagated up the stack.


115-125: The safeExecuteHandler function adds a layer of robustness by recovering from panics. This is crucial in a blockchain context where unexpected failures can have significant repercussions.


Line range hint 148-178: The AddAction function encapsulates the creation and immediate execution of actions well. It handles various edge cases and errors effectively, contributing to the module's resilience.


206-221: The validateActionMsgSigners function ensures that the message signers are correctly validated against the module's authority. This is a critical security feature to prevent unauthorized actions.

warden/x/intent/module/module.go (1)

190-190: The ProvideModule function and the ModuleInputs and ModuleOutputs structs are well-defined and follow good software engineering practices by clearly separating input and output dependencies. This modular design aids in testing and maintenance.

Also applies to: 201-241

warden/x/warden/module/module.go (3)

26-26: Import of intenttypes is correctly added to integrate with the x/intent module.


217-223: Initialization of intentAuthority using intenttypes.ModuleName is correctly implemented.


217-223: The usage of intentAuthority in the ProvideModule function is correctly implemented, ensuring that the authority is properly set for intent handling.

IntentsRegistry stores mappings between typeUrls and function that
returns an intent.

Example:
MsgAddSpaceOwner -> function of x/warden that returns the Space's
AdminIntent
@Pitasi Pitasi force-pushed the msg-create-action branch from d190ed9 to 9798f43 Compare June 3, 2024 12:47
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: 3

Outside diff range and nitpick comments (1)
warden/x/intent/types/registry.go (1)

10-10: Review the documentation for clarity and completeness.

Consider enhancing the documentation for IntentsRegistry to include examples or more detailed explanations of its usage.

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between d190ed9 and e980819.

Files ignored due to path filters (8)
  • api/warden/intent/action.pulsar.go is excluded by !api/**
  • api/warden/intent/tx.pulsar.go is excluded by !api/**
  • api/warden/intent/tx_grpc.pb.go is excluded by !**/*.pb.go, !api/**
  • api/warden/warden/v1beta2/tx.pulsar.go is excluded by !api/**
  • api/warden/warden/v1beta2/tx_grpc.pb.go is excluded by !**/*.pb.go, !api/**
  • warden/x/intent/types/action.pb.go is excluded by !**/*.pb.go
  • warden/x/intent/types/tx.pb.go is excluded by !**/*.pb.go
  • warden/x/warden/types/v1beta2/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (28)
  • .github/workflows/wardend.yml (1 hunks)
  • proto/warden/intent/action.proto (2 hunks)
  • proto/warden/intent/tx.proto (2 hunks)
  • proto/warden/warden/v1beta2/tx.proto (8 hunks)
  • warden/app/wasm-interop/custom_msg.go (3 hunks)
  • warden/testutil/keeper/intent.go (1 hunks)
  • warden/testutil/keeper/warden.go (3 hunks)
  • warden/x/intent/keeper/actions.go (5 hunks)
  • warden/x/intent/keeper/keeper.go (5 hunks)
  • warden/x/intent/keeper/msg_server_approve_action.go (1 hunks)
  • warden/x/intent/keeper/msg_server_new_action.go (1 hunks)
  • warden/x/intent/module/module.go (5 hunks)
  • warden/x/intent/types/action.go (1 hunks)
  • warden/x/intent/types/codec.go (1 hunks)
  • warden/x/intent/types/errors.go (1 hunks)
  • warden/x/intent/types/registry.go (1 hunks)
  • warden/x/warden/keeper/intents.go (1 hunks)
  • warden/x/warden/keeper/keeper.go (5 hunks)
  • warden/x/warden/keeper/msg_server.go (2 hunks)
  • warden/x/warden/keeper/msg_server_add_space_owner.go (1 hunks)
  • warden/x/warden/keeper/msg_server_new_key_request.go (3 hunks)
  • warden/x/warden/keeper/msg_server_new_signature_request.go (3 hunks)
  • warden/x/warden/keeper/msg_server_remove_space_owner.go (1 hunks)
  • warden/x/warden/keeper/msg_server_update_key.go (1 hunks)
  • warden/x/warden/keeper/msg_server_update_space.go (1 hunks)
  • warden/x/warden/module/module.go (2 hunks)
  • warden/x/warden/types/expected_keepers.go (1 hunks)
  • warden/x/warden/types/v1beta2/errors.go (1 hunks)
Files skipped from review due to trivial changes (4)
  • .github/workflows/wardend.yml
  • warden/app/wasm-interop/custom_msg.go
  • warden/x/warden/keeper/msg_server.go
  • warden/x/warden/types/v1beta2/errors.go
Files skipped from review as they are similar to previous changes (19)
  • proto/warden/intent/action.proto
  • proto/warden/intent/tx.proto
  • proto/warden/warden/v1beta2/tx.proto
  • warden/testutil/keeper/intent.go
  • warden/testutil/keeper/warden.go
  • warden/x/intent/keeper/msg_server_approve_action.go
  • warden/x/intent/keeper/msg_server_new_action.go
  • warden/x/intent/module/module.go
  • warden/x/intent/types/action.go
  • warden/x/intent/types/codec.go
  • warden/x/intent/types/errors.go
  • warden/x/warden/keeper/intents.go
  • warden/x/warden/keeper/keeper.go
  • warden/x/warden/keeper/msg_server_add_space_owner.go
  • warden/x/warden/keeper/msg_server_remove_space_owner.go
  • warden/x/warden/keeper/msg_server_update_key.go
  • warden/x/warden/keeper/msg_server_update_space.go
  • warden/x/warden/module/module.go
  • warden/x/warden/types/expected_keepers.go
Additional context used
Path-based instructions (5)
warden/x/warden/keeper/msg_server_new_key_request.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_new_signature_request.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/keeper.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/types/registry.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/actions.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

Additional comments not posted (14)
warden/x/warden/keeper/msg_server_new_key_request.go (4)

10-10: Ensure proper error handling for assertIntentAuthority.

Verification successful

The assertIntentAuthority function is defined in warden/x/warden/keeper/keeper.go and it does handle errors by returning wrapped errors when the authority does not match. This function is used in multiple places, including NewKeyRequest, NewSignatureRequest, RemoveSpaceOwner, AddSpaceOwner, and UpdateSpace.

The error handling in assertIntentAuthority appears to be correctly implemented, as it returns an error when the authority check fails.

  • warden/x/warden/keeper/keeper.go: func (k Keeper) assertIntentAuthority(addr string) error {

The function checks if the provided authority matches the expected authority and returns a wrapped error if it does not.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `assertIntentAuthority` handles all possible error scenarios correctly.

# Test: Search for the function implementation and check error handling.
ast-grep --lang go --pattern $'func (k msgServer) assertIntentAuthority($_) $_ {
  $$$
}'

Length of output: 90



Script:

#!/bin/bash
# Description: Verify the existence and error handling of the `assertIntentAuthority` function.

# Step 1: Search for the definition of the `assertIntentAuthority` function.
rg 'func \(k msgServer\) assertIntentAuthority' -t go

# Step 2: If found, display the function implementation to check error handling.
rg 'func \(k msgServer\) assertIntentAuthority' -t go --context 20

Length of output: 124



Script:

#!/bin/bash
# Description: Verify the existence and error handling of any function related to `assertIntentAuthority`.

# Step 1: Search for any function containing `assertIntentAuthority` in its name or body.
rg 'assertIntentAuthority' -t go --context 20

Length of output: 15549


15-15: Check for potential security issues with GetActionCreator.

Verification successful

The GetActionCreator method retrieves a value from the context using a specific key and returns it as a string. If the value is not found or is not a string, it returns an empty string. This method does not appear to expose sensitive data or allow unauthorized access directly. However, the security of this method depends on how the context is managed and what data is stored under the actionCreatorKey.

  • Ensure that the context is securely managed and that only authorized code can set the actionCreatorKey value.
  • Verify that the actionCreatorKey is not exposed or manipulated in an insecure manner elsewhere in the codebase.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `GetActionCreator` does not expose sensitive data or allow unauthorized access.

# Test: Search for the function implementation and review its security aspects.
ast-grep --lang go --pattern $'func (k msgServer) GetActionCreator($_) $_ {
  $$$
}'

Length of output: 85



Script:

#!/bin/bash
# Description: Broaden the search for the `GetActionCreator` method to locate its definition and review its implementation.

# Search for the definition of `GetActionCreator` in the codebase.
rg 'func.*GetActionCreator' --glob '*.go'

# Once found, extract the implementation of `GetActionCreator` for review.
# Assuming the method is found in a file, extract the relevant lines.
# This part will be executed manually based on the search results.

Length of output: 140



Script:

#!/bin/bash
# Description: Extract the implementation of the `GetActionCreator` method from `warden/x/intent/keeper/actions.go` for review.

# Extract the implementation of `GetActionCreator`.
sed -n '/func (k Keeper) GetActionCreator(ctx context.Context) string {/,/^}/p' warden/x/intent/keeper/actions.go

Length of output: 264


29-29: Review the use of MustAccAddressFromBech32 for potential panics.


39-39: Validate the fields of KeyRequest for correctness.

warden/x/warden/keeper/msg_server_new_signature_request.go (3)

17-17: Check for potential security issues with GetActionCreator.

Verification successful

The GetActionCreator function retrieves a value from the context using a specific key and returns it as a string. If the value is not found or cannot be cast to a string, it returns an empty string. This approach appears to be straightforward and does not inherently expose sensitive data or allow unauthorized access, assuming the context is managed correctly.

  • The function is defined in warden/x/intent/keeper/actions.go.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `GetActionCreator` does not expose sensitive data or allow unauthorized access.

# Test: Search for the function implementation and review its security aspects.
ast-grep --lang go --pattern $'func (k msgServer) GetActionCreator($_) $_ {
  $$$
}'

Length of output: 85



Script:

#!/bin/bash
# Description: Search for the definition of the `GetActionCreator` function in the codebase.

# Search for the function definition in Go files.
rg 'func.*GetActionCreator' --glob '*.go'

# If found, display the implementation of the function.
# Extract the file name and line number, then display the surrounding lines for context.
rg 'func.*GetActionCreator' --glob '*.go' -l | xargs -I {} sh -c 'echo "File: {}"; rg -A 10 -B 10 "func.*GetActionCreator" {}'

Length of output: 888


12-12: Ensure proper error handling for assertIntentAuthority.

Verification successful

The assertIntentAuthority function was found in warden/x/warden/keeper/keeper.go at line 131. However, the subsequent ast-grep command did not provide specific details about the error handling within this function.

To ensure proper error handling for assertIntentAuthority, we need to inspect the function's implementation directly.


The assertIntentAuthority function in warden/x/warden/keeper/keeper.go includes error handling that returns an error if the provided address does not match the expected authority. This confirms that the function handles potential errors appropriately.

  • The function checks if the provided address matches the expected authority.
  • If the addresses do not match, it returns a wrapped error indicating the mismatch.

This error handling appears to be sufficient for the function's purpose.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `assertIntentAuthority` handles all possible error scenarios correctly.

# Test: Search for the function implementation and check error handling.
ast-grep --lang go --pattern $'func (k msgServer) assertIntentAuthority($_) $_ {
  $$$
}'

Length of output: 90



Script:

#!/bin/bash
# Locate the `assertIntentAuthority` function in the codebase
rg 'func (k msgServer) assertIntentAuthority' --no-heading --line-number

# If found, analyze the error handling within the function
ast-grep --lang go --pattern $'func (k msgServer) assertIntentAuthority($_) $_ {
  $$$
}'

Length of output: 165



Script:

#!/bin/bash
# Locate any function with a similar name or purpose to `assertIntentAuthority`
rg 'func .*assert.*Authority' --no-heading --line-number

# If found, analyze the error handling within the function
ast-grep --lang go --pattern $'func $_($_) $_ {
  $$$
}'

Length of output: 168486



Script:

#!/bin/bash
# Display the implementation of the `assertIntentAuthority` function to verify error handling.
sed -n '131,151p' warden/x/warden/keeper/keeper.go

Length of output: 438


62-62: Validate the fields of SignRequest for correctness.

warden/x/intent/keeper/keeper.go (3)

101-101: Review the implementation of IntentRegistry.

Verification successful

The implementation of the IntentRegistry method in the Keeper class has been found. It simply returns the intentsRegistry field of the Keeper struct.

  • Location: warden/x/intent/keeper/keeper.go
  • Implementation:
    func (k Keeper) IntentRegistry() *types.IntentsRegistry {
      return k.intentsRegistry
    }

This implementation appears straightforward, but you may want to manually verify that the intentsRegistry field is properly initialized and managed elsewhere in the codebase.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the implementation of `IntentRegistry` to ensure it handles all edge cases.

# Test: Search for the implementation of `IntentRegistry`.
ast-grep --lang go --pattern $'func (k Keeper) IntentRegistry($_) $_ {
  $$$
}'

Length of output: 80



Script:

#!/bin/bash
# Description: Verify the implementation of `IntentRegistry` in the keeper.go file and the entire repository if not found.

# Test: Search for the implementation of `IntentRegistry` in keeper.go.
ast-grep --lang go --pattern $'func (k Keeper) IntentRegistry() *types.IntentsRegistry {
  $$$
}' warden/x/intent/keeper/keeper.go

# If not found, search the entire repository.
if [ $? -ne 0 ]; then
  ast-grep --lang go --pattern $'func (k Keeper) IntentRegistry() *types.IntentsRegistry {
    $$$
  }'
fi

Length of output: 346


75-75: Check the initialization of router in NewKeeper.


47-47: Ensure NewKeeper function parameters are validated.

warden/x/intent/types/registry.go (1)

62-62: Validate the initialization of IntentsRegistry.

Verification successful

The NewIntentsRegistry function initializes an IntentsRegistry object with the p property set to a map. To ensure that all properties are correctly initialized, we need to check the definition of the IntentsRegistry struct and verify if there are any other properties that require initialization.


The IntentsRegistry struct only contains the p property, which is a map. The NewIntentsRegistry function correctly initializes this property.

  • IntentsRegistry struct:

    • p map[string]ProviderFnWithCtx
  • NewIntentsRegistry function:

    • Initializes p with make(map[string]ProviderFnWithCtx)

No other properties need initialization.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Ensure that `IntentsRegistry` is correctly initialized and all properties are set as expected.

# Test: Search for the initialization of `IntentsRegistry`.
ast-grep --lang go --pattern $'func NewIntentsRegistry() $_ {
  $$$
}'

Length of output: 383



Script:

#!/bin/bash
# Description: Check the definition of the `IntentsRegistry` struct to ensure all properties are initialized.

# Search for the definition of `IntentsRegistry`.
ast-grep --lang go --pattern $'type IntentsRegistry struct {
  $$$
}'

Length of output: 251

warden/x/intent/keeper/actions.go (3)

116-116: Ensure safeExecuteHandler properly handles panics.

Verification successful

The safeExecuteHandler function does include a mechanism to handle panics. Specifically, it uses a deferred function to recover from any panic, logs the panic message, and includes the stack trace. This ensures that the function can handle unexpected errors gracefully.

  • The defer statement is used to ensure that the recovery logic is executed even if a panic occurs.
  • The recover function is used to catch the panic.
  • The error message is formatted to include the message, the panic value, and the stack trace.

Here are the relevant lines from the code:

  • Line 118: defer func() {
  • Line 119: if r := recover(); r != nil {
  • Line 120: err = fmt.Errorf("handling x/intent action msg [%s] PANICKED: %v\n%s", msg, r, string(debug.Stack()))
  • Line 121: }
  • Line 122: }

This confirms that the safeExecuteHandler function properly handles panics.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `safeExecuteHandler` correctly recovers from panics and logs them appropriately.

# Test: Search for panic recovery in `safeExecuteHandler`.
ast-grep --lang go --pattern $'func safeExecuteHandler($_, $_, $_) $_ {
  $$$
}'

Length of output: 805


72-72: Review the error handling in ExecuteAction.

Verification successful

The error handling in the ExecuteAction method is thorough and appropriate. Errors are checked and handled at all critical points, including unpacking the message, finding the handler, executing the handler, setting the result, and persisting the action. Each error is either logged or returned with a formatted message.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify that `ExecuteAction` handles all errors appropriately and logs them correctly.

# Test: Search for error handling in `ExecuteAction`.
ast-grep --lang go --pattern $'func (k Keeper) ExecuteAction($_, $_) $_ {
  $$$
}'

Length of output: 3011


148-148: Check the logic in AddAction for potential issues.

@Pitasi Pitasi force-pushed the msg-create-action branch 2 times, most recently from 2acf7ba to 3ec0c2c Compare June 4, 2024 10:30
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

Outside diff range and nitpick comments (2)
CHANGELOG.md (2)

Line range hint 60-60: Adjust the indentation for list items to maintain consistency and readability.

-    * (shield) Add new operators: `<`, `>`, `<=`, `>=`, `==`, `!=` for comparing integers to each others.
+  * (shield) Add new operators: `<`, `>`, `<=`, `>=`, `==`, `!=` for comparing integers to each others.
-    * (shield) Add support for `string` objects
+  * (shield) Add support for `string` objects
-    * (shield) Add `contains(elem, array)` builtin function for checking if `elem` is contained in the `array`
+  * (shield) Add `contains(elem, array)` builtin function for checking if `elem` is contained in the `array`
-    * (shield) Add `+`, `-`, `*`, `/` math operators for basic integer arithmetic
+  * (shield) Add `+`, `-`, `*`, `/` math operators for basic integer arithmetic
-    * (shield) Add negative prefix operator to handle negative expressions and integers
+  * (shield) Add negative prefix operator to handle negative expressions and integers
-    * (shield) Change integer representation from int64 to big.Int
+  * (shield) Change integer representation from int64 to big.Int

Also applies to: 77-77, 89-90, 114-116, 121-121, 124-124


Line range hint 46-46: Correct grammatical errors to enhance clarity and professionalism.

- * (shield) Add new operators: `<`, `>`, `<=`, `>=`, `==`, `!=` for comparing integers to each others.
+ * (shield) Add new operators: `<`, `>`, `<=`, `>=`, `==`, `!=` for comparing integers to each other.
- * (x/intent) [#117](https://github.com/warden-protocol/wardenprotocol/pull/117) Pin the intent definition when an Action is created instead of just referencing it. This allows faster queries "by address" by storing the list of addresses directly inside the action, instead of having to re-evaluate the linked intent for each action.
+ * (x/intent) [#117](https://github.com/warden-protocol/wardenprotocol/pull/117) Pin the intent definition when an Action is created instead of just referencing it. This allows faster queries "by address" by storing the list of addresses directly inside the action, instead of having to re-evaluate the linked intent for each action.
- * (x/warden) [#122](https://github.com/warden-protocol/wardenprotocol/pull/122) Improve `SpacesByOwner` query by adding a new "owner -> space id" index.
+ * (x/warden) [#122](https://github.com/warden-protocol/wardenprotocol/pull/122) Improve the `SpacesByOwner` query by adding a new "owner -> space id" index.

Also applies to: 113-113, 116-116

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between e980819 and 3ec0c2c.

Files ignored due to path filters (6)
  • api/warden/intent/tx.pulsar.go is excluded by !api/**
  • api/warden/intent/tx_grpc.pb.go is excluded by !**/*.pb.go, !api/**
  • api/warden/warden/v1beta2/tx.pulsar.go is excluded by !api/**
  • api/warden/warden/v1beta2/tx_grpc.pb.go is excluded by !**/*.pb.go, !api/**
  • warden/x/intent/types/tx.pb.go is excluded by !**/*.pb.go
  • warden/x/warden/types/v1beta2/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (25)
  • .github/workflows/wardend.yml (1 hunks)
  • CHANGELOG.md (1 hunks)
  • proto/warden/intent/action.proto (2 hunks)
  • proto/warden/intent/tx.proto (2 hunks)
  • proto/warden/warden/v1beta2/tx.proto (8 hunks)
  • warden/app/wasm-interop/custom_msg.go (3 hunks)
  • warden/testutil/keeper/warden.go (3 hunks)
  • warden/x/intent/keeper/actions.go (5 hunks)
  • warden/x/intent/keeper/keeper.go (5 hunks)
  • warden/x/intent/keeper/msg_server_new_action.go (1 hunks)
  • warden/x/intent/types/action.go (1 hunks)
  • warden/x/intent/types/codec.go (1 hunks)
  • warden/x/intent/types/errors.go (1 hunks)
  • warden/x/warden/keeper/intents.go (1 hunks)
  • warden/x/warden/keeper/keeper.go (5 hunks)
  • warden/x/warden/keeper/msg_server.go (2 hunks)
  • warden/x/warden/keeper/msg_server_add_space_owner.go (1 hunks)
  • warden/x/warden/keeper/msg_server_new_key_request.go (3 hunks)
  • warden/x/warden/keeper/msg_server_new_signature_request.go (3 hunks)
  • warden/x/warden/keeper/msg_server_remove_space_owner.go (1 hunks)
  • warden/x/warden/keeper/msg_server_update_key.go (1 hunks)
  • warden/x/warden/keeper/msg_server_update_space.go (1 hunks)
  • warden/x/warden/module/module.go (2 hunks)
  • warden/x/warden/types/expected_keepers.go (1 hunks)
  • warden/x/warden/types/v1beta2/errors.go (1 hunks)
Files skipped from review as they are similar to previous changes (18)
  • .github/workflows/wardend.yml
  • proto/warden/intent/action.proto
  • proto/warden/intent/tx.proto
  • proto/warden/warden/v1beta2/tx.proto
  • warden/app/wasm-interop/custom_msg.go
  • warden/testutil/keeper/warden.go
  • warden/x/intent/keeper/msg_server_new_action.go
  • warden/x/intent/types/action.go
  • warden/x/intent/types/codec.go
  • warden/x/intent/types/errors.go
  • warden/x/warden/keeper/intents.go
  • warden/x/warden/keeper/keeper.go
  • warden/x/warden/keeper/msg_server.go
  • warden/x/warden/keeper/msg_server_add_space_owner.go
  • warden/x/warden/keeper/msg_server_update_key.go
  • warden/x/warden/module/module.go
  • warden/x/warden/types/expected_keepers.go
  • warden/x/warden/types/v1beta2/errors.go
Additional context used
Path-based instructions (7)
warden/x/warden/keeper/msg_server_remove_space_owner.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_update_space.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_new_key_request.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_new_signature_request.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/keeper.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/actions.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

LanguageTool
CHANGELOG.md

[uncategorized] ~46-~46: The grammatical number of this noun doesn’t look right. Consider replacing it. (AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)
Context: ...tocol/225) Fix shield to handle grouped expression * (shield) Add new operators: <, >,...


[uncategorized] ~113-~113: The grammatical number of this noun doesn’t look right. Consider replacing it. (AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)
Context: ...nd x/warden's store design to improve queries performance: * (x/intent) [#117](ht...


[uncategorized] ~116-~116: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...otocol/wardenprotocol/pull/122) Improve SpacesByOwner query by adding a new "ow...

Markdownlint
CHANGELOG.md

60-60: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


77-77: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


89-89: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


90-90: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


114-114: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


115-115: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


116-116: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


121-121: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


124-124: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


41-41: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


135-135: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


140-140: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


141-141: Expected: 1; Actual: 3 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


121-121: null (MD034, no-bare-urls)
Bare URL used

Additional comments not posted (7)
warden/x/warden/keeper/msg_server_remove_space_owner.go (1)

10-10: Ensure authority validation is robust and correctly implemented.

warden/x/warden/keeper/msg_server_update_space.go (1)

9-9: Ensure authority validation is robust and correctly implemented.

warden/x/warden/keeper/msg_server_new_key_request.go (1)

10-10: Ensure authority validation is robust and correctly implemented.

warden/x/warden/keeper/msg_server_new_signature_request.go (1)

12-12: Ensure authority validation is robust and correctly implemented.

warden/x/intent/keeper/keeper.go (1)

11-11: Ensure all imports are necessary and correctly utilized.

warden/x/intent/keeper/actions.go (1)

6-6: Ensure proper usage of debug information for error handling.

CHANGELOG.md (1)

53-53: Ensure the description of MsgNewAction aligns with the PR objectives and provides sufficient detail about its functionality.

Verification successful

The MsgNewAction entry in the CHANGELOG.md file is consistent with the codebase. The references found in the codebase confirm that MsgNewAction is a unique entry point for creating actions, as described.

  • warden/x/intent/types/tx.pb.go: Defines the MsgNewAction struct and its methods.
  • warden/x/intent/keeper/msg_server_new_action.go: Implements the NewAction method using MsgNewAction.
  • proto/warden/intent/tx.proto: Defines the NewAction RPC method using MsgNewAction.

These references align with the CHANGELOG entry, confirming its accuracy.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the description of `MsgNewAction` in the PR description and objectives.

# Test: Search for `MsgNewAction` in the PR description and objectives. Expect: Consistent and detailed description.
grep -i "MsgNewAction" CHANGELOG.md

Length of output: 109



Script:

#!/bin/bash
# Description: Verify the description of `MsgNewAction` in the PR description and objectives.

# Test: Search for `MsgNewAction` in the PR description and objectives. Expect: Consistent and detailed description.
gh pr view --json body --jq '.body' | grep -i "MsgNewAction"

Length of output: 109



Script:

#!/bin/bash
# Description: Search the codebase for references to `MsgNewAction` to verify its purpose and ensure the CHANGELOG entry is accurate.

# Test: Search for `MsgNewAction` in the codebase. Expect: Detailed references and descriptions.
rg "MsgNewAction"

Length of output: 24588

@Overseven Overseven self-requested a review June 4, 2024 14:06
Pitasi added 9 commits June 5, 2024 13:25
This is quite the paradigm shift on how Actions are created, and more
importantly executed.

Before we let other modules (e.g. x/warden) handle the whole lifecycle
of the Actions. The x/intent module was being called only after new
approvals.

With this commit, we start empowering x/intent, similar to how x/gov
works. In the following commits we'll introduce a single MsgNewAction to
create new actions, and fix the existing x/warden handlers to use the
new flow.

An Action wraps a Msg. Through the base App's MessageRouter, we'll
invoke the correct handler for the wrapped Msg.

The handler called this way should check that the signer (also referred
as "authority") is the address of x/intent module, to avoid arbitrary
users to execute that Msg themselves.
This new transaction message will be the only entrypoint for creating a
new Action, wrapping any other Msg.

The IntentsRegistry is used to fetch the intent to be applied for this
Action (freezing it at the current time) and letting other modules
inject their logic for retrieving it.
It will be used to check that certain msg handlers are only invoked by
x/intent and not by any user.
This is the first message that we're moving onto the new x/intent flow.

In the x/warden module we'll have a separate file defining all the
Intents provider functions for the interesting msg types (such as
MsgAddSpaceOwner) that knows where to fetch the Intent from.
I took the chance to rename "creator" into "authority" since it makes
more sense, as it will be populated with the module account address of
x/intent.

I removed broken code for registering Action handlers, which no longer
exist.

I removed the `btl` field, present in many messages, as it now it's
specified only once in MsgNewAction and will be resposability of
x/intent to handle it.
@Pitasi Pitasi force-pushed the msg-create-action branch from 3ec0c2c to 0e6ed85 Compare June 5, 2024 11:25
@Pitasi Pitasi requested a review from Overseven June 5, 2024 11:26
@Overseven
Copy link
Contributor

How do I run integration tests? I tried to execute just test from tests dir, but got an error: warden node never became running. I'm also tried this instructions

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: 5

Outside diff range and nitpick comments (1)
CHANGELOG.md (1)

Line range hint 60-60: Correct the indentation in the changelog to maintain consistency.

- * (shield) Add new operators: `<`, `>`, `<=`, `>=`, `==`, `!=` for comparing integers to each others.
+ * (shield) Add new operators: `<`, `>`, `<=`, `>=`, `==`, `!=` for comparing integers to each other.

Also applies to: 77-77, 89-89, 90-90, 114-114, 115-115, 116-116, 121-121, 124-124

Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 3ec0c2c and 0e6ed85.

Files ignored due to path filters (8)
  • api/warden/intent/action.pulsar.go is excluded by !api/**
  • api/warden/intent/tx.pulsar.go is excluded by !api/**
  • api/warden/intent/tx_grpc.pb.go is excluded by !**/*.pb.go, !api/**
  • api/warden/warden/v1beta2/tx.pulsar.go is excluded by !api/**
  • api/warden/warden/v1beta2/tx_grpc.pb.go is excluded by !**/*.pb.go, !api/**
  • warden/x/intent/types/action.pb.go is excluded by !**/*.pb.go
  • warden/x/intent/types/tx.pb.go is excluded by !**/*.pb.go
  • warden/x/warden/types/v1beta2/tx.pb.go is excluded by !**/*.pb.go
Files selected for processing (28)
  • .github/workflows/wardend.yml (1 hunks)
  • CHANGELOG.md (1 hunks)
  • proto/warden/intent/action.proto (3 hunks)
  • proto/warden/intent/tx.proto (2 hunks)
  • proto/warden/warden/v1beta2/tx.proto (8 hunks)
  • warden/app/wasm-interop/custom_msg.go (3 hunks)
  • warden/testutil/keeper/intent.go (1 hunks)
  • warden/testutil/keeper/warden.go (3 hunks)
  • warden/x/intent/keeper/actions.go (5 hunks)
  • warden/x/intent/keeper/keeper.go (5 hunks)
  • warden/x/intent/keeper/msg_server_approve_action.go (1 hunks)
  • warden/x/intent/keeper/msg_server_new_action.go (1 hunks)
  • warden/x/intent/module/module.go (5 hunks)
  • warden/x/intent/types/action.go (1 hunks)
  • warden/x/intent/types/codec.go (1 hunks)
  • warden/x/intent/types/errors.go (1 hunks)
  • warden/x/warden/keeper/intents.go (1 hunks)
  • warden/x/warden/keeper/keeper.go (5 hunks)
  • warden/x/warden/keeper/msg_server.go (2 hunks)
  • warden/x/warden/keeper/msg_server_add_space_owner.go (1 hunks)
  • warden/x/warden/keeper/msg_server_new_key_request.go (3 hunks)
  • warden/x/warden/keeper/msg_server_new_signature_request.go (3 hunks)
  • warden/x/warden/keeper/msg_server_remove_space_owner.go (1 hunks)
  • warden/x/warden/keeper/msg_server_update_key.go (1 hunks)
  • warden/x/warden/keeper/msg_server_update_space.go (1 hunks)
  • warden/x/warden/module/module.go (2 hunks)
  • warden/x/warden/types/expected_keepers.go (1 hunks)
  • warden/x/warden/types/v1beta2/errors.go (1 hunks)
Files skipped from review due to trivial changes (1)
  • warden/x/intent/keeper/msg_server_approve_action.go
Files skipped from review as they are similar to previous changes (22)
  • .github/workflows/wardend.yml
  • proto/warden/intent/action.proto
  • proto/warden/intent/tx.proto
  • proto/warden/warden/v1beta2/tx.proto
  • warden/app/wasm-interop/custom_msg.go
  • warden/testutil/keeper/intent.go
  • warden/testutil/keeper/warden.go
  • warden/x/intent/keeper/msg_server_new_action.go
  • warden/x/intent/module/module.go
  • warden/x/intent/types/action.go
  • warden/x/intent/types/codec.go
  • warden/x/intent/types/errors.go
  • warden/x/warden/keeper/intents.go
  • warden/x/warden/keeper/keeper.go
  • warden/x/warden/keeper/msg_server.go
  • warden/x/warden/keeper/msg_server_add_space_owner.go
  • warden/x/warden/keeper/msg_server_remove_space_owner.go
  • warden/x/warden/keeper/msg_server_update_key.go
  • warden/x/warden/keeper/msg_server_update_space.go
  • warden/x/warden/module/module.go
  • warden/x/warden/types/expected_keepers.go
  • warden/x/warden/types/v1beta2/errors.go
Additional context used
Path-based instructions (5)
warden/x/warden/keeper/msg_server_new_key_request.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/warden/keeper/msg_server_new_signature_request.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/keeper.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

warden/x/intent/keeper/actions.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

CHANGELOG.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

LanguageTool
CHANGELOG.md

[uncategorized] ~113-~113: The grammatical number of this noun doesn’t look right. Consider replacing it. (AI_EN_LECTOR_REPLACEMENT_NOUN_NUMBER)
Context: ...nd x/warden's store design to improve queries performance: * (x/intent) [#117](ht...


[uncategorized] ~116-~116: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...otocol/wardenprotocol/pull/122) Improve SpacesByOwner query by adding a new "ow...

Markdownlint
CHANGELOG.md

60-60: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


77-77: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


89-89: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


90-90: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


114-114: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


115-115: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


116-116: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


121-121: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


124-124: Expected: 2; Actual: 4 (MD007, ul-indent)
Unordered list indentation


41-41: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


135-135: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


140-140: Expected: 1; Actual: 2 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


141-141: Expected: 1; Actual: 3 (MD012, no-multiple-blanks)
Multiple consecutive blank lines


121-121: null (MD034, no-bare-urls)
Bare URL used

Additional comments not posted (9)
warden/x/warden/keeper/msg_server_new_key_request.go (2)

10-10: Ensure proper error handling for assertIntentAuthority.

Verification successful

Proper error handling for assertIntentAuthority is implemented in msg_server_new_key_request.go.

  • msg_server_new_key_request.go:11-13: The error handling pattern if err := k.assertIntentAuthority(msg.Authority); err != nil { return nil, err } is present.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify proper error handling for `assertIntentAuthority` in `msg_server_new_key_request.go`.

# Test: Search for error handling around `assertIntentAuthority`.
ast-grep --lang go --pattern $'if err := k.assertIntentAuthority($_); err != nil { $$$ }'

Length of output: 1647


15-15: Check for potential data races when accessing GetActionCreator.

Verification successful

There are no indications of concurrent access to GetActionCreator in the codebase. Additionally, the implementation of GetActionCreator does not involve any internal concurrency mechanisms that could lead to data races.

  • GetActionCreator implementation:
    • File: warden/x/intent/keeper/actions.go
    • Lines: 135-141
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check for potential data races when accessing `GetActionCreator`.

# Test: Search for concurrent access to `GetActionCreator`.
ast-grep --lang go --pattern $'go func() { k.intentKeeper.GetActionCreator($_) }'

Length of output: 82



Script:

#!/bin/bash
# Description: Check for potential data races when accessing `GetActionCreator`.

# Test 1: Search for concurrent access to `GetActionCreator` using different patterns.
ast-grep --lang go --pattern $'go $_ { k.intentKeeper.GetActionCreator($_) }'
ast-grep --lang go --pattern $'go func($_) { k.intentKeeper.GetActionCreator($_) }'

# Test 2: Retrieve the implementation of `GetActionCreator` to inspect for internal concurrency issues.
ast-grep --lang go --pattern $'func ($_ $_) GetActionCreator($_) $_ { $$$ }'

Length of output: 670

warden/x/warden/keeper/msg_server_new_signature_request.go (2)

12-12: Ensure proper error handling for assertIntentAuthority.

Verification successful

Proper error handling for assertIntentAuthority is present in msg_server_new_signature_request.go.

  • msg_server_new_signature_request.go:13-15: Error handling for assertIntentAuthority is implemented correctly.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify proper error handling for `assertIntentAuthority` in `msg_server_new_signature_request.go`.

# Test: Search for error handling around `assertIntentAuthority`.
ast-grep --lang go --pattern $'if err := k.assertIntentAuthority($_); err != nil { $$$ }'

Length of output: 1647


17-17: Check for potential data races when accessing GetActionCreator.

Verification successful

No data races detected when accessing GetActionCreator.

  • The GetActionCreator method simply retrieves a value from the context and does not involve any operations that could cause data races.
  • No concurrent access patterns to GetActionCreator were found in the codebase.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Check for potential data races when accessing `GetActionCreator`.

# Test: Search for concurrent access to `GetActionCreator`.
ast-grep --lang go --pattern $'go func() { k.intentKeeper.GetActionCreator($_) }'

Length of output: 82



Script:

#!/bin/bash
# Description: Check for potential data races when accessing `GetActionCreator`.

# Test 1: Search for concurrent access to `GetActionCreator` using different patterns.
ast-grep --lang go --pattern $'go $_ { k.intentKeeper.GetActionCreator($_) }'

# Test 2: Search for the implementation of `GetActionCreator` to inspect for internal concurrency issues.
ast-grep --lang go --pattern $'func ($_ $_) GetActionCreator($_) $_'

Length of output: 577

warden/x/intent/keeper/keeper.go (1)

47-47: Ensure the authority address is validated correctly.

Verification successful

The validation logic for the authority address in keeper.go is correctly implemented and consistent with other instances in the codebase.

  • warden/x/intent/keeper/keeper.go lines 55-57: The authority address is validated using sdk.AccAddressFromBech32, and an appropriate error message is generated if the address is invalid.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the validation logic for the authority address in `keeper.go`.

# Test: Search for the validation logic for the authority address.
ast-grep --lang go --pattern $'if _, err := sdk.AccAddressFromBech32($_); err != nil { $$$ }'

Length of output: 1152

warden/x/intent/keeper/actions.go (3)

72-72: Ensure proper context handling in ExecuteAction.

Verification successful

Proper context handling in ExecuteAction verified. The method correctly unwraps the SDK context and uses it consistently throughout its operations.

  • sdkCtx := sdk.UnwrapSDKContext(ctx) at line 72 ensures the SDK context is correctly unwrapped.
  • The context is then used in subsequent operations, including preparing the handler context and executing the handler.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify proper context handling in `ExecuteAction`.

# Test: Search for context handling logic in `ExecuteAction`.
ast-grep --lang go --pattern $'func (k Keeper) ExecuteAction(ctx context.Context, act *types.Action) error { $$$ }'

Length of output: 3044


116-116: Ensure error handling in safeExecuteHandler is robust.

Verification successful

The safeExecuteHandler function includes robust error handling by using a deferred function to recover from panics and log detailed error messages. It also captures and returns any errors from the handler.

  • The function uses a deferred function to recover from panics and logs an error message with the panic details and stack trace.
  • It captures and returns any error from the handler.
Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify robust error handling in `safeExecuteHandler`.

# Test: Search for error handling logic in `safeExecuteHandler`.
ast-grep --lang go --pattern $'func safeExecuteHandler(ctx sdk.Context, msg sdk.Msg, handler baseapp.MsgServiceHandler) (res *sdk.Result, err error) { $$$ }'

Length of output: 882


207-207: Validate message signers correctly to ensure security.

Verification successful

The validateActionMsgSigners method in warden/x/intent/keeper/actions.go correctly validates the message signers by:

  1. Retrieving the signers using k.cdc.GetMsgV1Signers(msg).
  2. Checking for errors in retrieving the signers.
  3. Ensuring there is exactly one signer.
  4. Verifying that the signer's address matches the expected authority.

This logic ensures that the message signers are validated correctly, maintaining security.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the validation logic for message signers in `actions.go`.

# Test: Search for the validation logic for message signers.
ast-grep --lang go --pattern $'func (k Keeper) validateActionMsgSigners(msg sdk.Msg) error { $$$ }'

Length of output: 1077

CHANGELOG.md (1)

53-53: Ensure the changelog entry for MsgNewAction is clear and accurate.

Verification successful

The changelog entry for MsgNewAction is present and accurately describes the addition of MsgNewAction as a unique entry point for creating actions. The implementation and usage of MsgNewAction are well-documented in the codebase, confirming the changelog's accuracy.

  • The MsgNewAction struct is defined in multiple files, including tx.pb.go and tx.pulsar.go.
  • The struct includes fields such as Creator, Message, and ActionTimeoutHeight.
  • The MsgNewAction is used in various parts of the codebase, including custom_msg.go, codec.go, and msg_server_new_action.go.

The changelog entry is clear and accurate.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify the changelog entry for `MsgNewAction`.

# Test: Search for the changelog entry for `MsgNewAction`.
rg 'MsgNewAction' CHANGELOG.md

Length of output: 104



Script:

#!/bin/bash
# Description: Locate and review the implementation and usage of `MsgNewAction`.

# Search for the implementation of `MsgNewAction`.
ast-grep --lang go --pattern 'type MsgNewAction struct { $$$ }'

# Search for the usage of `MsgNewAction` in the codebase.
rg 'MsgNewAction'

Length of output: 26677

@Pitasi
Copy link
Contributor Author

Pitasi commented Jun 5, 2024

How do I run integration tests? I tried to execute just test from tests dir, but got an error: warden node never became running. I'm also tried this instructions

just test should be enough, but maybe we have some timing issues inside the tests that makes them flaky 🤔

@Overseven
Copy link
Contributor

just test should be enough, but maybe we have some timing issues inside the tests that makes them flaky 🤔

A new issue has been created

@Pitasi Pitasi force-pushed the msg-create-action branch from e8244f9 to d797300 Compare June 5, 2024 13:42
Copy link
Contributor

@Overseven Overseven left a comment

Choose a reason for hiding this comment

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

I think I've found everything I could for now

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

Outside diff range and nitpick comments (3)
contracts/README.md (3)

Line range hint 10-10: Consider rephrasing to avoid repetition: "You need Rust to generate schema files, Docker to build a contract, and an account in the Warden Protocol blockchain with some balance to deploy contracts and perform transactions."


Line range hint 14-14: Add a comma after "To generate schema files" for better readability.

- To generate schema files perform following commands:
+ To generate schema files, perform following commands:

Line range hint 39-39: Add a comma after "After a successful build" to improve the flow of the sentence.

- After a successful build you'll see a newly generated `sample.wasm` file in the `artifacts` directory.
+ After a successful build, you'll see a newly generated `sample.wasm` file in the `artifacts` directory.
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 0e6ed85 and d797300.

Files selected for processing (9)
  • .github/workflows/wardend.yml (1 hunks)
  • contracts/README.md (1 hunks)
  • contracts/contracts/sample/src/contract.rs (4 hunks)
  • contracts/contracts/sample/src/msg.rs (1 hunks)
  • contracts/packages/bindings/src/msg.rs (2 hunks)
  • warden/app/wasm-interop/custom_msg.go (3 hunks)
  • warden/x/intent/keeper/actions.go (5 hunks)
  • warden/x/intent/keeper/keeper.go (5 hunks)
  • warden/x/intent/types/errors.go (1 hunks)
Files skipped from review as they are similar to previous changes (4)
  • .github/workflows/wardend.yml
  • warden/app/wasm-interop/custom_msg.go
  • warden/x/intent/keeper/keeper.go
  • warden/x/intent/types/errors.go
Additional context used
Path-based instructions (2)
contracts/README.md (1)

Pattern **/*.md: "Assess the documentation for misspellings, grammatical errors, missing documentation and correctness"

warden/x/intent/keeper/actions.go (1)

Pattern **/*.go: Review the Golang code for conformity with the Uber Golang style guide, highlighting any deviations.

LanguageTool
contracts/README.md

[style] ~10-~10: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym. (ENGLISH_WORD_REPEAT_BEGINNING_RULE)
Context: ...ou need a Docker to build a contract. - You need an account in the Warden Protocol ...


[style] ~10-~10: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...n Protocol blockchain with some balance in order to deploy contracts and perform transactio...


[uncategorized] ~14-~14: A comma might be missing here. (AI_EN_LECTOR_MISSING_PUNCTUATION_COMMA)
Context: ... ## Generate Schema To generate schema files perform following commands: ```shell #...


[uncategorized] ~14-~14: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...chema To generate schema files perform following commands: ```shell # generate bindings...


[typographical] ~39-~39: It appears that a comma is missing. (DURING_THAT_TIME_COMMA)
Context: ...ptimizer:0.13.0 ``` After a successful build you'll see a newly generated `sample.wa...


[style] ~43-~43: Consider a shorter alternative to avoid wordiness. (IN_ORDER_TO_PREMIUM)
Context: ...ry in your $PATH environment variable in order to perform following steps. All of the fo...


[uncategorized] ~43-~43: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...nvironment variable in order to perform following steps. All of the following commands a...


[style] ~44-~44: Consider removing “of” to be more concise (ALL_OF_THE)
Context: ...e in order to perform following steps. All of the following commands are executed with th...


[uncategorized] ~58-~58: Possible missing article found. (AI_HYDRA_LEO_MISSING_THE)
Context: ...sm list-code ``` Let's assume its 100. Next step is to instantiate our contract usi...


[uncategorized] ~64-~64: You might be missing the article “the” here. (AI_EN_LECTOR_MISSING_DETERMINER_THE)
Context: ...y --chain-id warden ``` Let's find out address of the newly created contract. The simp...

Additional comments not posted (11)
contracts/contracts/sample/src/msg.rs (2)

7-12: The addition of timeout_height and intent_id to ExecuteMsg::NewKeyRequest aligns well with the PR's objectives to enhance intent handling.


19-24: The structure of QueryMsg::WardenAllKeys with pagination and address derivation fields is well-suited for querying keys in the Warden Protocol.

contracts/packages/bindings/src/msg.rs (1)

Line range hint 1-20: The WardenMsg::NewKeyRequest structure is consistent with the changes in other parts of the project, supporting the unified handling of new key requests with intent and timeout specifications.

contracts/README.md (1)

91-91: Ensure that the space_id and keychain_id exist before executing this transaction to avoid potential errors.

contracts/contracts/sample/src/contract.rs (3)

41-56: The implementation of execute function for handling NewKeyRequest is robust, incorporating error handling and event propagation which aligns with the PR's objectives.


86-89: The query function's handling of WardenAllKeys with pagination and address derivation is well-implemented, ensuring effective data retrieval.


1-1: Ensure all necessary imports are included and correctly used throughout the contract.

Verification successful

All necessary imports are included and correctly used throughout the contract.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that all imports are used in the contract
rg --type rust "use" contracts/contracts/sample/src/contract.rs | rg --type rust -v "//"

Length of output: 446

warden/x/intent/keeper/actions.go (4)

72-104: The ExecuteAction function is well-implemented, handling message unpacking, execution, and error management effectively. It aligns with the PR's objectives to centralize and manage action execution.


115-125: The implementation of safeExecuteHandler with panic recovery is a robust approach to handling errors in message processing.


Line range hint 148-178: The AddAction function is effectively implemented, managing the creation and immediate execution of actions, which supports the PR's objectives of efficient action management.


206-221: The validateActionMsgSigners function correctly ensures that only the x/intent module account can sign action messages, enhancing security.

@Pitasi Pitasi merged commit dbf46c8 into main Jun 5, 2024
7 checks passed
@Pitasi Pitasi deleted the msg-create-action branch June 5, 2024 13:57
@coderabbitai coderabbitai bot mentioned this pull request Jan 14, 2025
@coderabbitai coderabbitai bot mentioned this pull request Jan 23, 2025
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.

Add MsgNewAction tx
2 participants