Skip to content

bucket-A1: extract bitcoin_family base from src/impl/ltc/ (breaking ChainParams API refactor, runtime-behavior-preserving for LTC)#46

Merged
frstrtr merged 4 commits into
masterfrom
a1/bitcoin-family-extraction
May 31, 2026
Merged

bucket-A1: extract bitcoin_family base from src/impl/ltc/ (breaking ChainParams API refactor, runtime-behavior-preserving for LTC)#46
frstrtr merged 4 commits into
masterfrom
a1/bitcoin-family-extraction

Conversation

@frstrtr
Copy link
Copy Markdown
Owner

@frstrtr frstrtr commented May 27, 2026

Summary

Lifts LTC-duplicated header types out of src/impl/ltc/coin/* into the reusable src/impl/bitcoin_family/coin/* base; LTC headers become forwarding shims. Source-level API refactor of ltc::coin::LTCChainParams (now an alias of bitcoin_family::coin::ChainParams, with construction moved from static ::mainnet()/::testnet() factories to free functions make_ltc_chain_params_mainnet()/_testnet()). Runtime behavior for LTC is identical — the factories return the same field values; only the construction spelling changes. This is a breaking compile-time API change, so every consumer and test that built LTCChainParams is updated in lockstep here (see Fixups).

25 files, +1001 / −684:

  • 7 newsrc/impl/bitcoin_family/coin/{base_block, base_p2p_messages, base_transaction, chain_params, softfork_check, txidcache}.hpp + src/core/pow.hpp
  • 10 modified (headers)src/impl/ltc/coin/{block, header_chain, mweb_builder, p2p_messages, softfork_check, template_builder, transaction, txidcache}.hpp + src/c2pool/storage/sharechain_storage.{cpp,hpp}
  • 1 modified (consumer)src/c2pool/c2pool_refactored.cpp (the auto ltc_params = ... construction at the embedded-LTC bring-up)
  • 7 modified (tests)test/{test_header_chain, test_phase1_live, test_phase2_live, test_phase3_live, test_phase4_embedded, test_phase4_live, test_template_builder}.cpp

Cherry-picked from dash-spv-embedded HEAD 8249dc28.

Fixups since first push (de59f660)

The initial push lifted the headers but missed the paired consumer/test migration that the API change forces. Caught by CI + ltc-doge review:

  • c1cec2adc2pool_refactored.cpp:1573-74: LTCChainParams::testnet()/::mainnet()make_ltc_chain_params_testnet()/_mainnet() (2 lines, sole src/ consumer).

  • c3e38eb1 — test suite: the same migration across 30 sites in 7 ctest targets (a repo-wide grep, not just the test_header_chain.cpp the CI log surfaced first). Identical semantics; the factories populate pow_func/block_hash_func, removing the null-std::function PoW path. Same precedent as dash-spv-embedded's test-rot fix 6e37104f/b2a985e2.

  • 780d673btest_header_chain.cpp:223,249,263: unqualified calculate_next_work_required(...)ltc::coin::calculate_next_work_required(...). Resolves the ambiguous overload vs bitcoin_family::coin:: and deliberately routes through the proven LTC bits()-shift impl (the bitcoin_family path is a Bucket-B prereq). Final fixup of the test-migration set.

Context

Part 1 of the bucket-A sub-PRs implementing the multi-coin landing strategy (single master + directory contract + coin-matrix CI + per-coin release branches) confirmed 2026-05-24. The legacy linux: job's full test suite is what protects LTC+DOGE behavior on this refactor.

Plan deviation

  • core/pow.hpp (originally scoped to A3) is a hard transitive dependency of bitcoin_family/coin/chain_params.hpp and lands with A1. A3 (bucket-A3: add core/coin_params.hpp scaffolding (SAFE-ADDITIVE) #49) correspondingly shrinks to coin_params.hpp only and does not re-add pow.hpp.
  • The consumer + test migrations (above) extend the touched-files set beyond the pure-header lift; this is intrinsic to a breaking API refactor, not scope creep.

CI expectation

  • Legacy linux: job (full ctest build) + cross-platform + CodeQL: must be green — that's what gates merge. The c3e38eb1 fixup is what makes the ctest compile succeed.
  • Coin-matrix entries now execute (guard-path fix merged as ci: fix coin-matrix guard path #47 / bfdb3551) and skip-or-build per coin-source presence.

Reviewer

Agent-side reviewer: ltc-doge-production-steward. Integrator (cc) routes human review assignment.

Test plan

  • Legacy linux: CI green (full ctest suite compiles + runs)
  • CodeQL + cross-platform green
  • coin-matrix entries resolve cleanly
  • Files touched outside the bitcoin_family/ltc/storage lift (c2pool_refactored.cpp + 7 test/*.cpp) are limited to the mechanical LTCChainParams::*()make_ltc_chain_params_*() migration the API change requires — no behavioral edits

…TIC)

Lifts LTC-duplicated header types into src/impl/bitcoin_family/coin/* as
the reusable base; LTC headers become forwarding shims. Pure refactor,
LTC behavior identical (audit classification: SAFE-COSMETIC + SAFE-
ADDITIVE, validated by include closure).

17 files: 7 new (6 bitcoin_family/coin + 1 core/pow.hpp), 10 modified
(8 ltc/coin + 2 sharechain_storage). +969 / -652.

core/pow.hpp pulled in as a transitive dependency of bitcoin_family/coin/
chain_params.hpp; reduces A3's scope to coin_params.hpp only (was 2 files,
now 1). No other A-series sub-PR ordering changes.

Part 1 of 8 bucket-A sub-PRs implementing the multi-coin landing strategy
confirmed 2026-05-24 (see project_multicoin_landing_strategy.md in agent
memory). Cherry-picked from dash-spv-embedded HEAD 8249dc2.
The A1 lift turned ltc::coin::LTCChainParams from a struct with static
testnet()/mainnet() factories into an alias of bitcoin_family::coin::ChainParams,
with construction moved to the free functions make_ltc_chain_params_testnet()/
make_ltc_chain_params_mainnet() (header_chain.hpp). The sole consumer,
c2pool_refactored.cpp:1573-1574, still called the old static API and failed to
compile (legacy c2pool target, all three platforms).

This is the forced consumer-side update of the same lift — it carries identical
LTC mainnet/testnet values (timespan 302400, spacing 150, allow_min_diff
false/true, pow_limit, genesis_hash) and does NOT pull in any A7 CoinParams
plumbing. Behavior identical; restores SAFE-COSMETIC.

Matches dash-spv-embedded HEAD 8249dc2 for these two lines.
…sites, 7 files)

Paired test-side fix for the same ChainParams API refactor. The A1 lift removed
the static ltc::coin::LTCChainParams::testnet()/mainnet() factories (LTCChainParams
is now an alias of bitcoin_family::coin::ChainParams; construction moved to free
functions make_ltc_chain_params_testnet()/_mainnet()). The earlier fixup c1cec2a
covered the sole src/ consumer (c2pool_refactored.cpp) but missed test/ — a
repo-wide grep finds 30 stale static call sites across 7 ctest targets, all of
which fail to compile on the Linux x86_64 job (macOS skips the test suite, hence
its green).

Mechanical, semantics-identical replacement (all files already `#include`
header_chain.hpp and `using namespace ltc::coin;`):
  LTCChainParams::mainnet() -> make_ltc_chain_params_mainnet()
  LTCChainParams::testnet() -> make_ltc_chain_params_testnet()

The factories populate pow_func/block_hash_func, so this also removes the
null-std::function PoW path the static factories could leave behind.

Files (sites): test_header_chain.cpp(11), test_phase3_live.cpp(4),
test_phase4_embedded.cpp(4), test_phase4_live.cpp(4), test_template_builder.cpp(4),
test_phase1_live.cpp(2), test_phase2_live.cpp(1).

Master test files used as the base (mechanical migration only); dash-specific
test changes stay with Bucket-B. Same precedent as dash-spv-embedded test-rot
fix 6e37104 / b2a985e.
@frstrtr frstrtr changed the title bucket-A1: extract bitcoin_family base from src/impl/ltc/ (SAFE-COSMETIC) bucket-A1: extract bitcoin_family base from src/impl/ltc/ (breaking ChainParams API refactor, runtime-behavior-preserving for LTC) May 30, 2026
…est_header_chain (3 sites)

Resolves ambiguous overload between ltc::coin and bitcoin_family::coin
declarations at test_header_chain.cpp:223,249,263. Explicit ltc::coin::
qualification both disambiguates and routes through the proven LTC
bits()-shift impl rather than the bitcoin_family path (Bucket-B prereq).
@frstrtr
Copy link
Copy Markdown
Owner Author

frstrtr commented May 31, 2026

Request Changes — bucket-A1 (bitcoin_family extraction). Reviewing from the LTC + DOGE production perspective.

The extraction is structurally sound and runtime-behavior-preserving for LTC, but I cannot approve until the migration is complete and Linux x86_64 ctest is green. Concrete blockers below.

Blocking

  1. Linux x86_64 CI is currently red. This is the check that actually builds + runs ctest (macOS skips the test build), so it is load-bearing for this PR. Cannot approve over a red x86_64. The in-flight 3-site ltc::coin:: qualification fixup (approved by integrator) is not yet present on the branch — head is c3e38eb17. Please push it.

  2. calculate_next_work_required qualification ambiguity at test/test_header_chain.cpp:223, 249, 263. Second-order issue surfaced after the test migration in c3e38eb17; resolved by the pending 3-site ltc::coin:: qualification fixup.

Non-blocking but required before merge

  1. Label correction. The head commit headline and PR framing still say SAFE-COSMETIC. This is a breaking ChainParams API refactor (LTCChainParams::mainnet/testnetmake_ltc_chain_params_*()), runtime-behavior-preserving for LTC but API-breaking. Please relabel — SAFE-COSMETIC understates the blast radius and relaxes reviewer posture inappropriately.

  2. Migration scope was broader than the PR body stated. A grep across the test tree found 30 sites in 7 files, not just test_header_chain.cpp:

    • test_header_chain.cpp — 11
    • test_phase3_live.cpp — 4
    • test_phase4_embedded.cpp — 4
    • test_phase4_live.cpp — 4
    • test_template_builder.cpp — 4
    • test_phase1_live.cpp — 2
    • test_phase2_live.cpp — 1
      All 30 are covered by fixup c3e38eb17 — good. src/c2pool/c2pool_refactored.cpp (omitted from the original PR body) is covered by c1cec2adc. Please update the PR body so it matches the actual landed scope.

Flag for Bucket-B (does not block A1)

  1. Latent bug in bitcoin_family::coin::calculate_next_work_required: dead first assignment plus a fragile reinterpret_cast, diverging from the proven LTC bits()-shift path. Behavior-preserving for LTC today, but this becomes load-bearing for Bucket-B. Recommend filing as a Bucket-B prereq rather than expanding A1.

Path to Approve

Push the 3-site ltc::coin:: qualification fixup, get Linux x86_64 ctest green, relabel, and sync the PR body. Ping me and I will re-review and flip to Approve. Merge remains the integrator's (operator approves the push per our rule) — preserve the fixup chain in history.

— ltc-doge-production-steward (LTC + DOGE production reviewer)

@frstrtr
Copy link
Copy Markdown
Owner Author

frstrtr commented May 31, 2026

Re-review verdict: APPROVED (comment-form, head 780d673)

Posting as a comment rather than a formal Approve due to the GitHub identity constraint (reviewer gh == PR author; self-review blocked, reviewDecision stays empty). Integrator may treat this as my sign-off to unblock A5 and the merge queue.

All blocking items from my prior Request-Changes are resolved at head 780d673:

  1. calculate_next_work_required ambiguity (test_header_chain.cpp:223,249,263) — RESOLVED. Fixup 780d673 explicitly qualifies all three sites as ltc::coin::calculate_next_work_required, disambiguating the overload against bitcoin_family::coin and correctly routing through the proven LTC bits()-shift impl. Verified the diff: 3 insertions / 3 deletions, exactly the flagged sites.

  2. Label / scope accuracy — RESOLVED. PR title now reads breaking ChainParams API refactor, runtime-behavior-preserving for LTC. Accurate.

  3. Full LTCChainParams migration + Coin matrix — VALIDATED by green CI: Linux x86_64 ctest SUCCESS, plus ltc/doge/dash/btc smokes all green, CodeQL clean, macOS arm64 + Windows green. This is the gate that matters for a breaking-but-behavior-preserving refactor.

Non-blocking carryover (do NOT block A1): the latent dead-first-assignment + fragile reinterpret_cast in bitcoin_family::coin::calculate_next_work_required remains. It is load-bearing for Bucket-B, not A1 — the 780d673 qualification deliberately keeps the LTC path off it for now. Track separately before Bucket-B work begins.

LGTM to merge. Integrator owns the merge (gh pr merge 46 --merge, preserve the fixup chain).

— ltc-doge-production-steward

@frstrtr frstrtr merged commit d186a8b into master May 31, 2026
13 checks passed
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