From 1d3a69d8e96d992f85a45cf6f05d91b6889a9e3e Mon Sep 17 00:00:00 2001 From: rvnminers-A-and-N Date: Tue, 1 Oct 2024 18:22:18 -0400 Subject: [PATCH 1/8] SHA256 For Testnet Like EVR Has --- src/chain.h | 2 +- src/chainparams.cpp | 9 +++++++++ src/pow.cpp | 4 ++-- src/primitives/block.cpp | 36 +++++++++++++++++++++++++++++++----- src/primitives/block.h | 4 +++- src/rpc/mining.cpp | 4 ++-- src/validation.cpp | 4 ++-- 7 files changed, 50 insertions(+), 13 deletions(-) diff --git a/src/chain.h b/src/chain.h index 677f67403d..6786d9311f 100644 --- a/src/chain.h +++ b/src/chain.h @@ -423,7 +423,7 @@ class CDiskBlockIndex : public CBlockIndex READWRITE(hashMerkleRoot); READWRITE(nTime); READWRITE(nBits); - if (nTime < nKAWPOWActivationTime) { + if (nTime < nKAWPOWActivationTime && !fKawpowAsMiningAlgo) { READWRITE(nNonce); } else { //KAWPOW diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7a8929cecd..7e2c9e9b96 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -270,6 +270,9 @@ class CMainParams : public CChainParams { nKAAAWWWPOWActivationTime = 1588788000; // UTC: Wed May 06 2020 18:00:00 nKAWPOWActivationTime = nKAAAWWWPOWActivationTime; + + // Use SHA256 or KawPow depending on this choice + fKawpowAsMiningAlgo = true; // The value is set here but declared as global in primitives/block.h /** RVN End **/ } }; @@ -417,6 +420,7 @@ class CTestNetParams : public CChainParams { vSeeds.emplace_back("seed-testnet-raven.bitactivate.com", false); vSeeds.emplace_back("seed-testnet-raven.ravencoin.com", false); vSeeds.emplace_back("seed-testnet-raven.ravencoin.org", false); + vSeeds.emplace_back("trvn.crypticwizardry.com", false); base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,111); base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,196); @@ -491,6 +495,9 @@ class CTestNetParams : public CChainParams { nKAAAWWWPOWActivationTime = 1585159200; //Wed Mar 25 2020 18:00:00 UTC nKAWPOWActivationTime = nKAAAWWWPOWActivationTime; + + // Use SHA256 or KawPow depending on this choice + fKawpowAsMiningAlgo = false; // The value is set here but declared as global in primitives/block.h /** RVN End **/ } }; @@ -696,6 +703,8 @@ class CRegTestParams : public CChainParams { // If you are looking to test the kawpow hashing function in regtest. You will need to change this number nKAAAWWWPOWActivationTime = 3582830167; nKAWPOWActivationTime = nKAAAWWWPOWActivationTime; + // Use SHA256 or KawPow depending on this choice + fKawpowAsMiningAlgo = false; // The value is set here but declared as global in primitives/block.h /** RVN End **/ } }; diff --git a/src/pow.cpp b/src/pow.cpp index a5a245a8e6..dc4970287f 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -58,7 +58,7 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockH } // Count how blocks are KAWPOW mined in the last 180 blocks - if (pindex->nTime >= nKAWPOWActivationTime) { + if (pindex->nTime >= nKAWPOWActivationTime && fKawpowAsMiningAlgo) { nKAWPOWBlocksFound++; } @@ -72,7 +72,7 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockH // 180 KAWPOW blocks already. If we haven't we are going to return our // temp limit. This will allow us to change algos to kawpow without having to // change the DGW math. - if (pblock->nTime >= nKAWPOWActivationTime) { + if (pblock->nTime >= nKAWPOWActivationTime && fKawpowAsMiningAlgo) { if (nKAWPOWBlocksFound != nPastBlocks) { const arith_uint256 bnKawPowLimit = UintToArith256(params.kawpowLimit); return bnKawPowLimit.GetCompact(); diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index 6b653597c6..ea7b5fe1e3 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -17,6 +17,7 @@ static const uint32_t TESTNET_X16RV2ACTIVATIONTIME = 1567533600; static const uint32_t REGTEST_X16RV2ACTIVATIONTIME = 1569931200; uint32_t nKAWPOWActivationTime; +bool fKawpowAsMiningAlgo; BlockNetwork bNetwork = BlockNetwork(); @@ -37,45 +38,65 @@ void BlockNetwork::SetNetwork(const std::string& net) uint256 CBlockHeader::GetHash() const { + // Check if we are before the Kawpow activation time if (nTime < nKAWPOWActivationTime) { uint32_t nTimeToUse = MAINNET_X16RV2ACTIVATIONTIME; + if (bNetwork.fOnTestnet) { nTimeToUse = TESTNET_X16RV2ACTIVATIONTIME; } else if (bNetwork.fOnRegtest) { nTimeToUse = REGTEST_X16RV2ACTIVATIONTIME; } + + // Use X16RV2 or X16R before Kawpow activation if (nTime >= nTimeToUse) { return HashX16RV2(BEGIN(nVersion), END(nNonce), hashPrevBlock); } return HashX16R(BEGIN(nVersion), END(nNonce), hashPrevBlock); } else { - return KAWPOWHash_OnlyMix(*this); + // Kawpow activation time has passed, now check if we are on the testnet + if (bNetwork.fOnTestnet && !fKawpowAsMiningAlgo) { + // If on testnet and Kawpow is disabled, use SerializeHash (CPU-friendly) + return SerializeHash(*this); + } else { + // Otherwise, use Kawpow (mainnet or regtest, or Kawpow on testnet) + return KAWPOWHash_OnlyMix(*this); + } } } + uint256 CBlockHeader::GetHashFull(uint256& mix_hash) const { + // Check if we are before the Kawpow activation time if (nTime < nKAWPOWActivationTime) { uint32_t nTimeToUse = MAINNET_X16RV2ACTIVATIONTIME; + if (bNetwork.fOnTestnet) { nTimeToUse = TESTNET_X16RV2ACTIVATIONTIME; } else if (bNetwork.fOnRegtest) { nTimeToUse = REGTEST_X16RV2ACTIVATIONTIME; } + + // Use X16RV2 or X16R before Kawpow activation if (nTime >= nTimeToUse) { return HashX16RV2(BEGIN(nVersion), END(nNonce), hashPrevBlock); } return HashX16R(BEGIN(nVersion), END(nNonce), hashPrevBlock); } else { - return KAWPOWHash(*this, mix_hash); + // Kawpow activation time has passed, now check if we are on the testnet + if (bNetwork.fOnTestnet && !fKawpowAsMiningAlgo) { + // If on testnet and Kawpow is disabled, use SerializeHash (CPU-friendly) + return SerializeHash(*this); + } else { + // Otherwise, use Kawpow (mainnet or regtest, or Kawpow on testnet) + return KAWPOWHash(*this, mix_hash); + } } } - - - uint256 CBlockHeader::GetX16RHash() const { return HashX16R(BEGIN(nVersion), END(nNonce), hashPrevBlock); @@ -86,6 +107,11 @@ uint256 CBlockHeader::GetX16RV2Hash() const return HashX16RV2(BEGIN(nVersion), END(nNonce), hashPrevBlock); } +uint256 CBlockHeader::GetSerializeHash() const +{ + return SerializeHash(*this); // Use standard SHA256 mining +} + /** * @brief This takes a block header, removes the nNonce64 and the mixHash. Then performs a serialized hash of it SHA256D. * This will be used as the input to the KAAAWWWPOW hashing function diff --git a/src/primitives/block.h b/src/primitives/block.h index e1c06e9f18..27f8ee5c60 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -20,6 +20,7 @@ */ extern uint32_t nKAWPOWActivationTime; +extern bool fKawpowAsMiningAlgo; // declared global here but value is set in chainparams.cpp class BlockNetwork { @@ -64,7 +65,7 @@ class CBlockHeader READWRITE(hashMerkleRoot); READWRITE(nTime); READWRITE(nBits); - if (nTime < nKAWPOWActivationTime) { + if (nTime < nKAWPOWActivationTime && !fKawpowAsMiningAlgo) { READWRITE(nNonce); } else { READWRITE(nHeight); @@ -95,6 +96,7 @@ class CBlockHeader uint256 GetHash() const; uint256 GetX16RHash() const; uint256 GetX16RV2Hash() const; + uint256 GetSerializeHash() const; uint256 GetHashFull(uint256& mix_hash) const; uint256 GetKAWPOWHeaderHash() const; diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index a9cc09d1c5..840cf7a218 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -139,7 +139,7 @@ UniValue generateBlocks(std::shared_ptr coinbaseScript, int nGen uint256 mix_hash; while (nMaxTries > 0 && pblock->nNonce < nInnerLoopCount && !CheckProofOfWork(pblock->GetHashFull(mix_hash), pblock->nBits, GetParams().GetConsensus())) { - if (pblock->nTime < nKAWPOWActivationTime) { + if (pblock->nTime < nKAWPOWActivationTime && !fKawpowAsMiningAlgo) { ++pblock->nNonce; } else { ++pblock->nNonce64; @@ -714,7 +714,7 @@ UniValue getblocktemplate(const JSONRPCRequest& request) result.push_back(Pair("default_witness_commitment", HexStr(pblocktemplate->vchCoinbaseCommitment.begin(), pblocktemplate->vchCoinbaseCommitment.end()))); } - if (pblock->nTime >= nKAWPOWActivationTime) { + if (pblock->nTime >= nKAWPOWActivationTime && fKawpowAsMiningAlgo) { std::string address = gArgs.GetArg("-miningaddress", ""); if (IsValidDestinationString(address)) { static std::string lastheader = ""; diff --git a/src/validation.cpp b/src/validation.cpp index 1c33e9a394..79d1b355fc 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3946,7 +3946,7 @@ static bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW = true) { // If we are checking a KAWPOW block below a know checkpoint height. We can validate the proof of work using the mix_hash - if (fCheckPOW && block.nTime >= nKAWPOWActivationTime) { + if (fCheckPOW && block.nTime >= nKAWPOWActivationTime && fKawpowAsMiningAlgo) { CBlockIndex* pcheckpoint = Checkpoints::GetLastCheckpoint(GetParams().Checkpoints()); if (fCheckPOW && pcheckpoint && block.nHeight <= (uint32_t)pcheckpoint->nHeight) { if (!CheckProofOfWork(block.GetHash(), block.nBits, consensusParams)) { @@ -3963,7 +3963,7 @@ static bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, return state.DoS(50, false, REJECT_INVALID, "high-hash", false, "proof of work failed"); } - if (fCheckPOW && block.nTime >= nKAWPOWActivationTime) { + if (fCheckPOW && block.nTime >= nKAWPOWActivationTime && fKawpowAsMiningAlgo) { if (mix_hash != block.mix_hash) { return state.DoS(50, false, REJECT_INVALID, "invalid-mix-hash", false, "mix_hash validity failed"); } From 76b497798abc427f71dd15622ccefd522c5a9bfc Mon Sep 17 00:00:00 2001 From: rvnminers-A-and-N Date: Tue, 1 Oct 2024 19:09:18 -0400 Subject: [PATCH 2/8] Some More Changes Towards SHA256 Testnet Mining --- src/chain.h | 2 +- src/chainparams.cpp | 3 +++ src/chainparams.h | 1 + src/primitives/block.cpp | 5 +++-- src/primitives/block.h | 4 +++- 5 files changed, 11 insertions(+), 4 deletions(-) diff --git a/src/chain.h b/src/chain.h index 6786d9311f..50e8460369 100644 --- a/src/chain.h +++ b/src/chain.h @@ -423,7 +423,7 @@ class CDiskBlockIndex : public CBlockIndex READWRITE(hashMerkleRoot); READWRITE(nTime); READWRITE(nBits); - if (nTime < nKAWPOWActivationTime && !fKawpowAsMiningAlgo) { + if (nTime < nKAWPOWActivationTime || (bNetwork.fOnTestnet && !fKawpowAsMiningAlgo && nTime >= nSHA256KawpowSwitchActivationTime)) { READWRITE(nNonce); } else { //KAWPOW diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7e2c9e9b96..befc65db00 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -272,6 +272,7 @@ class CMainParams : public CChainParams { nKAWPOWActivationTime = nKAAAWWWPOWActivationTime; // Use SHA256 or KawPow depending on this choice + nSHA256KawpowSwitchActivationTime = 1730332800; // UTC: Thur Oct 31 2024 00:00:00 fKawpowAsMiningAlgo = true; // The value is set here but declared as global in primitives/block.h /** RVN End **/ } @@ -497,6 +498,7 @@ class CTestNetParams : public CChainParams { nKAWPOWActivationTime = nKAAAWWWPOWActivationTime; // Use SHA256 or KawPow depending on this choice + nSHA256KawpowSwitchActivationTime = 1730332800; // UTC: Thur Oct 31 2024 00:00:00 fKawpowAsMiningAlgo = false; // The value is set here but declared as global in primitives/block.h /** RVN End **/ } @@ -704,6 +706,7 @@ class CRegTestParams : public CChainParams { nKAAAWWWPOWActivationTime = 3582830167; nKAWPOWActivationTime = nKAAAWWWPOWActivationTime; // Use SHA256 or KawPow depending on this choice + nSHA256KawpowSwitchActivationTime = 1730332800; // UTC: Thur Oct 31 2024 00:00:00 fKawpowAsMiningAlgo = false; // The value is set here but declared as global in primitives/block.h /** RVN End **/ } diff --git a/src/chainparams.h b/src/chainparams.h index ee9e028d2b..6de5733945 100644 --- a/src/chainparams.h +++ b/src/chainparams.h @@ -201,6 +201,7 @@ class CChainParams int nAssetActivationHeight; uint32_t nKAAAWWWPOWActivationTime; + uint32_t nSHA256KawpowSwitchActivationTime; /** RVN End **/ }; diff --git a/src/primitives/block.cpp b/src/primitives/block.cpp index ea7b5fe1e3..b74ac9d2e9 100644 --- a/src/primitives/block.cpp +++ b/src/primitives/block.cpp @@ -17,6 +17,7 @@ static const uint32_t TESTNET_X16RV2ACTIVATIONTIME = 1567533600; static const uint32_t REGTEST_X16RV2ACTIVATIONTIME = 1569931200; uint32_t nKAWPOWActivationTime; +uint32_t nSHA256KawpowSwitchActivationTime; bool fKawpowAsMiningAlgo; BlockNetwork bNetwork = BlockNetwork(); @@ -56,7 +57,7 @@ uint256 CBlockHeader::GetHash() const return HashX16R(BEGIN(nVersion), END(nNonce), hashPrevBlock); } else { // Kawpow activation time has passed, now check if we are on the testnet - if (bNetwork.fOnTestnet && !fKawpowAsMiningAlgo) { + if (bNetwork.fOnTestnet && !fKawpowAsMiningAlgo && nTime >= nSHA256KawpowSwitchActivationTime) { // If on testnet and Kawpow is disabled, use SerializeHash (CPU-friendly) return SerializeHash(*this); } else { @@ -87,7 +88,7 @@ uint256 CBlockHeader::GetHashFull(uint256& mix_hash) const return HashX16R(BEGIN(nVersion), END(nNonce), hashPrevBlock); } else { // Kawpow activation time has passed, now check if we are on the testnet - if (bNetwork.fOnTestnet && !fKawpowAsMiningAlgo) { + if (bNetwork.fOnTestnet && !fKawpowAsMiningAlgo && nTime >= nSHA256KawpowSwitchActivationTime) { // If on testnet and Kawpow is disabled, use SerializeHash (CPU-friendly) return SerializeHash(*this); } else { diff --git a/src/primitives/block.h b/src/primitives/block.h index 27f8ee5c60..70e80c194d 100644 --- a/src/primitives/block.h +++ b/src/primitives/block.h @@ -20,6 +20,7 @@ */ extern uint32_t nKAWPOWActivationTime; +extern uint32_t nSHA256KawpowSwitchActivationTime; extern bool fKawpowAsMiningAlgo; // declared global here but value is set in chainparams.cpp class BlockNetwork @@ -65,7 +66,8 @@ class CBlockHeader READWRITE(hashMerkleRoot); READWRITE(nTime); READWRITE(nBits); - if (nTime < nKAWPOWActivationTime && !fKawpowAsMiningAlgo) { + //If the time is before the kawpow activation time OR (on testnet, kawpow is not set as the mining algo, and past the sha256 switch activation time) + if (nTime < nKAWPOWActivationTime || (bNetwork.fOnTestnet && !fKawpowAsMiningAlgo && nTime >= nSHA256KawpowSwitchActivationTime)) { READWRITE(nNonce); } else { READWRITE(nHeight); From 57b6f07014f04bc52faa42778b8062f80137d52c Mon Sep 17 00:00:00 2001 From: rvnminers-A-and-N Date: Tue, 1 Oct 2024 21:29:10 -0400 Subject: [PATCH 3/8] Compile Fixes --- src/bench/bench.h | 1 + src/rpc/protocol.cpp | 2 +- src/support/lockedpool.h | 1 + src/test/cuckoocache_tests.cpp | 1 + src/util.cpp | 4 ++-- src/wallet/db.cpp | 4 ++-- 6 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/bench/bench.h b/src/bench/bench.h index 12167a293a..5bd3311170 100644 --- a/src/bench/bench.h +++ b/src/bench/bench.h @@ -10,6 +10,7 @@ #include #include #include +#include #include #include diff --git a/src/rpc/protocol.cpp b/src/rpc/protocol.cpp index 6db357c2a0..7d517e3bb3 100644 --- a/src/rpc/protocol.cpp +++ b/src/rpc/protocol.cpp @@ -75,7 +75,7 @@ static fs::path GetAuthCookieFile(bool temp=false) arg += ".tmp"; } fs::path path(arg); - if (!path.is_complete()) path = GetDataDir() / path; + if (!path.is_absolute()) path = GetDataDir() / path; return path; } diff --git a/src/support/lockedpool.h b/src/support/lockedpool.h index e78791ca1b..7199bf25aa 100644 --- a/src/support/lockedpool.h +++ b/src/support/lockedpool.h @@ -11,6 +11,7 @@ #include #include #include +#include /** * OS-dependent allocation and deallocation of locked/pinned memory pages. diff --git a/src/test/cuckoocache_tests.cpp b/src/test/cuckoocache_tests.cpp index 1afa524bbc..03bada9ca7 100644 --- a/src/test/cuckoocache_tests.cpp +++ b/src/test/cuckoocache_tests.cpp @@ -8,6 +8,7 @@ #include "test/test_raven.h" #include "random.h" #include +#include /** Test Suite for CuckooCache * diff --git a/src/util.cpp b/src/util.cpp index 7542cc2d75..a5ed1ec0c3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -620,7 +620,7 @@ void ClearDatadirCache() fs::path GetConfigFile(const std::string &confPath) { fs::path pathConfigFile(confPath); - if (!pathConfigFile.is_complete()) + if (!pathConfigFile.is_absolute()) pathConfigFile = GetDataDir(false) / pathConfigFile; return pathConfigFile; @@ -657,7 +657,7 @@ void ArgsManager::ReadConfigFile(const std::string &confPath) fs::path GetPidFile() { fs::path pathPidFile(gArgs.GetArg("-pid", RAVEN_PID_FILENAME)); - if (!pathPidFile.is_complete()) pathPidFile = GetDataDir() / pathPidFile; + if (!pathPidFile.is_absolute()) pathPidFile = GetDataDir() / pathPidFile; return pathPidFile; } diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index 26e0b1ca1e..3f553a1562 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -267,7 +267,7 @@ bool CDB::VerifyEnvironment(const std::string& walletFile, const fs::path& dataD LogPrintf("Using wallet %s\n", walletFile); // Wallet file must be a plain filename without a directory - if (walletFile != fs::basename(walletFile) + fs::extension(walletFile)) + if (walletFile != fs::path(walletFile).filename()) { errorStr = strprintf(_("Wallet %s resides outside data directory %s"), walletFile, dataDir.string()); return false; @@ -706,7 +706,7 @@ bool CWalletDBWrapper::Backup(const std::string& strDest) pathDest /= strFile; try { - fs::copy_file(pathSrc, pathDest, fs::copy_option::overwrite_if_exists); + fs::copy_file(pathSrc, pathDest, fs::copy_options::overwrite_existing); LogPrintf("copied %s to %s\n", strFile, pathDest.string()); return true; } catch (const fs::filesystem_error& e) { From b9971551881d7bb7a68b5db781459faaf658165e Mon Sep 17 00:00:00 2001 From: rvnminers-A-and-N Date: Thu, 17 Oct 2024 13:00:04 -0400 Subject: [PATCH 4/8] Ensure Only Testnet Uses Sha256 Mining --- src/chainparams.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index befc65db00..3c03788027 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -707,7 +707,7 @@ class CRegTestParams : public CChainParams { nKAWPOWActivationTime = nKAAAWWWPOWActivationTime; // Use SHA256 or KawPow depending on this choice nSHA256KawpowSwitchActivationTime = 1730332800; // UTC: Thur Oct 31 2024 00:00:00 - fKawpowAsMiningAlgo = false; // The value is set here but declared as global in primitives/block.h + fKawpowAsMiningAlgo = true; // The value is set here but declared as global in primitives/block.h /** RVN End **/ } }; From 0cb2737ad4435a03e28c928ac2ba8b70e2b4f7b1 Mon Sep 17 00:00:00 2001 From: rvnminers-A-and-N Date: Thu, 17 Oct 2024 15:10:02 -0400 Subject: [PATCH 5/8] Changes For Algo Flag In raven.conf File --- src/chainparams.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 3c03788027..5b510db0bd 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -499,7 +499,18 @@ class CTestNetParams : public CChainParams { // Use SHA256 or KawPow depending on this choice nSHA256KawpowSwitchActivationTime = 1730332800; // UTC: Thur Oct 31 2024 00:00:00 - fKawpowAsMiningAlgo = false; // The value is set here but declared as global in primitives/block.h + //fKawpowAsMiningAlgo = false; // The value is set here but declared as global in primitives/block.h + + //Use Global Arguments from raven.conf to determine algo, SHA256 for SHA + if (gArgs.GetBoolArg("-testnet", false)) { + std::string algo = gArgs.GetArg("-algo", "Kawpow"); // Default to Kawpow if `algo` not set + + if (algo == "SHA256") { + fKawpowAsMiningAlgo = false; // Switch to SHA256 on testnet + } else { + fKawpowAsMiningAlgo = true; // Use Kawpow by default or if set to Kawpow + } + } /** RVN End **/ } }; From 3fdea86d7b60508e7c75928510fe10399500beaf Mon Sep 17 00:00:00 2001 From: rvnminers-A-and-N Date: Thu, 17 Oct 2024 17:56:37 -0400 Subject: [PATCH 6/8] More Changes Towards The Algo Param/Documentation --- doc/man/raven-qt.1 | 4 ++++ doc/man/ravend.1 | 4 ++++ src/chainparams.cpp | 6 ++++-- src/init.cpp | 1 + 4 files changed, 13 insertions(+), 2 deletions(-) diff --git a/doc/man/raven-qt.1 b/doc/man/raven-qt.1 index 035d12efec..a8483c740f 100644 --- a/doc/man/raven-qt.1 +++ b/doc/man/raven-qt.1 @@ -357,6 +357,10 @@ Debugging/Testing options: .IP Append comment to the user agent string .HP +\fB\-algo=\fR +.IP +Sets the mining algorithm. Default is Kawpow; alternative is SHA256, which is useful for testnet mining. +.HP \fB\-debug=\fR .IP Output debugging information (default: 0, supplying is diff --git a/doc/man/ravend.1 b/doc/man/ravend.1 index a0507a9147..a58ea8c6c8 100644 --- a/doc/man/ravend.1 +++ b/doc/man/ravend.1 @@ -362,6 +362,10 @@ Debugging/Testing options: .IP Append comment to the user agent string .HP +\fB\-algo=\fR +.IP +Sets the mining algorithm. Default is Kawpow; alternative is SHA256, which is useful for testnet mining. +.HP \fB\-debug=\fR .IP Output debugging information (default: 0, supplying is diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 5b510db0bd..6846078f11 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -506,9 +506,11 @@ class CTestNetParams : public CChainParams { std::string algo = gArgs.GetArg("-algo", "Kawpow"); // Default to Kawpow if `algo` not set if (algo == "SHA256") { - fKawpowAsMiningAlgo = false; // Switch to SHA256 on testnet + fKawpowAsMiningAlgo = false; + } else if (algo == "Kawpow") { + fKawpowAsMiningAlgo = true; } else { - fKawpowAsMiningAlgo = true; // Use Kawpow by default or if set to Kawpow + return InitError(strprintf("Invalid value for -algo: %s. Supported values are 'SHA256' and 'Kawpow'.", algo)); } } /** RVN End **/ diff --git a/src/init.cpp b/src/init.cpp index 9bef67af9f..8b4bc3a5bd 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -539,6 +539,7 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageGroup(_("Debugging/Testing options:")); strUsage += HelpMessageOpt("-uacomment=", _("Append comment to the user agent string")); + strUsage += HelpMessageOpt("-algo=", _("Sets the value for the mining algo. Default is Kawpow; alternative is SHA256, which is useful for quick testnet mining.")); if (showDebug) { strUsage += HelpMessageOpt("-checkblocks=", strprintf(_("How many blocks to check at startup (default: %u, 0 = all)"), DEFAULT_CHECKBLOCKS)); From 4510e50251f23942f176b97d725ef8a148186043 Mon Sep 17 00:00:00 2001 From: rvnminers-A-and-N Date: Thu, 17 Oct 2024 18:31:04 -0400 Subject: [PATCH 7/8] Some fixes --- src/chainparams.cpp | 15 +++++---------- src/init.cpp | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 10 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 6846078f11..8d9c67d3c0 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -501,17 +501,12 @@ class CTestNetParams : public CChainParams { nSHA256KawpowSwitchActivationTime = 1730332800; // UTC: Thur Oct 31 2024 00:00:00 //fKawpowAsMiningAlgo = false; // The value is set here but declared as global in primitives/block.h - //Use Global Arguments from raven.conf to determine algo, SHA256 for SHA + // Use Global Arguments from raven.conf to determine algo if (gArgs.GetBoolArg("-testnet", false)) { - std::string algo = gArgs.GetArg("-algo", "Kawpow"); // Default to Kawpow if `algo` not set - - if (algo == "SHA256") { - fKawpowAsMiningAlgo = false; - } else if (algo == "Kawpow") { - fKawpowAsMiningAlgo = true; - } else { - return InitError(strprintf("Invalid value for -algo: %s. Supported values are 'SHA256' and 'Kawpow'.", algo)); - } + std::string algo = gArgs.GetArg("-algo", "Kawpow"); // Default to KawPow if not set + + // Set the mining algorithm flag (already validated in init.cpp) + fKawpowAsMiningAlgo = (algo == "Kawpow"); } /** RVN End **/ } diff --git a/src/init.cpp b/src/init.cpp index 8b4bc3a5bd..9946752921 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -913,6 +913,22 @@ void InitParameterInteraction() LogPrintf("%s: Ignoring blockmaxsize setting which is overridden by blockmaxweight", __func__); } } + + // Ensure -algo only works on testnet and validate the algo value + if (gArgs.GetBoolArg("-testnet", false)) { + std::string algo = gArgs.GetArg("-algo", "Kawpow"); // Default to Kawpow if not set + + // Hard-coded validation logic + if (algo != "SHA256" && algo != "Kawpow") { + // Log an error but don't prevent the node from starting + LogPrintf("%s: Invalid value for -algo: %s. Defaulting to Kawpow.\n", __func__, algo); + } + } else { + // Log if -algo is ignored because -testnet is not enabled + if (gArgs.IsArgSet("-algo")) { + LogPrintf("%s: Ignoring -algo setting as -testnet is not enabled.\n", __func__); + } + } } static std::string ResolveErrMsg(const char * const optname, const std::string& strBind) From b291da9a2b701ed8be315dd5b52f6d5ef47ed38f Mon Sep 17 00:00:00 2001 From: rvnminers-A-and-N Date: Tue, 19 Nov 2024 13:17:37 -0500 Subject: [PATCH 8/8] Seed Node Addition For Testnet in chainparamsseeds --- src/chainparamsseeds.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chainparamsseeds.h b/src/chainparamsseeds.h index ae7ac2ad0c..3a412d4283 100644 --- a/src/chainparamsseeds.h +++ b/src/chainparamsseeds.h @@ -198,6 +198,7 @@ static SeedSpec6 pnSeed6_test[] = { {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xa8,0x77,0x64,0x8c}, 18770}, {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x53,0xf3,0xbf,0xc7}, 18770}, {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x23,0xa8,0x17,0x4c}, 18770}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x53,0xcd,0x97,0xb7}, 18770} + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x53,0xcd,0x97,0xb7}, 18770}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x4a,0x8b,0x16,0x6d}, 18770} }; #endif // RAVEN_CHAINPARAMSSEEDS_H