Implement genesis reconciliation protocol for sidechain stability
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.
This commit is contained in:
+20
-5
@@ -361,11 +361,26 @@ Params::Params(int argc, char* const argv[])
|
||||
m_mainWallet.encode(display_wallet_buf);
|
||||
}
|
||||
|
||||
// Initialize dev wallet
|
||||
const char* dev_wallet_str = "SC11VXXJyJTZcFJikJrgQKE2HmfXCt2DnRoM7tLB2vm3H2urbN1bUvaVGHY1osS4pmKrQ558cXmAf4nRYDayAmER6PYG6QRoNX";
|
||||
if (!m_devWallet.decode(dev_wallet_str)) {
|
||||
LOGERR(1, "Failed to decode dev wallet address");
|
||||
}
|
||||
// Initialize dev wallet based on network type
|
||||
const char* dev_wallet_str = nullptr;
|
||||
if (m_mainWallet.valid()) {
|
||||
switch (m_mainWallet.type()) {
|
||||
case NetworkType::Mainnet:
|
||||
dev_wallet_str = "SC11VXXJyJTZcFJikJrgQKE2HmfXCt2DnRoM7tLB2vm3H2urbN1bUvaVGHY1osS4pmKrQ558cXmAf4nRYDayAmER6PYG6QRoNX";
|
||||
break;
|
||||
case NetworkType::Testnet:
|
||||
dev_wallet_str = "SC1ToqmproHYLhyPtehEMhE6dYRT7YziKRhaTtRCX2tVFDjqPJDXKtHPfLDvD6pn5b8pm1ZLrDQ2FfcHUEtapFDnbxk5RBBYmqT";
|
||||
break;
|
||||
case NetworkType::Stagenet:
|
||||
dev_wallet_str = "";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (dev_wallet_str && !m_devWallet.decode(dev_wallet_str)) {
|
||||
LOGERR(1, "Failed to decode dev wallet address");
|
||||
}
|
||||
|
||||
m_displayWallet.assign(display_wallet_buf, Wallet::ADDRESS_LENGTH);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user