Browse Source

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.
duke
Duke 4 months ago
parent
commit
27db254d68
  1. 27
      src/main.cpp
  2. 2
      src/miner.cpp
  3. 3
      src/rpc/rawtransaction.cpp
  4. 3
      src/validationinterface.cpp
  5. 2
      src/wallet/asyncrpcoperation_mergetoaddress.cpp
  6. 4
      src/wallet/asyncrpcoperation_sendmany.cpp
  7. 2
      src/wallet/asyncrpcoperation_shieldcoinbase.cpp
  8. 9
      src/wallet/rpcwallet.cpp
  9. 20
      src/wallet/wallet.cpp

27
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<size_t>::max() >= std::numeric_limits<int64_t>::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;

2
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();

3
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));

3
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));

2
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_) {

4
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_) {

2
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_) {

9
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();

20
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<CRecipient>& 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<CRecipient>& 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<CRecipient>& vecSend, CWalletTx& wt
txNew.vin.push_back(CTxIn(coin.first->GetHash(),coin.second,CScript(),
std::numeric_limits<unsigned int>::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<CRecipient>& vecSend, CWalletTx& wt
return false;
}
}
*/
// Grab the current consensus branch ID
auto consensusBranchId = CurrentEpochBranchId(chainActive.Height() + 1, Params().GetConsensus());

Loading…
Cancel
Save