Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/chain.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
* current network-adjusted time before the block will be accepted.
*/
static const int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60;
static const int64_t MAX_FUTURE_BLOCK_TIME_DGW = MAX_FUTURE_BLOCK_TIME / 10;

/**
* Timestamp window used as a grace period by code that compares external
Expand Down
9 changes: 9 additions & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,9 @@ class CMainParams : public CChainParams {

//Global Burn Address
strGlobalBurnAddress = "RXBurnXXXXXXXXXXXXXXXXXXXXXXWUo9FV";

// DGW Activation
nDGWActivationBlock = 341200;
/** RVN End **/
}
};
Expand Down Expand Up @@ -319,6 +322,9 @@ class CTestNetParams : public CChainParams {

// Global Burn Address
strGlobalBurnAddress = "n1BurnXXXXXXXXXXXXXXXXXXXXXXU1qejP";

// DGW Activation
nDGWActivationBlock = 345000;
/** RVN End **/
}
};
Expand Down Expand Up @@ -470,6 +476,9 @@ class CRegTestParams : public CChainParams {

// Global Burn Address
strGlobalBurnAddress = "n1BurnXXXXXXXXXXXXXXXXXXXXXXU1qejP";

// DGW Activation
nDGWActivationBlock = 200;
/** RVN End **/
}
};
Expand Down
4 changes: 4 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ class CChainParams
const std::string& IssueSubAssetBurnAddress() const { return strIssueSubAssetBurnAddress; }
const std::string& IssueUniqueAssetBurnAddress() const { return strIssueUniqueAssetBurnAddress; }
const std::string& GlobalBurnAddress() const { return strGlobalBurnAddress; }

unsigned int DGWActivationBlock() const { return nDGWActivationBlock; }
/** RVN End **/

protected:
Expand Down Expand Up @@ -136,6 +138,8 @@ class CChainParams

// Global Burn Address
std::string strGlobalBurnAddress;

unsigned int nDGWActivationBlock;
/** RVN End **/
};

Expand Down
9 changes: 4 additions & 5 deletions src/pow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ unsigned int static DarkGravityWave(const CBlockIndex* pindexLast, const CBlockH

unsigned int nProofOfWorkLimit = UintToArith256(params.powLimit).GetCompact();
const arith_uint256 bnPowLimit = UintToArith256(params.powLimit);
int64_t nPastBlocks = 60;
int64_t nPastBlocks = 180; // ~3hr

// make sure we have at least (nPastBlocks + 1) blocks, otherwise just return powLimit
if (!pindexLast || pindexLast->nHeight < nPastBlocks) {
Expand Down Expand Up @@ -126,15 +126,14 @@ unsigned int GetNextWorkRequired(const CBlockIndex* pindexLast, const CBlockHead
int btc = GetNextWorkRequiredBTC(pindexLast, pblock, params);
int64_t nPrevBlockTime = (pindexLast->pprev ? pindexLast->pprev->GetBlockTime() : pindexLast->GetBlockTime());

int version = (pblock->nVersion & 0xF0000000) >> 28;
if (version >= 3 && !CheckPOWHeightAssets(pindexLast->nHeight + 1)) {
if (IsDGWActive(pindexLast->nHeight + 1)) {
LogPrint(BCLog::NET, "Block %s - version: %s: found next work required using DGW: [%s] (BTC would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n",
pindexLast->nHeight, pblock->nVersion, dgw, btc, btc - dgw, (float)(btc - dgw) * 100.0 / (float)dgw, pindexLast->GetBlockTime() - nPrevBlockTime);
pindexLast->nHeight + 1, pblock->nVersion, dgw, btc, btc - dgw, (float)(btc - dgw) * 100.0 / (float)dgw, pindexLast->GetBlockTime() - nPrevBlockTime);
return dgw;
}
else {
LogPrint(BCLog::NET, "Block %s - version: %s: found next work required using BTC: [%s] (DGW would have been [%s]\t(%+d)\t(%0.3f%%)\t(%s sec))\n",
pindexLast->nHeight, pblock->nVersion, btc, dgw, dgw - btc, (float)(dgw - btc) * 100.0 / (float)btc, pindexLast->GetBlockTime() - nPrevBlockTime);
pindexLast->nHeight + 1, pblock->nVersion, btc, dgw, dgw - btc, (float)(dgw - btc) * 100.0 / (float)btc, pindexLast->GetBlockTime() - nPrevBlockTime);
return btc;
}

Expand Down
7 changes: 7 additions & 0 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1389,6 +1389,12 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
obj.push_back(Pair("headers", pindexBestHeader ? pindexBestHeader->nHeight : -1));
obj.push_back(Pair("bestblockhash", chainActive.Tip()->GetBlockHash().GetHex()));
obj.push_back(Pair("difficulty", (double)GetDifficulty()));
if (IsDGWActive(chainActive.Height())) {
obj.push_back(Pair("difficulty_algorithm", "DGW-180"));
} else {
obj.push_back(Pair("difficulty_algorithm", "BTC"));
obj.push_back(Pair("DGW_activation_height", (int)Params().DGWActivationBlock()));
}
obj.push_back(Pair("mediantime", (int64_t)chainActive.Tip()->GetMedianTimePast()));
obj.push_back(Pair("verificationprogress", GuessVerificationProgress(Params().TxData(), chainActive.Tip())));
obj.push_back(Pair("chainwork", chainActive.Tip()->nChainWork.GetHex()));
Expand All @@ -1414,6 +1420,7 @@ UniValue getblockchaininfo(const JSONRPCRequest& request)
const Consensus::Params& consensusParams = Params().GetConsensus();
//CBlockIndex* tip = chainActive.Tip();


UniValue softforks(UniValue::VARR);
UniValue bip9_softforks(UniValue::VOBJ);
// softforks.push_back(SoftForkDesc("bip34", 2, tip, consensusParams));
Expand Down
16 changes: 14 additions & 2 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3467,8 +3467,16 @@ static bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationSta
return state.Invalid(false, REJECT_INVALID, "time-too-old", "block's timestamp is too early");

// Check timestamp
if (block.GetBlockTime() > nAdjustedTime + MAX_FUTURE_BLOCK_TIME)
return state.Invalid(false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future");
if (IsDGWActive(pindexPrev->nHeight+1))
{
if (block.GetBlockTime() > nAdjustedTime + MAX_FUTURE_BLOCK_TIME_DGW)
return state.Invalid(false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future");
}
else
{
if (block.GetBlockTime() > nAdjustedTime + MAX_FUTURE_BLOCK_TIME)
return state.Invalid(false, REJECT_INVALID, "time-too-new", "block timestamp too far in the future");
}

// Reject outdated version blocks when 95% (75% on testnet) of the network has upgraded:
// check for version 2, 3 and 4 upgrades
Expand Down Expand Up @@ -5021,6 +5029,10 @@ bool AreAssetsDeployed() {

return fAssetsIsActive;
}

bool IsDGWActive(unsigned int nBlockNumber) {
return nBlockNumber >= Params().DGWActivationBlock();
}
/** RVN END */

class CMainCleanup
Expand Down
2 changes: 2 additions & 0 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,8 @@ bool LoadMempool();

/** RVN START */
bool AreAssetsDeployed();

bool IsDGWActive(unsigned int nBlockNumber);
/** RVN END */

#endif // RAVEN_VALIDATION_H