Skip to content

feat: add created_timestamp to cctx status#2644

Merged
gartnera merged 4 commits intodevelopfrom
cctx_created_at
Aug 13, 2024
Merged

feat: add created_timestamp to cctx status#2644
gartnera merged 4 commits intodevelopfrom
cctx_created_at

Conversation

@gartnera
Copy link
Contributor

@gartnera gartnera commented Aug 6, 2024

Description

Add created_timestamp to CCTX status. Closes #2611. The goal of this field is to be able to do last_update_timestamp - created_timestamp to be able to calculate CCTX latency.

However, it seems that last_update_timestamp is not currently updated on a successful outbound:

    {
      "creator": "zeta1f5g89sfvwyxcd6eh2yqt69ru3rmhm42nwy77ed",
      "index": "0x1bfdd79dbd3f3c8638b91f524e224f6f8e160218265eae7b6347a814067643d9",
      "zeta_fees": "0",
      "relayed_message": "733ab8b06dddef27eaa72294b0d7c9cef7f12db9d97b1de3619ed2c6beb3860147e30ca8a7dc989162637274317170666532796d63653766327879356e683861643571336a38766474377630707a327076356a78",
      "cctx_status": {
        "status": "OutboundMined",
        "status_message": "Outbound succeeded, mined",
        "lastUpdate_timestamp": "1722966771",
        "isAbortRefunded": false,
        "createdAt_timestamp": "1722966771"
      },

I would need to either:

  • add logic to always update last_update_timestamp on any status change
  • add a new field which is like status_update_timestamp which is always updated on status change

Please advise which option you prefer.

Update: LastUpdateTimestamp is now set in SetCrossChainTx so that it is always updated.

Summary by CodeRabbit

  • New Features

    • Added a CreatedTimestamp field to the transaction status, enabling improved tracking of when cross-chain transactions are created.
  • Bug Fixes

    • Consolidated timestamp generation for status updates, enhancing the consistency between creation and last update times.
  • Tests

    • Enhanced test cases to include the new CreatedTimestamp field for more accurate tracking and validation of cross-chain transaction statuses.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 6, 2024

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

The changes introduce a new CreatedTimestamp field to the Status message within the cross-chain transaction (CCTX) framework. This field captures the creation time of transactions, enhancing tracking and logging capabilities. The updated structure ensures consistency in timestamp management across various components, improving the reliability of transaction state reporting. Overall, these modifications aim to provide clearer insights into transaction timelines, addressing issues related to the monitoring of outbound CCTX trackers.

Changes

Files Change Summary
proto/zetachain/zetacore/crosschain/cross_chain_tx.proto Added a created_timestamp field to the Status message to capture transaction creation time for better tracking of CCTX states.
testutil/sample/crosschain.go Modified the Status function to use a single generated timestamp for both CreatedTimestamp and LastUpdateTimestamp, ensuring consistency in status reporting.
x/crosschain/keeper/abci_test.go Enhanced CctxStatus in tests by adding CreatedTimestamp populated with Unix format, improving tracking of CCTX creation time in various test scenarios.
x/crosschain/types/cctx.go Introduced the CreatedTimestamp field in the Status struct to capture the creation time of the CCTX, aiding in tracking and auditing purposes.

Sequence Diagram(s)

sequenceDiagram
    participant CCTX as CrossChainTx
    participant Status as Status Struct
    participant Tracker as Tracker Component

    CCTX->>Status: Initialize new transaction
    Status->>Status: Set CreatedTimestamp
    Status->>Tracker: Log transaction creation
    Tracker->>CCTX: Monitor transaction status
Loading

Assessment against linked issues

Objective Addressed Explanation
Add created_at to CCTX status (#2611)
Improve detection of uncompleted outbound CCTX trackers (#2611)
Enhance accuracy of transaction timing monitoring (#2611)

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

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

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

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

@codecov
Copy link

codecov bot commented Aug 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 70.35%. Comparing base (8efbf3c) to head (e8c5f26).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff            @@
##           develop    #2644   +/-   ##
========================================
  Coverage    70.35%   70.35%           
========================================
  Files          338      338           
  Lines        18599    18599           
========================================
  Hits         13085    13085           
  Misses        4922     4922           
  Partials       592      592           
Files Coverage Δ
x/crosschain/keeper/abci.go 75.58% <ø> (-0.29%) ⬇️
x/crosschain/keeper/cctx.go 94.44% <100.00%> (+0.21%) ⬆️
.../crosschain/keeper/msg_server_refund_aborted_tx.go 100.00% <100.00%> (ø)
x/crosschain/types/cctx.go 94.02% <100.00%> (ø)
x/crosschain/types/status.go 100.00% <100.00%> (ø)

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (1)
proto/zetachain/zetacore/crosschain/cross_chain_tx.proto (1)

92-93: Clarify the purpose and usage of created_timestamp.

The comment indicates that created_timestamp is only populated on new transactions. Ensure that this is clearly documented in the protobuf file to avoid confusion.

-  // when the CCTX was created. only populated on new transactions.
+  // Timestamp indicating when the CCTX was created. This field is only populated on new transactions.
Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

Commits

Files that changed from the base of the PR and between b56e758 and 9d88da1.

Files ignored due to path filters (1)
  • x/crosschain/types/cross_chain_tx.pb.go is excluded by !**/*.pb.go, !**/*.pb.go
Files selected for processing (4)
  • proto/zetachain/zetacore/crosschain/cross_chain_tx.proto (1 hunks)
  • testutil/sample/crosschain.go (1 hunks)
  • x/crosschain/keeper/abci_test.go (9 hunks)
  • x/crosschain/types/cctx.go (1 hunks)
Additional context used
Path-based instructions (4)
proto/zetachain/zetacore/crosschain/cross_chain_tx.proto (1)

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

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

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

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

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

testutil/sample/crosschain.go (1)

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

Additional comments not posted (5)
proto/zetachain/zetacore/crosschain/cross_chain_tx.proto (1)

92-93: Ensure backward compatibility with existing data.

The addition of the created_timestamp field should be backward compatible. Ensure that the field is optional to avoid issues with existing data that do not have this field populated.

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

209-211: Ensure consistent timestamp usage.

The CreatedTimestamp field is populated with the Unix timestamp of the block header's time. Ensure that this timestamp is used consistently across the codebase to avoid discrepancies.

x/crosschain/keeper/abci_test.go (2)

131-133: Ensure comprehensive test coverage for CreatedTimestamp.

The CreatedTimestamp field is correctly integrated into the test cases. Ensure that all edge cases are covered, such as scenarios where the timestamp might be missing or invalid.

Also applies to: 156-158, 185-187, 214-216, 242-244, 265-267, 288-290, 311-313, 333-335


131-133: LGTM!

The test cases are well-structured and cover the necessary scenarios for the CreatedTimestamp field.

Also applies to: 156-158, 185-187, 214-216, 242-244, 265-267, 288-290, 311-313, 333-335

testutil/sample/crosschain.go (1)

199-205: LGTM! Ensure the function usage in the codebase aligns with the new changes.

The code changes are approved. The initialization and assignment of createdAt to both CreatedTimestamp and LastUpdateTimestamp enhance consistency in timestamp handling.

However, ensure that all function calls to Status are verified to align with the new changes.

@gartnera gartnera requested a review from a team August 6, 2024 19:19
@lumtis
Copy link
Contributor

lumtis commented Aug 6, 2024

However, it seems that last_update_timestamp is not currently updated on a successful outbound:

There are part of the workflow where the timestamp is not updated, we need to fix this. We can create an issue for this.

Copy link
Collaborator

@morde08 morde08 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
Copy link
Contributor

lumtis commented Aug 12, 2024

@gartnera any blockers for merging this one ?

@gartnera gartnera force-pushed the cctx_created_at branch 2 times, most recently from 53d233e to 804c789 Compare August 12, 2024 15:54
@gartnera
Copy link
Contributor Author

gartnera commented Aug 12, 2024

@gartnera any blockers for merging this one ?

With 53a902a I think it should be good to go.

@gartnera gartnera added the UPGRADE_TESTS Run make start-upgrade-tests label Aug 12, 2024
@gartnera gartnera added the UPGRADE_IMPORT_MAINNET_TESTS Run make start-upgrade-import-mainnet-test label Aug 13, 2024
@gartnera gartnera enabled auto-merge August 13, 2024 17:35
@gartnera gartnera added this pull request to the merge queue Aug 13, 2024
Merged via the queue into develop with commit 3a542cc Aug 13, 2024
@gartnera gartnera deleted the cctx_created_at branch August 13, 2024 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking:proto UPGRADE_IMPORT_MAINNET_TESTS Run make start-upgrade-import-mainnet-test UPGRADE_TESTS Run make start-upgrade-tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add created_at to CCTX status

5 participants