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(sui): custom sui_executeTransactionBlock #3662

Merged
merged 4 commits into from
Mar 7, 2025

Conversation

swift1337
Copy link
Contributor

@swift1337 swift1337 commented Mar 6, 2025

Makes SUI signer broadcast tx in a proper way without relying on WaitForLocalExecution.

Closes #3620

Summary by CodeRabbit

  • New Features
    • Introduced enhanced Sui transaction processing with a new execution method that streamlines transaction broadcasting and improves tracking through detailed logging.
  • Tests
    • Added tests to ensure the reliability of transaction response parsing from the Sui network.

@swift1337 swift1337 added no-changelog Skip changelog CI check SUI_TESTS Run make start-sui-tests labels Mar 6, 2025
@swift1337 swift1337 self-assigned this Mar 6, 2025
@swift1337 swift1337 requested a review from a team as a code owner March 6, 2025 17:55
Copy link
Contributor

coderabbitai bot commented Mar 6, 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

This pull request introduces a new client method, SuiExecuteTransactionBlock, that constructs and executes a Sui transaction block via the API. It adds a helper function, parseRPC, to unmarshal JSON-RPC responses into a specified type, along with corresponding tests to validate its behavior. Additionally, the changes include a logging enhancement in the signer’s ProcessCCTX method and a removal of the RequestType field in the signer’s broadcast method, streamlining the API request structure.

Changes

File(s) Summary of Changes
zetaclient/.../client.go, zetaclient/.../client_live_test.go Added SuiExecuteTransactionBlock to initiate a transaction block and a generic parseRPC function for JSON parsing. A corresponding test (TestParseRPC) has been implemented to validate the parsing logic.
zetaclient/.../signer/signer.go, zetaclient/.../signer/signer_tx.go Inserted a new log statement in ProcessCCTX to log the broadcasted transaction digest and removed the RequestType field from the request in the broadcast method.

Sequence Diagram(s)

sequenceDiagram
    participant C as Client
    participant API as Sui API
    participant P as parseRPC
    
    C->>API: Invoke SuiCall with method "SuiExecuteTransactionBlock" and parameters
    API-->>C: Return raw JSON response
    C->>P: Call parseRPC(raw response)
    P-->>C: Return parsed SuiTransactionBlockResponse
Loading

Possibly related PRs

Suggested labels

breaking:proto, breaking:cli, UPGRADE_TESTS

Suggested reviewers

  • lumtis
  • skosito

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

Copy link

codecov bot commented Mar 6, 2025

Codecov Report

Attention: Patch coverage is 37.73585% with 33 lines in your changes missing coverage. Please review.

Project coverage is 64.57%. Comparing base (af5b542) to head (41c036f).
Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
zetaclient/chains/sui/client/client.go 32.65% 31 Missing and 2 partials ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3662      +/-   ##
===========================================
- Coverage    64.61%   64.57%   -0.05%     
===========================================
  Files          470      470              
  Lines        32857    32907      +50     
===========================================
+ Hits         21232    21249      +17     
- Misses       10659    10690      +31     
- Partials       966      968       +2     
Files with missing lines Coverage Δ
zetaclient/chains/sui/signer/signer.go 75.00% <100.00%> (+0.86%) ⬆️
zetaclient/chains/sui/signer/signer_tx.go 60.93% <100.00%> (-0.61%) ⬇️
zetaclient/chains/sui/client/client.go 10.45% <32.65%> (+10.45%) ⬆️
🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@lumtis lumtis left a comment

Choose a reason for hiding this comment

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

LGTM

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

🧹 Nitpick comments (3)
zetaclient/chains/sui/client/client_live_test.go (1)

121-145: Add negative scenario testing
This test only validates a successful response. Consider adding coverage for malformed JSON, missing fields, or error responses to ensure robust handling of all edge cases and improve test reliability.

zetaclient/chains/sui/client/client.go (2)

159-198: Improve test coverage for SuiExecuteTransactionBlock
Static analysis indicates untested lines (167-173, 175-178, 180-190, 192-195, 197). Consider adding tests for optional parameters (Options, RequestType), as well as error scenarios, to ensure comprehensive coverage.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 167-173: zetaclient/chains/sui/client/client.go#L167-L173
Added lines #L167 - L173 were not covered by tests


[warning] 175-178: zetaclient/chains/sui/client/client.go#L175-L178
Added lines #L175 - L178 were not covered by tests


[warning] 180-190: zetaclient/chains/sui/client/client.go#L180-L190
Added lines #L180 - L190 were not covered by tests


[warning] 192-195: zetaclient/chains/sui/client/client.go#L192-L195
Added lines #L192 - L195 were not covered by tests


[warning] 197-197: zetaclient/chains/sui/client/client.go#L197
Added line #L197 was not covered by tests


222-247: Validate error handling in parseRPC
Lines 239-240 and 243-244 handle unsuccessful parse attempts but remain untested. Expanding tests with malformed JSON or missing result fields would improve reliability and coverage.

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 239-240: zetaclient/chains/sui/client/client.go#L239-L240
Added lines #L239 - L240 were not covered by tests


[warning] 243-244: zetaclient/chains/sui/client/client.go#L243-L244
Added lines #L243 - L244 were not covered by tests

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between d3e0991 and b5c420b.

📒 Files selected for processing (4)
  • zetaclient/chains/sui/client/client.go (3 hunks)
  • zetaclient/chains/sui/client/client_live_test.go (1 hunks)
  • zetaclient/chains/sui/signer/signer.go (1 hunks)
  • zetaclient/chains/sui/signer/signer_tx.go (1 hunks)
🧰 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.

  • zetaclient/chains/sui/signer/signer.go
  • zetaclient/chains/sui/client/client_live_test.go
  • zetaclient/chains/sui/client/client.go
  • zetaclient/chains/sui/signer/signer_tx.go
🪛 GitHub Check: codecov/patch
zetaclient/chains/sui/client/client.go

[warning] 167-173: zetaclient/chains/sui/client/client.go#L167-L173
Added lines #L167 - L173 were not covered by tests


[warning] 175-178: zetaclient/chains/sui/client/client.go#L175-L178
Added lines #L175 - L178 were not covered by tests


[warning] 180-190: zetaclient/chains/sui/client/client.go#L180-L190
Added lines #L180 - L190 were not covered by tests


[warning] 192-195: zetaclient/chains/sui/client/client.go#L192-L195
Added lines #L192 - L195 were not covered by tests


[warning] 197-197: zetaclient/chains/sui/client/client.go#L197
Added line #L197 was not covered by tests


[warning] 239-240: zetaclient/chains/sui/client/client.go#L239-L240
Added lines #L239 - L240 were not covered by tests


[warning] 243-244: zetaclient/chains/sui/client/client.go#L243-L244
Added lines #L243 - L244 were not covered by tests

🔇 Additional comments (3)
zetaclient/chains/sui/signer/signer.go (1)

88-88: Enhance traceability with broadcast logs
Logging the broadcast transaction digest is beneficial for debugging and traceability. No concerns here.

zetaclient/chains/sui/signer/signer_tx.go (1)

81-82: Confirm removal of RequestType
Previously, the request potentially included RequestType (e.g., WaitForLocalExecution). Please verify that removing it aligns with the desired behavior and does not alter the expected outcomes.

zetaclient/chains/sui/client/client.go (1)

5-5: Appropriate JSON import
The addition of "encoding/json" is necessary for the new parsing logic. This change is straightforward and approved.

@swift1337 swift1337 enabled auto-merge March 7, 2025 09:21
@swift1337 swift1337 added this pull request to the merge queue Mar 7, 2025
Merged via the queue into develop with commit e00e14a Mar 7, 2025
44 of 45 checks passed
@swift1337 swift1337 deleted the feat/sui/wait-for-local-exec branch March 7, 2025 09:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
no-changelog Skip changelog CI check SUI_TESTS Run make start-sui-tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Investigate WaitForLocalExecution for broadcasting withdrawals
3 participants