diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 26ac1b5332f31..b398bd5331a73 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -485,21 +485,9 @@ class CTestNetParams : public CChainParams { nDefaultPort = 29999; nPruneAfterHeight = 1000; - ///////////////////////////////////////////////////////////////////////// - uint32_t nTime = 1563050000; - uint32_t nNonce = 0; - while (UintToArith256(genesis.GetHash()) > - UintToArith256(consensus.powLimit)) - { - nNonce++; - genesis = CreateGenesisBlock(nTime, nNonce, 0x1f00ffff, 1, 0 * COIN); - } - genesis = CreateGenesisBlock(nTime, nNonce, 0x1f00ffff, 1, 0 * COIN); - consensus.hashGenesisBlock = genesis.GetHash(); - ///////////////////////////////////////////////////////////////////////// - + genesis = CreateGenesisBlock(1563589000, 62255, 0x1f00ffff, 1, 0 * COIN); consensus.hashGenesisBlock = genesis.GetHash(); - // assert(consensus.hashGenesisBlock == uint256S("0x0000071f25514da6d65c4fa2187ef8ee1f6b6a68b7761af91ecfb28dc85d3e8a")); + assert(consensus.hashGenesisBlock == uint256S("0x0000b67f0d64e977df72e86de5ef38e46b03d163790ed9a12e43240915be7197")); vFixedSeeds.clear(); vFixedSeeds = std::vector(pnSeed6_test, pnSeed6_test + ARRAYLEN(pnSeed6_test)); @@ -549,7 +537,7 @@ class CTestNetParams : public CChainParams { }; chainTxData = ChainTxData{ - nTime, // * UNIX timestamp of last known number of transactions + 1563589000, // * UNIX timestamp of last known number of transactions 0, // * total number of transactions between genesis and that timestamp // (the tx=... number in the SetBestChain debug.log lines) 0.0 // * estimated number of transactions per second after that timestamp diff --git a/src/kernel.cpp b/src/kernel.cpp index 5f0805672d0cb..e162b239c5f36 100644 --- a/src/kernel.cpp +++ b/src/kernel.cpp @@ -36,7 +36,7 @@ unsigned int getIntervalVersion(bool fTestNet) // Hard checkpoints of stake modifiers to ensure they are deterministic static std::map mapStakeModifierCheckpoints = - boost::assign::map_list_of(0, 0xfd11f4e7); + boost::assign::map_list_of(0, 0x0e00670b); // Get time weight int64_t GetWeight(int64_t nIntervalBeginning, int64_t nIntervalEnd) diff --git a/src/util.cpp b/src/util.cpp index 057fec67457ee..23c0b160ab668 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -571,7 +571,7 @@ boost::filesystem::path GetDefaultDataDir() // Unix: ~/.dashcore #ifdef WIN32 // Windows - return GetSpecialFolderPath(CSIDL_APPDATA) / "pactestneta"; + return GetSpecialFolderPath(CSIDL_APPDATA) / "PACGlobal"; #else fs::path pathRet; char* pszHome = getenv("HOME"); @@ -581,10 +581,10 @@ boost::filesystem::path GetDefaultDataDir() pathRet = fs::path(pszHome); #ifdef MAC_OSX // Mac - return pathRet / "Library/Application Support/pactestneta"; + return pathRet / "Library/Application Support/PACGlobal"; #else // Unix - return pathRet / ".pactestneta"; + return pathRet / ".PACGlobal"; #endif #endif } diff --git a/src/validation.cpp b/src/validation.cpp index 960e86b15bda0..0d3949111b2f9 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -3165,54 +3165,50 @@ bool ResetBlockFailureFlags(CBlockIndex *pindex) { return true; } -static void AcceptProofOfStakeBlock(const CBlock &block, CBlockIndex *pindexNew) +bool AcceptProofOfStakeBlock(const CBlock &block, CBlockIndex *pindex) { - if(!pindexNew) - return; + if (!pindex) + return false; if (block.IsProofOfStake()) { - pindexNew->SetProofOfStake(); - pindexNew->prevoutStake = block.vtx[1]->vin[0].prevout; - pindexNew->nStakeTime = block.nTime; + pindex->SetProofOfStake(); + pindex->prevoutStake = block.vtx[1]->vin[0].prevout; + pindex->nStakeTime = block.nTime; } else { - pindexNew->prevoutStake.SetNull(); - pindexNew->nStakeTime = 0; + pindex->prevoutStake.SetNull(); + pindex->nStakeTime = 0; } - //update previous block pointer - // pindexNew->pprev->pnext = pindexNew; - // ppcoin: compute chain trust score - pindexNew->bnChainTrust = (pindexNew->pprev ? pindexNew->pprev->bnChainTrust : ArithToUint256(0 + pindexNew->GetBlockTrust())); + pindex->bnChainTrust = (pindex->pprev ? pindex->pprev->bnChainTrust : ArithToUint256(0 + pindex->GetBlockTrust())); // ppcoin: compute stake entropy bit for stake modifier - if (!pindexNew->SetStakeEntropyBit(pindexNew->GetStakeEntropyBit())) + if (!pindex->SetStakeEntropyBit(pindex->GetStakeEntropyBit())) LogPrintf("AcceptProofOfStakeBlock() : SetStakeEntropyBit() failed \n"); - uint256 hash = block.GetHash(); - // ppcoin: record proof-of-stake hash value - if (pindexNew->IsProofOfStake()) { + if (pindex->IsProofOfStake()) { + uint256 hash = block.GetHash(); if (!mapProofOfStake.count(hash)) LogPrintf("AcceptProofOfStakeBlock() : hashProofOfStake not found in map \n"); - pindexNew->hashProofOfStake = mapProofOfStake[hash]; + pindex->hashProofOfStake = mapProofOfStake[hash]; } // ppcoin: compute stake modifier uint64_t nStakeModifier = 0; bool fGeneratedStakeModifier = false; - if (!ComputeNextStakeModifier(pindexNew, nStakeModifier, fGeneratedStakeModifier)) + if (!ComputeNextStakeModifier(pindex, nStakeModifier, fGeneratedStakeModifier)) LogPrintf("AcceptProofOfStakeBlock() : ComputeNextStakeModifier() failed \n"); - pindexNew->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier); - pindexNew->nStakeModifierChecksum = GetStakeModifierChecksum(pindexNew); - if (!CheckStakeModifierCheckpoints(pindexNew->nHeight, pindexNew->nStakeModifierChecksum)) { - LogPrintf("AcceptProofOfStakeBlock() : Rejected by stake modifier checkpoint height=%d, modifier=%s \n", pindexNew->nHeight, std::to_string(nStakeModifier)); - LogPrintf("pindexNew->nStakeModifierChecksum = %08x\n", pindexNew->nStakeModifierChecksum); - } else { - LogPrintf("AcceptProofOfStakeBlock() : Accepted stake modifier - checksum %08x\n", pindexNew->nStakeModifierChecksum); + pindex->SetStakeModifier(nStakeModifier, fGeneratedStakeModifier); + pindex->nStakeModifierChecksum = GetStakeModifierChecksum(pindex); + if (!CheckStakeModifierCheckpoints(pindex->nHeight, pindex->nStakeModifierChecksum)) { + LogPrintf("AcceptProofOfStakeBlock() : Rejected by stake modifier checkpoint height=%d, modifier=0x%016llx, checksum=0x%08x\n", + pindex->nHeight, nStakeModifier, pindex->nStakeModifierChecksum); + return false; } - setDirtyBlockIndex.insert(pindexNew); + setDirtyBlockIndex.insert(pindex); + return true; } CBlockIndex* AddToBlockIndex(const CBlockHeader& block, enum BlockStatus nStatus = BLOCK_VALID_TREE) @@ -3794,7 +3790,8 @@ static bool AcceptBlock(const std::shared_ptr& pblock, CValidation return error("%s: %s", __func__, FormatStateMessage(state)); } - AcceptProofOfStakeBlock(block, pindex); + if (!AcceptProofOfStakeBlock(block, pindex)) + return false; // Header is valid/has work, merkle tree is good...RELAY NOW // (but if it does not build on our best tip, let the SendMessages loop relay it) @@ -4427,7 +4424,8 @@ static bool AddGenesisBlock(const CChainParams& chainparams, const CBlock& block if (!WriteBlockToDisk(block, blockPos, chainparams.MessageStart())) return error("%s: writing genesis block to disk failed", __func__); CBlockIndex *pindex = AddToBlockIndex(block); - AcceptProofOfStakeBlock(block, pindex); + if (!AcceptProofOfStakeBlock(block, pindex)) + return error("%s: genesis block not accepted", __func__); if (!ReceivedBlockTransactions(block, state, pindex, blockPos)) return error("%s: genesis block not accepted", __func__); return true; diff --git a/src/version.h b/src/version.h index 148cfd2e3645b..4f98cc244a1fa 100644 --- a/src/version.h +++ b/src/version.h @@ -11,7 +11,7 @@ */ -static const int PROTOCOL_VERSION = 70215; +static const int PROTOCOL_VERSION = 70216; //! initial proto version, to be increased after version/verack negotiation static const int INIT_PROTO_VERSION = 209; @@ -20,7 +20,7 @@ static const int INIT_PROTO_VERSION = 209; static const int GETHEADERS_VERSION = 70077; //! disconnect from peers older than this proto version -static const int MIN_PEER_PROTO_VERSION = 70213; +static const int MIN_PEER_PROTO_VERSION = 70216; //! nTime field added to CAddress, starting with this version; //! if possible, avoid requesting addresses nodes older than this