-
Notifications
You must be signed in to change notification settings - Fork 113
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
refactor(zetaclient): drop outboundprocessor
#3410
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe pull request introduces a comprehensive refactoring of the outbound transaction processing mechanism across multiple components in the Zetachain client. The primary focus is on removing the Changes
Suggested labels
Suggested reviewers
Possibly related PRs
The changes represent a significant architectural refactoring that simplifies the outbound transaction processing workflow by consolidating responsibilities within the ✨ Finishing Touches
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? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
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)
Other keywords and placeholders
Documentation and Community
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #3410 +/- ##
===========================================
- Coverage 63.03% 62.99% -0.04%
===========================================
Files 436 435 -1
Lines 30660 30665 +5
===========================================
- Hits 19325 19318 -7
- Misses 10525 10537 +12
Partials 810 810
|
There was a problem hiding this 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 (7)
zetaclient/chains/base/signer.go (2)
116-120
: Clarify early-return logic inMarkOutbound
.
WhenIsOutboundActive(outboundID)
already matches the desired state, you silently return. This is concise but may benefit from a trace log if diagnosing unexpected inactivity.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 116-120: zetaclient/chains/base/signer.go#L116-L120
Added lines #L116 - L120 were not covered by tests
144-152
: Record total active outbounds for analytics.
Removing the outbound from the map upon completion is correct. Ensure you have coverage or monitoring metrics for thetime_taken
field, so you can build performance dashboards around average outbound durations.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 144-152: zetaclient/chains/base/signer.go#L144-L152
Added lines #L144 - L152 were not covered by testszetaclient/chains/bitcoin/bitcoin.go (1)
147-147
: Missing test coverage.
The static analysis indicates this line is untested. Consider adding a unit test scenario to ensureOutboundIDFromCCTX
interacts correctly with subsequent processing logic.Would you like me to propose a concise test to cover this line?
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 147-147: zetaclient/chains/bitcoin/bitcoin.go#L147
Added line #L147 was not covered by testszetaclient/chains/solana/signer/signer.go (1)
123-123
: Include a stack trace for debugging
Capturing a stack trace in case of panics would aid in troubleshooting deeper issues.defer func() { signer.MarkOutbound(outboundID, false) - if err := recover(); err != nil { + if r := recover(); r != nil { + debug.PrintStack() signer.Logger().Std.Error().Msgf("TryProcessOutbound: %s, caught panic error: %v", cctx.Index, r) } }()🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 123-123: zetaclient/chains/solana/signer/signer.go#L123
Added line #L123 was not covered by testszetaclient/chains/bitcoin/signer/signer.go (1)
288-288
: Use stack traces for improved panic handling
Adding a debug stack trace would help in diagnosing issues when a panic occurs.defer func() { signer.MarkOutbound(outboundID, false) - if err := recover(); err != nil { + if r := recover(); r != nil { + debug.PrintStack() signer.Logger().Std.Error().Msgf("BTC TryProcessOutbound: %s, caught panic error: %v", cctx.Index, r) } }()🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 288-288: zetaclient/chains/bitcoin/signer/signer.go#L288
Added line #L288 was not covered by testszetaclient/chains/base/observer.go (1)
134-134
: Retain chain ID context in logs for easier debugging
Removing the chain ID from the log messages streamlines output, but consider whether additional context might be lost. For troubleshooting, chain-specific logs can be crucial.Also applies to: 138-138, 145-145, 148-148
zetaclient/chains/evm/signer/signer.go (1)
249-249
: Add a stack trace for debugging panics
Emitting stack traces on recovery simplifies troubleshooting deeper panic causes.defer func() { signer.MarkOutbound(outboundID, false) - if r := recover(); r != nil { + if r := recover(); r != nil { + debug.PrintStack() signer.Logger().Std.Error().Msgf("TryProcessOutbound: %s, caught panic error: %v", cctx.Index, r) } }()
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (15)
zetaclient/chains/base/observer.go
(1 hunks)zetaclient/chains/base/signer.go
(4 hunks)zetaclient/chains/bitcoin/bitcoin.go
(3 hunks)zetaclient/chains/bitcoin/signer/signer.go
(1 hunks)zetaclient/chains/evm/evm.go
(4 hunks)zetaclient/chains/evm/signer/signer.go
(1 hunks)zetaclient/chains/evm/signer/signer_test.go
(1 hunks)zetaclient/chains/interfaces/interfaces.go
(0 hunks)zetaclient/chains/solana/signer/signer.go
(1 hunks)zetaclient/chains/ton/signer/signer.go
(1 hunks)zetaclient/chains/ton/signer/signer_test.go
(1 hunks)zetaclient/orchestrator/orchestrator.go
(7 hunks)zetaclient/outboundprocessor/outbound_processor.go
(0 hunks)zetaclient/outboundprocessor/outbound_processor_test.go
(0 hunks)zetaclient/testutils/mocks/chain_signer.go
(0 hunks)
💤 Files with no reviewable changes (4)
- zetaclient/outboundprocessor/outbound_processor_test.go
- zetaclient/testutils/mocks/chain_signer.go
- zetaclient/chains/interfaces/interfaces.go
- zetaclient/outboundprocessor/outbound_processor.go
🧰 Additional context used
📓 Path-based instructions (11)
zetaclient/chains/evm/signer/signer_test.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/chains/base/observer.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/chains/evm/signer/signer.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/chains/ton/signer/signer_test.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/chains/ton/signer/signer.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/chains/bitcoin/signer/signer.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/chains/evm/evm.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/orchestrator/orchestrator.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/chains/bitcoin/bitcoin.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/chains/base/signer.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
zetaclient/chains/solana/signer/signer.go (1)
Pattern **/*.go
: Review the Go code, point out issues relative to principles of clean code, expressiveness, and performance.
🪛 GitHub Check: codecov/patch
zetaclient/chains/base/observer.go
[warning] 138-138: zetaclient/chains/base/observer.go#L138
Added line #L138 was not covered by tests
[warning] 145-145: zetaclient/chains/base/observer.go#L145
Added line #L145 was not covered by tests
[warning] 148-148: zetaclient/chains/base/observer.go#L148
Added line #L148 was not covered by tests
zetaclient/chains/bitcoin/signer/signer.go
[warning] 283-285: zetaclient/chains/bitcoin/signer/signer.go#L283-L285
Added lines #L283 - L285 were not covered by tests
[warning] 288-288: zetaclient/chains/bitcoin/signer/signer.go#L288
Added line #L288 was not covered by tests
zetaclient/chains/evm/evm.go
[warning] 166-166: zetaclient/chains/evm/evm.go#L166
Added line #L166 was not covered by tests
[warning] 191-191: zetaclient/chains/evm/evm.go#L191
Added line #L191 was not covered by tests
zetaclient/orchestrator/orchestrator.go
[warning] 429-431: zetaclient/orchestrator/orchestrator.go#L429-L431
Added lines #L429 - L431 were not covered by tests
[warning] 436-442: zetaclient/orchestrator/orchestrator.go#L436-L442
Added lines #L436 - L442 were not covered by tests
[warning] 454-454: zetaclient/orchestrator/orchestrator.go#L454
Added line #L454 was not covered by tests
[warning] 482-483: zetaclient/orchestrator/orchestrator.go#L482-L483
Added lines #L482 - L483 were not covered by tests
[warning] 487-487: zetaclient/orchestrator/orchestrator.go#L487
Added line #L487 was not covered by tests
[warning] 514-515: zetaclient/orchestrator/orchestrator.go#L514-L515
Added lines #L514 - L515 were not covered by tests
[warning] 534-534: zetaclient/orchestrator/orchestrator.go#L534
Added line #L534 was not covered by tests
[warning] 544-545: zetaclient/orchestrator/orchestrator.go#L544-L545
Added lines #L544 - L545 were not covered by tests
zetaclient/chains/bitcoin/bitcoin.go
[warning] 147-147: zetaclient/chains/bitcoin/bitcoin.go#L147
Added line #L147 was not covered by tests
[warning] 176-176: zetaclient/chains/bitcoin/bitcoin.go#L176
Added line #L176 was not covered by tests
zetaclient/chains/base/signer.go
[warning] 116-120: zetaclient/chains/base/signer.go#L116-L120
Added lines #L116 - L120 were not covered by tests
[warning] 122-137: zetaclient/chains/base/signer.go#L122-L137
Added lines #L122 - L137 were not covered by tests
[warning] 139-142: zetaclient/chains/base/signer.go#L139-L142
Added lines #L139 - L142 were not covered by tests
[warning] 144-152: zetaclient/chains/base/signer.go#L144-L152
Added lines #L144 - L152 were not covered by tests
[warning] 155-160: zetaclient/chains/base/signer.go#L155-L160
Added lines #L155 - L160 were not covered by tests
[warning] 164-165: zetaclient/chains/base/signer.go#L164-L165
Added lines #L164 - L165 were not covered by tests
[warning] 169-171: zetaclient/chains/base/signer.go#L169-L171
Added lines #L169 - L171 were not covered by tests
zetaclient/chains/solana/signer/signer.go
[warning] 118-120: zetaclient/chains/solana/signer/signer.go#L118-L120
Added lines #L118 - L120 were not covered by tests
[warning] 123-123: zetaclient/chains/solana/signer/signer.go#L123
Added line #L123 was not covered by tests
🔇 Additional comments (28)
zetaclient/chains/evm/evm.go (3)
36-36
: Removed processor parameter looks consistent.
By removing theproc *outboundprocessor.Processor
parameter from the constructor, you simplify dependencies and ensure that outbound processing is handled solely by the signer. This declutters the interface and promotes a more cohesive design.
166-166
: Add test coverage for outbound ID generation.
The new line usingbase.OutboundIDFromCCTX
is untested according to coverage reports. Even though this function is relatively straightforward, consider adding a test to confirm correct IDs for various scenarios, such as edge cases involving different chain parameters.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 166-166: zetaclient/chains/evm/evm.go#L166
Added line #L166 was not covered by tests
191-191
: TestIsOutboundActive
usage.
Line 191 callse.signer.IsOutboundActive
to check for active outbounds. Ensure that there's a dedicated test verifying that calls toIsOutboundActive
accurately reflect the updated state in different concurrency scenarios.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 191-191: zetaclient/chains/evm/evm.go#L191
Added line #L191 was not covered by testszetaclient/orchestrator/orchestrator.go (8)
429-431
: Improve testing for observer type checks.
These lines ensure the observer is indeed a Solana observer. Please add tests to confirm that an error is correctly logged when the observer is of an unexpected type, ensuring robust defensive checks.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 429-431: zetaclient/orchestrator/orchestrator.go#L429-L431
Added lines #L429 - L431 were not covered by tests
436-442
: Validate Solana signer in tests.
Here, the additional type check for a Solana signer helps prevent incorrect usage. Consider writing negative tests to confirm that an error is emitted when a signer is not of the correct type.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 436-442: zetaclient/orchestrator/orchestrator.go#L436-L442
Added lines #L436 - L442 were not covered by tests
454-454
: Outbound ID creation for Solana.
Ensurebase.OutboundIDFromCCTX(cctx)
logic is covered by unit tests for the Solana flow, verifying that each portion of the ID (index, receiver chain ID, nonce) is correctly derived.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 454-454: zetaclient/orchestrator/orchestrator.go#L454
Added line #L454 was not covered by tests
482-483
: Add test to verify active outbound skipping.
Skipping outbound processing whensolSigner.IsOutboundActive(outboundID)
istrue
is important to avoid re-processing. Implement a test confirming this logic is triggered correctly.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 482-483: zetaclient/orchestrator/orchestrator.go#L482-L483
Added lines #L482 - L483 were not covered by tests
487-487
: Include coverage for concurrency edge cases inTryProcessOutbound
.
Line 487 launchesTryProcessOutbound
asynchronously. Validate concurrency aspects by testing multiple simultaneous outbound attempts, ensuring no race conditions occur.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 487-487: zetaclient/orchestrator/orchestrator.go#L487
Added line #L487 was not covered by tests
514-515
: Validate TON signer type checks.
As with the Solana code path, verifying that the signer is indeed a TON signer prevents misuse. Add a targeted test to confirm that an error is handled gracefully for invalid signers.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 514-515: zetaclient/orchestrator/orchestrator.go#L514-L515
Added lines #L514 - L515 were not covered by tests
534-534
: Include test coverage for TON outbound ID generation.
Line 534 callsbase.OutboundIDFromCCTX
; you should validate correctness in the TON integration tests as well, guarding against unexpected parameter mismatches.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 534-534: zetaclient/orchestrator/orchestrator.go#L534
Added line #L534 was not covered by tests
544-545
: Confirm correctness ofIsOutboundActive
for TON.
WhentonSigner.IsOutboundActive(outboundID)
returnstrue
, the code correctly skips processing. A thorough test would confirm that re-processing never occurs prematurely.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 544-545: zetaclient/orchestrator/orchestrator.go#L544-L545
Added lines #L544 - L545 were not covered by testszetaclient/chains/base/signer.go (8)
4-4
: Imports aligned with new functionalities.
The newly introduced imports (fmt
,time
,github.com/zeta-chain/node/x/crosschain/types
) are cleanly integrated without extraneous overhead. Good job keeping them concise.Also applies to: 6-6, 11-11
31-32
: Add concurrency-based tests foractiveOutbounds
.
TheactiveOutbounds
map is a straightforward approach to track active outbounds, but concurrency testing is crucial. Confirm that two concurrent calls updating the same outbound ID handle the mutex properly.Also applies to: 51-51
114-114
: Blank line changes.
No functional changes were made on line 114.
122-137
: Highlight time of activation for debugging.
Logging the timestamp on activation is helpful for diagnosing outbound latencies. Consider adding a structured test verifying that the logger message matches the tracked time for newly activated outbounds.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 122-137: zetaclient/chains/base/signer.go#L122-L137
Added lines #L122 - L137 were not covered by tests
139-142
: Ensure found check is tested.
These lines handle the scenario where the outbound isn't even tracked. A test verifying that callingMarkOutbound(..., false)
on untracked IDs is safe would be valuable.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 139-142: zetaclient/chains/base/signer.go#L139-L142
Added lines #L139 - L142 were not covered by tests
155-160
: Simple concurrency check forIsOutboundActive
.
This method looks safe under a locked section. Consider a small concurrency test verifying no data race if multiple goroutines callIsOutboundActive
simultaneously on the same or different IDs.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 155-160: zetaclient/chains/base/signer.go#L155-L160
Added lines #L155 - L160 were not covered by tests
163-167
: Test malformed index values inOutboundID
.
A quick negative test for unexpected or malformed indexes (like an empty string) ensures robust ID generation.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 164-165: zetaclient/chains/base/signer.go#L164-L165
Added lines #L164 - L165 were not covered by tests
169-172
: Coverage forOutboundIDFromCCTX
.
Although straightforward, add a test for cross-checking the correct combination ofIndex
,ReceiverChainId
, andTssNonce
fromcctx
objects.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 169-171: zetaclient/chains/base/signer.go#L169-L171
Added lines #L169 - L171 were not covered by testszetaclient/chains/evm/signer/signer_test.go (1)
152-152
: Use updated signature forTryProcessOutbound
gracefully.
This invocation aligns with the newly updated method signature that no longer requires the outbound processor argument. Consider adding assertions to confirm that the function updates outbound state or produces expected signals.zetaclient/chains/bitcoin/bitcoin.go (3)
14-14
: New import usage is appropriate.
Introducing thebase
package appears necessary forOutboundIDFromCCTX
.
26-26
: Constructor simplified by removing the processor argument.
Eliminating theproc
parameter helps reduce complexity and aligns with the new pattern of delegating outbound responsibilities to the signer.
176-176
: Lack of coverage forIsOutboundActive
check.
This branch is crucial for preventing concurrent or duplicate processing. Adding test coverage here helps ensure outbound concurrency control remains correct over time.Please confirm if you want additional guidance on extending your tests to exercise this condition.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 176-176: zetaclient/chains/bitcoin/bitcoin.go#L176
Added line #L176 was not covered by testszetaclient/chains/ton/signer/signer_test.go (1)
75-75
:nil
chain observer argument inTryProcessOutbound
.
Make sure passingnil
forinterfaces.ChainObserver
is valid and won't cause downstream issues. If the observer is optional, confirm you have adequate test coverage for that scenario.zetaclient/chains/ton/signer/signer.go (1)
81-83
: Mark outbound as active within a proper deferred unmark.
This pattern clearly indicates when outbound processing begins and ends, improving concurrency safety. Ensure no race conditions occur if multiple goroutines invoke this logic concurrently.zetaclient/chains/solana/signer/signer.go (1)
118-120
: Add test coverage for new outbound tracking logic
These lines introduce important state changes (MarkOutbound(outboundID, true)
), which appear untested according to the coverage report. Please add or expand unit tests to confirm that marking outbound as active functions correctly under normal conditions and error scenarios.I can help create the necessary test cases or open a new issue for tracking if you’d like.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 118-120: zetaclient/chains/solana/signer/signer.go#L118-L120
Added lines #L118 - L120 were not covered by testszetaclient/chains/bitcoin/signer/signer.go (1)
283-285
: Enhance test coverage for added outbound ID tracking
Similar to the Solana signer, these new lines for marking outbounds should be tested to ensure stability and correctness.Happy to assist you in writing or enhancing the relevant tests to verify that outbounds are marked active accurately.
🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 283-285: zetaclient/chains/bitcoin/signer/signer.go#L283-L285
Added lines #L283 - L285 were not covered by testszetaclient/chains/evm/signer/signer.go (1)
244-246
: Provide test coverage for outbound tracking logic
Lines 244 to 246 introduce a new outbound state transition. It’s best practice to confirm that tests encompass these changes to prevent regressions.I can help prepare tests to validate that
MarkOutbound(outboundID, true)
behaves as expected in various scenarios.
Closes #3330
Summary by CodeRabbit
Release Notes
Refactor
outboundprocessor
package and related dependencies across multiple chain signersSigner
structChanges
outboundProcessor
parameter fromTryProcessOutbound
methodsbase.OutboundIDFromCCTX
MarkOutbound
method to track active outbound transactionsoutboundprocessor
initialization from various chain implementations