fix(zetaclient): backport respect DisableTssBlockScan in Bitcoin observer#4599
fix(zetaclient): backport respect DisableTssBlockScan in Bitcoin observer#4599skosito wants to merge 1 commit into
Conversation
* fix(zetaclient): respect DisableTssBlockScan in Bitcoin observer * same fix in inbound tracker * log * changelog
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. 🗂️ Base branches to auto review (1)
Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
| func Test_ObserveInbound_DisableTssBlockScan(t *testing.T) { | ||
| chain := chains.BitcoinMainnet | ||
| ob := newTestSuite(t, chain) | ||
|
|
||
| // flip the chain param to disable inbound scanning | ||
| chainParams := ob.ChainParams() | ||
| chainParams.DisableTssBlockScan = true | ||
| ob.SetChainParams(chainParams) | ||
|
|
||
| // ObserveInbound should return early without scanning any block. | ||
| // We intentionally do NOT mock GetBlockHash/GetBlockVerbose — if scanning | ||
| // were attempted, the mock client would fail the test on unexpected calls. | ||
| err := ob.ObserveInbound(ob.ctx) | ||
| require.NoError(t, err) | ||
| } |
There was a problem hiding this comment.
Test does not cover public callers (
ProcessInboundTrackers / ProcessInternalTrackers)
The guard lives inside observeInboundTrackers, but ProcessInboundTrackers still calls ob.ZetaRepo().GetInboundTrackers(ctx) and ProcessInternalTrackers still calls ob.GetInboundInternalTrackers before reaching the guard. Those callers are the ones actually triggered by the scheduler, yet neither is covered by a test here. A test for each public entry-point would confirm the full intended behaviour (and would also catch any future guard-bypass regression if the guard is accidentally moved or removed in a refactor).
Prompt To Fix With AI
This is a comment left during a code review.
Path: zetaclient/chains/bitcoin/observer/inbound_test.go
Line: 149-163
Comment:
**Test does not cover public callers (`ProcessInboundTrackers` / `ProcessInternalTrackers`)**
The guard lives inside `observeInboundTrackers`, but `ProcessInboundTrackers` still calls `ob.ZetaRepo().GetInboundTrackers(ctx)` and `ProcessInternalTrackers` still calls `ob.GetInboundInternalTrackers` before reaching the guard. Those callers are the ones actually triggered by the scheduler, yet neither is covered by a test here. A test for each public entry-point would confirm the full intended behaviour (and would also catch any future guard-bypass regression if the guard is accidentally moved or removed in a refactor).
How can I resolve this? If you propose a fix, please make it concise.
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
original PR #4597
How Has This Been Tested?
Note
Medium Risk
When
DisableTssBlockScanis enabled, Bitcoin inbound deposits will no longer be observed/voted on (by design), so misconfiguration could halt deposit processing; changes are otherwise localized with added unit coverage.Overview
Respects
DisableTssBlockScanfor Bitcoin inbound handling. The Bitcoin observer now returns early from bothObserveInboundblock-range scanning andobserveInboundTrackersprocessing whenChainParams.DisableTssBlockScanis true, emitting sampled info logs.Adds unit tests asserting that with the flag enabled, neither block scanning nor inbound-tracker processing attempts any Bitcoin RPC calls and the methods exit cleanly.
Reviewed by Cursor Bugbot for commit 3b718ef. Configure here.
Greptile Summary
This PR ports the
DisableTssBlockScanguard from the EVM observer to the Bitcoin observer, ensuring that when the flag is set bothObserveInboundandobserveInboundTrackersreturn early without scanning or voting on inbound transactions.inbound.go: guard is inserted afterupdateLastBlock(preserving block-height tracking) but before any scanning, matching the intent of the flag.inbound_tracker.go: guard is inserted at the top ofobserveInboundTrackers, covering both external (ProcessInboundTrackers) and internal (ProcessInternalTrackers) tracker paths via the shared helper.inbound_test.go: two new tests confirm the early-return behaviour by relying on testify mock's strict unexpected-call detection.Confidence Score: 4/5
The change is a targeted, minimal flag-check insertion with no impact on outbound processing; safe to merge.
Both guard locations are correct and the logic is straightforward. The only gap is that the public callers ProcessInboundTrackers and ProcessInternalTrackers still perform preliminary network/state work before the guard is reached inside observeInboundTrackers, and neither is covered by a dedicated test. This is a minor quality concern rather than a functional defect.
zetaclient/chains/bitcoin/observer/inbound_test.go — the tests exercise observeInboundTrackers directly but do not cover the public ProcessInboundTrackers and ProcessInternalTrackers entry-points.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Scheduler participant Observer Note over Scheduler,Observer: ObserveInbound path Scheduler->>Observer: ObserveInbound(ctx) Observer->>Observer: updateLastBlock(ctx) alt "DisableTssBlockScan == true" Observer-->>Scheduler: return nil (early exit) else "DisableTssBlockScan == false" Observer->>Observer: observeInboundInBlockRange(...) Observer-->>Scheduler: return nil end Note over Scheduler,Observer: ProcessInboundTrackers path Scheduler->>Observer: ProcessInboundTrackers(ctx) Observer->>Observer: GetInboundTrackers(ctx) Observer->>Observer: observeInboundTrackers(ctx, trackers, false) alt "DisableTssBlockScan == true" Observer-->>Scheduler: return nil (early exit) else "DisableTssBlockScan == false" Observer->>Observer: CheckReceiptAndPostVoteForBtcTxHash(...) Observer-->>Scheduler: return nil end Note over Scheduler,Observer: ProcessInternalTrackers path Scheduler->>Observer: ProcessInternalTrackers(ctx) Observer->>Observer: GetInboundInternalTrackers(ctx) Observer->>Observer: observeInboundTrackers(ctx, trackers, true) alt "DisableTssBlockScan == true" Observer-->>Scheduler: return nil (early exit) else "DisableTssBlockScan == false" Observer->>Observer: CheckReceiptAndPostVoteForBtcTxHash(...) Observer-->>Scheduler: return nil endPrompt To Fix All With AI
Reviews (1): Last reviewed commit: "fix(zetaclient): respect DisableTssBlock..." | Re-trigger Greptile