Skip to content

nmc(P1e): work-based reorg fork-choice (+6 KATs, 46->52) - #197

Merged
frstrtr merged 1 commit into
masterfrom
nmc/p1e-work-reorg-forkchoice
Jun 19, 2026
Merged

nmc(P1e): work-based reorg fork-choice (+6 KATs, 46->52)#197
frstrtr merged 1 commit into
masterfrom
nmc/p1e-work-reorg-forkchoice

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 19, 2026

Copy link
Copy Markdown
Owner

What

HeaderChain::connect_locked now selects the chain tip by most cumulative work (with an equal-work tie-break at the tip height), not greatest height — mirroring btc::coin::HeaderChain. Closes the last P1e fork-choice sub-leg; the prior leg only summed work, tip selection stayed height-proxy.

  • Heavier competing branch reorgs the tip even when shorter.
  • Equal-work sibling at the tip height switches the tip (network-consensus tie-break; matters on min-difficulty testnet where every block carries identical per-block work).
  • Idempotent reject of known hashes makes the switch flip-flop-proof.
  • Emits [EMB-NMC] REORG / EQUAL-WORK REORG log on branch switch.

Tests

New NmcP1eForkChoice suite (6 KATs): heavier-short-branch reorg, lighter-sibling no-reorg, equal-work switch, re-receive stability, post-reorg extend, first-header-is-tip.

nmc_auxpow_merkle_test 52/52 PASS (was 46). Build green; rides the allowlisted target, no CI change.

Scope

NMC tree only (src/impl/nmc/coin/header_chain.hpp + test). No cross-coin, no shared src/core.

connect_locked now selects the tip by most-cumulative-work (with an
equal-work tie-break at the tip height) instead of greatest-height,
mirroring btc::coin::HeaderChain. A heavier competing branch reorgs the
tip even when shorter; an equal-work sibling at the tip height switches
(network-consensus tie-break for min-difficulty testnet). Idempotent
reject of known hashes makes the switch flip-flop-proof.

New NmcP1eForkChoice suite: heavier-short-branch reorg, lighter-sibling
no-reorg, equal-work switch, re-receive stability, post-reorg extend,
first-header-is-tip. nmc_auxpow_merkle_test 52/52 PASS.
@frstrtr
frstrtr merged commit bd1f0e2 into master Jun 19, 2026
18 checks passed
@frstrtr
frstrtr deleted the nmc/p1e-work-reorg-forkchoice branch June 19, 2026 09:36
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.

1 participant