I think I fixed the testnet.
My OSC address is 2C9X2eEBLdJx1aTpea6w6iwbP3krNT9zGj . Bounty delivered. Thanks r3wt, glad to help.
The main error is the assert at line 2628 main.cpp:
~/test/OSC-master/src $ ./Ocoind --testnet
Ocoind: main.cpp:2628: bool LoadBlockIndex(bool): Assertion `block.GetHash() == (!fTestNet ? hashGenesisBlock : hashGenesisBlockTestNet)' failed.
Aborted
In a previous post I provided a hard coded diff to help get the testnet working. In this post I'll try to explain how to prep the testnet for a new genesis block. This is a unix command line walk through. It assumes that you have the source zip and already unpacked it.
Firstly, make sure you are working from a fresh testnet dir. OSC is coded for testnet2.
$cd .Ocoin/testnet2
$rm -rf database
$rm blkindex.dat
$rm .lock
$cd
Next go to main.cpp and make the following changes:
~/test/OSC-master/src $ diff --normal ~/OSC-master/src/main.cpp ./main.cpp
20c20
< const bool IsCalculatingGenesisBlockHash = false;
---
> const bool IsCalculatingGenesisBlockHash = true;
49c49
< const int64 nTestNetStartTime = nChainStartTime; // 2013-08-03 18:00:00 GMT
---
> const int64 nTestNetStartTime = GetAdjustedTime(); // 2013-08-03 18:00:00 GMT
2576c2576
< const char* pszTimestamp = "God IS L33T-- 08/02/2013 @ 2:33am";
---
> const char* pszTimestamp = "Testnet reproduction, sat 27th oct 2013";
2592c2592
< block.nTime = 1376591211;
---
> block.nTime = GetAdjustedTime();
2594c2594
< block.nNonce = 1355283799;
---
> block.nNonce = 0;
Compile:
~/test/OSC-master/src $ make -f makefile.unix USE_UPNP=- all
Run testnet for genesis block. Run from source dir because we will have to edit the source and compile again anyways. This build will fail on an assert and dump info for the genesis block into the debug.log file.
~/test/OSC-master/src $ ./Ocoind -testnet -gen
Ocoind: main.cpp:2626: bool LoadBlockIndex(bool): Assertion `block.hashMerkleRoot == uint256("0x184c70772fd0640c08b123b7b59f06f69442c88b29fb167d48e82e73bd1a9a01")' failed.
Aborted
~/test/OSC-master/src $ rm ./Ocoind
Open another terminal window and more/tail the debug.log.
~/test/OSC-master/src $ tail -f ~/.Ocoin/testnet2/debug.log
and you should have some output regarding your genesis block:
Ocoin version v0.1.1.1-g99999-r1 ()
Using OpenSSL version OpenSSL 1.0.1c 10 May 2012
Startup time: 10/27/13 20:01:44
Default data directory /home/woodchuck/.Ocoin
Used data directory /home/woodchuck/.Ocoin/testnet2
dbenv.open LogDir=/home/woodchuck/.Ocoin/testnet2/database ErrorFile=/home/woodchuck/.Ocoin/testnet2/db.log
Bound to [::]:48519
Bound to 0.0.0.0:48519
Loading block index...
nonce 00010000: hash = 3bfef7ab7ccef617b3741e7948e588cc3e3ee9bdebfef290524497d7963e8986
nonce 00020000: hash = 78bc0087fdddfaf90698ee74768035d4f09aae780f17f0791da7587624ecb7de
nonce 00030000: hash = d64e16e976691b90662dffc3f6d34c79591fc30cb85c6fe3c22e4d10068762a7
nonce 00040000: hash = 9750892f2fba00a386c828fb623a307b7c269ee2e9e2e4bf08c07a4df32f2dd0
nonce 00050000: hash = 020fd29a71b39774e56253b79490c575da272872330b076b1d7c73cc51289d5b
nonce 00060000: hash = f7fafa3fe1ca21ecfeca772c5dbe9e734159b69692fc0567997e1c892e0229f2
CBlock(hash=000053ce817c363a8c3885e29328a3df8d297f0c85dcb5aba37185ab68d89448, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=ede221767db6b172ad1a58be9256a1a3520b0ba3b2f0c2ec4495ff2095d23d64, nTime=1382904104, nBits=1f00ffff, nNonce=61558, vtx=1, vchBlockSig=)
Coinbase(hash=ede221767d, nTime=1382904104, ver=1, vin.size=1, vout.size=1, nLockTime=0, strTxComment=text:Ocoin genesis block)
CTxIn(COutPoint(0000000000, 4294967295), coinbase 04ffff001d020f2727546573746e657420726570726f64756374696f6e2c207361742032377468206f63742032303133)
CTxOut(empty)
vMerkleTree: ede221767d
block.GetHash() == 000053ce817c363a8c3885e29328a3df8d297f0c85dcb5aba37185ab68d89448
block.hashMerkleRoot == ede221767db6b172ad1a58be9256a1a3520b0ba3b2f0c2ec4495ff2095d23d64
block.nTime = 1382904104
block.nNonce = 61558
block.nBits = 520159231
Right of the bat, you can go to main.h and add your genesis block hash at line 51:
static const uint256 hashGenesisBlockTestNet("0x000053ce817c363a8c3885e29328a3df8d297f0c85dcb5aba37185ab68d89448");
Then we can make the changes in main.cpp that hard code the block. First change line 20 from true to false:
const bool IsCalculatingGenesisBlockHash = false;
Then set your ntime pulled from the log at line 49 of main.cpp:
const int64 nTestNetStartTime = 1382904104;
and fill the values from the log into lines 2592-2594 of main.cpp:
block.nTime = 1382904104;^M
block.nBits = 520159231;^M
block.nNonce = 61558;^M
Then you can update your merkel root at line 2626 in main.cpp:
assert(block.hashMerkleRoot == uint256("0xede221767db6b172ad1a58be9256a1a3520b0ba3b2f0c2ec4495ff2095d23d64"));^M
Compile, then scrub testnet directory:
~/test/OSC-master/src $ make -f makefile.unix clean
rm -f Ocoind test_Ocoin
rm -f obj/*.o
rm -f obj-test/*.o
rm -f obj/*.P
rm -f obj-test/*.P
rm -f obj/build.h
~/test/OSC-master/src $ make -f makefile.unix USE_UPNP=- all
~/test/OSC-master/src $ cp ./Ocoind ~/
~/test/OSC-master/src $ cd
~/ $ cd .Ocoin/testnet2
~/.Ocoin/testnet2 $ rm blkindex.dat
~/.Ocoin/testnet2 $ rm -rf database
~/.Ocoin/testnet2 $ rm .lock
~/.Ocoin/testnet2 $ cd
Run testnet:
~/ $ ./Ocoind -testnet&
You should have a happy happy current build with a working testnet net. If you tail the debug.log, you can see the peer data and the irc joins. You cannot mine until there are multiple nodes, and they confirm there is no blocks. What I did was compile and run on another computer and did an addnode= in the conf. I didn't mess with any of the irc settings, so the client will join the testnet2 irc channel still, and hopefully connect with other peers. None of the production net code is changed, so you can compile this code for the latest legit update.