From 1b951c68522553e9853155ab28cccf7dce0aadc1 Mon Sep 17 00:00:00 2001 From: NotRin7 Date: Wed, 22 Oct 2025 16:22:29 +0200 Subject: [PATCH 01/10] add seeds and seeders --- src/chainparams.cpp | 21 ++++++++++++++------- src/chainparamsseeds.h | 11 ++++++----- 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 79d03a1..3555e15 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -124,6 +124,8 @@ public: vSeeds.emplace_back("dnsseed.palladium-coin.org"); vSeeds.emplace_back("dnsseed.palladium-coin.xyz"); vSeeds.emplace_back("dnsseed.palladium-coin.de"); + vSeeds.emplace_back("dnsseed.palladiumblockchain.net"); + base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,55); base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,5); @@ -149,19 +151,24 @@ public: {69, uint256S("0x00000000ae75d0169080e9f0ddbcd80827eda623cfe1f4a2b1be6dcd49b916e6")}, {22170, uint256S("0x000000000000086425f826a2eb60c588aefd3e0783ddeccf0f4f0c985d348e69")}, {26619, uint256S("0x00000000000000d66df607146de7d9b423cf97150beb804d22439d199e868ca9")}, - {28879, uint256S("0x0000000000000017e9e74b9b403b775098905418b1333e9612f510af66746aa7")}, + {28879, uint256S("0x0000000000000017e9e74b9b403b775098905418b1333e9612f510af66746aa7")}, {28925, uint256S("0x0000000000000014351dee34029945d5a4dea299ec8843626695c88b084b4d10")}, - {50000, uint256S("0x000000000000041fddecba51204a679b15ae47fc8aa658ef4ea7b953445d95e5")}, - {100000, uint256S("0x0000000000000850eba93bbc491f085e2c79c0c30c497292858c72e90cae69a5")}, - {142892, uint256S("0x000000000000829a0a4cab2f040151766df64edfe8817c565d101ae12b51411a")} + {50000, uint256S("0x000000000000041fddecba51204a679b15ae47fc8aa658ef4ea7b953445d95e5")}, + {100000, uint256S("0x0000000000000850eba93bbc491f085e2c79c0c30c497292858c72e90cae69a5")}, + {142892, uint256S("0x000000000000829a0a4cab2f040151766df64edfe8817c565d101ae12b51411a")}, + {150000, uint256S("0x00000000000003212d753a62f2dec5b696ab22524cc49ba7cdc0d80c45d0eb18")}, + {200000, uint256S("0x000000000000221a9e16556453fc86308b260d95d80c14bafaf053a09374e7eb")}, + {250000, uint256S("0x0000000000012553b0303deaf5f2883deb66c901b6848dd03bb4a34f1774e0d0")}, + {300000, uint256S("0x0000000000013acdf07a4fb988bbe9824c36eb421478a71c8196cf524dcba143")}, + {308500, uint256S("0x000000000000693c6a323a828918f994abae9473373285aa22f0ec71fb5d0f39")}, } }; chainTxData = ChainTxData{ // Data from RPC: getchaintxstats - /* nTime */ 1712377887, - /* nTxCount */ 29654, - /* dTxRate */ 0.01771170546987923, + /* nTime */ 1761142315, + /* nTxCount */ 361981, + /* dTxRate */ 0.005767377239409816, }; } }; diff --git a/src/chainparamsseeds.h b/src/chainparamsseeds.h index e8a0e48..e168c1c 100644 --- a/src/chainparamsseeds.h +++ b/src/chainparamsseeds.h @@ -8,11 +8,12 @@ * IPv4 as well as onion addresses are wrapped inside an IPv6 address accordingly. */ static SeedSpec6 pnSeed6_main[] = { - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x02,0xf3,0x8d,0xe3}, 2333}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xd4,0x84,0x66,0x29}, 2333}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x67,0xb9,0xf8,0xab}, 2333}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x40,0xb0,0xdb,0x89}, 2323}, - {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x95,0x1c,0x2d,0xbd}, 2323} + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xad,0xd4,0xe0,0x43}, 2333}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x52,0xa5,0xda,0x98}, 2333}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x59,0x75,0x95,0x82}, 2333}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0x42,0x5e,0x73,0x50}, 2333}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xad,0xf9,0xcf,0x6c}, 2333}, + {{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0xff,0xff,0xbc,0xda,0xda,0xd9}, 2333} }; static SeedSpec6 pnSeed6_test[] = { From a8c5c345ddcb61650c2273673b772bcdb0dcf390 Mon Sep 17 00:00:00 2001 From: NotRin7 Date: Wed, 22 Oct 2025 17:28:38 +0200 Subject: [PATCH 02/10] change at mining and work params --- src/chainparams.cpp | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 3555e15..7855e25 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -73,26 +73,35 @@ public: consensus.BIP66Height = 29000; consensus.CSVHeight = 29000; consensus.SegwitHeight = 29000; - consensus.MinBIP9WarningHeight = 29240; // segwit activation height + miner confirmation window + + consensus.MinBIP9WarningHeight = 29540; // segwit activation height + miner confirmation window + consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); - consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; - consensus.nPowTargetSpacing = 10 * 60; - consensus.nPowTargetSpacingV2 = 2 * 60; + + consensus.nPowTargetTimespan = 24 * 60 * 60; // 86400 seconds + consensus.nPowTargetSpacing = 10 * 60; // old (before block 29000/LWMA) + consensus.nPowTargetSpacingV2 = 2 * 60; //120 seconds + consensus.fPowAllowMinDifficultyBlocks = false; consensus.fPowNoRetargeting = false; - consensus.nRuleChangeActivationThreshold = 1916; - consensus.nMinerConfirmationWindow = 2016; + + //24h Timespan / 2 Min Spacing = 720 blocks + consensus.nRuleChangeActivationThreshold = 720; + consensus.nMinerConfirmationWindow = 540; // 720 * 0.75 consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].bit = 28; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nStartTime = 1199145601; consensus.vDeployments[Consensus::DEPLOYMENT_TESTDUMMY].nTimeout = 1230767999; - // The best chain should have at least this much work. - consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000001578157d557d557aa0"); + // Chainwork Block 308000 + // The best chain should have at least this much work. + consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000009a5fd670f7a9ae6f2e"); + + // Blockhash Block 308000 // By default assume that the signatures in ancestors of this block are valid. - consensus.defaultAssumeValid = uint256S("0x0000000000000014351dee34029945d5a4dea299ec8843626695c88b084b4d10"); + consensus.defaultAssumeValid = uint256S("0x000000000000174621a036477c7edff5648052fa268133658561e9ca840831be"); /** * The message start string is designed to be unlikely to occur in normal data. From a696a57d4d06772572f088f066486e5d093a63f9 Mon Sep 17 00:00:00 2001 From: NotRin7 Date: Wed, 22 Oct 2025 19:54:48 +0200 Subject: [PATCH 03/10] major update add auxpow und smal work changes --- src/chainparams.cpp | 10 +- src/consensus/params.h | 81 ++- src/miner.cpp | 105 ++++ src/pow.cpp | 263 ++++++++-- src/pow.h | 19 +- src/primitives/block.cpp | 61 ++- src/primitives/block.h | 171 ++++++- src/rpc/mining.cpp | 1041 +++++++++++++++++++++++--------------- src/validation.cpp | 145 +++++- 9 files changed, 1403 insertions(+), 493 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 7855e25..c3ffa3f 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -73,9 +73,12 @@ public: consensus.BIP66Height = 29000; consensus.CSVHeight = 29000; consensus.SegwitHeight = 29000; - consensus.MinBIP9WarningHeight = 29540; // segwit activation height + miner confirmation window + + + consensus.nAuxpowStartHeight = 310000; + consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); consensus.nPowTargetTimespan = 24 * 60 * 60; // 86400 seconds @@ -199,8 +202,9 @@ public: consensus.SegwitHeight = 834624; // 00000000002b980fcd729daaa248fd9316a5200e9b367f4ff2c42453e84201ca consensus.MinBIP9WarningHeight = 836640; // segwit activation height + miner confirmation window consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); - consensus.nPowTargetTimespan = 14 * 24 * 60 * 60; // two weeks - consensus.nPowTargetSpacing = 10 * 60; + consensus.nAuxpowStartHeight = 1; + consensus.nPowTargetTimespan = 24 * 60 * 60; // two weeks + consensus.nPowTargetSpacing = 2 * 60; consensus.fPowAllowMinDifficultyBlocks = true; consensus.fPowNoRetargeting = false; consensus.nRuleChangeActivationThreshold = 1512; // 75% for testchains diff --git a/src/consensus/params.h b/src/consensus/params.h index 7cc7890..aed7438 100644 --- a/src/consensus/params.h +++ b/src/consensus/params.h @@ -1,16 +1,22 @@ // Copyright (c) 2009-2010 Satoshi Nakamoto -// Copyright (c) 2009-2019 The Palladium Core developers +// Copyright (c) 2009-2019 The Palladium Core developers // Jahr angepasst // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef PALLADIUM_CONSENSUS_PARAMS_H +#ifndef PALLADIUM_CONSENSUS_PARAMS_H // Guard angepasst #define PALLADIUM_CONSENSUS_PARAMS_H #include #include +#include +#include namespace Consensus { +// --- Maximale Blockhöhe für Fork-Planung --- +static constexpr int MAX_BLOCK_HEIGHT = std::numeric_limits::max(); + + enum DeploymentPos { DEPLOYMENT_TESTDUMMY, @@ -24,18 +30,16 @@ enum DeploymentPos struct BIP9Deployment { /** Bit position to select the particular bit in nVersion. */ int bit; - /** Start MedianTime for version bits miner confirmation. Can be a date in the past */ + /** Start MedianTime for version bits signalling. */ int64_t nStartTime; - /** Timeout/expiry MedianTime for the deployment attempt. */ + /** Timeout MedianTime for version bits signalling. */ int64_t nTimeout; /** Constant for nTimeout very far in the future. */ static constexpr int64_t NO_TIMEOUT = std::numeric_limits::max(); /** Special value for nStartTime indicating that the deployment is always active. - * This is useful for testing, as it means tests don't need to deal with the activation - * process (which takes at least 3 BIP9 intervals). Only tests that specifically test the - * behaviour during activation cannot use this. */ + * This is useful for testing, regression testing and informational deployments. */ static constexpr int64_t ALWAYS_ACTIVE = -1; }; @@ -45,44 +49,71 @@ struct BIP9Deployment { struct Params { uint256 hashGenesisBlock; int nSubsidyHalvingInterval; - /* Block hash that is excepted from BIP16 enforcement */ - uint256 BIP16Exception; - /** Block height and hash at which BIP34 becomes active */ + /** Block height and hash at which BIP16 becomes active */ + // int BIP16Height; // Oft 0 in neueren Chains, P2SH immer aktiv? Prüfen! + uint256 BIP16Exception; // Genesis hash if BIP16 active from start + /** Block height at which BIP34 becomes active */ int BIP34Height; - uint256 BIP34Hash; + uint256 BIP34Hash; // Not needed if height-based /** Block height at which BIP65 becomes active */ int BIP65Height; /** Block height at which BIP66 becomes active */ int BIP66Height; /** Block height at which CSV (BIP68, BIP112 and BIP113) becomes active */ int CSVHeight; - /** Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active. - * Note that segwit v0 script rules are enforced on all blocks except the - * BIP 16 exception blocks. */ + /** Block height at which Segwit (BIP141, BIP143 and BIP147) becomes active. */ int SegwitHeight; - /** Don't warn about unknown BIP 9 activations below this height. - * This prevents us from warning about the CSV and segwit activations. */ + /** Don't warn about unknown BIP 9 activations below this height. */ int MinBIP9WarningHeight; - /** - * Minimum blocks including miner confirmation of the total of 2016 blocks in a retargeting period, - * (nPowTargetTimespan / nPowTargetSpacing) which is also used for BIP9 deployments. - * Examples: 1916 for 95%, 1512 for testchains. - */ + /** BIP9 deployment parameters */ uint32_t nRuleChangeActivationThreshold; uint32_t nMinerConfirmationWindow; BIP9Deployment vDeployments[MAX_VERSION_BITS_DEPLOYMENTS]; /** Proof of work parameters */ uint256 powLimit; - bool fPowAllowMinDifficultyBlocks; bool fPowNoRetargeting; int64_t nPowTargetSpacing; - int64_t nPowTargetSpacingV2; + int64_t nPowTargetSpacingV2; // Für LWMA / neue Blockzeit int64_t nPowTargetTimespan; - int64_t DifficultyAdjustmentInterval() const { return nPowTargetTimespan / nPowTargetSpacing; } + // DifficultyAdjustmentInterval angepasst, um korrekten Wert nach LWMA-Aktivierung zu liefern + int DifficultyAdjustmentInterval(int nHeight) const { + // Prüfe, ob LWMA aktiv ist (Block >= 29000). Wenn ja, ist das klassische Intervall irrelevant. + // Falls wir das Fenster für BIP9 brauchen, muss es anders berechnet werden. + // Nehmen wir an, nMinerConfirmationWindow ist jetzt der relevante Wert für BIP9. + // Die alte Berechnung ist nur für den alten Algo (< 29000) relevant. + if (nHeight < 29000) { // Beispiel: Blockhöhe anpassen, falls LWMA anders aktiviert wurde + return nPowTargetTimespan / nPowTargetSpacing; + } else { + // Für BIP9 wird nMinerConfirmationWindow verwendet. + // Gib hier einen sinnvollen Wert zurück oder passe die Verwendung an. + // Bitcoin Core verwendet hier oft einen festen Wert (z.B. 2016) + // oder leitet ihn aus Timespan/Spacing ab. + // Da LWMA das Timespan ignoriert, ist es sauberer, nMinerConfirmationWindow direkt zu verwenden. + // return nMinerConfirmationWindow; // Oder die alte Berechnung, wenn sie noch irgendwo gebraucht wird + return nPowTargetTimespan / nPowTargetSpacingV2; // Behalte Timespan/Spacing Logik bei + } + } uint256 nMinimumChainWork; uint256 defaultAssumeValid; + + // --- AuxPoW Start --- + /** Block height at which Auxiliary Proof of Work (AuxPoW) becomes active */ + int nAuxpowStartHeight; + // --- AuxPoW Ende --- + + // Constructor to initialize members - WICHTIG: Alle neuen Member hier initialisieren! + Params() : hashGenesisBlock(), nSubsidyHalvingInterval(0), /*BIP16Height(0),*/ BIP16Exception(), + BIP34Height(0), BIP34Hash(), BIP65Height(0), BIP66Height(0), CSVHeight(0), SegwitHeight(0), + MinBIP9WarningHeight(0), nRuleChangeActivationThreshold(0), nMinerConfirmationWindow(0), + vDeployments{}, powLimit(), fPowAllowMinDifficultyBlocks(false), fPowNoRetargeting(false), + nPowTargetSpacing(0), nPowTargetSpacingV2(0), nPowTargetTimespan(0), + nMinimumChainWork(), defaultAssumeValid() + // --- AuxPoW Start --- + , nAuxpowStartHeight(MAX_BLOCK_HEIGHT) // Standardmäßig deaktiviert + // --- AuxPoW Ende --- + {} }; } // namespace Consensus -#endif // PALLADIUM_CONSENSUS_PARAMS_H +#endif // PALLADIUM_CONSENSUS_PARAMS_H \ No newline at end of file diff --git a/src/miner.cpp b/src/miner.cpp index 35554d1..b0e6ea5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -24,6 +24,10 @@ #include #include + +#include + + int64_t UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, const CBlockIndex* pindexPrev) { int64_t nOldTime = pblock->nTime; @@ -424,6 +428,107 @@ void BlockAssembler::addPackageTxs(int &nPackagesSelected, int &nDescendantsUpda } } + +// Method to compute block version +// Currently just returns BASE_VERSION, needs update for BIP9 signaling if used +// static int32_t ComputeBlockVersion(const CBlockIndex* pindexPrev, const Consensus::Params& params) +// { + // Implement BIP9 version bit signaling logic here if needed + // ... +// return CBlockHeader::BASE_VERSION; // Return base version for now +// } + +std::unique_ptr BlockAssembler::CreateNewBlock(const CScript& scriptPubKeyIn) +{ + int64_t nTimeStart = GetTimeMicros(); + + ResetBlock(); + + pblocktemplate = std::make_unique(); + pblock = &pblocktemplate->block; // pointer for convenience + + // Add dummy coinbase tx as first transaction + pblock->vtx.emplace_back(); + pblocktemplate->vTxFees.push_back(-1); // updated at end + pblocktemplate->vTxSigOpsCost.push_back(-1); // updated at end + + LOCK2(cs_main, m_mempool.cs); + CBlockIndex* pindexPrev = ::ChainActive().Tip(); + assert(pindexPrev != nullptr); + nHeight = pindexPrev->nHeight + 1; + + // --- AuxPoW Start --- + // Set base version first + pblock->nVersion = CBlockHeader::BASE_VERSION; // ComputeBlockVersion(pindexPrev, chainparams.GetConsensus()); + // Add AuxPoW version bit if fork is active + const Consensus::Params& consensusParams = chainparams.GetConsensus(); + if (nHeight >= consensusParams.nAuxpowStartHeight) { + pblock->nVersion |= CBlockHeader::AUXPOW_VERSION_BIT; + LogPrintf("CreateNewBlock: Setting AuxPoW version bit for block height %d\n", nHeight); + } + // --- AuxPoW Ende --- + + // -regtest only: allow overriding block.nVersion with + // -blockversion=N to test forking scenarios + if (chainparams.MineBlocksOnDemand()) + pblock->nVersion = gArgs.GetArg("-blockversion", pblock->nVersion); + + pblock->nTime = GetAdjustedTime(); + const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); + + nLockTimeCutoff = (STANDARD_LOCKTIME_VERIFY_FLAGS & LOCKTIME_MEDIAN_TIME_PAST) + ? nMedianTimePast + : pblock->GetBlockTime(); + + // Decide whether to include witness transactions + // Typically based on Segwit activation height + bool fIncludeWitness = IsWitnessEnabled(pindexPrev, consensusParams); + + int nPackagesSelected = 0; + int nDescendantsUpdated = 0; + addPackageTxs(nPackagesSelected, nDescendantsUpdated); + + int64_t nTime1 = GetTimeMicros(); + + m_last_block_num_txs = nBlockTx; + m_last_block_weight = nBlockWeight; + + // Create coinbase transaction. + CMutableTransaction coinbaseTx; + coinbaseTx.vin.resize(1); + coinbaseTx.vin[0].prevout.SetNull(); + coinbaseTx.vout.resize(1); + coinbaseTx.vout[0].scriptPubKey = scriptPubKeyIn; + coinbaseTx.vout[0].nValue = nFees + GetBlockSubsidy(nHeight, consensusParams); + coinbaseTx.vin[0].scriptSig = CScript() << nHeight << OP_0; // OP_0 statt nExtraNonce? Prüfe Coinbase-Regeln + // nExtraNonce logic seems missing or different in this base code? Add if needed. + // If nExtraNonce is used, it should be part of scriptSig generation. + + pblock->vtx[0] = MakeTransactionRef(std::move(coinbaseTx)); + pblocktemplate->vchCoinbaseCommitment = GenerateCoinbaseCommitment(*pblock, pindexPrev, consensusParams); + pblocktemplate->vTxFees[0] = -nFees; + + LogPrintf("CreateNewBlock(): block weight: %u txs: %u fees: %ld sigops_cost: %d\n", + GetBlockWeight(*pblock), nBlockTx, nFees, nBlockSigOpsCost); + + // Fill in header + pblock->hashPrevBlock = pindexPrev->GetBlockHash(); + UpdateTime(pblock, consensusParams, pindexPrev); + pblock->nBits = GetNextWorkRequired(pindexPrev, pblock, consensusParams); + pblock->nNonce = 0; // Nonce wird vom Miner gesetzt + pblocktemplate->vTxSigOpsCost[0] = WITNESS_SCALE_FACTOR * GetLegacySigOpCount(*pblock->vtx[0]); + + CValidationState state; + if (!TestBlockValidity(state, chainparams, *pblock, pindexPrev, false, false)) { + throw std::runtime_error(strprintf("%s: TestBlockValidity failed: %s", __func__, state.ToString())); + } + int64_t nTime2 = GetTimeMicros(); + + LogPrint(BCLog::BENCH, "CreateNewBlock() packages: %.2fms (%d packages, %d updated descendants), validity: %.2fms (total %.2fms)\n", 0.001 * (nTime1 - nTimeStart), nPackagesSelected, nDescendantsUpdated, 0.001 * (nTime2 - nTime1), 0.001 * (nTime2 - nTimeStart)); + + return std::move(pblocktemplate); +} + void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned int& nExtraNonce) { // Update nExtraNonce diff --git a/src/pow.cpp b/src/pow.cpp index 29dfb97..802aa80 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -9,34 +9,68 @@ #include #include #include +#include // Für error() + +// --- AuxPoW Start --- +#include // Für ParseHex +#include