Skip to content

Commit

Permalink
Rewards: Adjust Miner/Masternode reward ratio - Add sentinel version …
Browse files Browse the repository at this point in the history
…check - Bump version to v0.12.3.0 (#27)

* Update the version number

* Bump to 70213

* Adjust Rewards

* Update sentinel ping code to require min version

* Update blockHeight for reward change, update client version and copyright
  • Loading branch information
semiformal authored and alejandromgk committed Apr 10, 2018
1 parent 3f06348 commit 6faee5e
Show file tree
Hide file tree
Showing 13 changed files with 55 additions and 30 deletions.
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
AC_PREREQ([2.60])
define(_CLIENT_VERSION_MAJOR, 0)
define(_CLIENT_VERSION_MINOR, 12)
define(_CLIENT_VERSION_REVISION, 2)
define(_CLIENT_VERSION_BUILD, 3)
define(_CLIENT_VERSION_REVISION, 3)
define(_CLIENT_VERSION_BUILD, 0)
define(_CLIENT_VERSION_IS_RELEASE, true)
define(_COPYRIGHT_YEAR, 2017)
define(_COPYRIGHT_YEAR, 2018)
AC_INIT([Paccoin Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[https://github.com/paccoinpay/paccoin/issues],[paccoincore])
AC_CONFIG_SRCDIR([src/validation.cpp])
AC_CONFIG_HEADERS([src/config/paccoin-config.h])
Expand Down
8 changes: 7 additions & 1 deletion src/activemasternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,13 @@ bool CActiveMasternode::SendMasternodePing(CConnman& connman)
bool CActiveMasternode::UpdateSentinelPing(int version)
{
nSentinelVersion = version;
if(version < MIN_SENTINEL_VERSION ){
LogPrintf("CActiveMasternode::UpdateSentinelPing -- Sentinel is out of date please update. Version = %s\n", SafeIntVersionToString(version));
return false;
}

nSentinelPingTime = GetAdjustedTime();
LogPrint("masternode", "CActiveMasternode::UpdateSentinelPing -- Updated Sentinel Version = %s PingTime = %d\n", SafeIntVersionToString(nSentinelVersion), nSentinelPingTime);

return true;
}
Expand Down Expand Up @@ -197,7 +203,7 @@ void CActiveMasternode::ManageStateInitial(CConnman& connman)

void CActiveMasternode::ManageStateRemote()
{
LogPrint("masternode", "CActiveMasternode::ManageStateRemote -- Start status = %s, type = %s, pinger enabled = %d, pubKeyMasternode.GetID() = %s\n",
LogPrint("masternode", "CActiveMasternode::ManageStateRemote -- Start status = %s, type = %s, pinger enabled = %d, pubKeyMasternode.GetID() = %s\n",
GetStatus(), GetTypeString(), fPingerEnabled, pubKeyMasternode.GetID().ToString());

mnodeman.CheckMasternode(pubKeyMasternode, true);
Expand Down
6 changes: 3 additions & 3 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ class CMainParams : public CChainParams {
strNetworkID = "main";
consensus.nSubsidyHalvingInterval = 210240; // Note: actual number of blocks per calendar year with DGW v3 is ~200700 (for example 449750 - 249050)
consensus.nMasternodePaymentsStartBlock = 200; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
consensus.nMasternodePaymentsIncreaseBlock = 158000; // actual historical value
consensus.nMasternodePaymentsIncreasePeriod = 576*30; // 17280 - actual historical value
consensus.nMasternodePaymentsIncreaseBlock = 50000; // 50000 height aproximately April 20th
consensus.nMasternodePaymentsIncreasePeriod = 576*30; // Not used
consensus.nInstantSendKeepLock = 24;
consensus.nBudgetPaymentsStartBlock = 200; // actual historical value
consensus.nBudgetPaymentsCycleBlocks = 16616; // ~(60*24*30)/2.6, actual number of blocks per month is 200700 / 12 = 16725
Expand Down Expand Up @@ -241,7 +241,7 @@ class CTestNetParams : public CChainParams {
strNetworkID = "test";
consensus.nSubsidyHalvingInterval = 210240;
consensus.nMasternodePaymentsStartBlock = 2; // not true, but it's ok as long as it's less then nMasternodePaymentsIncreaseBlock
consensus.nMasternodePaymentsIncreaseBlock = 4030;
consensus.nMasternodePaymentsIncreaseBlock = 6200;
consensus.nMasternodePaymentsIncreasePeriod = 10;
consensus.nInstantSendKeepLock = 6;
consensus.nBudgetPaymentsStartBlock = 2;
Expand Down
6 changes: 3 additions & 3 deletions src/clientversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
//! These need to be macros, as clientversion.cpp's and paccoin*-res.rc's voodoo requires it
#define CLIENT_VERSION_MAJOR 0
#define CLIENT_VERSION_MINOR 12
#define CLIENT_VERSION_REVISION 2
#define CLIENT_VERSION_BUILD 3
#define CLIENT_VERSION_REVISION 3
#define CLIENT_VERSION_BUILD 0

//! Set to true for release, false for prerelease or test build
#define CLIENT_VERSION_IS_RELEASE true
Expand All @@ -26,7 +26,7 @@
* Copyright year (2009-this)
* Todo: update this when changing our copyright comments in the source
*/
#define COPYRIGHT_YEAR 2017
#define COPYRIGHT_YEAR 2018

#endif //HAVE_CONFIG_H

Expand Down
4 changes: 2 additions & 2 deletions src/masternode-payments.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ void CMasternodePayments::FillBlockPayee(CMutableTransaction& txNew, int nBlockH
}

// GET MASTERNODE PAYMENT VARIABLES SETUP
CAmount masternodePayment = GetMasternodePayment(nBlockHeight, blockReward);
CAmount masternodePayment = GetMasternodePayment(nBlockHeight, blockReward, Params().GetConsensus());

// split reward between miner ...
txNew.vout[0].nValue -= masternodePayment;
Expand Down Expand Up @@ -549,7 +549,7 @@ bool CMasternodeBlockPayees::IsTransactionValid(const CTransaction& txNew)
int nMaxSignatures = 0;
std::string strPayeesPossible = "";

CAmount nMasternodePayment = GetMasternodePayment(nBlockHeight, txNew.GetValueOut());
CAmount nMasternodePayment = GetMasternodePayment(nBlockHeight, txNew.GetValueOut(), Params().GetConsensus());

//require at least MNPAYMENTS_SIGNATURES_REQUIRED signatures

Expand Down
2 changes: 1 addition & 1 deletion src/masternode-payments.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ static const int MNPAYMENTS_SIGNATURES_TOTAL = 10;
// V1 - Last protocol version before update
// V2 - Newest protocol version
static const int MIN_MASTERNODE_PAYMENT_PROTO_VERSION_1 = 70206;
static const int MIN_MASTERNODE_PAYMENT_PROTO_VERSION_2 = 70208;
static const int MIN_MASTERNODE_PAYMENT_PROTO_VERSION_2 = 70213;

extern CCriticalSection cs_vecPayees;
extern CCriticalSection cs_mapMasternodeBlocks;
Expand Down
2 changes: 1 addition & 1 deletion src/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ void CMasternode::UpdateLastPaid(const CBlockIndex *pindex, int nMaxBlocksToScan
if(!ReadBlockFromDisk(block, BlockReading, Params().GetConsensus())) // shouldn't really happen
continue;

CAmount nMasternodePayment = GetMasternodePayment(BlockReading->nHeight, block.vtx[0].GetValueOut());
CAmount nMasternodePayment = GetMasternodePayment(BlockReading->nHeight, block.vtx[0].GetValueOut(), Params().GetConsensus());

BOOST_FOREACH(CTxOut txout, block.vtx[0].vout)
if(mnpayee == txout.scriptPubKey && nMasternodePayment == txout.nValue) {
Expand Down
4 changes: 4 additions & 0 deletions src/masternode.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ static const int MASTERNODE_POSE_BAN_MAX_SCORE = 5;
// sentinel version before sentinel ping implementation
#define DEFAULT_SENTINEL_VERSION 0x010001

// sentinel with voting fix to enable proposals
#define MIN_SENTINEL_VERSION 0x010200


class CMasternodePing
{
public:
Expand Down
10 changes: 10 additions & 0 deletions src/rpc/governance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,16 @@ UniValue gobject(const UniValue& params, bool fHelp)
return returnObj;
}

if(mn.IsWatchdogExpired()) {
nFailed++;
statusObj.push_back(Pair("result", "failed"));
statusObj.push_back(Pair("errorMessage", "WATCHDOG_EXPIRED nodes aren't allowed to vote."));
resultsObj.push_back(Pair("paccoin.conf", statusObj));
returnObj.push_back(Pair("overall", strprintf("Voted successfully %d time(s) and failed %d time(s).", nSuccessful, nFailed)));
returnObj.push_back(Pair("detail", resultsObj));
return returnObj;
}

CGovernanceVote vote(mn.vin.prevout, hash, eVoteSignal, eVoteOutcome);
if(!vote.Sign(activeMasternode.keyMasternode, activeMasternode.pubKeyMasternode)) {
nFailed++;
Expand Down
3 changes: 1 addition & 2 deletions src/rpc/masternode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -846,6 +846,5 @@ UniValue sentinelping(const UniValue& params, bool fHelp)
);
}

activeMasternode.UpdateSentinelPing(StringVersionToInt(params[0].get_str()));
return true;
return activeMasternode.UpdateSentinelPing(StringVersionToInt(params[0].get_str()));
}
22 changes: 14 additions & 8 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,7 +1239,7 @@ CAmount GetBlockSubsidy(int nPrevBits, int nPrevHeight, const Consensus::Params&
} else {
dDiff = ConvertBitsToDouble(nPrevBits);
}

if (nPrevHeight < 100)
{
nSubsidyBase = 35500000;
Expand All @@ -1260,17 +1260,23 @@ CAmount GetBlockSubsidy(int nPrevBits, int nPrevHeight, const Consensus::Params&
return fSuperblockPartOnly ? nSuperblockPart : nSubsidy - nSuperblockPart;
}

CAmount GetMasternodePayment(int nHeight, CAmount blockValue)
CAmount GetMasternodePayment(int nHeight, CAmount blockValue, const Consensus::Params& consensusParams)
{
double dMasternodePart = 9.0/16.0;
CAmount ret = blockValue * dMasternodePart; // 45% of the total block reward.
return ret;
double dMasternodePart;

if(nHeight < consensusParams.nMasternodePaymentsIncreaseBlock){
dMasternodePart = 9.0/16.0; // 56.25% of the block reward.
} else {
dMasternodePart = 15.0/16.0; // 93.75% of the block reward.
}

return (blockValue * dMasternodePart);
}

double GetSubsidyMultiplier(int nPrevHeight, int nSubsidyAdjustmentInterval)
{
double dMultiplier = 0.0;

if (nPrevHeight < 100) {
dMultiplier = 1.0;
} else if (nPrevHeight <= nSubsidyAdjustmentInterval * 1) {
Expand All @@ -1292,7 +1298,7 @@ double GetSubsidyMultiplier(int nPrevHeight, int nSubsidyAdjustmentInterval)
} else {
dMultiplier = 0.0;
}

return dMultiplier;
}

Expand Down Expand Up @@ -3959,7 +3965,7 @@ bool LoadBlockIndex()
return true;
}

bool InitBlockIndex(const CChainParams& chainparams)
bool InitBlockIndex(const CChainParams& chainparams)
{
LOCK(cs_main);

Expand Down
10 changes: 5 additions & 5 deletions src/validation.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ static const unsigned int DEFAULT_CHECKLEVEL = 3;
// Setting the target to > than 945MB will make it likely we can respect the target.
static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 945 * 1024 * 1024;

/**
/**
* Process an incoming block. This only returns after the best known valid
* block is made active. Note that it does not, however, guarantee that the
* specific block passed to it has been checked for validity!
Expand All @@ -209,7 +209,7 @@ static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES = 945 * 1024 * 1024;
*
* Note that we guarantee that either the proof-of-work is valid on pblock, or
* (and possibly also) BlockChecked will have been called.
*
*
* @param[in] pblock The block we want to process.
* @param[in] fForceProcessing Process this block even if unrequested; used for non-network block sources and whitelisted peers.
* @param[out] dbp The already known disk position of pblock, or NULL if not yet stored.
Expand Down Expand Up @@ -263,7 +263,7 @@ bool ActivateBestChain(CValidationState& state, const CChainParams& chainparams,

double ConvertBitsToDouble(unsigned int nBits);
CAmount GetBlockSubsidy(int nBits, int nHeight, const Consensus::Params& consensusParams, bool fSuperblockPartOnly = false);
CAmount GetMasternodePayment(int nHeight, CAmount blockValue);
CAmount GetMasternodePayment(int nHeight, CAmount blockValue, const Consensus::Params& consensusParams);
double GetSubsidyMultiplier(int nPrevHeight, int nSubsidyAdjustmentInterval);

/**
Expand Down Expand Up @@ -318,7 +318,7 @@ unsigned int GetLegacySigOpCount(const CTransaction& tx);

/**
* Count ECDSA signature operations in pay-to-script-hash inputs.
*
*
* @param[in] mapInputs Map of previous transactions that have outputs we're spending
* @return maximum number of sigops required to validate this transaction's inputs
* @see CTransaction::FetchInputs
Expand Down Expand Up @@ -381,7 +381,7 @@ bool CheckSequenceLocks(const CTransaction &tx, int flags, LockPoints* lp = NULL

/**
* Closure representing one script verification
* Note that this stores references to the spending transaction
* Note that this stores references to the spending transaction
*/
class CScriptCheck
{
Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* network protocol versioning
*/

static const int PROTOCOL_VERSION = 70212;
static const int PROTOCOL_VERSION = 70213;

//! initial proto version, to be increased after version/verack negotiation
static const int INIT_PROTO_VERSION = 209;
Expand Down

0 comments on commit 6faee5e

Please sign in to comment.