Browse Source

Do not apply overwinter/sapling consensus rules to block 0

wolfssl
Duke 3 months ago
parent
commit
07b041fd94
  1. 6
      src/hush-tx.cpp
  2. 14
      src/main.cpp
  3. 4
      src/miner.cpp
  4. 2
      src/rpc/rawtransaction.cpp
  5. 2
      src/validationinterface.cpp
  6. 4
      src/wallet/rpcwallet.cpp
  7. 16
      src/wallet/wallet.cpp

6
src/hush-tx.cpp

@ -195,12 +195,14 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para
{ {
CMutableTransaction mtx; CMutableTransaction mtx;
bool isOverwintered = NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER); const bool isOverwintered = nHeight>=1 ? true : false; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER);
const bool isSapling = nHeight>=1 ? true : false;
if (isOverwintered) { if (isOverwintered) {
mtx.fOverwintered = true; mtx.fOverwintered = true;
mtx.nExpiryHeight = nHeight + 60; mtx.nExpiryHeight = nHeight + 60;
if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) { //if (NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) {
if(isSapling) {
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
mtx.nVersion = SAPLING_TX_VERSION; mtx.nVersion = SAPLING_TX_VERSION;
} else { } else {

14
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 IsStandardTx(const CTransaction& tx, string& reason, const int nHeight)
{ {
const bool overwinterActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); const bool overwinterActive = nHeight>=1 ? true : false; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
const bool saplingActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING); const bool saplingActive = nHeight>=1 ? true : false; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
if (saplingActive) { if (saplingActive) {
// Sapling standard rules apply // Sapling standard rules apply
@ -3073,7 +3073,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
// However, this is only reliable if the last block was on or after // However, this is only reliable if the last block was on or after
// the Sapling activation height. Otherwise, the last anchor was the // the Sapling activation height. Otherwise, the last anchor was the
// empty root. // empty root.
const bool sapling = true; // NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING); const bool sapling = pindex->pprev->GetHeight() >= 1 ? true : false; // NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
if (sapling) { if (sapling) {
view.PopAnchor(pindex->pprev->hashFinalSaplingRoot, SAPLING); view.PopAnchor(pindex->pprev->hashFinalSaplingRoot, SAPLING);
} else { } else {
@ -3492,7 +3492,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
// If Sapling is active, block.hashFinalSaplingRoot must be the // If Sapling is active, block.hashFinalSaplingRoot must be the
// same as the root of the Sapling tree // same as the root of the Sapling tree
const bool sapling = true; //NetworkUpgradeActive(pindex->GetHeight(), chainparams.GetConsensus(), Consensus::UPGRADE_SAPLING); const bool sapling = pindex->GetHeight()>=1 ? true : false; //NetworkUpgradeActive(pindex->GetHeight(), chainparams.GetConsensus(), Consensus::UPGRADE_SAPLING);
if (sapling) { if (sapling) {
if (block.hashFinalSaplingRoot != sapling_tree.root()) { if (block.hashFinalSaplingRoot != sapling_tree.root()) {
return state.DoS(100, return state.DoS(100,
@ -5219,7 +5219,7 @@ bool ContextualCheckBlock(int32_t slowflag,const CBlock& block, CValidationState
{ {
const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->GetHeight() + 1; const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->GetHeight() + 1;
const Consensus::Params& consensusParams = Params().GetConsensus(); const Consensus::Params& consensusParams = Params().GetConsensus();
bool sapling = true; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); // bool sapling = nHeight>=1 ? true : false; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING);
// Check that all transactions are finalized // Check that all transactions are finalized
for (uint32_t i = 0; i < block.vtx.size(); i++) { for (uint32_t i = 0; i < block.vtx.size(); i++) {
@ -8214,12 +8214,12 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
mtx.nVersion = SAPLING_TX_VERSION; mtx.nVersion = SAPLING_TX_VERSION;
} else { } else {
bool isOverwintered = true; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER); const bool isOverwintered = nHeight>=1 ? true : false; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_OVERWINTER);
if (isOverwintered) if (isOverwintered)
{ {
mtx.fOverwintered = true; mtx.fOverwintered = true;
mtx.nExpiryHeight = nHeight + expiryDelta; mtx.nExpiryHeight = nHeight + expiryDelta;
const bool sapling = true; const bool sapling = nHeight>=1 ? true : false;
if (sapling) // NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING)) if (sapling) // NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING))
{ {
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID; mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;

4
src/miner.cpp

@ -233,8 +233,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
const int nHeight = pindexPrev->GetHeight() + 1; const int nHeight = pindexPrev->GetHeight() + 1;
const Consensus::Params &consensusParams = chainparams.GetConsensus(); const Consensus::Params &consensusParams = chainparams.GetConsensus();
uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams); uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams);
// Sapling NU is always active // Sapling NU is always active for height>=1
const bool sapling = true; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING); const bool sapling = nHeight>=1 ? true : false; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING);
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast(); const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
uint32_t proposedTime = GetTime(); uint32_t proposedTime = GetTime();

2
src/rpc/rawtransaction.cpp

@ -690,7 +690,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp, const CPubKey&
} }
if (params.size() > 3 && !params[3].isNull()) { if (params.size() > 3 && !params[3].isNull()) {
const bool overwinter = true; const bool overwinter = nextBlockHeight>=1 ? true : false;
if (overwinter) { // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { if (overwinter) { // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
int64_t nExpiryHeight = params[3].get_int64(); int64_t nExpiryHeight = params[3].get_int64();
if (nExpiryHeight < 0 || nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD) { if (nExpiryHeight < 0 || nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD) {

2
src/validationinterface.cpp

@ -149,7 +149,7 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip)
// the Sapling activation height. Otherwise, the last anchor was the // the Sapling activation height. Otherwise, the last anchor was the
// empty root. // empty root.
SaplingMerkleTree oldSaplingTree; SaplingMerkleTree oldSaplingTree;
const bool sapling = true; const bool sapling = pindex->pprev->GetHeight() >= 1 ? true : false;
if (sapling) { // NetworkUpgradeActive(pindex->pprev->GetHeight(),Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { if (sapling) { // NetworkUpgradeActive(pindex->pprev->GetHeight(),Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
assert(pcoinsTip->GetSaplingAnchorAt(pindex->pprev->hashFinalSaplingRoot, oldSaplingTree)); assert(pcoinsTip->GetSaplingAnchorAt(pindex->pprev->hashFinalSaplingRoot, oldSaplingTree));
} else { } else {

4
src/wallet/rpcwallet.cpp

@ -5467,7 +5467,7 @@ UniValue z_shieldcoinbase(const UniValue& params, bool fHelp, const CPubKey& myp
} }
int nextBlockHeight = chainActive.Height() + 1; int nextBlockHeight = chainActive.Height() + 1;
bool overwinterActive = true; // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); bool overwinterActive = nextBlockHeight>=1 ? true : false; // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING; unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
// Prepare to get coinbase utxos // Prepare to get coinbase utxos
@ -5714,7 +5714,7 @@ UniValue z_mergetoaddress(const UniValue& params, bool fHelp, const CPubKey& myp
} }
const int nextBlockHeight = chainActive.Height() + 1; const int nextBlockHeight = chainActive.Height() + 1;
const bool overwinterActive = true; // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER); const bool overwinterActive = nextBlockHeight >=1 ? true : false; // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
// Validate the destination address // Validate the destination address
auto destaddress = params[1].get_str(); auto destaddress = params[1].get_str();

16
src/wallet/wallet.cpp

@ -511,6 +511,9 @@ void CWallet::RunSaplingSweep(int blockHeight) {
// if (!NetworkUpgradeActive(blockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { // if (!NetworkUpgradeActive(blockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
// return; // return;
// } // }
if (blockHeight == 0)
return;
AssertLockHeld(cs_wallet); AssertLockHeld(cs_wallet);
if (!fSweepEnabled) { if (!fSweepEnabled) {
return; return;
@ -3688,7 +3691,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
txNew.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast(); txNew.nLockTime = (uint32_t)chainActive.Tip()->GetMedianTimePast();
// Activates after Overwinter network upgrade // Activates after Overwinter network upgrade
const bool overwinter = true; const bool overwinter = nextBlockHeight >=1 ? true : false;
if (overwinter) { // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { if (overwinter) { // NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
if (txNew.nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD){ if (txNew.nExpiryHeight >= TX_EXPIRY_HEIGHT_THRESHOLD){
strFailReason = _("nExpiryHeight must be less than TX_EXPIRY_HEIGHT_THRESHOLD."); strFailReason = _("nExpiryHeight must be less than TX_EXPIRY_HEIGHT_THRESHOLD.");
@ -3697,7 +3700,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
} }
unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING; unsigned int max_tx_size = MAX_TX_SIZE_AFTER_SAPLING;
/* Sapling is always active /* Sapling is always active since height=1
if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) { if (!NetworkUpgradeActive(nextBlockHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING; max_tx_size = MAX_TX_SIZE_BEFORE_SAPLING;
} }
@ -3898,13 +3901,13 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
// All Hush Arrakis Chains always have overwinter NU and so this option was never used // 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 // Check mempooltxinputlimit to avoid creating a transaction which the local mempool rejects
// const size_t limit = 0; // (size_t)GetArg("-mempooltxinputlimit", 0); // const size_t limit = 0; // (size_t)GetArg("-mempooltxinputlimit", 0);
{ //{
LOCK(cs_main); // LOCK(cs_main);
const bool overwinter = true; //const bool overwinter = true;
//if (NetworkUpgradeActive(chainActive.Height() + 1, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) { //if (NetworkUpgradeActive(chainActive.Height() + 1, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER)) {
// limit = 0; // limit = 0;
//} //}
} //}
/* /*
if (limit > 0) { if (limit > 0) {
size_t n = txNew.vin.size(); size_t n = txNew.vin.size();
@ -5044,6 +5047,7 @@ SpendingKeyAddResult AddSpendingKeyToWallet::operator()(const libzcash::SaplingE
if (params.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight == Consensus::NetworkUpgrade::ALWAYS_ACTIVE) { if (params.vUpgrades[Consensus::UPGRADE_SAPLING].nActivationHeight == Consensus::NetworkUpgrade::ALWAYS_ACTIVE) {
m_wallet->mapSaplingZKeyMetadata[ivk].nCreateTime = nTime; m_wallet->mapSaplingZKeyMetadata[ivk].nCreateTime = nTime;
} else { } else {
// TODO: set a better time for HUSH+DRAGONX
// 154051200 seconds from epoch is Friday, 26 October 2018 00:00:00 GMT - definitely before Sapling activates // 154051200 seconds from epoch is Friday, 26 October 2018 00:00:00 GMT - definitely before Sapling activates
m_wallet->mapSaplingZKeyMetadata[ivk].nCreateTime = std::max((int64_t) 154051200, nTime); m_wallet->mapSaplingZKeyMetadata[ivk].nCreateTime = std::max((int64_t) 154051200, nTime);
} }

Loading…
Cancel
Save