Skip to content

tighten up bitcoin_core_sv2 JDP ValidationContext - #617

Draft
plebhash wants to merge 5 commits into
stratum-mining:mainfrom
plebhash:2026-07-14-tighter-validation-context
Draft

tighten up bitcoin_core_sv2 JDP ValidationContext#617
plebhash wants to merge 5 commits into
stratum-mining:mainfrom
plebhash:2026-07-14-tighter-validation-context

Conversation

@plebhash

@plebhash plebhash commented Jul 15, 2026

Copy link
Copy Markdown
Member

close #597 #595

pre-requisite for #268

@plebhash plebhash changed the title 2026 07 14 tighter validation context tighten up bitcoin_core_sv2 JDP ValidationContext Jul 15, 2026
@plebhash
plebhash force-pushed the 2026-07-14-tighter-validation-context branch 9 times, most recently from 3d638df to f9465c7 Compare July 15, 2026 21:20
plebhash added 5 commits July 16, 2026 14:16
…idation context

Restrict DeclareMiningJob stale-chain-tip classification to actual
prev_hash drift and simplify related context state.

- classify stale-tip strictly by prev_hash drift (v30x + v31x)
- remove redundant min_ntime from ValidationContext
- make jd-server drift checks prev_hash-only
- prune now-unused BIP34 mempool plumbing/logging
- remove unused timestamp from JdResponse::Success
- keep timestamp handling local to handler checkBlock assembly
- rename remaining timestamp references to ntime for clarity
…mempool_mirror_prev_hash

Replace the expensive createNewBlock call (which assembles a full block
template with mempool transactions) with a lightweight getTip query.
Only the prev_hash is needed for stale-tip detection, so updating just
the mirror's prev_hash via getTip is sufficient when the tip changed.

Rename force_update_mempool_mirror to force_update_mempool_mirror_prev_hash
to make the narrowed scope explicit.
…in-tip

When a declared job is already stale at arrival (coinbase built from an
old tip), checkBlock returns bad-cb-height but prev_hash may not have
drifted during validation.  Treat this rejection as stale-chain-tip so
that JDC's non-fatal stale path is exercised instead of triggering a
fallback.
BIP34 mismatch is no longer detectable on `BitcoinCoreSv2JDP`, which now solely relies on `prev_hash` to detect chain tip drifts

that is fine, because if BIP34 drifted, `prev_hash` will be inevitably different

that's why we're changing the shape of `assert_jdp_stale_chain_tip_scenario`
Cover the path where a declared job uses a coinbase built from a
previous tip that is no longer the current tip at validation time.
In this scenario checkBlock rejects with bad-cb-height while no
in-handler prev_hash drift occurs, so the handler must map the
rejection to stale-chain-tip.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bitcoin_core_sv2: JDP stale-chain-tip detection should use prev_hash only (avoid min_ntime/nbits/bip34 drift)

1 participant