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

Detailed description of revert handling #527

Merged
merged 1 commit into from
Jan 15, 2025
Merged

Detailed description of revert handling #527

merged 1 commit into from
Jan 15, 2025

Conversation

fadeev
Copy link
Member

@fadeev fadeev commented Jan 9, 2025

Summary by CodeRabbit

  • Documentation
    • Enhanced documentation for ZetaChain gateway functionality
    • Clarified details about withdrawal and contract call processes
    • Improved explanations for RevertOptions, CallOptions, and Revertable interface
    • Added more precise information about cross-chain transaction handling and error management

@fadeev fadeev requested a review from a team as a code owner January 9, 2025 12:21
Copy link

vercel bot commented Jan 9, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
docs-v2 ✅ Ready (Inspect) Visit Preview Jan 9, 2025 0:33am

Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

📝 Walkthrough

Walkthrough

The pull request introduces documentation updates for the ZetaChain gateway, focusing on clarifying the technical details of cross-chain interactions. The modifications provide more precise explanations of function parameters, struct fields, and interface behaviors related to withdrawal, contract calls, and error handling mechanisms. The changes aim to enhance the documentation's clarity by offering more explicit descriptions of how cross-chain transactions and revert processes work within the ZetaChain ecosystem.

Changes

File Change Summary
src/pages/developers/chains/zetachain.mdx - Updated documentation for withdrawAndCall and call function parameters
- Refined explanations for RevertOptions struct fields
- Clarified Revertable interface details
- Elaborated on cross-chain transaction and revert mechanisms

Sequence Diagram

sequenceDiagram
    participant Sender
    participant ZetaChain Gateway
    participant Target Chain
    
    Sender->>ZetaChain Gateway: Initiate Cross-Chain Transaction
    alt Arbitrary Call
        Sender-->>ZetaChain Gateway: Encode Function Selector + Arguments
    else Authenticated Call
        Sender-->>ZetaChain Gateway: Encode Arguments Only
    end
    
    ZetaChain Gateway->>Target Chain: Execute Transaction
    
    alt Transaction Fails
        Target Chain-->>ZetaChain Gateway: Revert Triggered
        ZetaChain Gateway->>Sender: Handle Revert Based on RevertOptions
    end
Loading

The sequence diagram illustrates the high-level flow of a cross-chain transaction through the ZetaChain gateway, highlighting the different call types and potential revert scenarios described in the updated documentation.

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

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.

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

🧹 Nitpick comments (4)
src/pages/developers/chains/zetachain.mdx (4)

113-115: Enhance authenticated calls documentation with an example

The explanation of authenticated calls would benefit from a concrete example showing the ABI-encoded arguments format, similar to the arbitrary calls section.

Consider adding an example like:

 For authenticated calls the `message` is just ABI-encoded arguments (no function
 selector in the beginning, because authenticated calls are routed to a specific
 `onCall` function).
+
+For example, to encode two parameters (address and uint256):
+```
+0000000000000000000000001234567890123456789012345678901234567890
+0000000000000000000000000000000000000000000000000000000000000064
+```
+
+This represents:
+- An address parameter: `0x1234567890123456789012345678901234567890`
+- A uint256 parameter: `100` (hex: 64)
🧰 Tools
🪛 LanguageTool

[uncategorized] ~113-~113: Possible missing comma found.
Context: ...imal (616c696365). For authenticated calls the message is just ABI-encoded argum...

(AI_HYDRA_LEO_MISSING_COMMA)


[formatting] ~114-~114: If the ‘because’ clause is essential to the meaning, do not use a comma before the clause.
Context: ...s (no function selector in the beginning, because authenticated calls are routed to a spe...

(COMMA_BEFORE_BECAUSE)


153-161: Add examples for gas fee calculations

The explanation of gas fee handling would be clearer with concrete examples showing how the protocol calculates and deducts gas fees from the deposit amount.

Consider adding an example:

 For CCTXS from a connected chain to ZetaChain, however, gas fees for revert
 execution are deducted from the deposit amount. If a CCTX reverts, the protocol
 will swap a fraction of the deposit amount into ZRC-20 gas tokens of the chain
 on which the revert is to be executed. If the deposit amount is insufficient,
 the CCTX will abort and `onRevert` will not be called.
+
+For example:
+- Initial deposit: 100 USDC
+- Gas required for revert: equivalent to 5 USDC
+- Final revert amount: 95 USDC
🧰 Tools
🪛 LanguageTool

[style] ~154-~154: Consider using just “returned”.
Context: ... amount that has been withdrawn will be returned back as revertContext.amount in ZRC-20 tok...

(RETURN_BACK)


182-187: Add cross-references to related sections

The explanation of the asset field would be more helpful with cross-references to related sections about deposits and withdrawals.

Consider adding links:

 On a connected chain `asset` is an address of an ERC-20 deposited using
 Gateway's `deposit` or `depositAndCall`. If a gas token was deposited, the
 `asset` is a zero address.
+See the [Deposit Tokens](#deposit-tokens) section for more details.

 On ZetaChain `asset` is an address of a ZRC-20 withdrawn using Gateway's
 `withdraw` or `withdrawAndCall`.
+See the [Withdraw ZRC-20 Tokens](#withdraw-zrc-20-tokens) section for more details.
🧰 Tools
🪛 LanguageTool

[uncategorized] ~182-~182: Possible missing comma found.
Context: ...ontext) external; } ``` On a connected chain asset is an address of an ERC-20 depo...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~186-~186: Possible missing comma found.
Context: ...ted, the asset is a zero address. On ZetaChain asset is an address of a ZRC-20 withd...

(AI_HYDRA_LEO_MISSING_COMMA)


134-134: Fix grammatical issues

There are a few grammatical issues to address:

  1. Line 134: Duplicate "the" in "transferred the the"
  2. Line 154: Redundant "back" in "returned back"

Apply these corrections:

-tokens will be transferred the the `msg.sender`
+tokens will be transferred to the `msg.sender`

-will be returned back as
+will be returned as

Also applies to: 154-154

🧰 Tools
🪛 LanguageTool

[uncategorized] ~134-~134: “the” seems less likely than “to”.
Context: ...ecified, the tokens will be transferred the the msg.sender that initiated the Gat...

(AI_HYDRA_LEO_CP_THE_TO)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4c51089 and be5210c.

📒 Files selected for processing (1)
  • src/pages/developers/chains/zetachain.mdx (4 hunks)
🧰 Additional context used
🪛 LanguageTool
src/pages/developers/chains/zetachain.mdx

[uncategorized] ~113-~113: Possible missing comma found.
Context: ...imal (616c696365). For authenticated calls the message is just ABI-encoded argum...

(AI_HYDRA_LEO_MISSING_COMMA)


[formatting] ~114-~114: If the ‘because’ clause is essential to the meaning, do not use a comma before the clause.
Context: ...s (no function selector in the beginning, because authenticated calls are routed to a spe...

(COMMA_BEFORE_BECAUSE)


[uncategorized] ~134-~134: “the” seems less likely than “to”.
Context: ...ecified, the tokens will be transferred the the msg.sender that initiated the Gat...

(AI_HYDRA_LEO_CP_THE_TO)


[style] ~154-~154: Consider using just “returned”.
Context: ... amount that has been withdrawn will be returned back as revertContext.amount in ZRC-20 tok...

(RETURN_BACK)


[formatting] ~164-~164: If the ‘because’ clause is essential to the meaning, do not use a comma before the clause.
Context: ...in to ZetaChain does not support reverts, because there are no assets to cover the revert...

(COMMA_BEFORE_BECAUSE)


[uncategorized] ~182-~182: Possible missing comma found.
Context: ...ontext) external; } ``` On a connected chain asset is an address of an ERC-20 depo...

(AI_HYDRA_LEO_MISSING_COMMA)


[uncategorized] ~186-~186: Possible missing comma found.
Context: ...ted, the asset is a zero address. On ZetaChain asset is an address of a ZRC-20 withd...

(AI_HYDRA_LEO_MISSING_COMMA)

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build

src/pages/developers/chains/zetachain.mdx Show resolved Hide resolved
@fadeev fadeev merged commit a6dfdc1 into main Jan 15, 2025
6 checks passed
@fadeev fadeev deleted the revert-details branch January 15, 2025 08:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants