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
2 changes: 1 addition & 1 deletion DigitalNote.pro
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
TEMPLATE = app
TARGET = DigitalNote-qt
VERSION = 1.0.1.4
VERSION = 1.0.1.5
INCLUDEPATH += src src/json src/qt src/qt/plugins/mrichtexteditor
QT += core gui widgets network printsupport
DEFINES += ENABLE_WALLET
Expand Down
215 changes: 134 additions & 81 deletions src/blockparams.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,6 +47,7 @@ double VRFup2 = 1.5;
double VRFup3 = 2;
double TerminalAverage = 0;
double TerminalFactor = 10000;
double debugTerminalAverage = 0;
CBigNum newBN = 0;
CBigNum oldBN = 0;
int64_t VLrate1 = 0;
Expand All@@ -68,16 +69,23 @@ int64_t scantime_1 = 0;
int64_t scantime_2 = 0;
int64_t prevPoW = 0; // hybrid value
int64_t prevPoS = 0; // hybrid value
uint64_t blkTime = 0;
uint64_t cntTime = 0;
uint64_t prvTime = 0;
uint64_t difTime = 0;
uint64_t hourRounds = 0;
uint64_t difCurve = 0;
uint64_t debugHourRounds = 0;
uint64_t debugDifCurve = 0;
bool fDryRun;
bool fCRVreset;
const CBlockIndex* pindexPrev = 0;
const CBlockIndex* BlockVelocityType = 0;
CBigNum bnVelocity = 0;
CBigNum bnOld;
CBigNum bnNew;
std::string difType ("");
unsigned int retarget = DIFF_VRX; // Default with VRX
uint64_t cntTime = 0;
uint64_t prvTime = 0;
uint64_t difTimePoS = 0;
uint64_t difTimePoW = 0;
string loggedpayee = "";


//////////////////////////////////////////////////////////////////////////////
Expand All@@ -89,29 +97,35 @@ string loggedpayee = "";
// Debug log printing
//

void VRXswngPoSdebug()
void VRXswngdebug()
{
// Print for debugging
LogPrintf("Previously discovered PoS block: %u: \n",prvTime);
LogPrintf("Current block-time: %u: \n",cntTime);
LogPrintf("Time since last PoS block: %u: \n",difTimePoS);
if(difTimePoS > 1 * 60 * 60) { TerminalAverage /= 2; LogPrintf("diffTimePoS is greater than 1 Hours: %u \n",cntTime);}
if(difTimePoS > 2 * 60 * 60) { TerminalAverage /= 2; LogPrintf("diffTimePoS is greater than 2 Hours: %u \n",cntTime);}
if(difTimePoS > 3 * 60 * 60) { TerminalAverage /= 2; LogPrintf("diffTimePoS is greater than 3 Hours: %u \n",cntTime);}
if(difTimePoS > 4 * 60 * 60) { TerminalAverage /= 2; LogPrintf("diffTimePoS is greater than 4 Hours: %u \n",cntTime);}
return;
}
LogPrintf("Previously discovered %s block: %u: \n",difType.c_str(),prvTime);
LogPrintf("Current block-time: %u: \n",difType.c_str(),cntTime);
LogPrintf("Time since last %s block: %u: \n",difType.c_str(),difTime);
// Handle updated versions as well as legacy
if(GetTime() > nPaymentUpdate_2) {
debugHourRounds = hourRounds;
debugTerminalAverage = TerminalAverage;
debugDifCurve = difCurve;
while(difTime > (debugHourRounds * 60 * 60)) {
debugTerminalAverage /= debugDifCurve;
LogPrintf("diffTime%s is greater than %u Hours: %u \n",difType.c_str(),debugHourRounds,cntTime);
LogPrintf("Difficulty will be multiplied by: %d \n",debugTerminalAverage);
// Break loop after 5 hours, otherwise time threshold will auto-break loop
if (debugHourRounds > 5){
break;
}
debugDifCurve ++;
debugHourRounds ++;
}
} else {
if(difTime > (hourRounds+0) * 60 * 60) {LogPrintf("diffTime%s is greater than 1 Hours: %u \n",difType.c_str(),cntTime);}
if(difTime > (hourRounds+1) * 60 * 60) {LogPrintf("diffTime%s is greater than 2 Hours: %u \n",difType.c_str(),cntTime);}
if(difTime > (hourRounds+2) * 60 * 60) {LogPrintf("diffTime%s is greater than 3 Hours: %u \n",difType.c_str(),cntTime);}
if(difTime > (hourRounds+3) * 60 * 60) {LogPrintf("diffTime%s is greater than 4 Hours: %u \n",difType.c_str(),cntTime);}
}

void VRXswngPoWdebug()
{
// Print for debugging
LogPrintf("Previously discovered PoW block: %u: \n",prvTime);
LogPrintf("Current block-time: %u: \n",cntTime);
LogPrintf("Time since last PoW block: %u: \n",difTimePoW);
if(difTimePoW > 1 * 60 * 60) { TerminalAverage /= 2; LogPrintf("diffTimePoW is greater than 1 Hours: %u \n",cntTime);}
if(difTimePoW > 2 * 60 * 60) { TerminalAverage /= 2; LogPrintf("diffTimePoW is greater than 2 Hours: %u \n",cntTime);}
if(difTimePoW > 3 * 60 * 60) { TerminalAverage /= 2; LogPrintf("diffTimePoW is greater than 3 Hours: %u \n",cntTime);}
if(difTimePoW > 4 * 60 * 60) { TerminalAverage /= 2; LogPrintf("diffTimePoW is greater than 4 Hours: %u \n",cntTime);}
return;
}

Expand DownExpand Up@@ -161,9 +175,9 @@ void GNTdebug()
//

//
// This is VRX revised implementation
// This is VRX (v3.5) revised implementation
//
// Terminal-Velocity-RateX, v10-Beta-R7, written by Jonathan Dan Zaretsky - cryptocoderz@gmail.com
// Terminal-Velocity-RateX, v10-Beta-R9, written by Jonathan Dan Zaretsky - cryptocoderz@gmail.com
void VRX_BaseEngine(const CBlockIndex* pindexLast, bool fProofOfStake)
{
// Set base values
Expand DownExpand Up@@ -231,14 +245,8 @@ void VRX_BaseEngine(const CBlockIndex* pindexLast, bool fProofOfStake)
// v1.1
if(pindexBest->GetBlockTime() > 1520198278) // ON Sunday, March 4, 2018 9:17:58 PM
{
if(pindexPrev->IsProofOfStake())
{
prevPoS ++;
}
else if(pindexPrev->IsProofOfWork())
{
prevPoW ++;
}
if(pindexPrev->IsProofOfStake()) { prevPoS ++; }
else if(pindexPrev->IsProofOfWork()) { prevPoW ++; }
}

// move up per scan round
Expand All@@ -249,6 +257,19 @@ void VRX_BaseEngine(const CBlockIndex* pindexLast, bool fProofOfStake)
return;
}

void VRX_Simulate_Retarget()
{
// Perform retarget simulation
TerminalFactor *= TerminalAverage;
difficultyfactor = TerminalFactor;
bnOld.SetCompact(BlockVelocityType->nBits);
bnNew = bnOld / difficultyfactor;
bnNew *= 10000;
// Reset TerminalFactor for actual retarget
TerminalFactor = 10000;
return;
}

void VRX_ThreadCurve(const CBlockIndex* pindexLast, bool fProofOfStake)
{
// Run VRX engine
Expand All@@ -270,78 +291,110 @@ void VRX_ThreadCurve(const CBlockIndex* pindexLast, bool fProofOfStake)
if(pindexBest->GetBlockTime() > 1520198278) // ON Sunday, March 4, 2018 9:17:58 PM
{
// Define time values
blkTime = pindexLast->GetBlockTime();
cntTime = BlockVelocityType->GetBlockTime();
prvTime = BlockVelocityType->pprev->GetBlockTime();

if(fProofOfStake)
{
difTimePoS = cntTime - prvTime;

// Debug print toggle
if(fDebug) VRXswngPoSdebug();
// Normal Run
else if(!fDebug)
{
if(difTimePoS > 1 * 60 * 60) { TerminalAverage /= 2; }
if(difTimePoS > 2 * 60 * 60) { TerminalAverage /= 2; }
if(difTimePoS > 3 * 60 * 60) { TerminalAverage /= 2; }
if(difTimePoS > 4 * 60 * 60) { TerminalAverage /= 2; }
}
difTime = cntTime - prvTime;
hourRounds = 1;
difCurve = 2;
fCRVreset = false;

// Debug print toggle
if(fProofOfStake) {
difType = "PoS";
} else {
difType = "PoW";
}
else if(!fProofOfStake)
{
difTimePoW = cntTime - prvTime;

// Debug print toggle
if(fDebug) VRXswngPoWdebug();
// Normal Run
else if(!fDebug)
{
if(difTimePoW > 1 * 60 * 60) { TerminalAverage /= 2; }
if(difTimePoW > 2 * 60 * 60) { TerminalAverage /= 2; }
if(difTimePoW > 3 * 60 * 60) { TerminalAverage /= 2; }
if(difTimePoW > 4 * 60 * 60) { TerminalAverage /= 2; }
if(fDebug) VRXswngdebug();

// Version 1.2 Extended Curve Run Upgrade
if(pindexLast->GetBlockTime() > nPaymentUpdate_2) {// ON Monday, Jun 24, 2019 12:00:00 PM PDT
// Set unbiased comparison
difTime = blkTime - cntTime;
// Run Curve
while(difTime > (hourRounds * 60 * 60)) {
// Break loop after 5 hours, otherwise time threshold will auto-break loop
if (hourRounds > 5){
fCRVreset = true;
break;
}
// Drop difficulty per round
TerminalAverage /= difCurve;
// Simulate retarget for sanity
VRX_Simulate_Retarget();
// Increase Curve per round
difCurve ++;
// Move up an hour per round
hourRounds ++;
}
} else {// Version 1.1 Standard Curve Run
if(difTime > (hourRounds+0) * 60 * 60) { TerminalAverage /= difCurve; }
if(difTime > (hourRounds+1) * 60 * 60) { TerminalAverage /= difCurve; }
if(difTime > (hourRounds+2) * 60 * 60) { TerminalAverage /= difCurve; }
if(difTime > (hourRounds+3) * 60 * 60) { TerminalAverage /= difCurve; }
}
}
return;
}

unsigned int VRX_Retarget(const CBlockIndex* pindexLast, bool fProofOfStake)
void VRX_Dry_Run(const CBlockIndex* pindexLast)
{
const CBigNum bnVelocity = fProofOfStake ? Params().ProofOfStakeLimit() : Params().ProofOfWorkLimit();

// Check for blocks to index | Allowing for initial chain start
if (pindexLast->nHeight < scanheight+124)
return bnVelocity.GetCompact(); // can't index prevblock
if (pindexLast->nHeight < scanheight+124) {
fDryRun = true;
return; // can't index prevblock
}

// Live fork toggle diff reset
// Reset difficulty for payments update
if(pindexLast->GetBlockTime() > 0)
{
if(pindexLast->GetBlockTime() > nPaymentUpdate_1) // Monday, May 20, 2019 12:00:00 AM
if(pindexLast->GetBlockTime() > nPaymentUpdate_1) // ON Monday, May 20, 2019 12:00:00 AM
{
if(pindexLast->GetBlockTime() < nPaymentUpdate_1+480) {
return bnVelocity.GetCompact(); // diff reset
fDryRun = true;
return; // diff reset
}
}
if(pindexLast->GetBlockTime() > nPaymentUpdate_2) // ON Monday, Jun 24, 2019 12:00:00 PM PDT
{
if(pindexLast->GetBlockTime() < nPaymentUpdate_2+480) {
fDryRun = true;
return; // diff reset
}
}
}

// Test Fork
if (nLiveForkToggle != 0) {
// Do nothing
}// TODO setup next testing fork

// Standard, non-Dry Run
fDryRun = false;
return;
}

unsigned int VRX_Retarget(const CBlockIndex* pindexLast, bool fProofOfStake)
{
// Set base values
bnVelocity = fProofOfStake ? Params().ProofOfStakeLimit() : Params().ProofOfWorkLimit();

// Differentiate PoW/PoS prev block
BlockVelocityType = GetLastBlockIndex(pindexLast, fProofOfStake);

// Check for a dry run
VRX_Dry_Run(pindexLast);
if(fDryRun) { return bnVelocity.GetCompact(); }

// Run VRX threadcurve
VRX_ThreadCurve(pindexLast, fProofOfStake);
if (fCRVreset) { return bnVelocity.GetCompact(); }

// Retarget
TerminalFactor *= TerminalAverage;
difficultyfactor = TerminalFactor;
bnOld.SetCompact(BlockVelocityType->nBits);
bnNew = bnOld / difficultyfactor;
bnNew *= 10000;
// Retarget using simulation
VRX_Simulate_Retarget();

// Limit
if (bnNew > bnVelocity)
bnNew = bnVelocity;
if (bnNew > bnVelocity) { bnNew = bnVelocity; }

// Final log
oldBN = bnOld.GetCompact();
Expand DownExpand Up@@ -479,7 +532,7 @@ int64_t GetMasternodePayment(int nHeight, int64_t blockValue)
{
// Define values
int64_t ret = 0;
int64_t swingSubsidy = blockValue - (100 * COIN); // 200 XDN ceiling
int64_t swingSubsidy = 200 * COIN; // 200 XDN ceiling
int64_t seesawHeight = nHeight;
int64_t seesawInterval = seesawHeight / 30;
int64_t seesawEpoch = seesawInterval / 15;
Expand DownExpand Up@@ -561,7 +614,7 @@ int64_t GetMasternodePayment(int nHeight, int64_t blockValue)
int64_t GetDevOpsPayment(int nHeight, int64_t blockValue)
{
int64_t ret2 = 0;
ret2 = blockValue - (250 * COIN); // 50 XDN per block
ret2 = 50 * COIN; // 50 XDN per block

return ret2;
}
5 changes: 3 additions & 2 deletions src/blockparams.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -31,12 +31,13 @@ enum DiffMode {
DIFF_VRX = 1, // Retarget using Terminal-Velocity-RateX
};

void VRXswngPoSdebug();
void VRXswngPoWdebug();
void VRXswngdebug();
void VRXdebug();
void GNTdebug();
void VRX_BaseEngine(const CBlockIndex* pindexLast, bool fProofOfStake);
void VRX_Simulate_Retarget();
void VRX_ThreadCurve(const CBlockIndex* pindexLast, bool fProofOfStake);
void VRX_Dry_Run(const CBlockIndex* pindexLast);
unsigned int VRX_Retarget(const CBlockIndex* pindexLast, bool fProofOfStake);
unsigned int GetNextTargetRequired(const CBlockIndex* pindexLast, bool fProofOfStake);
int64_t GetProofOfWorkReward(int nHeight, int64_t nFees);
Expand Down
3 changes: 1 addition & 2 deletions src/chainparams.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -102,8 +102,7 @@ class CMainParams : public CChainParams {

nPoolMaxTransactions = 9;
strMNenginePoolDummyAddress = "dUnVN6zz2apaoWkb5krGoBCwwo8ZD3axue";
strDevOpsAddress = "dSCXLHTZJJqTej8ZRszZxbLrS6dDGVJhw7";
strDevOpsScriptPubKey = "76a9148c2fad4e8bdfdc047ad5ad5378084de415e1538988ac";
strDevOpsAddress = "dHy3LZvqX5B2rAAoLiA7Y7rpvkLXKTkD18";
nEndPoWBlock = 0x7fffffff;
nStartPoSBlock = 0;
}
Expand Down
2 changes: 0 additions & 2 deletions src/chainparams.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -73,7 +73,6 @@ class CChainParams
int PoolMaxTransactions() const { return nPoolMaxTransactions; }
std::string MNenginePoolDummyAddress() const { return strMNenginePoolDummyAddress; }
std::string DevOpsAddress() const { return strDevOpsAddress; }
std::string DevOpsPubKey() const { return strDevOpsScriptPubKey; }
protected:
CChainParams() {};

Expand All@@ -93,7 +92,6 @@ class CChainParams
int nPoolMaxTransactions;
std::string strMNenginePoolDummyAddress;
std::string strDevOpsAddress;
std::string strDevOpsScriptPubKey;
};

/**
Expand Down
2 changes: 1 addition & 1 deletion src/clientversion.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -9,7 +9,7 @@
#define CLIENT_VERSION_MAJOR 1
#define CLIENT_VERSION_MINOR 0
#define CLIENT_VERSION_REVISION 1
#define CLIENT_VERSION_BUILD 4
#define CLIENT_VERSION_BUILD 5

// Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand Down
2 changes: 2 additions & 0 deletions src/fork.h
Original file line numberDiff line numberDiff line change
Expand Up@@ -12,6 +12,8 @@
static const int64_t nReservePhaseStart = 1;
/** Masternode/Devops Payment Update 1 **/
static const int64_t nPaymentUpdate_1 = 1558310400;
/** Masternode/Devops Payment Update 2 **/
static const int64_t nPaymentUpdate_2 = 1561402800;
/** Velocity toggle block */
static const int64_t VELOCITY_TOGGLE = 175; // Implementation of the Velocity system into the chain.
/** Velocity retarget toggle block */
Expand Down
3 changes: 3 additions & 0 deletions src/init.cpp
Original file line numberDiff line numberDiff line change
Expand Up@@ -548,6 +548,9 @@ bool AppInit2(boost::thread_group& threadGroup)
//ignore masternodes below protocol version
nMasternodeMinProtocol = GetArg("-masternodeminprotocol", MIN_POOL_PEER_PROTO_VERSION);

//log startup time for advanced Masternode checks delay (required for proper sync)
nMasterNodeChecksDelayBaseTime = GetTime();

if (fDaemon)
fprintf(stdout, "DigitalNote server starting\n");

Expand Down
Loading