nmc: P1 PD embedded AuxChainEmbedded (dual-target + parent-coinbase commitment) - #214
Merged
Conversation
Adds nmc::coin::Mempool — a byte-faithful mirror of src/impl/btc/coin/ mempool.hpp re-homed into namespace nmc::coin so the NMC coin tree stays self-contained (no btc::coin symbols). Namecoin is a Bitcoin fork: same wire format, 21M money cap, 100-block coinbase maturity (NMC_LIMITS, instantiated locally from the public core::coin::ChainLimits; no core edit). Feeds the P1 PC template builder next. Coverage: +3 KATs in the existing (CI-allowlisted) nmc_auxpow_merkle_test (add/contains/remove + dedup, feerate-ordered selection, confirmed-block cleanup). Suite 66 -> 69 green. Fence held: src/impl/nmc/ only, no build.yml / src/core / bitcoin_family change. Reference: namecoin-core (Bitcoin fork) txmempool.cpp / amount.h MAX_MONEY, consensus.h COINBASE_MATURITY.
Re-home the BTC native block-template builder into the NMC coin tree so the
embedded merge-mined Namecoin chain can build block templates (WorkData)
natively from its HeaderChain + Mempool, without the getblocktemplate RPC.
* coin/rpc_data.hpp -- nmc::coin::rpc::WorkData (template payload)
* coin/template_builder.hpp -- get_block_subsidy (50 NMC, halving every
210,000 blocks, identical to Bitcoin), compute_merkle_root (SHA256d),
CoinNodeInterface, TemplateBuilder::build_template, EmbeddedCoinNode;
log tags [EMB-NMC].
* coin/header_chain.hpp -- add get_header_by_height (parent-link walk,
no height index), is_synced (DEFAULT_MAX_TIP_AGE gate), and the
get_next_work_required / calculate_next_work_required retarget the
builder needs. NMC shares Bitcoins 2016-block / 10-minute retarget.
* coin/coin_smoke.cpp + CMakeLists -- force-compile the header-only builder.
PC is the STRUCTURAL builder only; merge-mining commitment / dual-target
(phase PD) are not implemented here.
KATs: nmc_template_builder_test (10) covers subsidy halving boundaries,
compute_merkle_root (0/1/2/odd/even leaves, independently re-derived), and
build_template on a seeded chain (tip -> WorkData; empty -> nullopt).
Suite 69 -> 79 green. Fenced to src/impl/nmc/ (plus the one build.yml
--target allowlist line). btc/core trees consumed READ-ONLY.
…ommitment)
Implements c2pool::merged::IAuxChainBackend over the embedded NMC
HeaderChain + TemplateBuilder (analog of doge aux_chain_embedded.hpp,
adapted to the BTC parent / SHA256d / NMCChainParams::aux_chain_id).
Build-side complement of the P1c/P1d/P1f verify legs:
* get_work_template() surfaces the aux PoW target (dual-target check)
and the NMC block-hash committed in the parent BTC coinbase;
* chain_id sourced from NMCChainParams::aux_chain_id (the same field
the verify side pins), not the transport-layer config copy;
* sync gate: empty/stale chain yields empty work (no daemon, no leak);
* submit_block P2P-relay path + submit_aux_block fallback (logged).
+4 KATs into the existing nmc_template_builder_test exe (10->14 green):
dual-target re-derivation, parent-coinbase commitment == tip, sync gate,
createauxblock==getblocktemplate, submit/get_block_hex cache.
Fence: src/impl/nmc/ only; btc tree READ-ONLY; merged_mining seam
consumed READ-ONLY. No core/ or build.yml change (rides existing exe).
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.
Stacked on #213 (PC). Phase PD of the embedded merge-mined Namecoin lane.
What
Implements
c2pool::merged::IAuxChainBackend(nmc::coin::AuxChainEmbedded) over the embedded NMC HeaderChain + TemplateBuilder — the build-side complement of the P1c/P1d/P1f verify legs. Analog ofsrc/impl/doge/coin/aux_chain_embedded.hpp, adapted to the BTC parent (SHA256d) andNMCChainParams::aux_chain_id.get_work_template()surfaces:aux_merkle_root());NMCChainParams::aux_chain_id(the same consensus field the verify side pins, not the transport-layer config copy);Plus
submit_block(P2P-relay, embedded) +submit_aux_blockfallback (logged; no daemon to RPC).Tests
+4 KATs into the existing
nmc_template_builder_testexe (10 -> 14 green, exit 0): dual-target independent re-derivation, parent-coinbase commitment == tip, sync gate, createauxblock==getblocktemplate, submit/get_block_hex cache.Fence
src/impl/nmc/only; btc tree consumed READ-ONLY; merged_mining seam consumed READ-ONLY. No core/ and no build.yml change — rides the existing test exe (no new NOT_BUILT allowlist entry).Caveat (carried from P1f)
aux_chain_id/auxpow_activation_heightremain unpinned (-1 sentinel) in production params; the KATs use a TEST-only pin (1 / 19200). Pinning against a live namecoind is the open P1f blocker on integrator.