Skip to content

fix(query cctx): show when a CCTX was aborted unsuccessfully#431

Merged
fadeev merged 1 commit intomainfrom
query-cctx-fix-aborted
Oct 27, 2025
Merged

fix(query cctx): show when a CCTX was aborted unsuccessfully#431
fadeev merged 1 commit intomainfrom
query-cctx-fix-aborted

Conversation

@fadeev
Copy link
Member

@fadeev fadeev commented Oct 27, 2025

yarn -s zetachain q cctx --hash 0x4c89b921a2f4131f88ee30bc22bea7c75de89c487f2c82c85fa3623af5ad5072 --rpc https://zetachain.blockpi.network/lcd/v1/public 
137 → 7000 ❌ Aborted
CCTX:     0x0fcf4206d0154a285a55680ff7a26df17d099914cd7a1efaf501ee59719176bd
Tx Hash:  0x4c89b921a2f4131f88ee30bc22bea7c75de89c487f2c82c85fa3623af5ad5072 (on chain 137)
Tx Hash:  0xdeba6846dddac4ebb937e10cf23671dc71b85af4611e7b47c83a4df362e64359 (on chain 7000)
Sender:   0x9691bBce4680d0c0bb9E798a71984984Ab1440C1
Receiver: 0xDbAF291a4380749a0E6474E25Ab8A3186475074A
Message:  b1b3ae1230a2234f65b5643566e420617a90394795b6df46643f954f51b215db000021051de70f3e971b62a0707da18100392af14f7fb6770014001403fc00140028000026182a4c566a6eb2f7dc9ed280dae5dac4d9968c26182a4c566a6eb2f7dc9ed280dae5dac4d9968cadf73eba3ebaa7254e859549a44c74ef7cff75011de70f3e971b62a0707da18100392af14f7fb67700000000000000000000000000000000000000000000000000b19e30078bb00000000000000000000000000000000000000000000000000000000286ec2795f50000000000000000000000000000000000000000000000000000027383ca3cfa00000000000000000000000000000000000000000000000000000000000000050000000000000000000000000000000000000000000000000000000068d5e51203f7f3e253508289ec46fdabbbb8c5c21d4c9b4ef1f7f3e253508289ec46fdabbbb8c5c21d4c9b4ef103f876327f4dd491ca6bd9c4e33d60ca41eaeef603514948992760ea1bb2d0cfbede4ccbbde6587092ab1a47ead6eed2bf1178a6b9bb590e7c23603319efb83c23d1db6e9cf4f3faf3c7acfa721dc9014904f7f3e253508289ec46fdabbbb8c5c21d4c9b4ef1f7f3e253508289ec46fdabbbb8c5c21d4c9b4ef103f876327f4dd491ca6bd9c4e33d60ca41eaeef6df25db6c8735e4238a86423d0380572505422bfd0300c000c000a0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000060000000000000000000000000adf73eba3ebaa7254e859549a44c74ef7cff75010000000000000000000000005f0b1a82749cb4e2278ec87f8bf6b618dc71a8bf00000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000600000000000000000000000005f0b1a82749cb4e2278ec87f8bf6b618dc71a8bf000000000000000000000000d97b1de3619ed2c6beb3860147e30ca8a7dc989100000000000000000000000000000000000000000000000000000000000001f40000000000000000000000000000000000000000000000000000000000000001000000000000000000000000d97b1de3619ed2c6beb3860147e30ca8a7dc98910000000000000000000000001de70f3e971b62a0707da18100392af14f7fb677000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010040000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000005977f12664b4e634dfbaad0ad4a6a81057254da8eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
Amount:   50000000000000000 Gas tokens
Status:   Aborted, revert failed to be processed
Error:    {"type":"internal_error","error":"ZRC20 is paused"}

7000 ❌ Abort failed
Reason for revert: {"type":"internal_error","error":"unable to pay for outbound tx using gas token, outbound chain: 137, required: 70374205282000000, available: 50000000000000000: not enough gas"}
Reason for abort:  failed to process abort: ZRC20 is paused
Revert Address:    0x9691bBce4680d0c0bb9E798a71984984Ab1440C1
Call on Revert:    true
Abort Address:     0xDbAF291a4380749a0E6474E25Ab8A3186475074A
Revert Message:    b1b3ae1230a2234f65b5643566e420617a90394795b6df46643f954f51b215db630575eba98025fcf36888bb7624e5072e8ea264
Revert Gas Limit:  1000000

Summary by CodeRabbit

Release Notes

  • New Features

    • Added detailed abort and revert reason fields to transaction status reporting.
    • Enhanced error messaging with distinct statuses for failed aborts versus completed aborts.
  • Improvements

    • Improved cross-chain transaction status visibility with additional diagnostic information.

@fadeev fadeev requested review from a team as code owners October 27, 2025 13:02
@github-actions github-actions bot added the fix label Oct 27, 2025
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 27, 2025

📝 Walkthrough

Walkthrough

Adds abort_message field to the CCTX status type definition and updates the status query handler to differentiate between successful aborts (with refunds) and abort failures (without refunds), including enhanced display of abort/revert failure reasons.

Changes

Cohort / File(s) Change Summary
Type Definitions
types/trackCCTX.types.ts
Added abort_message: string field to CrossChainTx.cctx_status to extend public interface with abort message property
Status Query Implementation
packages/commands/src/query/cctx.ts
Expanded status destructuring to include isAbortRefunded, error_message_abort, and error_message_revert; introduced isAbortFailed conditional when status is "Aborted" without refund; added separate abort failure rendering path with distinct symbol and messaging; updated revert/abort output block with new reason fields; replaced null "Revert Message" placeholder with "-"

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20–30 minutes

  • Verify the abort vs. abort\_failed distinction logic and all conditional paths are correctly triggered
  • Confirm null handling for error_message_abort, error_message_revert, and revert_message fields are consistent throughout status rendering
  • Review status output formatting changes ensure all new reason fields display correctly across abort, abort\_failed, and revert scenarios
  • Validate that isAbortRefunded field is reliably provided from the API response

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title Check ✅ Passed The title "fix(query cctx): show when a CCTX was aborted unsuccessfully" directly corresponds to the primary changes in the pull request. The main modification across both files introduces logic to distinguish between successful and failed abort attempts, specifically adding the isAbortFailed status path and related messaging fields to display when an abort operation was unsuccessful. The title is concise, uses descriptive and meaningful language, and clearly conveys the primary intent of the changeset without vague terms or unnecessary noise.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch query-cctx-fix-aborted

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/commands/src/query/cctx.ts (1)

255-268: Handle Aborted tri‑state explicitly (success/failed/unknown).

When isAbortRefunded is undefined, statusMessage stays “Unknown” but statusIcon is ✅, which is misleading.

Apply:

-    const isAborted = status === "Aborted" && isAbortRefunded === true;
-    const isAbortFailed = status === "Aborted" && isAbortRefunded === false;
+    const hasAbort = status === "Aborted";
+    const isAborted = hasAbort && isAbortRefunded === true;
+    const isAbortFailed = hasAbort && isAbortRefunded === false;
+    const isAbortUnknown = hasAbort && isAbortRefunded == null;
-
-    const statusIcon = isPendingRevert ? "🔄" : "✅";
+    const statusIcon = isPendingRevert ? "🔄" : (isAbortFailed ? "❌" : (isAborted ? "✅" : (isAbortUnknown ? "❓" : "✅")));
@@
-    } else if (isAbortFailed) {
+    } else if (isAbortFailed) {
       statusMessage = "Abort failed";
+    } else if (isAbortUnknown) {
+      statusMessage = "Abort status unknown";
     }
🧹 Nitpick comments (5)
types/trackCCTX.types.ts (1)

58-68: Align abort fields and document intent.

You’ve added abort_message but the CLI prints error_message_abort and never surfaces abort_message. This can confuse readers/operators.

  • Add a brief doc on how abort_message differs from error_message_abort.
  • Either render abort_message in the CLI (preferred) or remove it to avoid duplication.
packages/commands/src/query/cctx.ts (4)

181-188: Default abort/revert error fields and include abort_message.

Prevent “undefined” in output and surface the new field.

Apply:

-  const {
-    status,
-    status_message,
-    isAbortRefunded,
-    error_message = "",
-    error_message_abort,
-    error_message_revert,
-  } = cctx_status;
+  const {
+    status,
+    status_message,
+    isAbortRefunded,
+    error_message = "",
+    error_message_abort = "-",
+    error_message_revert = "-",
+    abort_message = "-",
+  } = cctx_status;

275-278: Improve revert message decoding (UTF‑8 first, hex fallback).

Hex is less readable for typical Error(string) reverts. Try UTF‑8, fallback to hex.

Apply within the same scope:

-    const revertMessage = revert_message
-      ? Buffer.from(revert_message, "base64").toString("hex")
-      : "-";
+    const revertMessage = (() => {
+      if (!revert_message) return "-";
+      const buf = Buffer.from(revert_message, "base64");
+      const utf8 = buf.toString("utf8");
+      // Heuristic: if UTF‑8 has many replacement chars or non‑printables, show hex
+      const printable = /[\x20-\x7E\s]/.test(utf8);
+      return printable ? utf8 : `0x${buf.toString("hex")}`;
+    })();

Optionally extract a helper if reused later.


283-286: Use distinct icon for Abort success vs unknown.

For unknown, prefer “❓” to avoid implying success.

Apply:

-    } else if (isAbortFailed) {
-      chainDetails = `${receiver_chainId} ❌ ${statusMessage}`;
+    } else if (isAbortFailed) {
+      chainDetails = `${receiver_chainId} ❌ ${statusMessage}`;
+    } else if (isAbortUnknown) {
+      chainDetails = `${receiver_chainId} ❓ ${statusMessage}`;
     }

290-297: Render the new abort_message alongside reasons.

Expose abort_message to operators.

Apply:

     let revertOrAbortTx = `
 ${chainDetails}
 Reason for revert: ${error_message_revert}
 Reason for abort:  ${error_message_abort}
+Abort Message:     ${abort_message}
 Revert Address:    ${revertAddress}
 Call on Revert:    ${call_on_revert}
 Abort Address:     ${abort_address}
 Revert Message:    ${revertMessage}
 Revert Gas Limit:  ${revert_gas_limit}
 `;
📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between a3ef47b and 276dfe2.

📒 Files selected for processing (2)
  • packages/commands/src/query/cctx.ts (4 hunks)
  • types/trackCCTX.types.ts (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: fadeev
PR: zeta-chain/toolkit#346
File: packages/commands/src/ton/depositAndCall.ts:0-0
Timestamp: 2025-06-13T15:33:54.781Z
Learning: fadeev prefers responses in English.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: build
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
packages/commands/src/query/cctx.ts (1)

180-186: Guard outbound_params[0] to avoid runtime crash.

formatCCTX destructures outbound_params[0] unconditionally. If empty, this throws.

  • Is outbound_params guaranteed to have index 0 for all statuses?
  • If not, add a guard:
-  const { receiver_chainId, receiver } = outbound_params[0];
+  const firstOutbound = outbound_params[0];
+  const receiver_chainId = firstOutbound?.receiver_chainId ?? "-";
+  const receiver = firstOutbound?.receiver ?? "-";

Copy link
Member

@hernan-clich hernan-clich left a comment

Choose a reason for hiding this comment

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

Tested ACK

@fadeev fadeev merged commit 31170ea into main Oct 27, 2025
15 checks passed
@fadeev fadeev deleted the query-cctx-fix-aborted branch October 27, 2025 14:41
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.

2 participants