Potentially fix #382 by not checking the genesis block against sapling consensus rules
This commit is contained in:
31
src/main.cpp
31
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)
|
||||
{
|
||||
const bool overwinterActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
const bool saplingActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
const bool overwinterActive = nHeight >=1 ? true : false; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
const bool saplingActive = nHeight >=1 ? true : false; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
|
||||
if (saplingActive) {
|
||||
// Sapling standard rules apply
|
||||
@@ -1220,8 +1220,10 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde
|
||||
const int dosLevel,
|
||||
bool (*isInitBlockDownload)(),int32_t validateprices)
|
||||
{
|
||||
const bool overwinterActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
const bool saplingActive = true; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
const bool overwinterActive = nHeight >=1 ? true : false; //NetworkUpgradeActive(nHeight, Params().GetConsensus(), Consensus::UPGRADE_OVERWINTER);
|
||||
const bool saplingActive = nHeight >=1 ? true : false; //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
|
||||
@@ -1230,6 +1232,7 @@ bool ContextualCheckTransaction(int32_t slowflag,const CBlock *block, CBlockInde
|
||||
return state.DoS((ht < 0 || nHeight < ht) ? 0 : dosLevel,error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet",nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel),REJECT_INVALID, "tx-overwinter-not-active");
|
||||
//return state.DoS(isInitBlockDownload() ? 0 : dosLevel,error("ContextualCheckTransaction(): ht.%d activates.%d dosLevel.%d overwinter is not active yet",nHeight, Params().GetConsensus().vUpgrades[Consensus::UPGRADE_OVERWINTER].nActivationHeight, dosLevel),REJECT_INVALID, "tx-overwinter-not-active");
|
||||
}
|
||||
*/
|
||||
|
||||
if (saplingActive) {
|
||||
// Reject transactions with valid version but missing overwintered flag
|
||||
@@ -3073,7 +3076,7 @@ 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.
|
||||
const bool sapling = true; // NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
const bool sapling = pindex->GetHeight() >= 2 ? true : false; // NetworkUpgradeActive(pindex->pprev->GetHeight(), Params().GetConsensus(), Consensus::UPGRADE_SAPLING);
|
||||
if (sapling) {
|
||||
view.PopAnchor(pindex->pprev->hashFinalSaplingRoot, SAPLING);
|
||||
} else {
|
||||
@@ -3152,7 +3155,6 @@ static int64_t nTimeTotal = 0;
|
||||
bool FindBlockPos(int32_t tmpflag,CValidationState &state, CDiskBlockPos &pos, unsigned int nAddSize, unsigned int nHeight, uint64_t nTime, bool fKnown = false);
|
||||
bool ReceivedBlockTransactions(const CBlock &block, CValidationState& state, CBlockIndex *pindexNew, const CDiskBlockPos& pos);
|
||||
|
||||
|
||||
bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pindex, CCoinsViewCache& view, bool fJustCheck,bool fCheckPOW)
|
||||
{
|
||||
CDiskBlockPos blockPos;
|
||||
@@ -3164,7 +3166,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
//fprintf(stderr,"connectblock ht.%d\n",(int32_t)pindex->GetHeight());
|
||||
AssertLockHeld(cs_main);
|
||||
|
||||
bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||
const bool ishush3 = strncmp(SMART_CHAIN_SYMBOL, "HUSH3",5) == 0 ? true : false;
|
||||
|
||||
// At startup, HUSH3 doesn't know a block height yet and so we must wait until
|
||||
// connecting a block to set our private/blocktime flags, which are height-dependent
|
||||
@@ -3336,11 +3338,6 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
|
||||
// that is on the tip of our chain
|
||||
//assert(view.GetSproutAnchorAt(old_sprout_tree_root, sprout_tree));
|
||||
|
||||
//{
|
||||
// Consistency check: the root of the tree we're given should
|
||||
// match what we asked for.
|
||||
//assert(sprout_tree.root() == old_sprout_tree_root);
|
||||
//}
|
||||
|
||||
SaplingMerkleTree sapling_tree;
|
||||
assert(view.GetSaplingAnchorAt(view.GetBestAnchor(SAPLING), sapling_tree));
|
||||
@@ -3492,7 +3489,7 @@ 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
|
||||
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 (block.hashFinalSaplingRoot != sapling_tree.root()) {
|
||||
return state.DoS(100,
|
||||
@@ -5218,8 +5215,8 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
|
||||
bool ContextualCheckBlock(int32_t slowflag,const CBlock& block, CValidationState& state, CBlockIndex * const pindexPrev)
|
||||
{
|
||||
const int nHeight = pindexPrev == NULL ? 0 : pindexPrev->GetHeight() + 1;
|
||||
const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
bool sapling = true; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING);
|
||||
//const Consensus::Params& consensusParams = Params().GetConsensus();
|
||||
//bool sapling = true; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING);
|
||||
|
||||
// Check that all transactions are finalized
|
||||
for (uint32_t i = 0; i < block.vtx.size(); i++) {
|
||||
@@ -8213,12 +8210,12 @@ CMutableTransaction CreateNewContextualCMutableTransaction(const Consensus::Para
|
||||
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
|
||||
mtx.nVersion = SAPLING_TX_VERSION;
|
||||
} 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)
|
||||
{
|
||||
mtx.fOverwintered = true;
|
||||
mtx.nExpiryHeight = nHeight + expiryDelta;
|
||||
const bool sapling = true;
|
||||
const bool sapling = nHeight >=1 ? true : false;
|
||||
if (sapling) // NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING))
|
||||
{
|
||||
mtx.nVersionGroupId = SAPLING_VERSION_GROUP_ID;
|
||||
|
||||
@@ -233,8 +233,8 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
|
||||
const int nHeight = pindexPrev->GetHeight() + 1;
|
||||
const Consensus::Params &consensusParams = chainparams.GetConsensus();
|
||||
uint32_t consensusBranchId = CurrentEpochBranchId(nHeight, consensusParams);
|
||||
// Sapling NU is always active
|
||||
const bool sapling = true; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING);
|
||||
// Sapling NU is always active when height>=1
|
||||
const bool sapling = nHeight>=1 ? true : false; //NetworkUpgradeActive(nHeight, consensusParams, Consensus::UPGRADE_SAPLING);
|
||||
|
||||
const int64_t nMedianTimePast = pindexPrev->GetMedianTimePast();
|
||||
uint32_t proposedTime = GetTime();
|
||||
|
||||
@@ -149,7 +149,7 @@ void ThreadNotifyWallets(CBlockIndex *pindexLastTip)
|
||||
// the Sapling activation height. Otherwise, the last anchor was the
|
||||
// empty root.
|
||||
SaplingMerkleTree oldSaplingTree;
|
||||
const bool sapling = true;
|
||||
const bool sapling = pindex->GetHeight() >= 2 ? true : false;
|
||||
if (sapling) { // NetworkUpgradeActive(pindex->pprev->GetHeight(),Params().GetConsensus(), Consensus::UPGRADE_SAPLING)) {
|
||||
assert(pcoinsTip->GetSaplingAnchorAt(pindex->pprev->hashFinalSaplingRoot, oldSaplingTree));
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user