Genesid block error when i start compiled client

Hi,
i have cloned and compiled this Peercoin client: GitHub - peercoin/peercoin: Reference implementation of the Peercoin protocol. with Microsoft Visual Studio 2013 C++ compiler
But when i run binary, it is failed at this line: https://github.com/ppcoin/ppcoin/blob/master/src/util.h#L604

This is call stack:

Peercoin.exe!Hash160(const std::vector<unsigned char,std::allocator > & vch) Line 602 Peercoin.exe!CBlock::GetStakeEntropyBit() Line 2216 Peercoin.exe!CBlock::AddToBlockIndex(unsigned int nFile, unsigned int nBlockPos) Line 1834 Peercoin.exe!LoadBlockIndex(bool fAllowNew) Line 2365 Peercoin.exe!AppInit2(int argc, char * * argv) Line 375 Peercoin.exe!AppInit(int argc, char * * argv) Line 128 Peercoin.exe!main(int argc, char * * argv) Line 114

I have determined that an error occurs due to the vector “vchBlockSig” (https://github.com/ppcoin/ppcoin/blob/master/src/main.h#L893) have size=0 for the Genesis block.

I tried modify code https://github.com/ppcoin/ppcoin/blob/master/src/util.h#L601 with this one

inline uint160 Hash160(const std::vector<unsigned char>& vch) { uint256 hash1 = 0; if (vch.size()) SHA256(&vch[0], vch.size(), (unsigned char*)&hash1); uint160 hash2; RIPEMD160((unsigned char*)&hash1, sizeof(hash1), (unsigned char*)&hash2); return hash2; }

But in this case error occurs at line https://github.com/ppcoin/ppcoin/blob/master/src/main.cpp#L1852 (checksum is failed).

Can you help me wit this code?

Please merge in this pull request: https://github.com/ppcoin/ppcoin/pull/112/
Which is the same as cloning this branch https://github.com/hrobeers/Peershares/tree/ppcoin-master-testfix (make sure to checkout the “ppcoin-master-testfix” branch once cloned)

An then compile and run the unit tests.
That could give a first indication.

Can you post you debug.log file too? (please clean it first)

Hi,
when i run unit-tests, debug.log does not contain any useful information.

debug.log:

Disconnected 1.192.176.160:9901 for misbehavior (score=100) Disconnected 2.192.176.160:9901 for misbehavior (score=100) Disconnected 1.192.176.160:9901 for misbehavior (score=111) Disconnected 1.192.176.160:9901 for misbehavior (score=100) stored orphan tx a4e643a476 (mapsz 1) stored orphan tx f699d23250 (mapsz 2) stored orphan tx e07377d511 (mapsz 3) stored orphan tx 068b5a9e05 (mapsz 4) stored orphan tx 7bea72bfbb (mapsz 5) stored orphan tx 9301d4c1d1 (mapsz 6) stored orphan tx af707f84c3 (mapsz 7) stored orphan tx 42a4128028 (mapsz 8) stored orphan tx 82d6bd1916 (mapsz 9) stored orphan tx 4fe64863de (mapsz 10) stored orphan tx a1e2a8cbdd (mapsz 11) stored orphan tx da36006431 (mapsz 12) stored orphan tx 6fb0be6d85 (mapsz 13) stored orphan tx 78232ebc72 (mapsz 14) stored orphan tx ed45dc5154 (mapsz 15)

console:

When i run ppcoind itself, debug.log looks like this:

PPCoin version v0.5.3.0-gf01ccea-beta ($Format:%cD) Default data directory C:\Users\Kostja\AppData\Roaming\PPCoin Loading addresses... dbenv.open LogDir=C:\Users\Kostja\AppData\Roaming\PPCoin\database ErrorFile=C:\Users\Kostja\AppData\Roaming\PPCoin\db.log Loaded 0 addresses addresses 469ms Loading block index... PPCoin Network: genesis=0x0000000032fe677166d5 nBitsLimit=0x1d00ffff nBitsInitial=0x1c00ffff nStakeMinAge=2592000 nCoinbaseMaturity=500 nModifierInterval=21600 0000000032fe677166d54963b62a4677d8957e87c508eaa4fd7eb1c880cd27e3 0000000032fe677166d54963b62a4677d8957e87c508eaa4fd7eb1c880cd27e3 3c2d8f85fab4d17aac558cc648a1a58acff0de6deb890c29985690052c5993c2 CBlock(hash=0000000032fe677166d5, ver=1, hashPrevBlock=00000000000000000000, hashMerkleRoot=3c2d8f85fa, nTime=1345084287, nBits=1d00ffff, nNonce=2179302059, vtx=1, vchBlockSig=) Coinbase(hash=3c2d8f85fa, nTime=1345083810, ver=1, vin.size=1, vout.size=1, nLockTime=0) CTxIn(COutPoint(0000000000, -1), coinbase 04ffff001d020f274b4d61746f6e69732030372d4155472d3230313220506172616c6c656c2043757272656e6369657320416e642054686520526f61646d617020546f204d6f6e65746172792046726565646f6d) CTxOut(empty) vMerkleTree: 3c2d8f85fa

Your test output shows a vector subscript out of range on line 16 in src/test/base64_tests.cpp.

Does your base64_tests.cpp file looks like this one https://github.com/hrobeers/Peershares/blob/ppcoin-master-testfix/src/test/base64_tests.cpp?
How come that you get an error on a vector while there is no vector in the file at all?

Also ppcoin has 55 test cases, and your output only shows 40.

If you’ve been editing the code it’s very difficult for us to help you.

[quote=“hrobeers, post:4, topic:3861”]Your test output shows a vector subscript out of range on line 16 in src/test/base64_tests.cpp.

Does your base64_tests.cpp file looks like this one https://github.com/hrobeers/Peershares/blob/ppcoin-master-testfix/src/test/base64_tests.cpp?
How come that you get an error on a vector while there is no vector in the file at all?[/quote]

This is call stack for this error:

unit-tests.exe!DecodeBase64(const std::basic_string<char,std::char_traits,std::allocator > & str) Line 733 C++ unit-tests.exe!base64_tests::base64_testvectors::test_method() Line 17 C++ unit-tests.exe!base64_tests::base64_testvectors_invoker() Line 9 C++

So, error occurs in this function (util.cpp line 730):

string DecodeBase64(const string& str) { vector<unsigned char> vchRet = DecodeBase64(str.c_str()); return string((const char*)&vchRet[0], vchRet.size()); }

vector “vchRet” have size=0 and next call “&vchRet[0]” is throw an error.

So for some reason

DecodeBase64(str.c_str()); 

is returning an empty vector.

What is in “str” at that point?

Can you debug into DecodeBase64(str.c_str()); to see what is going wrong?

[quote=“hrobeers, post:6, topic:3861”]So for some reason

DecodeBase64(str.c_str()); 

is returning an empty vector.

What is in “str” at that point?

Can you debug into DecodeBase64(str.c_str()); to see what is going wrong?[/quote]

std::string strDec = DecodeBase64(strEnc); throw an error because strEnc=""
strEnc="" because std::string strEnc = EncodeBase64(vstrIn[0] ) = “”
EncodeBase64(vstrIn[0]) = “” because vstrIn[0]=""
vstrIn[0]="" because static const std::string vstrIn[] = {"",“f”,“fo”,“foo”,“foob”,“fooba”,“foobar”};

There seem to be some differences in how msvc2013 handles the peercoin code.
I’m not sure if the msvc2013 compiler is supported by this codebase, I guess it isn’t.
The windows binaries seem to be compiled with MinGW.

Sorry but I can’t help you with msvc.