Skip to content

btc/v36: network-id/prefix independence (#95 BTC mirror) - #96

Merged
frstrtr merged 4 commits into
masterfrom
btc/v36-parity-network-prefix-independence
Jun 16, 2026
Merged

btc/v36: network-id/prefix independence (#95 BTC mirror)#96
frstrtr merged 4 commits into
masterfrom
btc/v36-parity-network-prefix-independence

Conversation

@frstrtr

@frstrtr frstrtr commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Problem

btc::PoolConfig::set_network_id() set the network IDENTIFIER correctly but then
derived the transport PREFIX from it via an XOR-rotate scheme
(b = id[i] ^ id[(i+3)%8] ^ 0x5A). In the p2pool model, PREFIX and IDENTIFIER are
two independent per-network constants with no algebraic relationship. As a result
c2pool structurally could not join any p2pool sharechain via a custom network id:
pass --network-id and the prefix is wrong (derived); omit it and the identifier is
wrong (compiled default). No config-only fix existed.

This is the BTC mirror of the ltc/config_pool.hpp fix (ltc-doge root-cause). Btc-only
PR per the per-coin isolation invariant — not bundled with ltc.

Fix

  • set_network_id(network_id_hex, prefix_hex_override = "") now takes an independent
    prefix override and sets override_prefix_hex directly; it never derives the prefix.
  • When no prefix override is supplied, override_prefix_hex stays empty so prefix_hex()
    falls back to the compiled network-default prefix.
  • chain_fingerprint_u64() now hashes the effective prefix_hex()/identifier_hex()
    rather than the raw overrides, so the chain fingerprint stays coherent with the prefix
    actually used on the wire.

Verification

  • make c2pool-btcBuilt target c2pool-btc, exit 0 (only pre-existing stdlib warnings).
  • Single file changed: src/impl/btc/config_pool.hpp (+28/-26). Zero ltc/shared footprint.

Notes

  • BTC entrypoint main_btc.cpp does not yet parse --network-id/--prefix at all
    (pre-existing gap, broader than this defect) — so the new prefix-override parameter is
    not yet wired to a CLI flag on the BTC side. The header fix removes the corruption; CLI
    wiring can follow as a separate change if desired.

frstrtr added 4 commits June 12, 2026 08:29
V37 base data structure per the v1.0 design doc (all OQ/S decisions
resolved): multichain lane container, MRR roll-up pyramid (OQ-5 default
geometry), epoch-scaled incremental decay accumulators with exact
epoch-boundary rebuild (OQ-2), PayoutDescriptor v1 identity canon
(OQ-3, S-1/S-2/S-3), quantized whole-bucket window eviction (OQ-1),
reorg journal D=64 with full-rebuild fallback (OQ-7), canonical lane
digest with F-1 raw-work leaves (OQ-4), Q62 fixed-point model.

Header-only, stdlib-only, namespace v37; standalone test suite with an
independent full-scan reference implementation as the consensus gate:
100338 checks, 0 failures (g++ 13.3 -O2 and ASan/UBSan). Range pinning,
spec errata, and CI follow-ups in src/sharechain/v37/IMPLEMENTATION-NOTES.md.
PREFIX and IDENTIFIER are two INDEPENDENT per-network constants in the
p2pool model, with no algebraic relationship. The previous set_network_id
derived PREFIX from IDENTIFIER via an XOR-rotate scheme that has no p2pool
analog, so c2pool structurally could not join any p2pool sharechain via a
custom network id: supplying the id corrupted the transport framing prefix.

- set_network_id now takes an independent prefix override and sets
  override_prefix_hex directly; it never derives the prefix.
- When no prefix override is supplied, override_prefix_hex stays empty so
  prefix_hex() falls back to the compiled network-default prefix.
- chain_fingerprint_u64 now hashes the effective prefix_hex()/identifier_hex()
  so the chain fingerprint stays coherent with the prefix actually used on
  the wire (it could previously hash an empty/derived prefix).

Mirror of the ltc/config_pool.hpp fix; btc-only, per per-coin isolation.
Connect the B2-net private-chain overrides to the entrypoint so the
independent IDENTIFIER/PREFIX constants exposed by set_network_id
(9034b59) are reachable from the command line.

- --network-id ID : c2pool sharechain IDENTIFIER override (hex, <=8B)
- --prefix HEX    : c2pool sharechain PREFIX override (hex, <=8B),
                    an independent per-network constant, never derived
                    from IDENTIFIER
- bare --network-id keeps the compiled default prefix; --prefix without
  --network-id is a no-op and warns rather than silently ignoring
- usage text updated to document both flags

Build GREEN (c2pool-btc); --help and override parse smoke-tested.
v37_test is registered in CTest via add_subdirectory(v37/test) but was
absent from the explicit --target lists in build.yml, so ctest reported
the binary as missing (Not Run -> FAILURE). CI builds named targets only,
not all; add v37_test to both the Linux and ASAN+UBSan build lists so the
header-only/stdlib-only suite (100338 checks, 0 failures) actually builds
and runs. No CMake change needed; registration was already correct.
@frstrtr
frstrtr merged commit c38b37d into master Jun 16, 2026
17 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