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

refactor(crosschain): set outbound hash in cctx when adding outbound tracker #3594

Merged
merged 3 commits into from
Feb 28, 2025

Conversation

lumtis
Copy link
Member

@lumtis lumtis commented Feb 26, 2025

Description

Closes #3490

Summary by CodeRabbit

  • New Features
    • Outbound transaction tracking now captures and records an additional hash for cross-chain transactions. This enhancement improves the way explorers and front-end applications locate and verify outbound transactions, providing more transparent tracking data.

@lumtis lumtis requested a review from a team as a code owner February 26, 2025 14:31
Copy link
Contributor

coderabbitai bot commented Feb 26, 2025

📝 Walkthrough

Walkthrough

This pull request adds a new changelog entry for PR 3594 and updates functionality related to outbound transaction tracking. The MockCctxByNonce function signature in the test utilities is modified to return a string consistently. In the production code, the AddOutboundTracker method now assigns the outbound hash from the transaction to the cross-chain transaction context before saving it. Test cases are updated to capture and use the returned cctx index from the modified function.

Changes

File(s) Change Summary
changelog.md Added a new changelog entry for PR [3594] detailing that the outbound hash is now stored in the cctx when adding an outbound tracker.
testutil/keeper/crosschain.go Modified the MockCctxByNonce function to return a string consistently—returning an empty string on error and the cctx index on success.
x/crosschain/keeper/msg_server_add_outbound_tracker.go Updated AddOutboundTracker to set the outbound hash from msg.TxHash in the current outbound tracker within the cctx and to persist the cctx by calling SetCrossChainTx; added clarifying comments.
x/crosschain/keeper/msg_server_add_outbound_tracker_test.go Added comments to mark the arrange, act, and assert phases in tests and utilized the returned cctx index from MockCctxByNonce for later assertions.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant MsgServer
    participant Keeper
    Client->>MsgServer: Request AddOutboundTracker(msg)
    Note over MsgServer: Set outbound hash in cctx using msg.TxHash
    MsgServer->>Keeper: SetCrossChainTx(ctx, updated cctx)
    Keeper-->>MsgServer: Acknowledgement
    MsgServer->>Client: Confirmation response
Loading

Possibly related PRs

Suggested labels

breaking:cli, TSS_MIGRATION_TESTS, V2_TESTS

Suggested reviewers

  • fbac
  • skosito
  • brewmaster012
  • kingpinXD

Tip

CodeRabbit's docstrings feature is now available as part of our Pro Plan! Simply use the command @coderabbitai generate docstrings to have CodeRabbit automatically generate docstrings for your pull request. We would love to hear your feedback on Discord.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 280c75c and f718697.

📒 Files selected for processing (4)
  • changelog.md (1 hunks)
  • testutil/keeper/crosschain.go (2 hunks)
  • x/crosschain/keeper/msg_server_add_outbound_tracker.go (1 hunks)
  • x/crosschain/keeper/msg_server_add_outbound_tracker_test.go (13 hunks)
✅ Files skipped from review due to trivial changes (1)
  • changelog.md
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.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/keeper/msg_server_add_outbound_tracker.go
  • x/crosschain/keeper/msg_server_add_outbound_tracker_test.go
  • testutil/keeper/crosschain.go
🔇 Additional comments (5)
x/crosschain/keeper/msg_server_add_outbound_tracker.go (1)

66-70: Excellent addition: Storing the outbound hash for improved traceability.

The implementation now properly sets the outbound hash from the transaction tracker and persists it to the store. This enhancement will significantly improve the ability of explorers and front-end applications to trace transactions through the system.

x/crosschain/keeper/msg_server_add_outbound_tracker_test.go (3)

25-41: Well-structured test organization with clear phase demarcation.

The addition of "arrange", "act", and "assert" comments improves test readability and maintainability. The storage of the cctxIndex from MockCctxByNonce allows for proper verification of the new functionality.


59-62: Good test coverage for the new outbound hash functionality.

The added assertions properly verify that the cross-chain transaction's outbound hash is correctly set to the provided hash, ensuring the new feature works as expected.


101-104: Consistent verification pattern across test cases.

The duplicate assertions for CCTX hash validation ensure consistent behavior across different test scenarios, which is a good practice for comprehensive test coverage.

testutil/keeper/crosschain.go (1)

481-510: Enhanced utility function with proper return value.

The modification of MockCctxByNonce to return the CCTX index is a valuable improvement that facilitates better test assertions. The implementation handles both success and error cases appropriately by returning either the index or an empty string.

✨ Finishing Touches
  • 📝 Generate Docstrings

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.
  • @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.

@lumtis lumtis added the CONSENSUS_BREAKING_ACK Acknowledge a consensus breaking change label Feb 26, 2025
Copy link

codecov bot commented Feb 26, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 64.65%. Comparing base (280c75c) to head (f718697).
Report is 7 commits behind head on develop.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3594      +/-   ##
===========================================
- Coverage    64.69%   64.65%   -0.05%     
===========================================
  Files          466      466              
  Lines        32477    32482       +5     
===========================================
- Hits         21010    21000      -10     
- Misses       10512    10522      +10     
- Partials       955      960       +5     
Files with missing lines Coverage Δ
...osschain/keeper/msg_server_add_outbound_tracker.go 83.58% <100.00%> (+1.32%) ⬆️

... and 3 files with indirect coverage changes

Copy link
Contributor

@ws4charlie ws4charlie left a comment

Choose a reason for hiding this comment

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

lgtm

@lumtis lumtis added this pull request to the merge queue Feb 28, 2025
Merged via the queue into develop with commit ed8e2dc Feb 28, 2025
47 checks passed
@lumtis lumtis deleted the outbound-tracket-set-hash branch February 28, 2025 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CONSENSUS_BREAKING_ACK Acknowledge a consensus breaking change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

MsgAddOutboundTracker: set the tx hash of the outbound to the hash in the tracker
4 participants