From 6c72cc4e2fca63cdfb9763f4cdc07fcae1f1b01c Mon Sep 17 00:00:00 2001 From: multipos Date: Sat, 30 Sep 2017 15:16:13 -0600 Subject: [PATCH] fixing pow-pos gap --- contrib/macdeploy/Info.plist | 6 +++--- posn.pro | 2 +- src/clientversion.h | 4 ++-- src/globalparams.cpp | 21 +++++++++++++++++---- src/globalparams.h | 4 ++-- src/init.cpp | 5 ++++- src/main.cpp | 7 ++++--- src/miner.cpp | 3 +-- src/rpcblockchain.cpp | 2 +- src/rpcmining.cpp | 8 ++++---- src/version.h | 3 ++- 11 files changed, 41 insertions(+), 24 deletions(-) diff --git a/contrib/macdeploy/Info.plist b/contrib/macdeploy/Info.plist index 401470d..b0a55a0 100644 --- a/contrib/macdeploy/Info.plist +++ b/contrib/macdeploy/Info.plist @@ -9,16 +9,16 @@ CFBundlePackageType APPL CFBundleGetInfoString - PoS-N 1.0.0.2 + PoS-N 1.1.0.1 CFBundleExecutable PoSN-Qt CFBundleIdentifier us.posncoin.posncoin-qt CFBundleShortVersionString - 1.0.0.2 + 1.1.0.1 CFBundleSignature P0SN CFBundleVersion - 1.0.0.2 + 1.1.0.1 diff --git a/posn.pro b/posn.pro index 5710fc9..2bf8c41 100644 --- a/posn.pro +++ b/posn.pro @@ -18,7 +18,7 @@ win32 { TEMPLATE = app TARGET = "PoSN-Qt" -VERSION = 1.0.0.2 +VERSION = 1.1.0.1 INCLUDEPATH += src src/json src/qt src/tor INCLUDEPATH += src/tor/adapter src/tor/common src/tor/ext INCLUDEPATH += src/tor/ext/curve25519_donna src/tor/ext/ed25519/donna diff --git a/src/clientversion.h b/src/clientversion.h index 69cf477..d254867 100644 --- a/src/clientversion.h +++ b/src/clientversion.h @@ -7,9 +7,9 @@ // These need to be macros, as version.cpp's and bitcoin-qt.rc's voodoo requires it #define CLIENT_VERSION_MAJOR 1 -#define CLIENT_VERSION_MINOR 0 +#define CLIENT_VERSION_MINOR 1 #define CLIENT_VERSION_REVISION 0 -#define CLIENT_VERSION_BUILD 2 +#define CLIENT_VERSION_BUILD 1 // Converts the parameter X to a string after macro replacement on X has been performed. // Don't merge these into one macro! diff --git a/src/globalparams.cpp b/src/globalparams.cpp index 9198584..1ab7940 100644 --- a/src/globalparams.cpp +++ b/src/globalparams.cpp @@ -8,6 +8,9 @@ /// ////////////////////////////////////////////////////////////////////// +// Monday, October 2, 2017 4:00:00 AM GMT +static const int64_t POS_START_TIME = 1506916800; + ////////////////////////////////////////////////////////////////////// /// @@ -60,8 +63,10 @@ static const int LAST_FAIR_LAUNCH_BLOCK_TESTNET = 30; // 6 min #if PROOF_MODEL == PURE_POS // must have a last PoW block if it is to be pure PoS // optional overlap between PoW and PoS -int LAST_POW_BLOCK = 101100; // 300 + 14 * 5 * 24 * 60 = 14 day -int FIRST_POS_BLOCK = 101101; // LAST_POW_BLOCK + 1 +int LAST_POW_BLOCK_ORIG = 101100; // 300 + 14 * 5 * 24 * 60 = 14 day +int FIRST_POS_BLOCK_ORIG = 101101; // LAST_POW_BLOCK_ORIG + 1 +int LAST_POW_BLOCK = 94478; // ALL MINING DEPLETED +int FIRST_POS_BLOCK = 94479; // LAST_POW_BLOCK + 1 static const int LAST_POW_BLOCK_TESTNET = 101100; static const int FIRST_POS_BLOCK_TESTNET = 81; #elif PROOF_MODEL == MIXED_POW_POS @@ -696,13 +701,21 @@ int64_t GetMaxPoWSubsidy(int nColor, const int64_t nReward) return nReward; } -int GetLastPoWBlock() +int GetLastPoWBlock(int64_t nTime) { + if (nTime < POS_START_TIME) + { + return fTestNet ? LAST_POW_BLOCK_TESTNET : LAST_POW_BLOCK_ORIG; + } return fTestNet ? LAST_POW_BLOCK_TESTNET : LAST_POW_BLOCK; } -int GetFirstPoSBlock() +int GetFirstPoSBlock(int64_t nTime) { + if (nTime < POS_START_TIME) + { + return fTestNet ? FIRST_POS_BLOCK_TESTNET : FIRST_POS_BLOCK_ORIG; + } return fTestNet ? FIRST_POS_BLOCK_TESTNET : FIRST_POS_BLOCK; } diff --git a/src/globalparams.h b/src/globalparams.h index 909d7b4..c521a7a 100644 --- a/src/globalparams.h +++ b/src/globalparams.h @@ -194,8 +194,8 @@ void FillNets(const std::map &mapDebit, int64_t GetTargetSpacing(int nHeight, bool fProofOfStake); int GetLastFairLaunchBlock(); #if PROOF_MODEL == PURE_POS -int GetLastPoWBlock(); -int GetFirstPoSBlock(); +int GetLastPoWBlock(int64_t nTime); +int GetFirstPoSBlock(int64_t nTime); #endif int64_t GetMaxPoWMint(int nColor); diff --git a/src/init.cpp b/src/init.cpp index 6b13c73..df5867e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -393,7 +393,10 @@ bool AppInit2() #endif // ensure that there is not a gap where no blocks can be signed - assert ((GetFirstPoSBlock() - 1) <= GetLastPoWBlock()); + int64_t inittime = GetAdjustedTime(); + int nLastPoWBlock = GetLastPoWBlock(inittime); + int nFirstPoSBlock = GetFirstPoSBlock(inittime); + assert ((nFirstPoSBlock - 1) <= nLastPoWBlock); // basic multicurrency checks and setup { diff --git a/src/main.cpp b/src/main.cpp index d4a25f2..cf555be 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1433,7 +1433,7 @@ struct AMOUNT GetPoWSubsidy(const CBlockIndex *pindexPrev, int nColor) static const int64_t STANDARD_REWARD = 9375 * BASE_COIN; // 9375 static const int nLastFairLaunchBlock = GetLastFairLaunchBlock(); - static const int nLastPoWBlock = GetLastPoWBlock(); + int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime()); struct AMOUNT stSubsidy; stSubsidy.nValue = 0; @@ -3335,8 +3335,9 @@ bool CBlock::CheckBlock(bool fCheckPOW, bool fCheckMerkleRoot, bool fCheckSig) c bool CBlock::AcceptBlock() { - static const int nLastPoWBlock = GetLastPoWBlock(); - static const int nFirstPoSBlock = GetFirstPoSBlock(); + int accepttime = GetAdjustedTime(); + int nLastPoWBlock = GetLastPoWBlock(accepttime); + int nFirstPoSBlock = GetFirstPoSBlock(accepttime); AssertLockHeld(cs_main); // Check for duplicate diff --git a/src/miner.cpp b/src/miner.cpp index 3a4a6cc..1a8ae8c 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -811,8 +811,7 @@ void StakeMiner(CWallet *pwallet) RenameThread("posncoin-miner"); #if PROOF_MODEL == PURE_POS - // - static const int nFirstPoSBlock = GetFirstPoSBlock(); + int nFirstPoSBlock = GetFirstPoSBlock(GetAdjustedTime()); int nTargetSpacing = GetTargetSpacing(pindexBest->nHeight +1, true); unsigned int nMilliWaitForPoS = nTargetSpacing * 1000 / 2; #endif diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index e02d15d..c59fd14 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -47,7 +47,7 @@ double GetDifficulty(const CBlockIndex* blockindex) double GetPoWMHashPS() { #if PROOF_MODEL == PURE_POS - static const int nLastPoWBlock = GetLastPoWBlock(); + int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime()); if (pindexBest->nHeight >= nLastPoWBlock) return 0; #endif diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index abb941b..1757170 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -62,7 +62,7 @@ Value getsubsidy(const Array& params, bool fHelp) int nSubsidyColor = PSN_COLOR_P02; #if PROOF_MODEL == PURE_POS - static const int nLastPoWBlock = GetLastPoWBlock(); + int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime()); #endif if (params.size() == 0) { @@ -263,7 +263,7 @@ Value getworkex(const Array& params, bool fHelp) throw JSONRPCError(-10, "posncoin is downloading blocks..."); #if PROOF_MODEL == PURE_POS - static const int nLastPoWBlock = GetLastPoWBlock(); + int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime()); if (pindexBest->nHeight >= nLastPoWBlock) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); #endif @@ -400,7 +400,7 @@ Value getwork(const Array& params, bool fHelp) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "posncoin is downloading blocks..."); #if PROOF_MODEL == PURE_POS - static const int nLastPoWBlock = GetLastPoWBlock(); + int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime()); if (pindexBest->nHeight >= nLastPoWBlock) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); #endif @@ -549,7 +549,7 @@ Value getblocktemplate(const Array& params, bool fHelp) throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "posncoin is downloading blocks..."); #if PROOF_MODEL == PURE_POS - static const int nLastPoWBlock = GetLastPoWBlock(); + int nLastPoWBlock = GetLastPoWBlock(GetAdjustedTime()); if (pindexBest->nHeight >= nLastPoWBlock) throw JSONRPCError(RPC_MISC_ERROR, "No more PoW blocks"); #endif diff --git a/src/version.h b/src/version.h index 69228ac..5302a3a 100644 --- a/src/version.h +++ b/src/version.h @@ -32,7 +32,8 @@ static const int DATABASE_VERSION = 70508; // 61017: original release version (v1.0.0.1) // fix staking loop (v1.0.0.2) -static const int PROTOCOL_VERSION = 61017; +// 61018: fix pow-pos gap (v1.1.0.1) +static const int PROTOCOL_VERSION = 61018; // earlier versions not supported as of Feb 2012, and are disconnected static const int MIN_PROTO_VERSION = 209;