Generating the genesis block... /sigh

So, I’ve been pounding my head against my desk for the last 90 minutes, trying to get the 0.1.1 branch to generate the genesis block, but I’m obviously missing something.

When I tail my debug.log file I see this output:

n=27M hash=7f1ea84affa4d7a1b71ba62cb1f30113e7de3e6c6efa0e10d0c9aa5d7327f015
n=28M hash=02ee511cbb596772d6fab0befedfc4d29a933f7881d46365fcc9b1d6d2aebbd8
n=29M hash=af7cc4da29951d3926eea531fa2fd5adfa11d62def9e764b83ae01e5f2ccaf8f
n=30M hash=934c499f9e2af2f95077308de4744a9fa435bfb04c3d3b7344970ec52bf8e5c9
n=31M hash=7ed2e3cc629e80ba7fc0159862ac11fae2e05950fae1261e551d0aef94141917
n=32M hash=756eb46ab02bed52649b582e4162e32ae399d1eae58b36d83ae625826967a07f
n=33M hash=297d292d51b4a46e931f57312e9bbe9ec275b2de8132f895afcc143dad33aa1c
n=34M hash=43cccc35dfb8519560316603614ddb6b0ab02648f6943775df2281322dfbb57f
n=35M hash=7a574b30947b2164ffc8e97ceba60e00a5ae85a8d72c669861c83edde0f8722c
n=36M hash=b61f40ccc603102adc03091a8eecacfe08ec7531ac06e667ae3846028802b181

Is that the nonce and hash that I move into main.cpp?

This is a major blocker, because without having a clearly defined process to reproduce this step, we can’t get the QA efforts moving along in parallel. If one of the devs is available, I’d like to coordinate a time where we can meet up in the project chat room to walk through the steps so I can document them and ask questions. Let me know what works for you.

Can’t’ give you specific help on this one. But generally doing something different for 1 or 2 hours works better than pounding one’s head against a desk :wink: Keep faith, you’re doing good work.

fuzzy@anonymized.invalid

fuzzy@anonymized.invalid

Can’t we decrease the initial difficulty?

I did that on a testing branch. The result is I generate multiple PoW blocks per second so it’s not ideal, but we can certainly find a good compromise.

I have just asked by321 to focus on this issue to the exclusion of his other work until resolved.

I’m going to let them keep running, but right now I have two Peershares daemons running on one AWS m1.small instance.

Node 1:

ubuntu:~/.ppcoin$ ./ppcoind getinfo
{
    "version" : "v0.3.0ppc-51-g38f5dde-beta",
    "protocolversion" : 60003,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "newmint" : 0.00000000,
    "stake" : 0.00000000,
    "blocks" : 0,
    "moneysupply" : 0.00000000,
    "connections" : 9,
    "proxy" : "",
    "ip" : "184.73.141.240",
    "difficulty" : 0.06249911,
    "testnet" : true,
    "keypoololdest" : 1393812941,
    "keypoolsize" : 101,
    "paytxfee" : 0.01000000,
    "errors" : ""
}
ubuntu:~/.ppcoin$ ./ppcoind getmininginfo
{
    "blocks" : 0,
    "currentblocksize" : 1000,
    "currentblocktx" : 0,
    "difficulty" : 0.06249911,
    "errors" : "",
    "generate" : true,
    "genproclimit" : -1,
    "hashespersec" : 330830,
    "networkghps" : 0.00894772,
    "pooledtx" : 0,
    "testnet" : true
}

Node 2:

ubuntu:~/.ppcoin-node2$ ./ppcoind getinfo
{
    "version" : "v0.3.0ppc-51-g38f5dde-beta",
    "protocolversion" : 60003,
    "walletversion" : 60000,
    "balance" : 0.00000000,
    "newmint" : 0.00000000,
    "stake" : 0.00000000,
    "blocks" : 0,
    "moneysupply" : 0.00000000,
    "connections" : 9,
    "proxy" : "",
    "ip" : "184.73.141.240",
    "difficulty" : 0.06249911,
    "testnet" : true,
    "keypoololdest" : 1393812941,
    "keypoolsize" : 101,
    "paytxfee" : 0.01000000,
    "errors" : ""
}
ubuntu:~/.ppcoin-node2$ ./ppcoind getmininginfo
{
    "blocks" : 0,
    "currentblocksize" : 1000,
    "currentblocktx" : 0,
    "difficulty" : 0.06249911,
    "errors" : "",
    "generate" : true,
    "genproclimit" : -1,
    "hashespersec" : 339397,
    "networkghps" : 0.00894772,
    "pooledtx" : 0,
    "testnet" : true
}

What I can’t tell is if they really are talking to one another, but from what I can tell, they are. Shutting down Node 2 will change “connections” from “9” to “8” when I run [font=courier]./ppcoind getinfo[/font] on Node 1.

Settings that I’m using for my two .conf files.

Node 1:

# NODE 1
# 'Clean' configuration file for Peershares development

testnet=1
dnsseed=0
upnp=0

gen=1

# listen on different ports than default testnet
port=19000
rpcport=19001

# always run a server
server=1

# enable SSL for RPC server
#rpcssl=1

rpcuser=node1
rpcpassword=1111

Node 2:

# NODE 2
# 'Clean' configuration file for Peershares development

testnet=1
dnsseed=0
upnp=0
listen=0
connect=127.0.0.1:19000

# listen on different ports than default testnet
port=19010
rpcport=19011

# always run a server
server=1

rpcuser=node2
rpcpassword=2222

Note, I am not seeing a chance in my debug.log output. It hasn’t chanced since last night, and the output still reads:

ubuntu:~/.ppcoin$ tail debug.log
n=27M hash=7f1ea84affa4d7a1b71ba62cb1f30113e7de3e6c6efa0e10d0c9aa5d7327f015
n=28M hash=02ee511cbb596772d6fab0befedfc4d29a933f7881d46365fcc9b1d6d2aebbd8
n=29M hash=af7cc4da29951d3926eea531fa2fd5adfa11d62def9e764b83ae01e5f2ccaf8f
n=30M hash=934c499f9e2af2f95077308de4744a9fa435bfb04c3d3b7344970ec52bf8e5c9
n=31M hash=7ed2e3cc629e80ba7fc0159862ac11fae2e05950fae1261e551d0aef94141917
n=32M hash=756eb46ab02bed52649b582e4162e32ae399d1eae58b36d83ae625826967a07f
n=33M hash=297d292d51b4a46e931f57312e9bbe9ec275b2de8132f895afcc143dad33aa1c
n=34M hash=43cccc35dfb8519560316603614ddb6b0ab02648f6943775df2281322dfbb57f
n=35M hash=7a574b30947b2164ffc8e97ceba60e00a5ae85a8d72c669861c83edde0f8722c
n=36M hash=b61f40ccc603102adc03091a8eecacfe08ec7531ac06e667ae3846028802b181

ok ben no u need to mine the genesis block on one computer before connecting two together and starting the network… they need the same genesis block assertion in the code and you need to tell them to connect to each other.

also if your debug.log file is not increasing on the n=36M then it has crashed

 Genesis Block:
        CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1)
           CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0)
           CTxIn(COutPoint(000000, -1), coinbase 04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73)
           CTxOut(nValue=50.00000000, scriptPubKey=0x5F1DF16B2B704C8A578D0B)
           vMerkleTree: 4a5e1e

is the kind of output we are looking for.

I have just mined a testnet genesis block in trying to explain the process and what I have done in a bitmessage to everyone so I know the output will work. The problem is the merkle root hash though I believe as I set the testnet to have 0 merkle root and I am struggling a litle to generate a merkle root the usual way i know how for this coin… bitmessage coming with more details and references

Fuzzybear

Monday Evening Update:

Fuzzy and I are racing to see who can solve our respective (local) genesis blocks first. We’ve been able to generate new merkle roots, based on a “proof of date” string of text and the current epoch time, so all looks good.

Once the block has been successfully solved, I’ll* provide an update.

* It will be me, because I’m going to beat Fuzzy to it :slight_smile:

i have a genesis block :slight_smile: put is back into the code, but it fails on the assert ‘Block.GetHash() == genesisblockhash’ i put my genesis hash in the main.h file inder genesisBlockHashOfficial and left the preceding 0x

So its not there yet :frowning: Will see if I can work further on this tonight

Fuzzybear

Update: Here is a copy of my code I compiled after i mined the genesis block and commented out that process. I changed the value in the main.h file https://github.com/FuzzyBearBTC/ppcoin/blob/patch-2/src/main.h#L56 from

static const uint256 hashGenesisBlockOfficial(“0x0000000032fe677166d54963b62a4677d8957e87c508eaa4fd7eb1c880cd27e3”);
to
static const uint256 hashGenesisBlockOfficial(“0x00000000d48475840f1fcfb94937aeb9dd3fd8a5bcb541ee8c704f63a92ffec8”);

and my main.cpp relevant code part looks like this:

        // Genesis Block:
//PPCoin Found Genesis Block:
//genesis hash=00000000d48475840f1fcfb94937aeb9dd3fd8a5bcb541ee8c704f63a92ffec8
//merkle root=63a9576ef4dc4663baf6b355f2df6f145d51976304ac04b8ab8905803d2661f5
//CBlock(hash=00000000d48475840f1f, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=63a9576ef4, nTime=1393912216, nBits=1d00ffff, nNonce=667438008, vtx=1, vchBlockSig=)
//  Coinbase(hash=63a9576ef4, nTime=1345083810, ver=1, vin.size=1, vout.size=1, nLockTime=0)
//    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d020f274030342d4d41522d32303134205275737369616e206d61726b65747320706c756e676520617320507574696e207469676874656e73204372696d65612067726970)
//    CTxOut(empty)
//  vMerkleTree: 63a9576ef4 
//PPCoin End Genesis Block
//00000000d48475840f1fcfb94937aeb9dd3fd8a5bcb541ee8c704f63a92ffec8
//0000000000000000000000000000000000000000000000000000000000000000
//63a9576ef4dc4663baf6b355f2df6f145d51976304ac04b8ab8905803d2661f5
//CBlock(hash=00000000d48475840f1f, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=63a9576ef4, nTime=1393912216, nBits=1d00ffff, nNonce=667438008, vtx=1, vchBlockSig=)
//  Coinbase(hash=63a9576ef4, nTime=1345083810, ver=1, vin.size=1, vout.size=1, nLockTime=0)
//    CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d020f274030342d4d41522d32303134205275737369616e206d61726b65747320706c756e676520617320507574696e207469676874656e73204372696d65612067726970)
//    CTxOut(empty)
//  vMerkleTree: 63a9576ef4 




        // Genesis block
        const char* pszTimestamp = "04-MAR-2014 Russian markets plunge as Putin tightens Crimea grip";
        CTransaction txNew;
        txNew.nTime = 1345083810;
        txNew.vin.resize(1);
        txNew.vout.resize(1);
        txNew.vin[0].scriptSig = CScript() << 486604799 << CBigNum(9999) << vector<unsigned char>((const unsigned char*)pszTimestamp, (const unsigned char*)pszTimestamp + strlen(pszTimestamp));
        txNew.vout[0].SetEmpty();
        CBlock block;
        block.vtx.push_back(txNew);
        block.hashPrevBlock = 0;
        block.hashMerkleRoot = block.BuildMerkleTree();
        block.nVersion = 1;
        block.nTime    = 1393891228;
        block.nBits    = bnProofOfWorkLimit.GetCompact();
        block.nNonce   = 667438008;

        if (fTestNet)
        {
            block.nTime    = 1393891228;
            block.nNonce   = 0;
        }
        
//        CBigNum bnTarget;
//        bnTarget.SetCompact(block.nBits);

//        while (block.GetHash() > bnTarget.getuint256())
//        {
//            if (block.nNonce % 1048576 == 0)
//                printf("n=%dM hash=%s\n", block.nNonce / 1048576,
//                       block.GetHash().ToString().c_str());
//           block.nTime = GetAdjustedTime();
//            block.nNonce++;
//        }
     
//        printf("PPCoin Found Genesis Block:\n");
//        printf("genesis hash=%s\n", block.GetHash().ToString().c_str());
//        printf("merkle root=%s\n", block.hashMerkleRoot.ToString().c_str());
//        block.print();
     
//        printf("PPCoin End Genesis Block\n");

        //// debug print
        printf("%s\n", block.GetHash().ToString().c_str());
        printf("%s\n", hashGenesisBlock.ToString().c_str());
        printf("%s\n", block.hashMerkleRoot.ToString().c_str());
        assert(block.hashMerkleRoot == uint256("0x63a9576ef4dc4663baf6b355f2df6f145d51976304ac04b8ab8905803d2661f5"));
        block.print();
//        assert(block.GetHash() == hashGenesisBlock);
//        assert(block.CheckBlock());

update:
By leaving the // assert(block.GetHash() == hashGenesisBlock); and // assert(block.CheckBlock()); commented out I have also seen that in the kernal.cpp file there are references to the 3 checkpoints
https://github.com/Peershares/Peershares/blob/master/src/kernel.cpp#L23 this is a key checkpoint value in the mapStakeModifierCheckpoints

The other 2 can be and should be removed as per this pull https://github.com/Peershares/Peershares/pull/46 but we need to put the correct value for the unsigned int on the genesis block. I am unsure where you would calculate this from or get this from. Anyone?

I was discussing with Ben last night as well the implications of the line

 if (block.nNonce % 1048576 == 0)

as I don’t feel I fully understand where the 1048576 value comes from.

Fuzzybear

[quote=“FuzzyBear, post:11, topic:1735”]… the implications of the line

 if (block.nNonce % 1048576 == 0)

as I don’t feel I fully understand where the 1048576 value comes from.[/quote]

1048576 is just 1 mega, or 1024x1024. It prints out progress every 1M, right ?

That sounds right, as my debug log lines are sequential, 1M…2M…3M…nM.

I have a (seemingly) legit contender for a genesis block, but have run out of time this morning to get the two nodes set up to mine the first few blocks.

If someone has a chance, and would like to play with it, here’s a copy of my [font=courier].peershares[/font] directory. The [font=courier]peershares.conf[/font] file isn’t configured correctly, so you’ll likely need to scrap that, or, alternatively, just grab the [font=courier]ppcoind[/font] file and use it to regenerate the [font=courier].peershares[/font] directory, so you can add your own.

https://github.com/brossi/peershares_genesis_block_test

The seeds that I used to compile this version of the daemon are based on the content found in this file:

yeah the length of time it is taking us to find blocks with cpu mining for 12 hours now

{ "blocks" : 0, "currentblocksize" : 1000, "currentblocktx" : 0, "difficulty" : 1.00000000, "errors" : "", "generate" : true, "genproclimit" : -1, "hashespersec" : 542209, "networkghps" : 0.14316558, "pooledtx" : 0, "testnet" : false }
on my server would suggest that there is something wrong. I have experienced this situation before in scrypt algo coins when the

static CBigNum bnProofOfWorkLimit(~uint256(0) >> 20);

was changed and you could mine genesis blocks successfully but the blockchain would never get past block 0 though. Will be reviewing the code and Sunny’s commits with the team tonight. Anyone on the team that wants to help out I’ll be in cryptocat room from 18:00 GMT.

In Bens repo we have added the seed nodes to the code so this server and Bens comps are hard coded as seed nodes to allow for the connection of nodes to work properly. I’ll send a pull request to the main Peershares repo tonight to remove the Peercoin Seed nodes from the code as this was causing issues in the loading of blockindex.dat

Fuzzybear

Ben, I let it run overnight (two instances connected locally) but didn’t mine any block, did you have any luck ?

Unfortunately, no, it didn’t show up over night for me either.

Back to the drawing board.

Today’s progress:

[ol][li]New test genesis block created[/li]
[li]First 400 blocks mined for the IPO[/li]
[li]Proof-of-stake minting confirmed, blocks have been totally transitioned from PoW[/li]
[li]Speculative market price of $1M per peershare set on the BE-n shadow exchange[/li]
[li]Fuzzybear announces retirement and completes purchase for majority stake of the Isle of Man[/li][/ol]

Awesome work today!

Great milestone.

Hehe love the 5 point :slight_smile: I completely overslept this morning and nearly lost the day job so I could do with early retirement.

Really great work though team, was many long evenings and real group effort, but we have our genesis block, and 500 + blocks mined, had transition from POW to pos . We now have a stable seed node as well outside our test servers so we can always run a client on test servers.

Well done team :slight_smile: just to add I’ve been buying up more peercoins as I do need to retire to solely work on peercoin and peershares :slight_smile:

Fuzzybear

Fuzzybear

Sent from my HTC Desire using Tapatalk 2