fix(markets): fail closed when difficulty-adjustment is unreachable - #42
Merged
Conversation
Product betting halt must use mempool remainingBlocks only. Drop the tip-height 2016-block fallback so a down height source cannot silently allow place_bet; UI already disables Place bet on command error. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Adrien Lacombe <adrienlacombe@users.noreply.github.com>
Satisfy desktop Tauri fmt check on import wrap and map_err chain. Signed-off-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Adrien Lacombe <adrienlacombe@users.noreply.github.com>
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.
Summary
Client trading halt for the v1 Bitcoin difficulty market must refuse new bets when mempool.space is down — not silently fall back to tip-height 2016-block math.
What changed
fetch_difficulty_halt_statusnow calls onlyGET https://mempool.space/api/v1/difficulty-adjustmentand parsesremainingBlocks(halt iff<= 24).MEMPOOL_TIP_HEIGHT_URL/height_fallbackfrom the product path.Err;place_betaborts before signing with “Betting is unavailable…” copy.difficulty_halt_status_from_adjustmentfor unit tests: 25 open, 24/0 halted, missing/nullremainingBlocks fails closed.Unchanged (by design)
difficulty_halt_statuserrors (marketstays null /loadError) — no UI churn.buzz-core/halt.tskept for unit tests.INDEXER_URL/AVNU_PROXY_URL/infra/aws/paymaster.tfchanges.Related issue
N/A — CEO ask on PR 31 tip-height fallback hole.
Testing
cargo test -p buzz-core remaining_blocks_signal_halts_at_24cargo test --manifest-path desktop/src-tauri/Cargo.toml commands::markets::tests(4 passed, including fail-closed parse)pnpm test -- src/features/markets/lib/markets.test.mjs(remainingBlocks thresholds)