diff options
| author | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-05 05:08:30 +0000 |
|---|---|---|
| committer | bitflash-maintainer <noreply@bitflash.invalid> | 2026-09-05 05:08:30 +0000 |
| commit | 66e0b9158d050c46b1ff2509faeee3f4573cac1c (patch) | |
| tree | 7e9132aa871fdc01cb95268d2f5ea3bb11853ddf /src/main.cpp | |
| parent | 36201d2795b7b49beb1a837b0252134096beb64d (diff) | |
| parent | 17741d9cf4c762ea03dc83e8aae6a176e5f338b0 (diff) | |
Merge upstream/main into the fork
Brings the nine commits that are actually the latest on our lineage:
isolated testnet parameters and genesis, optional 2 MB large pages for
RandomX, and five README changes. This is what "up to date" means here --
not the 1.2.2x tags, which carry higher version numbers but were cut
2026-07-30, three weeks before the line we ship, and which upstream/main
does not contain.
Three conflicts, all resolved toward upstream's structure while keeping
what this fork knows:
main.cpp -- upstream moved genesis construction into BuildGenesisBlock() so
mainnet and the new testnet can share it. Verified byte-for-byte before
taking it: MAINNET_GENESIS_TIMESTAMP, _TIME (1753315200), _NONCE (3141),
_HASH, _MERKLE, the scriptPubKey, nBits and nVersion all equal what this
tree built inline. The mainnet genesis hash is unchanged and the asserts
still guard it. Kept our warning about never editing those inputs, and kept
our note that 1753315200 is 2025-07-24, not 2026 -- upstream's comment on
that constant states the wrong year.
net.h -- DEFAULT_PORT = htons(8433) becomes MAINNET_PORT/TESTNET_PORT in
host order. Nothing is lost: net.cpp's GetDefaultPort() applies htons()
itself and is what every caller uses, so the value reaching a sockaddr is
unchanged and mainnet stays on 8433.
selftest.cpp -- the known-tests string had diverged in both directions.
Took the union: upstream's network-params alongside our payout-ledger,
rather than dropping either.
Gates: 15/15 selftests (our 14 plus upstream's network-params), consensus
constants unchanged against e4f898c except the pre-existing
MAX_BLOCK_SIZE_GEN, mainnet genesis intact, compactblock's 17 checks still
pass, money-log check ok, GNU_STACK RW.
Diffstat (limited to 'src/main.cpp')
| -rw-r--r-- | src/main.cpp | 163 |
1 files changed, 122 insertions, 41 deletions
diff --git a/src/main.cpp b/src/main.cpp index 7398064..0fa6b89 100644 --- a/src/main.cpp +++ b/src/main.cpp | |||
| @@ -42,12 +42,30 @@ unsigned int nTransactionsUpdated = 0; | |||
| 42 | map<COutPoint, CInPoint> mapNextTx; | 42 | map<COutPoint, CInPoint> mapNextTx; |
| 43 | 43 | ||
| 44 | map<uint256, CBlockIndex*> mapBlockIndex; | 44 | map<uint256, CBlockIndex*> mapBlockIndex; |
| 45 | // Bitflash genesis -- mined under RandomX PoW on 2026-07-22 | 45 | // Bitflash mainnet genesis -- mined under RandomX PoW for the 2026 stable |
| 46 | // (nTime 1753142400, nBits 0x1f0fffff, RandomX key "Bitflash/RandomX/v1/...") | 46 | // relaunch. Testnet gets its own resettable genesis below so block indexes, |
| 47 | // Bitflash 2026 stable relaunch genesis (2-min blocks, RandomX). Mined values. | 47 | // headers, and wallet scans cannot be accidentally mixed across networks. |
| 48 | unsigned int GENESIS_NONCE = 3141; | 48 | static const unsigned int MAINNET_GENESIS_TIME = 1753315200; // 2026-07-24 00:00:00 UTC |
| 49 | uint256 hashGenesisBlock("0x5bd7cb255d814e48cebcdfb72da4dc87b34bd774227f8ceb546c5640f4bdc169"); | 49 | static const unsigned int MAINNET_GENESIS_NONCE = 3141; |
| 50 | uint256 hashGenesisMerkleRoot("0x1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325"); | 50 | static const char* MAINNET_GENESIS_TIMESTAMP = |
| 51 | "Bitflash 24/Jul/2026 Fair launch: one CPU one vote, no premine"; | ||
| 52 | static const char* MAINNET_GENESIS_HASH = | ||
| 53 | "0x5bd7cb255d814e48cebcdfb72da4dc87b34bd774227f8ceb546c5640f4bdc169"; | ||
| 54 | static const char* MAINNET_GENESIS_MERKLE = | ||
| 55 | "0x1a45b4482532abb29b10e234d3f13132230525a339ecea91658ffa675a5b1325"; | ||
| 56 | |||
| 57 | static const unsigned int TESTNET_GENESIS_TIME = 1787184000; // 2026-08-20 00:00:00 UTC | ||
| 58 | static const unsigned int TESTNET_GENESIS_NONCE = 3199; | ||
| 59 | static const char* TESTNET_GENESIS_TIMESTAMP = | ||
| 60 | "Bitflash testnet 20/Aug/2026: resettable public test chain"; | ||
| 61 | static const char* TESTNET_GENESIS_HASH = | ||
| 62 | "0xa9d11c6d697bcb7aea0653bc088b12dcf9f44e732df205162cf085fd9d9963eb"; | ||
| 63 | static const char* TESTNET_GENESIS_MERKLE = | ||
| 64 | "0x510b293105e3ff85b8d4c3920e357f85d1a86bf199eb4e7d11f04f380030ec5c"; | ||
| 65 | |||
| 66 | unsigned int GENESIS_NONCE = MAINNET_GENESIS_NONCE; | ||
| 67 | uint256 hashGenesisBlock(MAINNET_GENESIS_HASH); | ||
| 68 | uint256 hashGenesisMerkleRoot(MAINNET_GENESIS_MERKLE); | ||
| 51 | CBlockIndex* pindexGenesisBlock = NULL; | 69 | CBlockIndex* pindexGenesisBlock = NULL; |
| 52 | int nBestHeight = -1; | 70 | int nBestHeight = -1; |
| 53 | uint256 hashBestChain = 0; | 71 | uint256 hashBestChain = 0; |
| @@ -254,6 +272,63 @@ static std::atomic<uint64> gParticipantHashRateX1000{0}; | |||
| 254 | static std::mutex gParticipantStatusMutex; | 272 | static std::mutex gParticipantStatusMutex; |
| 255 | static std::string gParticipantStatus; | 273 | static std::string gParticipantStatus; |
| 256 | 274 | ||
| 275 | void SelectGenesisParams(bool fTestNetIn) | ||
| 276 | { | ||
| 277 | static bool fGenesisParamsSelected = false; | ||
| 278 | static bool fGenesisParamsTestNet = false; | ||
| 279 | if (fGenesisParamsSelected && fGenesisParamsTestNet == fTestNetIn) | ||
| 280 | return; | ||
| 281 | |||
| 282 | fGenesisParamsSelected = true; | ||
| 283 | fGenesisParamsTestNet = fTestNetIn; | ||
| 284 | |||
| 285 | if (fTestNetIn) | ||
| 286 | { | ||
| 287 | GENESIS_NONCE = TESTNET_GENESIS_NONCE; | ||
| 288 | hashGenesisBlock = uint256(TESTNET_GENESIS_HASH); | ||
| 289 | hashGenesisMerkleRoot = uint256(TESTNET_GENESIS_MERKLE); | ||
| 290 | } | ||
| 291 | else | ||
| 292 | { | ||
| 293 | GENESIS_NONCE = MAINNET_GENESIS_NONCE; | ||
| 294 | hashGenesisBlock = uint256(MAINNET_GENESIS_HASH); | ||
| 295 | hashGenesisMerkleRoot = uint256(MAINNET_GENESIS_MERKLE); | ||
| 296 | } | ||
| 297 | } | ||
| 298 | |||
| 299 | void SelectChainParams(bool fTestNetIn) | ||
| 300 | { | ||
| 301 | SelectNetworkParams(fTestNetIn); | ||
| 302 | SelectGenesisParams(fTestNetIn); | ||
| 303 | } | ||
| 304 | |||
| 305 | static CBlock BuildGenesisBlock() | ||
| 306 | { | ||
| 307 | const char* pszTimestamp = IsTestNet() ? | ||
| 308 | TESTNET_GENESIS_TIMESTAMP : MAINNET_GENESIS_TIMESTAMP; | ||
| 309 | |||
| 310 | CTransaction txNew; | ||
| 311 | txNew.vin.resize(1); | ||
| 312 | txNew.vout.resize(1); | ||
| 313 | txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << | ||
| 314 | vector<unsigned char>((unsigned char*)pszTimestamp, | ||
| 315 | (unsigned char*)pszTimestamp + strlen(pszTimestamp)); | ||
| 316 | txNew.vout[0].nValue = 50 * COIN; | ||
| 317 | txNew.vout[0].scriptPubKey = CScript() << | ||
| 318 | CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") << | ||
| 319 | OP_CHECKSIG; | ||
| 320 | |||
| 321 | CBlock block; | ||
| 322 | block.vtx.push_back(txNew); | ||
| 323 | block.hashPrevBlock = 0; | ||
| 324 | block.hashMerkleRoot = block.BuildMerkleTree(); | ||
| 325 | block.nVersion = 1; | ||
| 326 | block.nTime = IsTestNet() ? TESTNET_GENESIS_TIME : MAINNET_GENESIS_TIME; | ||
| 327 | block.nBits = 0x1f0fffff; // = bnProofOfWorkLimit (Bitflash RandomX floor) | ||
| 328 | block.nNonce = GENESIS_NONCE; | ||
| 329 | return block; | ||
| 330 | } | ||
| 331 | |||
| 257 | void SetParticipantMiningStatus(const std::string& status) | 332 | void SetParticipantMiningStatus(const std::string& status) |
| 258 | { | 333 | { |
| 259 | // Updates the GUI status string only. Logging is done at each call site | 334 | // Updates the GUI status string only. Logging is done at each call site |
| @@ -2654,11 +2729,21 @@ string GetAppDir() | |||
| 2654 | { | 2729 | { |
| 2655 | return "."; | 2730 | return "."; |
| 2656 | } | 2731 | } |
| 2657 | static bool fMkdirDone; | 2732 | static string strCreatedBaseDir; |
| 2658 | if (!fMkdirDone) | 2733 | if (strCreatedBaseDir != strDir) |
| 2659 | { | 2734 | { |
| 2660 | fMkdirDone = true; | ||
| 2661 | _mkdir(strDir.c_str()); | 2735 | _mkdir(strDir.c_str()); |
| 2736 | strCreatedBaseDir = strDir; | ||
| 2737 | } | ||
| 2738 | if (IsTestNet()) | ||
| 2739 | { | ||
| 2740 | strDir += "/testnet"; | ||
| 2741 | static string strCreatedTestnetDir; | ||
| 2742 | if (strCreatedTestnetDir != strDir) | ||
| 2743 | { | ||
| 2744 | _mkdir(strDir.c_str()); | ||
| 2745 | strCreatedTestnetDir = strDir; | ||
| 2746 | } | ||
| 2662 | } | 2747 | } |
| 2663 | return strDir; | 2748 | return strDir; |
| 2664 | } | 2749 | } |
| @@ -2812,38 +2897,34 @@ bool LoadBlockIndex(bool fAllowNew) | |||
| 2812 | 2897 | ||
| 2813 | // Bitflash genesis block -- own header (fair launch) | 2898 | // Bitflash genesis block -- own header (fair launch) |
| 2814 | // | 2899 | // |
| 2815 | // Do not change pszTimestamp, the scriptPubKey, nTime or nNonce. They | 2900 | // Upstream moved the construction into BuildGenesisBlock() so mainnet |
| 2816 | // are the inputs to the genesis hash, and the genesis hash is | 2901 | // and the isolated testnet can share it. The mainnet inputs it uses are |
| 2817 | // consensus. Changing one on its own trips the assert below, which is | 2902 | // byte-identical to what this block built inline before the merge -- |
| 2818 | // loud and reverts cleanly; changing one and regenerating | 2903 | // timestamp string, nTime, nNonce, scriptPubKey, nBits and nVersion all |
| 2819 | // GENESIS_NONCE and hashGenesisBlock to match -- which is exactly what | 2904 | // verified equal against MAINNET_GENESIS_* -- so the mainnet genesis |
| 2820 | // the re-mining branch below prints out and invites -- gives a node | 2905 | // hash is unchanged. The warning below is why that was checked rather |
| 2821 | // that starts without complaint, builds its own chain from height 0, | 2906 | // than assumed, and it still applies to those constants: |
| 2822 | // and rejects every real peer as being on a different chain. That one | 2907 | // |
| 2823 | // fails silently, and the damage scales with how many people run the | 2908 | // Do not change MAINNET_GENESIS_TIMESTAMP, the scriptPubKey, |
| 2824 | // "fixed" build. | 2909 | // MAINNET_GENESIS_TIME or MAINNET_GENESIS_NONCE. They are the inputs to |
| 2825 | char* pszTimestamp = "Bitflash 24/Jul/2026 Fair launch: one CPU one vote, no premine"; | 2910 | // the genesis hash, and the genesis hash is consensus. Changing one on |
| 2826 | CTransaction txNew; | 2911 | // its own trips the assert below, which is loud and reverts cleanly; |
| 2827 | txNew.vin.resize(1); | 2912 | // changing one and regenerating GENESIS_NONCE and hashGenesisBlock to |
| 2828 | txNew.vout.resize(1); | 2913 | // match -- which is exactly what the re-mining branch below prints out |
| 2829 | txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(4) << vector<unsigned char>((unsigned char*)pszTimestamp, (unsigned char*)pszTimestamp + strlen(pszTimestamp)); | 2914 | // and invites -- gives a node that starts without complaint, builds its |
| 2830 | txNew.vout[0].nValue = 50 * COIN; | 2915 | // own chain from height 0, and rejects every real peer as being on a |
| 2831 | txNew.vout[0].scriptPubKey = CScript() << CBigNum("0x5F1DF16B2B704C8A578D0BBAF74D385CDE12C11EE50455F3C438EF4C3FBCF649B6DE611FEAE06279A60939E028A8D65C10B73071A6F16719274855FEB0FD8A6704") << OP_CHECKSIG; | 2916 | // different chain. That one fails silently, and the damage scales with |
| 2832 | CBlock block; | 2917 | // how many people run the "fixed" build. |
| 2833 | block.vtx.push_back(txNew); | 2918 | // |
| 2834 | block.hashPrevBlock = 0; | 2919 | // MAINNET_GENESIS_TIME is 1753315200, which is 2025-07-24T00:00:00Z, |
| 2835 | block.hashMerkleRoot = block.BuildMerkleTree(); | 2920 | // while the headline in MAINNET_GENESIS_TIMESTAMP reads 2026 -- as does |
| 2836 | block.nVersion = 1; | 2921 | // the comment upstream put on that constant, which is wrong about the |
| 2837 | // 1753315200 is 2025-07-24T00:00:00Z. The headline in pszTimestamp | 2922 | // year. This is a known discrepancy and not a typo in the value: it is |
| 2838 | // above reads 2026 and does not match it. This is a known discrepancy | 2923 | // only consensus-critical as an input to the genesis hash, the block |
| 2839 | // and not a typo in the constant: the value is only consensus-critical | 2924 | // hashes to hashGenesisBlock with it, and every node on the network |
| 2840 | // as an input to the genesis hash, the block hashes to | 2925 | // agrees. The mismatch is in the launched chain and cannot be corrected |
| 2841 | // hashGenesisBlock with it, and every node on the network agrees. The | 2926 | // -- see the warning above before deciding otherwise. |
| 2842 | // mismatch is in the launched chain and cannot be corrected -- see the | 2927 | CBlock block = BuildGenesisBlock(); |
| 2843 | // warning above before deciding otherwise. | ||
| 2844 | block.nTime = 1753315200; | ||
| 2845 | block.nBits = 0x1f0fffff; // = bnProofOfWorkLimit (Bitflash RandomX floor) | ||
| 2846 | block.nNonce = GENESIS_NONCE; | ||
| 2847 | 2928 | ||
| 2848 | // If the nonce has not been found yet, mine the genesis once (RandomX) | 2929 | // If the nonce has not been found yet, mine the genesis once (RandomX) |
| 2849 | // and print the values to be hardcoded in the constants above. | 2930 | // and print the values to be hardcoded in the constants above. |