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 new a new msg to remove inbound trackers #3469

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

kingpinXD
Copy link
Contributor

@kingpinXD kingpinXD commented Feb 5, 2025

Description

Closes #1345

How Has This Been Tested?

  • Tested CCTX in localnet
  • Tested in development environment
  • Go unit tests
  • Go integration tests
  • Tested via GitHub Actions

Summary by CodeRabbit

  • New Features
    • Introduced functionality to remove inbound trackers under emergency conditions via a new CLI command.
  • Documentation
    • Updated user documentation and API references to include details about the new removal command.
  • Tests
    • Added tests to ensure proper authorization and behavior when removing inbound trackers, including handling non-existent cases.

Copy link
Contributor

coderabbitai bot commented Feb 5, 2025

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

📝 Walkthrough

Walkthrough

A new feature has been implemented to remove inbound trackers through a dedicated MsgRemoveInboundTracker message. The changes extend the changelog, update documentation (CLI, OpenAPI, and specifications), add new protobuf definitions with RPC method support, update emergency policy authorization, introduce new CLI commands, and provide keeper logic with corresponding unit tests and message registration.

Changes

File(s) Change Summary
changelog.md Added a new "Features" entry for MsgRemoveInboundTracker.
docs/cli/zetacored/cli.md, docs/openapi/openapi.swagger.yaml, docs/spec/crosschain/messages.md Updated documentation with a new CLI command (zetacored tx crosschain remove-inbound-tracker), an OpenAPI response definition, and message documentation for MsgRemoveInboundTracker.
proto/zetachain/.../tx.proto Introduced the RPC method RemoveInboundTracker, added message definitions for MsgRemoveInboundTracker and MsgRemoveInboundTrackerResponse.
x/authority/types/authorization_list.go, x/authority/types/authorization_list_test.go Expanded the emergency policy authorization list to include MsgRemoveInboundTracker.
x/crosschain/client/cli/tx.go, x/crosschain/client/cli/tx_inbound_tracker.go Added new CLI command functions (CmdRemoveInboundTracker).
x/crosschain/keeper/msg_remove_inbound_tracker.go, x/crosschain/keeper/msg_remove_inbound_tracker_test.go Implemented keeper logic for processing RemoveInboundTracker requests and provided associated unit tests.
x/crosschain/types/codec.go, x/crosschain/types/message_remove_inbound_tracker.go, x/crosschain/types/message_remove_inbound_tracker_test.go Registered, defined, and tested the new MsgRemoveInboundTracker message type.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI Command
    participant MsgServer as Keeper (MsgServer)
    participant Auth as AuthorityKeeper

    CLI->>MsgServer: Send MsgRemoveInboundTracker message
    MsgServer->>Auth: CheckAuthorization(msg.creator)
    Auth-->>MsgServer: Return authorization status
    MsgServer->>MsgServer: Call RemoveInboundTrackerIfExists(chain_id, tx_hash)
    MsgServer-->>CLI: Return MsgRemoveInboundTrackerResponse
Loading

Assessment against linked issues

Objective Addressed Explanation
Implement RemoveInboundTracker (#1345)

Possibly related PRs

Suggested labels

ADMIN_TESTS, V2_TESTS

Suggested reviewers

  • fbac
  • swift1337
  • brewmaster012
  • skosito
  • ws4charlie
  • lumtis

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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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 Feb 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 65.48%. Comparing base (2bcd4f5) to head (6649975).

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3469      +/-   ##
===========================================
+ Coverage    65.41%   65.48%   +0.06%     
===========================================
  Files          442      445       +3     
  Lines        30522    30583      +61     
===========================================
+ Hits         19967    20028      +61     
  Misses        9700     9700              
  Partials       855      855              
Files with missing lines Coverage Δ
x/authority/migrations/v3/migrate.go 100.00% <100.00%> (ø)
x/authority/types/authorization_list.go 100.00% <ø> (ø)
x/crosschain/keeper/msg_remove_inbound_tracker.go 100.00% <100.00%> (ø)
...crosschain/types/message_remove_inbound_tracker.go 100.00% <100.00%> (ø)

@kingpinXD kingpinXD marked this pull request as ready for review February 5, 2025 01:02
@kingpinXD kingpinXD requested a review from a team as a code owner February 5, 2025 01:02
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

🧹 Nitpick comments (4)
x/crosschain/client/cli/tx_inbound_tracker.go (1)

59-63: Add input validation for tx-hash.

Consider validating the transaction hash format before proceeding with the command.

Add validation:

argChain, err := strconv.ParseInt(args[0], 10, 64)
if err != nil {
    return err
}
argTxHash := args[1]
+if len(argTxHash) == 0 {
+    return fmt.Errorf("transaction hash cannot be empty")
+}
docs/openapi/openapi.swagger.yaml (1)

59098-59099: New Object Definition Added: crosschainMsgRemoveInboundTrackerResponse

The new response object is correctly added with its type set to object. Please ensure that, if applicable, extended metadata (e.g., descriptions, examples, or property definitions) is documented either here or in the accompanying API documentation to facilitate client integration and clarity.

docs/spec/crosschain/messages.md (1)

37-48: Documentation Update for MsgRemoveInboundTracker:
The new documentation section for MsgRemoveInboundTracker is concise and clear. The protobuf code snippet correctly mirrors the proto definition (with the creator, chain_id, and tx_hash fields) and the associated description succinctly explains its purpose. Additionally, if markdown lint warnings regarding hard tabs arise, consider replacing any tab characters with spaces.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

43-43: Hard tabs
Column: 1

(MD010, no-hard-tabs)


44-44: Hard tabs
Column: 1

(MD010, no-hard-tabs)


45-45: Hard tabs
Column: 1

(MD010, no-hard-tabs)

docs/cli/zetacored/cli.md (1)

10604-10659: Detailed Command Documentation Enhancement
The new documentation block for the remove-inbound-tracker command is comprehensive and clear. However, there are a few stylistic improvements to consider:

  1. Fenced Code Block Language Specification: Several fenced code blocks (e.g., the command usage snippet starting at line 10611 and others around line 10617 and 10648) lack a language identifier. Specifying a language (such as bash or console) will enhance readability and ensure compliance with markdownlint (MD040).
  2. Hard Tabs: There’s an indication of hard tabs (e.g., around line 10658). Replace these with spaces to align with the style guidelines.

Proposed diff for fenced code block language identifier improvement:

-``` 
+```bash
 zetacored tx crosschain remove-inbound-tracker [chain-id] [tx-hash] [flags]
-```
+```

These minor adjustments will improve the clarity and maintainability of the CLI documentation.

🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

10605-10605: Hard tabs
Column: 54

(MD010, no-hard-tabs)


10611-10611: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


10617-10617: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


10648-10648: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


10658-10658: Hard tabs
Column: 54

(MD010, no-hard-tabs)

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1b02702 and f2e7598.

⛔ Files ignored due to path filters (2)
  • typescript/zetachain/zetacore/crosschain/tx_pb.d.ts is excluded by !**/*_pb.d.ts
  • x/crosschain/types/tx.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
📒 Files selected for processing (14)
  • changelog.md (1 hunks)
  • docs/cli/zetacored/cli.md (2 hunks)
  • docs/openapi/openapi.swagger.yaml (1 hunks)
  • docs/spec/crosschain/messages.md (1 hunks)
  • proto/zetachain/zetacore/crosschain/tx.proto (3 hunks)
  • x/authority/types/authorization_list.go (1 hunks)
  • x/authority/types/authorization_list_test.go (1 hunks)
  • x/crosschain/client/cli/tx.go (1 hunks)
  • x/crosschain/client/cli/tx_inbound_tracker.go (2 hunks)
  • x/crosschain/keeper/msg_remove_inbound_tracker.go (1 hunks)
  • x/crosschain/keeper/msg_remove_inbound_tracker_test.go (1 hunks)
  • x/crosschain/types/codec.go (2 hunks)
  • x/crosschain/types/message_remove_inbound_tracker.go (1 hunks)
  • x/crosschain/types/message_remove_inbound_tracker_test.go (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
`**/*.go`: Review the Go code, point out issues relative to ...

**/*.go: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.

  • x/crosschain/client/cli/tx.go
  • x/authority/types/authorization_list.go
  • x/authority/types/authorization_list_test.go
  • x/crosschain/client/cli/tx_inbound_tracker.go
  • x/crosschain/types/codec.go
  • x/crosschain/types/message_remove_inbound_tracker_test.go
  • x/crosschain/keeper/msg_remove_inbound_tracker.go
  • x/crosschain/keeper/msg_remove_inbound_tracker_test.go
  • x/crosschain/types/message_remove_inbound_tracker.go
`**/*.proto`: Review the Protobuf definitions, point out iss...

**/*.proto: Review the Protobuf definitions, point out issues relative to compatibility, and expressiveness.

  • proto/zetachain/zetacore/crosschain/tx.proto
🪛 markdownlint-cli2 (0.17.2)
docs/cli/zetacored/cli.md

10333-10333: Hard tabs
Column: 100

(MD010, no-hard-tabs)


10611-10611: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


10617-10617: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


10648-10648: Fenced code blocks should have a language specified
null

(MD040, fenced-code-language)


10658-10658: Hard tabs
Column: 54

(MD010, no-hard-tabs)

docs/spec/crosschain/messages.md

43-43: Hard tabs
Column: 1

(MD010, no-hard-tabs)


44-44: Hard tabs
Column: 1

(MD010, no-hard-tabs)


45-45: Hard tabs
Column: 1

(MD010, no-hard-tabs)

🔇 Additional comments (11)
x/crosschain/keeper/msg_remove_inbound_tracker.go (1)

26-26: Consider error handling for RemoveInboundTrackerIfExists.

The RemoveInboundTrackerIfExists operation might fail, but its errors are not being captured or propagated.

Consider handling potential errors:

-k.RemoveInboundTrackerIfExists(ctx, msg.ChainId, msg.TxHash)
-return &types.MsgRemoveInboundTrackerResponse{}, nil
+if err := k.RemoveInboundTrackerIfExists(ctx, msg.ChainId, msg.TxHash); err != nil {
+    return nil, errorsmod.Wrapf(err, "failed to remove inbound tracker for chain %d and tx %s", msg.ChainId, msg.TxHash)
+}
+return &types.MsgRemoveInboundTrackerResponse{}, nil
x/crosschain/client/cli/tx.go (1)

34-34: LGTM!

The command registration follows the established pattern and is properly integrated.

x/crosschain/types/codec.go (1)

22-22: LGTM: Message registration is properly implemented.

The new message type MsgRemoveInboundTracker is correctly registered in both RegisterCodec and RegisterInterfaces functions, following the established pattern.

Also applies to: 46-46

x/crosschain/keeper/msg_remove_inbound_tracker_test.go (1)

16-92: LGTM: Well-structured test cases.

The test cases are well-organized using the Arrange-Act-Assert pattern and cover essential scenarios:

  • Authorization failure
  • Successful removal
  • Non-existent tracker handling
x/crosschain/types/message_remove_inbound_tracker_test.go (2)

14-67: LGTM: Comprehensive ValidateBasic test cases.

The test cases for ValidateBasic cover all essential scenarios including invalid address, valid cases, and edge cases with unsupported chain IDs and transaction hashes.


69-107: LGTM: Well-structured GetSigners test cases.

The test cases properly validate both successful and panic scenarios for GetSigners.

x/authority/types/authorization_list.go (1)

51-51: LGTM: Emergency policy message properly registered.

The new message URL /zetachain.zetacore.crosschain.MsgRemoveInboundTracker is correctly added to the EmergencyPolicyMessages slice, maintaining consistency with other emergency operations.

x/authority/types/authorization_list_test.go (1)

408-408: LGTM! Well-placed authorization for the new message type.

The addition of MsgRemoveInboundTracker to the emergency policy list is appropriate, as it's grouped with similar critical operations and properly tested.

proto/zetachain/zetacore/crosschain/tx.proto (2)

21-22: New RPC Method Addition:
The addition of the RemoveInboundTracker RPC method in the Msg service follows the established pattern for similar methods and appears well integrated. Please ensure that this service method is properly wired up with the corresponding keeper logic and codec registration later in the codebase.


85-96: New Message Definitions for Inbound Tracker Removal:
The new message MsgRemoveInboundTracker (with fields creator, chain_id, and tx_hash) is clearly defined and documented. Its corresponding response message, MsgRemoveInboundTrackerResponse, is correctly declared (even if empty) to serve its purpose. This design is consistent with similar existing messages.

changelog.md (1)

5-8: Changelog Update for New Feature:
The changelog entry under the "Features" section is clear and appropriately documents the addition of MsgRemoveInboundTracker, including the PR reference and a brief description of its purpose. This concise update helps maintain transparency in feature changes.

x/crosschain/types/message_remove_inbound_tracker.go Outdated Show resolved Hide resolved
x/crosschain/keeper/msg_remove_inbound_tracker_test.go Outdated Show resolved Hide resolved
x/crosschain/types/message_remove_inbound_tracker_test.go Outdated Show resolved Hide resolved
Comment on lines 10330 to 10336
* [zetacored tx crosschain add-outbound-tracker](#zetacored-tx-crosschain-add-outbound-tracker) - Add an outbound tracker
* [zetacored tx crosschain migrate-tss-funds](#zetacored-tx-crosschain-migrate-tss-funds) - Migrate TSS funds to the latest TSS address
* [zetacored tx crosschain refund-aborted](#zetacored-tx-crosschain-refund-aborted) - Refund an aborted tx , the refund address is optional, if not provided, the refund will be sent to the sender/tx origin of the cctx.
* [zetacored tx crosschain remove-inbound-tracker](#zetacored-tx-crosschain-remove-inbound-tracker) - Remove an inbound tracker
* [zetacored tx crosschain remove-outbound-tracker](#zetacored-tx-crosschain-remove-outbound-tracker) - Remove an outbound tracker
* [zetacored tx crosschain update-tss-address](#zetacored-tx-crosschain-update-tss-address) - Create a new TSSVoter
* [zetacored tx crosschain vote-gas-price](#zetacored-tx-crosschain-vote-gas-price) - Broadcast message to vote gas price
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Verification agent

🧩 Analysis chain

New Command Entry and Markdown Style Consistency
The new command entry for zetacored tx crosschain remove-inbound-tracker is well integrated into the command list. Please verify that the anchor link (#zetacored-tx-crosschain-remove-inbound-tracker) correctly points to the corresponding section. Additionally, the static analysis hint indicates that a hard tab is detected on this line; consider replacing any hard tabs with spaces to adhere to markdownlint guidelines.

Proposed diff for hard tab replacement (if applicable):

-	* [zetacored tx crosschain remove-inbound-tracker](#zetacored-tx-crosschain-remove-inbound-tracker)	 - Remove an inbound tracker
+  * [zetacored tx crosschain remove-inbound-tracker](#zetacored-tx-crosschain-remove-inbound-tracker)  - Remove an inbound tracker

Error: No shell scripts or web queries found


🏁 Script executed:

#!/bin/bash
# Verify that the anchor link for "remove-inbound-tracker" in the command list correctly points to an existing section header
# and check if there are any hard tabs in the vicinity (lines 10320 to 10340) in the markdown file.

echo "Searching for markdown headers containing 'remove-inbound-tracker':"
rg -n "^#{1,6}\s+.*remove-inbound-tracker" docs/cli/zetacored/cli.md

echo ""
echo "Displaying lines 10320 to 10340 to inspect potential hard tabs (visible as '^I'):"
sed -n '10320,10340p' docs/cli/zetacored/cli.md | cat -A

Length of output: 2364

Anchor Link Validity and Hard Tab Removal

  • The anchor link #zetacored-tx-crosschain-remove-inbound-tracker correctly points to the corresponding header found at line 10607 in the markdown file.
  • Hard tabs are present in the command list entries (as shown by the ^I characters). It is recommended to replace these with spaces to comply with markdownlint guidelines.
🧰 Tools
🪛 markdownlint-cli2 (0.17.2)

10330-10330: Hard tabs
Column: 96

(MD010, no-hard-tabs)


10331-10331: Hard tabs
Column: 90

(MD010, no-hard-tabs)


10332-10332: Hard tabs
Column: 84

(MD010, no-hard-tabs)


10333-10333: Hard tabs
Column: 100

(MD010, no-hard-tabs)


10334-10334: Hard tabs
Column: 102

(MD010, no-hard-tabs)


10335-10335: Hard tabs
Column: 92

(MD010, no-hard-tabs)


10336-10336: Hard tabs
Column: 84

(MD010, no-hard-tabs)

@kingpinXD kingpinXD marked this pull request as draft February 5, 2025 05:57
@kingpinXD kingpinXD self-assigned this Feb 5, 2025
@kingpinXD kingpinXD added the UPGRADE_TESTS Run make start-upgrade-tests label Feb 5, 2025
return sdk.MustSortJSON(bz)
}

func (msg *MsgRemoveInboundTracker) ValidateBasic() error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think its okay to be be not stringent about validations

  • This message is sent by policy address
  • If the hash or chainID is wrong, it does nothing

@kingpinXD kingpinXD marked this pull request as ready for review February 5, 2025 15:19
x/authority/migrations/v3/migrate.go Outdated Show resolved Hide resolved
@kingpinXD kingpinXD requested a review from lumtis February 6, 2025 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement RemoveInboundTracker
2 participants