btc/v36: network-id/prefix independence (#95 BTC mirror) - #96
Merged
Conversation
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.
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.
Problem
btc::PoolConfig::set_network_id()set the network IDENTIFIER correctly but thenderived 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 aretwo 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-idand the prefix is wrong (derived); omit it and the identifier iswrong (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 independentprefix override and sets
override_prefix_hexdirectly; it never derives the prefix.override_prefix_hexstays empty soprefix_hex()falls back to the compiled network-default prefix.
chain_fingerprint_u64()now hashes the effectiveprefix_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-btc→Built target c2pool-btc, exit 0 (only pre-existing stdlib warnings).src/impl/btc/config_pool.hpp(+28/-26). Zero ltc/shared footprint.Notes
main_btc.cppdoes not yet parse--network-id/--prefixat 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.