Skip to content

Commit 2279ef2

Browse files
author
ChainMaster
committed
v2-rev1
1 parent 4e4fed0 commit 2279ef2

7 files changed

Lines changed: 92 additions & 8 deletions

File tree

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ dnl require autoconf 2.60 (AS_ECHO/AS_ECHO_N)
22
AC_PREREQ([2.60])
33
define(_CLIENT_VERSION_MAJOR, 2)
44
define(_CLIENT_VERSION_MINOR, 0)
5-
define(_CLIENT_VERSION_REVISION, 0)
5+
define(_CLIENT_VERSION_REVISION, 1)
66
define(_CLIENT_VERSION_BUILD, 0)
77
define(_CLIENT_VERSION_IS_RELEASE, true)
8-
define(_COPYRIGHT_YEAR, 2018)
8+
define(_COPYRIGHT_YEAR, 2019)
99
AC_INIT([QuantisNET Core],[_CLIENT_VERSION_MAJOR._CLIENT_VERSION_MINOR._CLIENT_VERSION_REVISION],[www.quantisnet.org],[quantisnet])
1010
AC_CONFIG_SRCDIR([src/main.cpp])
1111
AC_CONFIG_HEADERS([src/config/quantisnet-config.h])

src/clientversion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static std::string FormatVersion(int nVersion)
8888

8989
std::string FormatFullVersion()
9090
{
91-
return "v2.0-main";
91+
return "v2.0.1-main";
9292
}
9393

9494
/**

src/clientversion.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//! These need to be macros, as clientversion.cpp's and quantisnet*-res.rc's voodoo requires it
1818
#define CLIENT_VERSION_MAJOR 2
1919
#define CLIENT_VERSION_MINOR 0
20-
#define CLIENT_VERSION_REVISION 0
20+
#define CLIENT_VERSION_REVISION 1
2121
#define CLIENT_VERSION_BUILD 0
2222

2323
//! Set to true for release, false for prerelease or test build
@@ -27,7 +27,7 @@
2727
* Copyright year (2009-this)
2828
* Todo: update this when changing our copyright comments in the source
2929
*/
30-
#define COPYRIGHT_YEAR 2018
30+
#define COPYRIGHT_YEAR 2019
3131

3232
#endif //HAVE_CONFIG_H
3333

src/main.cpp

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ CCriticalSection cs_main;
6363

6464
BlockMap mapBlockIndex;
6565
map<uint256, uint256> mapProofOfStake;
66+
map<COutPoint, int> mapStakeSpent;
6667
set<pair<COutPoint, unsigned int> > setStakeSeen;
6768
map<unsigned int, unsigned int> mapHashedBlocks;
6869
CChain chainActive;
@@ -2552,6 +2553,11 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
25522553
if (coins->vout.size() < out.n + 1)
25532554
coins->vout.resize(out.n + 1);
25542555
coins->vout[out.n] = undo.txout;
2556+
2557+
// erase the spent input
2558+
if(IsSporkActive(SPORK_17_FAKE_STAKE_FIX) && block.GetBlockTime() >= GetSporkValue(SPORK_17_FAKE_STAKE_FIX))
2559+
mapStakeSpent.erase(out);
2560+
25552561
}
25562562
}
25572563
}
@@ -3026,6 +3032,28 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
30263032
if (!pblocktree->WriteTxIndex(vPos))
30273033
return state.Abort("Failed to write transaction index");
30283034

3035+
if(IsSporkActive(SPORK_17_FAKE_STAKE_FIX) && block.GetBlockTime() >= GetSporkValue(SPORK_17_FAKE_STAKE_FIX)){
3036+
// add new entries
3037+
for (const CTransaction tx:block.vtx) {
3038+
if (tx.IsCoinBase())
3039+
continue;
3040+
for (const CTxIn in: tx.vin) {
3041+
LogPrint("map", "mapStakeSpent: Insert %s | %u\n", in.prevout.ToString(), pindex->nHeight);
3042+
mapStakeSpent.insert(std::make_pair(in.prevout, pindex->nHeight));
3043+
}
3044+
}
3045+
3046+
// delete old entries
3047+
for (auto it = mapStakeSpent.begin(); it != mapStakeSpent.end();) {
3048+
if (it->second < pindex->nHeight - Params().MaxReorganizationDepth()) {
3049+
LogPrint("map", "mapStakeSpent: Erase %s | %u\n", it->first.ToString(), it->second);
3050+
it = mapStakeSpent.erase(it);
3051+
} else {
3052+
it++;
3053+
}
3054+
}
3055+
}
3056+
30293057
// add this block to the view's block chain
30303058
view.SetBestBlock(pindex->GetBlockHash());
30313059

@@ -4192,6 +4220,57 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CBlockIndex** ppindex,
41924220

41934221
int nHeight = pindex->nHeight;
41944222

4223+
if(IsSporkActive(SPORK_17_FAKE_STAKE_FIX) && block.GetBlockTime() >= GetSporkValue(SPORK_17_FAKE_STAKE_FIX)) {
4224+
4225+
if (block.IsProofOfStake()) {
4226+
LOCK(cs_main);
4227+
4228+
CCoinsViewCache coins(pcoinsTip);
4229+
4230+
if (!coins.HaveInputs(block.vtx[1])) {
4231+
// the inputs are spent at the chain tip so we should look at the recently spent outputs
4232+
4233+
for (CTxIn in : block.vtx[1].vin) {
4234+
auto it = mapStakeSpent.find(in.prevout);
4235+
if (it == mapStakeSpent.end()) {
4236+
return false;
4237+
}
4238+
if (it->second <= pindexPrev->nHeight) {
4239+
return false;
4240+
}
4241+
}
4242+
}
4243+
4244+
// if this is on a fork
4245+
if (!chainActive.Contains(pindexPrev) && pindexPrev != NULL) {
4246+
// start at the block we're adding on to
4247+
CBlockIndex *last = pindexPrev;
4248+
4249+
//while that block is not on the main chain
4250+
while (!chainActive.Contains(last) && pindexPrev != NULL) {
4251+
CBlock bl;
4252+
ReadBlockFromDisk(bl, last);
4253+
// loop through every spent input from said block
4254+
for (CTransaction t: bl.vtx) {
4255+
for (CTxIn in: t.vin) {
4256+
// loop through every spent input in the staking transaction of the new block
4257+
for (CTxIn stakeIn: block.vtx[1].vin) {
4258+
// if they spend the same input
4259+
if (stakeIn.prevout == in.prevout) {
4260+
//reject the block
4261+
return false;
4262+
}
4263+
}
4264+
}
4265+
}
4266+
4267+
// go to the parent block
4268+
last = pindexPrev->pprev;
4269+
}
4270+
}
4271+
}
4272+
}
4273+
41954274
// Write block to history file
41964275
try {
41974276
unsigned int nBlockSize = ::GetSerializeSize(block, SER_DISK, CLIENT_VERSION);

src/spork.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ int64_t GetSporkValue(int nSporkID)
130130
if (nSporkID == SPORK_14_NEW_PROTOCOL_ENFORCEMENT) r = SPORK_14_NEW_PROTOCOL_ENFORCEMENT_DEFAULT;
131131
if (nSporkID == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) r = SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2_DEFAULT;
132132
if (nSporkID == SPORK_16_ZEROCOIN_MAINTENANCE_MODE) r = SPORK_16_ZEROCOIN_MAINTENANCE_MODE_DEFAULT;
133+
if (nSporkID == SPORK_17_FAKE_STAKE_FIX) r = SPORK_17_FAKE_STAKE_FIX_DEFAULT;
133134

134135
if (r == -1) LogPrintf("GetSpork::Unknown Spork %d\n", nSporkID);
135136
}
@@ -271,6 +272,7 @@ int CSporkManager::GetSporkIDByName(std::string strName)
271272
if (strName == "SPORK_14_NEW_PROTOCOL_ENFORCEMENT") return SPORK_14_NEW_PROTOCOL_ENFORCEMENT;
272273
if (strName == "SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2") return SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2;
273274
if (strName == "SPORK_16_ZEROCOIN_MAINTENANCE_MODE") return SPORK_16_ZEROCOIN_MAINTENANCE_MODE;
275+
if (strName == "SPORK_17_FAKE_STAKE_FIX") return SPORK_17_FAKE_STAKE_FIX;
274276

275277
return -1;
276278
}
@@ -290,6 +292,7 @@ std::string CSporkManager::GetSporkNameByID(int id)
290292
if (id == SPORK_14_NEW_PROTOCOL_ENFORCEMENT) return "SPORK_14_NEW_PROTOCOL_ENFORCEMENT";
291293
if (id == SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2) return "SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2";
292294
if (id == SPORK_16_ZEROCOIN_MAINTENANCE_MODE) return "SPORK_16_ZEROCOIN_MAINTENANCE_MODE";
295+
if (id == SPORK_17_FAKE_STAKE_FIX) return "SPORK_17_FAKE_STAKE_FIX";
293296

294297
return "Unknown";
295298
}

src/spork.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ using namespace boost;
2727
Sporks 11,12, and 16 to be removed with 1st zerocoin release
2828
*/
2929
#define SPORK_START 10001
30-
#define SPORK_END 10015
30+
#define SPORK_END 10016
3131

3232
#define SPORK_2_SWIFTTX 10001
3333
#define SPORK_3_SWIFTTX_BLOCK_FILTERING 10002
@@ -42,6 +42,7 @@ using namespace boost;
4242
#define SPORK_14_NEW_PROTOCOL_ENFORCEMENT 10013
4343
#define SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2 10014
4444
#define SPORK_16_ZEROCOIN_MAINTENANCE_MODE 10015
45+
#define SPORK_17_FAKE_STAKE_FIX 10016
4546

4647
#define SPORK_2_SWIFTTX_DEFAULT 978307200 //2001-1-1
4748
#define SPORK_3_SWIFTTX_BLOCK_FILTERING_DEFAULT 1424217600 //2015-2-18
@@ -56,6 +57,7 @@ using namespace boost;
5657
#define SPORK_14_NEW_PROTOCOL_ENFORCEMENT_DEFAULT 4070908800 //OFF
5758
#define SPORK_15_NEW_PROTOCOL_ENFORCEMENT_2_DEFAULT 4070908800 //OFF
5859
#define SPORK_16_ZEROCOIN_MAINTENANCE_MODE_DEFAULT 1 //ON
60+
#define SPORK_17_FAKE_STAKE_FIX_DEFAULT 4070908800 //OFF
5961

6062
class CSporkMessage;
6163
class CSporkManager;

src/version.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* network protocol versioning
1313
*/
1414

15-
static const int PROTOCOL_VERSION = 72221;
15+
static const int PROTOCOL_VERSION = 72222;
1616

1717
//! initial proto version, to be increased after version/verack negotiation
1818
static const int INIT_PROTO_VERSION = 209;
@@ -22,7 +22,7 @@ static const int GETHEADERS_VERSION = 70000;
2222

2323
//! disconnect from peers older than this proto version
2424
static const int MIN_PEER_PROTO_VERSION_BEFORE_ENFORCEMENT = 72221;
25-
static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 72221;
25+
static const int MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT = 72222;
2626

2727
//! nTime field added to CAddress, starting with this version;
2828
//! if possible, avoid requesting addresses nodes older than this

0 commit comments

Comments
 (0)