From 27db254d688c7cd4d09114de98a99c0d4d7b07fa Mon Sep 17 00:00:00 2001 From: Duke Date: Sun, 21 Jan 2024 16:34:53 -0500 Subject: [PATCH] Sapling and Overwinter network upgrades are always active These NU's are always active for Hush Arrakis Chains so this code only serves to slow down all operations by constantly being checked. So we disable them which will speed up syncing, mining and creating transactions. --- src/main.cpp | 27 +++++++++++-------- src/miner.cpp | 2 +- src/rpc/rawtransaction.cpp | 3 ++- src/validationinterface.cpp | 3 ++- .../asyncrpcoperation_mergetoaddress.cpp | 2 ++ src/wallet/asyncrpcoperation_sendmany.cpp | 4 ++- .../asyncrpcoperation_shieldcoinbase.cpp | 2 ++ src/wallet/rpcwallet.cpp | 9 ++++--- src/wallet/wallet.cpp | 20 +++++++++----- 9 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index ff708fbcf..85c0556fc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -931,8 +931,8 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans) EXCLUSIVE_LOCKS_REQUIRE bool IsStandardTx(const CTransaction& tx, string& reason, const int nHeight) { - bool overwinterActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); - bool saplingActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); + const bool overwinterActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); + const bool saplingActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); if (saplingActive) { // Sapling standard rules apply @@ -1220,9 +1220,9 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde const int dosLevel, bool (*isInitBlockDownload)(),int32_t validateprices) { - bool overwinterActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); - bool saplingActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); - bool isSprout = false; //!overwinterActive; + const bool overwinterActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); + const bool saplingActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); + const bool isSprout = false; //!overwinterActive; // If Sprout rules apply, reject transactions which are intended for Overwinter and beyond if (isSprout && tx.fOverwintered) { @@ -1728,11 +1728,12 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa if ( nextBlockHeight <= 1 || chainActive.LastTip() == 0 ) tiptime = (uint32_t)time(NULL); else tiptime = (uint32_t)chainActive.LastTip()->nTime; + + /* // Node operator can choose to reject tx by number of transparent inputs static_assert(std::numeric_limits::max() >= std::numeric_limits::max(), "size_t too small"); - size_t limit = (size_t) GetArg("-mempooltxinputlimit", 0); - - // Limit is ignored if Overwinter is active, which is the case on HUSH3 and all HSC's + const size_t limit = 0; //(size_t) GetArg("-mempooltxinputlimit", 0); + // Limit is ignored if Overwinter is active, which is the case on HUSH3 and all HAC's if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { limit = 0; } @@ -1743,6 +1744,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa return false; } } + */ auto verifier = libzcash::ProofVerifier::Strict(); if (!CheckTransaction(tiptime,tx, state, verifier, 0, 0)) @@ -3071,7 +3073,8 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex // However, this is only reliable if the last block was on or after // the Sapling activation height. Otherwise, the last anchor was the // empty root. - if (NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { + const bool sapling = true; // NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING); + if (sapling) { view.PopAnchor(pindex->pprev->hashFinalSaplingRoot, SAPLING); } else { view.PopAnchor(SaplingMerkleTree::empty_root(), SAPLING); @@ -3489,7 +3492,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // If Sapling is active, block.hashFinalSaplingRoot must be the // same as the root of the Sapling tree - if (NetworkUpgradeActive(pindex->GetHeight(), chainparams.GetConsensus(), Consensus::UPGRADE_SAPLING)) { + const bool sapling = true; //NetworkUpgradeActive(pindex->GetHeight(), chainparams.GetConsensus(), Consensus::UPGRADE_SAPLING); + if (sapling) { if (block.hashFinalSaplingRoot != sapling_tree.root()) { return state.DoS(100, error("ConnectBlock(): block's hashFinalSaplingRoot is incorrect"), @@ -8214,7 +8218,8 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para { mtx.fOverwintered = true; mtx.nExpiryHeight = nHeight + expiryDelta; - if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) + const bool sapling = true; + if (sapling) // NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) { mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersion = SAPLING_TX_VERSION; diff --git a/src/miner.cpp b/src/miner.cpp index c7d6c500f..c3b7ccf44 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -234,7 +234,7 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32 const Consensus::Params &consensusParams = chainparams.GetConsensus(); uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); // Sapling NU is always active - bool sapling = true; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); + const bool sapling = true; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); uint32_t proposedTime = GetTime(); diff --git a/src/rpc/rawtransaction.cpp b/src/rpc/rawtransaction.cpp index 23890479f..b09f60c12 100644 --- a/src/rpc/rawtransaction.cpp +++ b/src/rpc/rawtransaction.cpp @@ -690,7 +690,8 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp, const CPubKey& } if (params.size() > 3 && !params[3].isNull()) { - if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { + const bool overwinter = true; + if (overwinter) { // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { int64_t nExpiryHeight = params[3].get_int64(); if (nExpiryHeight < 0 || nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD) { throw JSONRPCError(RPC_INVALID_PARAMETER, strprintf("Invalid parameter, expiryheight must be nonnegative and less than %d.", TX_EXPIRY_HEIGHT_THRESHOLD)); diff --git a/src/validationinterface.cpp b/src/validationinterface.cpp index 62ba5ea80..5294f851b 100644 --- a/src/validationinterface.cpp +++ b/src/validationinterface.cpp @@ -149,7 +149,8 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip) // the Sapling activation height. Otherwise, the last anchor was the // empty root. SaplingMerkleTree oldSaplingTree; - if (NetworkUpgradeActive(pindex->pprev->GetHeight(),Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { + const bool sapling = true; + if (sapling) { // NetworkUpgradeActive(pindex->pprev->GetHeight(),Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { assert(pcoinsTip->GetSaplingAnchorAt(pindex->pprev->hashFinalSaplingRoot, oldSaplingTree)); } else { assert(pcoinsTip->GetSaplingAnchorAt(SaplingMerkleTree::empty_root(), oldSaplingTree)); diff --git a/src/wallet/asyncrpcoperation_mergetoaddress.cpp b/src/wallet/asyncrpcoperation_mergetoaddress.cpp index fe1e14fb8..8777ad1bf 100644 --- a/src/wallet/asyncrpcoperation_mergetoaddress.cpp +++ b/src/wallet/asyncrpcoperation_mergetoaddress.cpp @@ -192,6 +192,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() size_t numInputs = utxoInputs_.size(); + /* // Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects size_t limit = (size_t)GetArg("-mempooltxinputlimit", 0); { @@ -205,6 +206,7 @@ bool AsyncRPCOperation_mergetoaddress::main_impl() strprintf("Number of transparent inputs %d is greater than mempooltxinputlimit of %d", numInputs, limit)); } + */ CAmount t_inputs_total = 0; for (MergeToAddressInputUTXO& t : utxoInputs_) { diff --git a/src/wallet/asyncrpcoperation_sendmany.cpp b/src/wallet/asyncrpcoperation_sendmany.cpp index d1573e02f..bef59b556 100644 --- a/src/wallet/asyncrpcoperation_sendmany.cpp +++ b/src/wallet/asyncrpcoperation_sendmany.cpp @@ -309,8 +309,9 @@ bool AsyncRPCOperation_sendmany::main_impl() { t_inputs_ = selectedTInputs; t_inputs_total = selectedUTXOAmount; + /* // Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects - size_t limit = (size_t)GetArg("-mempooltxinputlimit", 0); + const size_t limit = (size_t)GetArg("-mempooltxinputlimit", 0); { LOCK(cs_main); if (NetworkUpgradeActive(chainActive.Height() + 1, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { @@ -323,6 +324,7 @@ bool AsyncRPCOperation_sendmany::main_impl() { throw JSONRPCError(RPC_WALLET_ERROR, strprintf("Too many transparent inputs %zu > limit %zu", n, limit)); } } + */ // update the transaction with these inputs if (isUsingBuilder_) { diff --git a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp index cc0cc0c99..6658a50d1 100644 --- a/src/wallet/asyncrpcoperation_shieldcoinbase.cpp +++ b/src/wallet/asyncrpcoperation_shieldcoinbase.cpp @@ -164,6 +164,7 @@ bool AsyncRPCOperation_shieldcoinbase::main_impl() { size_t numInputs = inputs_.size(); + /* // Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects size_t limit = (size_t)GetArg("-mempooltxinputlimit", 0); { @@ -177,6 +178,7 @@ bool AsyncRPCOperation_shieldcoinbase::main_impl() { strprintf("Number of inputs %d is greater than mempooltxinputlimit of %d", numInputs, limit)); } + */ CAmount targetAmount = 0; for (ShieldCoinbaseUTXO & utxo : inputs_) { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e5dcbb657..bf7bee794 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -5270,7 +5270,9 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersion = SAPLING_TX_VERSION; unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING; - if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { + /* + const bool sapling = true; //NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { + if (!sapling) { if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { mtx.nVersionGroupId = OVERWINTER_VERSION_GROUP_ID; mtx.nVersion = OVERWINTER_TX_VERSION; @@ -5279,6 +5281,7 @@ UniValue z_sendmany(const UniValue& params, bool fHelp, const CPubKey& mypk) mtx.nVersion = 2; } } + */ // As a sanity check, estimate and verify that the size of the transaction will be valid. // Depending on the input notes, the actual tx size may turn out to be larger and perhaps invalid. @@ -5462,7 +5465,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp } int nextBlockHeight = chainActive.Height() + 1; - bool overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); + bool overwinterActive = true; // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING; // Prepare to get coinbase utxos @@ -5709,7 +5712,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp } const int nextBlockHeight = chainActive.Height() + 1; - const bool overwinterActive = NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); + const bool overwinterActive = true; // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); // Validate the destination address auto destaddress = params[1].get_str(); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3071d46a7..4954ac505 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2787,7 +2787,8 @@ int CWallet::ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate) // This should never fail: we should always be able to get the tree // state on the path to the tip of our chain if (pindex->pprev) { - if (NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { + const bool sapling = true; + if (sapling) { // NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { assert(pcoinsTip->GetSaplingAnchorAt(pindex->pprev->hashFinalSaplingRoot, saplingTree)); } } @@ -3687,7 +3688,8 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt txNew.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast(); // Activates after Overwinter network upgrade - if (NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { + const bool overwinter = true; + if (overwinter) { // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { if (txNew.nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD){ strFailReason = _("nExpiryHeight must be less than TX_EXPIRY_HEIGHT_THRESHOLD."); return false; @@ -3695,9 +3697,11 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt } unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING; + /* Sapling is always active if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING; } + */ /* // Discourage fee sniping. // @@ -3891,14 +3895,17 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(), std::numeric_limits::max()-1)); + // All Hush Arrakis Chains always have overwinter NU and so this option was never used // Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects - size_t limit = (size_t)GetArg("-mempooltxinputlimit", 0); + // const size_t limit = 0; // (size_t)GetArg("-mempooltxinputlimit", 0); { LOCK(cs_main); - if (NetworkUpgradeActive(chainActive.Height() + 1, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { - limit = 0; - } + const bool overwinter = true; + //if (NetworkUpgradeActive(chainActive.Height() + 1, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { + // limit = 0; + //} } + /* if (limit > 0) { size_t n = txNew.vin.size(); if (n > limit) { @@ -3906,6 +3913,7 @@ bool CWallet::CreateTransaction(const vector& vecSend, CWalletTx& wt return false; } } + */ // Grab the current consensus branch ID auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus());