refactor(zetaclient): wait for expected nonce and defer relayer signing
There is no reason to even try to submit the transaction until the nonce is in the expected range. Update: that would not be true if we enabled skipping the preflight checks (which may be a better solution than this).
If we defer relayer transaction signing until we're closer to actually being able to relay the transaction, we can avoid starting the two minute recentBlockhash timer (ref).
We need to continue doing TSS signing immediately to avoid desynchronization.
TODO:
- [ ] deduplicate
signer.client.GetAccountInfoWithOptscalls. We should only make 1 call even if we have N pending transactions - [ ] inject the fallbackTx as
txGetterTand resolve it only when actually needed. Although I don't exactly understand why we actually would want to do this. Testing for theNonceMismatchwill have a lot of false positives since we see it during normal operations.
Note, I have another older version of this logic that make the relayer more like a queue. But that has a bunch of concurrency overhead that could be a bit of maintenance burden.
Related to https://github.com/zeta-chain/node/issues/3383
Performance Test Comparison
We see 10-20% reductions in latency since we are spending less time in the relayer backoff loop
Before (nightly run)
perf_sol_wit | Latency report:
perf_sol_wit | min: 42.59
perf_sol_wit | max: 649.80
perf_sol_wit | mean: 330.21
perf_sol_wit | std: 182.90
perf_sol_wit | p50: 314.24
perf_sol_wit | p75: 480.37
perf_sol_wit | p90: 576.56
perf_sol_wit | p95: 616.17
After (this PR)
perf_sol_wit | Latency report:
perf_sol_wit | min: 26.58
perf_sol_wit | max: 568.70
perf_sol_wit | mean: 296.78
perf_sol_wit | std: 159.03
perf_sol_wit | p50: 296.59
perf_sol_wit | p75: 425.42
perf_sol_wit | p90: 512.57
perf_sol_wit | p95: 531.25
Summary by CodeRabbit
-
New Features
- Introduced enhanced retrieval of account details by allowing additional query options.
-
Refactor
- Improved outbound transaction handling by deferring transaction creation, which streamlines error management and processing efficiency.
[!IMPORTANT]
Review skipped
Auto incremental reviews are disabled on this repository.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
📝 Walkthrough
Walkthrough
This pull request introduces a new method to the SolanaRPCClient interface, GetAccountInfoWithOpts, allowing retrieval of account information using additional options. In parallel, the transaction signing logic is refactored by introducing a new function type txGetterT, with various transaction preparation functions updated to return a getter closure. The outbound processing now includes a loop to verify PDA nonce conditions before proceeding. The associated mock implementation is also updated to support the new interface method.
Changes
| File(s) | Change Summary |
|---|---|
zetaclient/chains/interfaces/.../interfaces.gozetaclient/testutils/mocks/.../solana_rpc.go |
Added new method GetAccountInfoWithOpts to the SolanaRPCClient interface and its mock implementation, providing an option-based account information retrieval. |
zetaclient/chains/solana/signer/signer.go |
Introduced a new function type txGetterT and refactored transaction preparation functions (e.g., prepareWhitelistTx, prepareWithdrawTx, etc.) to return a closure, along with adding a loop in TryProcessOutbound for PDA nonce verification. |
Sequence Diagram(s)
sequenceDiagram
participant S as Signer
participant RPC as SolanaRPCClient
participant Tx as Tx Getter Function
S->>RPC: GetAccountInfoWithOpts(ctx, account, opts)
alt PDA nonce < outbound nonce
loop Retry Loop
RPC-->>S: Return AccountInfo (nonce low)
S->>S: Wait and recheck PDA nonce
end
else PDA nonce ≥ outbound nonce
S->>Tx: Invoke txGetterT closure
Tx-->>S: Return Transaction
end
Possibly related PRs
- zeta-chain/node#3071: Introduces the same
GetAccountInfoWithOptsmethod in the mock implementation, ensuring interface consistency. - zeta-chain/node#3077: Focuses on implementing the new RPC method in mocks, aligning with the interface enhancements.
- zeta-chain/node#2563: Also adds the
GetAccountInfoWithOptsmethod, targeting uniform account info retrieval across implementations.
Suggested labels
breaking:cli
Suggested reviewers
- skosito
- lumtis
- fbac
- swift1337
- kingpinXD
- brewmaster012
🪧 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
@coderabbitaiin 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
@coderabbitaiin 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 pauseto pause the reviews on a PR.@coderabbitai resumeto resume the paused reviews.@coderabbitai reviewto trigger an incremental review. This is useful when automatic reviews are disabled for the repository.@coderabbitai full reviewto do a full review from scratch and review all the files again.@coderabbitai summaryto regenerate the summary of the PR.@coderabbitai generate docstringsto generate docstrings for this PR.@coderabbitai resolveresolve all the CodeRabbit review comments.@coderabbitai configurationto show the current CodeRabbit configuration for the repository.@coderabbitai helpto get help.
Other keywords and placeholders
- Add
@coderabbitai ignoreanywhere in the PR description to prevent this PR from being reviewed. - Add
@coderabbitai summaryto generate the high-level summary at a specific location in the PR description. - Add
@coderabbitaianywhere 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.
Codecov Report
Attention: Patch coverage is 0% with 115 lines in your changes missing coverage. Please review.
Project coverage is 64.47%. Comparing base (
93b9b1c) to head (d6c90df). Report is 109 commits behind head on develop.
| Files with missing lines | Patch % | Lines |
|---|---|---|
| zetaclient/chains/solana/signer/signer.go | 0.00% | 115 Missing :warning: |
Additional details and impacted files
@@ Coverage Diff @@
## develop #3633 +/- ##
===========================================
- Coverage 64.59% 64.47% -0.13%
===========================================
Files 469 469
Lines 32911 32973 +62
===========================================
Hits 21259 21259
- Misses 10687 10749 +62
Partials 965 965
| Files with missing lines | Coverage Δ | |
|---|---|---|
| zetaclient/chains/solana/signer/signer.go | 10.13% <0.00%> (-1.37%) |
:arrow_down: |
:rocket: New features to boost your workflow:
- :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
This PR will be replaced by https://github.com/zeta-chain/node/pull/3940