From 553424d19d97236f446d29ebc5d8f1c9747de6a9 Mon Sep 17 00:00:00 2001 From: Davide Grilli Date: Thu, 13 Nov 2025 15:34:55 +0100 Subject: [PATCH] fix: update testnet chain params and restore getblocktemplate security check Update testnet minimum chain work and default assume valid values to current state. Restore security check in getblocktemplate RPC to prevent usage during initial block download. --- src/chainparams.cpp | 4 ++-- src/rpc/mining.cpp | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index bf84989..cc5c02e 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -195,10 +195,10 @@ public: // The best chain should have at least this much work. - consensus.nMinimumChainWork = uint256S("0x00"); + consensus.nMinimumChainWork = uint256S("0x00000000000000000000000000000000000000000000000000003077e5d4c957"); // Current testnet chainwork // By default assume that the signatures in ancestors of this block are valid. - consensus.defaultAssumeValid = uint256S("0x00"); + consensus.defaultAssumeValid = uint256S("0x0000000000f8470a0cc0f6210b23bbeba248bf937205e34588aa84596b72c3bd"); // Current best block hash consensus.powLimit = uint256S("00000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffff"); diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 5277d63..e1a5a6d 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -491,10 +491,10 @@ static UniValue getblocktemplate(const JSONRPCRequest& request) if (g_rpc_node->connman->GetNodeCount(CConnman::CONNECTIONS_ALL) == 0) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, PACKAGE_NAME " is not connected!"); - // PATCH: Allow getblocktemplate even during initial block download for testnet purposes - // TODO: Remove this patch for mainnet - it's only for testnet startup - // if (::ChainstateActive().IsInitialBlockDownload()) - // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, PACKAGE_NAME " is in initial sync and waiting for blocks..."); + // Block getblocktemplate during initial block download for security + if (::ChainstateActive().IsInitialBlockDownload()) { + throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, PACKAGE_NAME " is in initial sync and waiting for blocks..."); + } static unsigned int nTransactionsUpdatedLast; const CTxMemPool& mempool = EnsureMemPool();