Skip to content

Commit

Permalink
Fix Checkpoint test, fix rpcmining bug v9.3 uses CScriptNum, cleanup …
Browse files Browse the repository at this point in the history
…BIP30/16 comments & set epoch to match v8 nodes
  • Loading branch information
GroundRod authored and GroundRod committed Jan 27, 2015
1 parent e7c07a3 commit b338c79
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 46 deletions.
2 changes: 2 additions & 0 deletions src/auxpow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ void RemoveMergedMiningHeader(vector<unsigned char>& vchAux)
throw runtime_error("merged mining aux too short");
vchAux.erase(vchAux.begin(), vchAux.begin() + sizeof(pchMergedMiningHeader));
}

uint256 CAuxPow::GetParentBlockHash()
{
return parentBlockHeader.GetHash();
}

bool CAuxPow::Check(uint256 hashAuxBlock, int nChainID)
{
if (nIndex != 0)
Expand Down
7 changes: 3 additions & 4 deletions src/checkpoints.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,13 @@ namespace Checkpoints
// (no blocks before with a timestamp after, none after with
// timestamp before)
// + Contains no strange transactions
static MapCheckpoints mapCheckpoints =
boost::assign::map_list_of
static MapCheckpoints mapCheckpoints = boost::assign::map_list_of
( 4500, uint256("0x00000000de37be98ca45cf0613fa2a321eba28e237543f9fee9b6a7605d03a94"))
( 198007, uint256("0x00fdfc9130416482887e4d56f89f4568c2f4d7764d14cc66833503f31a6ac73d"))
;

/* Devcoin had not testnet checkblocks, if they even start to exist, they can be added here */
static MapCheckpoints mapCheckpointsTestnet = boost::assign::map_list_of
// Ixcoin has no testnet checkblocks, if they even start to exist, they can be added here
static MapCheckpoints mapCheckpointsTestnet = boost::assign::map_list_of
( 0, uint256("0x0000000e266692d6c16814490ca60acda9398727680325386bbdd98c61457a48"))
;
static const CCheckpointData data = {
Expand Down
43 changes: 15 additions & 28 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2009,39 +2009,26 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
// See BIP30 and http://r6.ca/blog/20120206T005236Z.html for more information.
// This logic is not necessary for memory pool transactions, as AcceptToMemoryPool
// already refuses previously-known transaction ids entirely.
// This rule was originally applied all blocks whose timestamp was after March 15, 2012, 0:00 UTC.
// For Bitcoin, this rule was originally applied all blocks whose timestamp was after March 15, 2012, 0:00 UTC.
// Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the
// two in the chain that violate it. This prevents exploiting the issue against nodes in their
// initial block download.
//
// This rule applies to all IXCoin blocks whose timestamp is after March 15, 2016, 0:00 UTC.
// two in the chain that violate it.
//
// BIP30 for IXCOIN will go into effect on March 15, 2016 0:00 UTC
// date -d "2016-03-16 0:00 UTC" +"%s"
// GR Note: Ixcoin has no such two blocks, that I am aware of. The epoch 1388624831 has been
// arbitrarily picked while developing v8, so in order to remain compatiable with those v8 nodes
// now running on the network, our v9 core will continoue to have the same & remain compatiable.
//
// GR Updated on: 1/26/2015
// This prevents exploiting the issue against nodes in their initial block download.
//
// This rule applies to all IXCoin blocks whose timestamp is after 1388624831.
//
// BIP30 for IXCOIN has gone into effect on 02 Jan 2014 01:07:11 GMT
// Code Updated on: 1/27/2015 by GroundRod
// Generated from: http://www.epochconverter.com/
// Epoch timestamp: 1458000000
// Timestamp in milliseconds: 1458000000000
// Human time (GMT): Tue, 15 Mar 2016 00:00:00 GMT
// Human time (your time zone): Mon 14 Mar 2016 06:00:00 PM MDT
int64_t nBIP30SwitchTime = 1458000000;
// Epoch timestamp: 1388624831
// Human time: Thu, 02 Jan 2014 01:07:11 GMT
int64_t nBIP30SwitchTime = 1388624831;
bool fEnforceBIP30 = (!pindex->phashBlock) || (pindex->nTime > nBIP30SwitchTime);


// Big ToDo:
// The remainder of this code needs now to be fixed, tested and reviewed at a later time,
// on 1/26/2015 we can not debug and test mining operation, without it interfering.
//
// after BIP30 is enabled for some time, we could make the same change??
// namely the one suggested below??
// This rule was originally applied all blocks whose timestamp was after ?, 0:00 UTC.
// Now that the whole chain is irreversibly beyond that time it is applied to all blocks except the
// two in the chain that violate it. This prevents exploiting the issue against nodes in their
// initial block download.
//bool fEnforceBIP30 = (!pindex->phashBlock) || // Enforce on CreateNewBlock invocations which don't have a hash.
// !((pindex->nHeight==91842 && pindex->GetBlockHash() == uint256("0x00000000000a4d0a398161ffc163c503763b1f4360639393e0e4c8e300e0caec")) ||
// (pindex->nHeight==91880 && pindex->GetBlockHash() == uint256("0x00000000000743f190a18c5577a3c2d2a1f610ae9601ac046a38084ccb7cd721")));*/
if (fEnforceBIP30) {
for (unsigned int i = 0; i < block.vtx.size(); i++) {
uint256 hash = block.GetTxHash(i);
Expand All @@ -2051,7 +2038,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
}
}

// BIP16 didn't become active until Apr 1 2012
// As well, BIP16 didn't become active for Ixcoin, until 02 Jan 2014 01:07:11 GMT
int64_t nBIP16SwitchTime = 1388624831;
bool fStrictPayToScriptHash = (pindex->nTime >= nBIP16SwitchTime);

Expand Down
4 changes: 1 addition & 3 deletions src/rpcmining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -867,9 +867,7 @@ Value getauxblock(const Array& params, bool fHelp)
// Need to update only after we know CreateNewBlock succeeded
pindexPrev = pindexPrevNew;
// Push OP_2 just in case we want versioning later
// FIXME: Debugging 9.3 upgrade build problem, commenting out this line fixed it (GR)
// the problem is related to use of CBigNum, they are no longer referenced in script objects
//pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CBigNum(1) << OP_2;
pblock->vtx[0].vin[0].scriptSig = CScript() << pblock->nBits << CScriptNum(1) << OP_2;

pblock->hashMerkleRoot = pblock->BuildMerkleTree();
CAuxPow *blockAuxPow = new CAuxPow();
Expand Down
22 changes: 11 additions & 11 deletions src/test/Checkpoints_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,21 @@ BOOST_AUTO_TEST_SUITE(Checkpoints_tests)

BOOST_AUTO_TEST_CASE(sanity)
{
uint256 p11111 = uint256("0x0000000069e244f73d78e8fd29ba2fd2ed618bd6fa2ee92559f542fdb26e7c1d");
uint256 p134444 = uint256("0x00000000000005b12ffd4cd315cd34ffd4a594f430ac814c91184a0d42d2b0fe");
BOOST_CHECK(Checkpoints::CheckBlock(11111, p11111));
BOOST_CHECK(Checkpoints::CheckBlock(134444, p134444));
uint256 p4500 = uint256("0x00000000de37be98ca45cf0613fa2a321eba28e237543f9fee9b6a7605d03a94");
uint256 p198007 = uint256("0x00fdfc9130416482887e4d56f89f4568c2f4d7764d14cc66833503f31a6ac73d");
BOOST_CHECK(Checkpoints::CheckBlock(4500, p4500));
BOOST_CHECK(Checkpoints::CheckBlock(198007, p198007));



// Wrong hashes at checkpoints should fail:
BOOST_CHECK(!Checkpoints::CheckBlock(11111, p134444));
BOOST_CHECK(!Checkpoints::CheckBlock(134444, p11111));
BOOST_CHECK(!Checkpoints::CheckBlock(4500, p198007));
BOOST_CHECK(!Checkpoints::CheckBlock(198007, p4500));

// ... but any hash not at a checkpoint should succeed:
BOOST_CHECK(Checkpoints::CheckBlock(11111+1, p134444));
BOOST_CHECK(Checkpoints::CheckBlock(134444+1, p11111));
BOOST_CHECK(Checkpoints::CheckBlock(4500+1, p198007));
BOOST_CHECK(Checkpoints::CheckBlock(198007+1, p4500));

BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 134444);
}
BOOST_CHECK(Checkpoints::GetTotalBlocksEstimate() >= 198007);
}

BOOST_AUTO_TEST_SUITE_END()

0 comments on commit b338c79

Please sign in to comment.