Pass nullptr instead of uv_default_loop_checked() when deserializing
cached blocks at startup. This skips parallel key pre-computation
during the one-time cache load, avoiding a threading check that was
failing on macOS arm64.
The parallel optimization is only used during cache loading - normal
runtime block processing from peers is unaffected.
- Added m_readyToMine flag to SideChain
- Display LOADING SIDECHAIN banner at startup
- Delay stratum server and mining until sidechain sync completes
- Display MINING IS NOW ENABLED when ready
- Prevents premature mining that caused peer bans and chain splits
P2PServer starts immediately for sync, but stratum port doesn't
open until sidechain is fully loaded and after pruning completes
Added bounds check in get_hashing_blob_nolock() to handle empty
m_transactionHashes when old/stale template slots are accessed.
Returns 0 and logs at level 3 instead of vector out-of-bounds crash.
Primarily affects external stratum miners that may
hold onto old job IDs across template updates
Root cause: Merkle verification failures (error 659) and peer bans occurred
because protocol TX was not consistently present in m_transactions[1].
Parser fix (pool_block_parser.inl):
- Skip dummy transactions[0] entry when populating m_transactions
- Add protocol TX computation after parsing for Carrot v1 blocks
Block template fix (block_template.cpp):
- Insert protocol TX at position [1] during block creation in update()
- Insert protocol TX during select_mempool_transactions()
get_pow_hash fix (pool_block.cpp):
- Ensure protocol TX is populated before serialize_mainchain_data()
The protocol TX must be at m_transactions[1] before ANY serialization
occurs, otherwise sender and receiver compute different merkle roots.
Tested: Multiple restart cycles with two nodes, no bans, chains stay synced.
Problem: P2Pool nodes starting at different times or experiencing network
issues would create independent genesis blocks, resulting in incompatible
chains. Nodes would ban each other for invalid blocks that were actually
valid on a different chain. Cache resume after restart frequently failed
due to genesis mismatch between nodes.
Solution: Oldest compatible genesis wins protocol that coordinates
genesis selection across peers before mining begins.
New P2P message GENESIS_INFO exchanges:
- Genesis block hash
- Genesis timestamp
- Genesis mainchain height
- Protocol version
Startup behavior:
- Wait up to 90 seconds for peer genesis info (with progress logging)
- Adopt oldest genesis from compatible peers
- Only create own genesis if no peers respond
Late joiner reconciliation:
- Running nodes that receive older genesis from new peer will purge
their sidechain and re-sync to the older chain
- Cache files deleted on purge to prevent reload of stale blocks
Protocol versioning:
- PROTOCOL_VERSION constant at top of side_chain.h
- Increment only on consensus-breaking changes
- Version mismatch logs warning, prevents genesis adoption
Tiebreaker: When timestamps match, lexicographically lower hash wins.