fix(bitbox): coalesce overlapping scan ticks onto a single init()#683
Open
joshuakrueger-dfx wants to merge 1 commit into
Open
fix(bitbox): coalesce overlapping scan ticks onto a single init()#683joshuakrueger-dfx wants to merge 1 commit into
joshuakrueger-dfx wants to merge 1 commit into
Conversation
connectToBitbox guarded re-entry only with `state is BitboxConnecting`. Once the flow moved past that state (BitboxCheckHash) while the init future was still pending, a late 500ms scan tick re-entered connectToBitbox and started a SECOND init() on the shared BitBox SDK manager — undefined behaviour that wedged pairing. Extend the guard with `_pendingInit != null`, which covers the whole connect window. _pendingInit is cleared on failure/close, so genuine retries after a failed attempt still pass the guard. Regression (device-free): connect_bitbox_cubit_test.dart — a late connectToBitbox while init is pending must not call service.init again (verifyNever) and leaves the BitboxCheckHash state intact. Issue RealUnitCH#657 — Part 7, finding F1 (HIGH).
b07e243 to
fc88938
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses Issue #657 — Part 7, finding F1 (HIGH).
Problem
connectToBitboxguarded re-entry only withstate is BitboxConnecting. Once the flow moved past that state (BitboxCheckHash) while the init future was still pending, a late 500 ms scan tick re-enteredconnectToBitboxand started a secondinit()on the shared BitBox SDK manager — undefined behaviour that wedged pairing (Big-Brother analysis confirmed the state guard alone is defeated).Fix
Extend the guard:
if (state is BitboxConnecting || _pendingInit != null) return;—_pendingInitcovers the whole connect window and is cleared on failure/close, so genuine retries still pass. Minimal, additive, happy path unchanged.Tests (RED→GREEN, proven, device-free)
New regression: a late
connectToBitboxwhile init is pending must not callservice.initagain (verifyNever) and leavesBitboxCheckHashintact — fails on the old code (verified). Full suite green includingtest/integration/connect_bitbox_flow_test.dart(the replug/re-attach contract),flutter analyzeclean.🤖 Big Brother fleet analysis + operator hand-finish. Ref #657.