Author

Topic: Problem with altcoin creation InvalidChainFound (5 LTC bounty for solution) (Read 1771 times)

member
Activity: 92
Merit: 10
Your pszTimestamp is a long string, right?

Search this lines in main.cpp:
Code:
        if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100)
            return state.DoS(100, error("CTransaction::CheckTransaction() : coinbase script size"));

Change the "> 100" condition to something larger, like 200, 300:
Code:
        if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 300)




Looks like that was the problem. Changed the pszTimestamp as a last resort last night and it worked as it was shorter than what I was trying to use before.

Anyway your answer was the closest so bounty goes to you send me your LTC address.

Thanks everyone that answered.  Smiley
sr. member
Activity: 364
Merit: 250
I'm really quite sane!
Your pszTimestamp is a long string, right?

Search this lines in main.cpp:
Code:
        if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100)
            return state.DoS(100, error("CTransaction::CheckTransaction() : coinbase script size"));

Change the "> 100" condition to something larger, like 200, 300:
Code:
        if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 300)




Looks like CheckTransaction() has been failing since the start, so elbandi's solution will probably work. I'd change the timestamp string instead of altering validation rules though, but I guess it doesn't really matter in this case.
hero member
Activity: 525
Merit: 529
Your pszTimestamp is a long string, right?

Search this lines in main.cpp:
Code:
        if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 100)
            return state.DoS(100, error("CTransaction::CheckTransaction() : coinbase script size"));

Change the "> 100" condition to something larger, like 200, 300:
Code:
        if (vin[0].scriptSig.size() < 2 || vin[0].scriptSig.size() > 300)


member
Activity: 92
Merit: 10
Still the same problem.

Running on testnet.

Code:
2014-09-09 18:09:34 ERROR: CTransaction::CheckTransaction() : coinbase script size
2014-09-09 18:09:34 ERROR: CheckBlock() : CheckTransaction failed
2014-09-09 18:09:34 InvalidChainFound: invalid block=0de531eb4f906d988164b15dac2711b8ca03ad2b8a2c859ef054c5c8e378d9ea  height=0  log2_work=20.000022  date=2014-09-09 14:06:25

Tried different configurations of checkpoints.cpp like

Code:
    
static MapCheckpoints mapCheckpointsTestnet =
        boost::assign::map_list_of
        (  0, uint256("0x0de531eb4f906d988164b15dac2711b8ca03ad2b8a2c859ef054c5c8e378d9ea"))
        ;
    static const CCheckpointData dataTestnet = {
        &mapCheckpointsTestnet,
        1410271585,
        0,
        10000
    };



member
Activity: 92
Merit: 10
thanks trying now.
legendary
Activity: 1008
Merit: 1022
change

Code:
static MapCheckpoints mapCheckpoints =
        boost::assign::map_list_of
        (  1500, uint256("0x841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967"))
        ;
    static const CCheckpointData data = {
        &mapCheckpoints,
        1402691751, // * UNIX timestamp of last checkpoint block
        4404988,    // * total number of transactions between genesis and last checkpoint
                    //   (the tx=... number in the SetBestChain debug.log lines)
        10000.0     // * estimated number of transactions per day after checkpoint
    };

to

Code:
static MapCheckpoints mapCheckpoints =
        boost::assign::map_list_of
        (  0, uint256("0x*********Insert Genesis Hash Here**********"))
        ;
    static const CCheckpointData data = {
        &mapCheckpoints,
        ********Inserttimestamphere******, // * UNIX timestamp of last checkpoint block
        1,    // * total number of transactions between genesis and last checkpoint
                    //   (the tx=... number in the SetBestChain debug.log lines)
        10000.0     // * estimated number of transactions per day after checkpoint
    };

by changing the gensis block, the timestamp and change the 4404988 to 1.

Rebuild the client.

Now run the client and mine some blocks.

To checkpoint the chain.

To get a block hash type in the console getblockhash 10 or any block number to get the hash. To get the number of transactions and time go to appdata/roaming/litecoin/debug and look at the block number. This will show transactions and timestamp which you will need to convert to epooch.

You also may be able to comment out the second check
Code:
[code]
static MapCheckpoints mapCheckpoints =
        boost::assign::map_list_of
        (  0, uint256("0x*********Insert Genesis Hash Here**********"))
        ;
    static const CCheckpointData data = {
        &mapCheckpoints,
        //********Inserttimestamphere******, // * UNIX timestamp of last checkpoint block
       // 1,    // * total number of transactions between genesis and last checkpoint
                    //   (the tx=... number in the SetBestChain debug.log lines)
       // 10000.0     // * estimated number of transactions per day after checkpoint
    };

[/code]
member
Activity: 109
Merit: 35
Looks like what muddafudda says is spot-on, it could indeed be the checkpoints.
Code:
static MapCheckpoints mapCheckpoints =
        boost::assign::map_list_of
        (  1500, uint256("0x841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967"))
        ;


You've got Litecoin's block 1500 hash as your first checkpoint. You need to remove the 841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967 after uint256("0x then put your genesis own block hash in instead and recompile.
member
Activity: 92
Merit: 10
Here is my checkpoints.cpp

Code:
// Copyright (c) 2009-2012 The Bitcoin developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.

#include // for 'map_list_of()'
#include

#include "checkpoints.h"

#include "main.h"
#include "uint256.h"

namespace Checkpoints
{
    typedef std::map MapCheckpoints;

    // How many times we expect transactions after the last checkpoint to
    // be slower. This number is a compromise, as it can't be accurate for
    // every system. When reindexing from a fast disk with a slow CPU, it
    // can be up to 20, while when downloading from a slow network with a
    // fast multicore CPU, it won't be much higher than 1.
    static const double fSigcheckVerificationFactor = 5.0;

    struct CCheckpointData {
        const MapCheckpoints *mapCheckpoints;
        int64 nTimeLastCheckpoint;
        int64 nTransactionsLastCheckpoint;
        double fTransactionsPerDay;
    };

    // What makes a good checkpoint block?
    // + Is surrounded by blocks with reasonable timestamps
    //   (no blocks before with a timestamp after, none after with
    //    timestamp before)
    // + Contains no strange transactions
    static MapCheckpoints mapCheckpoints =
        boost::assign::map_list_of
        (  1500, uint256("0x841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967"))
        ;
    static const CCheckpointData data = {
        &mapCheckpoints,
        1402691751, // * UNIX timestamp of last checkpoint block
        4404988,    // * total number of transactions between genesis and last checkpoint
                    //   (the tx=... number in the SetBestChain debug.log lines)
        10000.0     // * estimated number of transactions per day after checkpoint
    };

    static MapCheckpoints mapCheckpointsTestnet =
        boost::assign::map_list_of
        (   546, uint256("0xa0fea99a6897f531600c8ae53367b126824fd6a847b2b2b73817a95b8e27e602"))
        ;
    static const CCheckpointData dataTestnet = {
        &mapCheckpointsTestnet,
        1365458829,
        547,
        576
    };

    const CCheckpointData &Checkpoints() {
        if (fTestNet)
            return dataTestnet;
        else
            return data;
    }

    bool CheckBlock(int nHeight, const uint256& hash)
    {
       
        return true; //added
       
        if (!GetBoolArg("-checkpoints", true))
            return true;

        const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;

        MapCheckpoints::const_iterator i = checkpoints.find(nHeight);
        if (i == checkpoints.end()) return true;
        return hash == i->second;
    }

    // Guess how far we are in the verification process at the given block index
    double GuessVerificationProgress(CBlockIndex *pindex) {
        if (pindex==NULL)
            return 0.0;

        int64 nNow = time(NULL);

        double fWorkBefore = 0.0; // Amount of work done before pindex
        double fWorkAfter = 0.0;  // Amount of work left after pindex (estimated)
        // Work is defined as: 1.0 per transaction before the last checkoint, and
        // fSigcheckVerificationFactor per transaction after.

        const CCheckpointData &data = Checkpoints();

        if (pindex->nChainTx <= data.nTransactionsLastCheckpoint) {
            double nCheapBefore = pindex->nChainTx;
            double nCheapAfter = data.nTransactionsLastCheckpoint - pindex->nChainTx;
            double nExpensiveAfter = (nNow - data.nTimeLastCheckpoint)/86400.0*data.fTransactionsPerDay;
            fWorkBefore = nCheapBefore;
            fWorkAfter = nCheapAfter + nExpensiveAfter*fSigcheckVerificationFactor;
        } else {
            double nCheapBefore = data.nTransactionsLastCheckpoint;
            double nExpensiveBefore = pindex->nChainTx - data.nTransactionsLastCheckpoint;
            double nExpensiveAfter = (nNow - pindex->nTime)/86400.0*data.fTransactionsPerDay;
            fWorkBefore = nCheapBefore + nExpensiveBefore*fSigcheckVerificationFactor;
            fWorkAfter = nExpensiveAfter*fSigcheckVerificationFactor;
        }

        return fWorkBefore / (fWorkBefore + fWorkAfter);
    }

    int GetTotalBlocksEstimate()
    {
        return 0;
        if (!GetBoolArg("-checkpoints", true))
            return 0;

        const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;

        return checkpoints.rbegin()->first;
    }

    CBlockIndex* GetLastCheckpoint(const std::map& mapBlockIndex)
    {
        return NULL;
        if (!GetBoolArg("-checkpoints", true))
            return NULL;

        const MapCheckpoints& checkpoints = *Checkpoints().mapCheckpoints;

        BOOST_REVERSE_FOREACH(const MapCheckpoints::value_type& i, checkpoints)
        {
            const uint256& hash = i.second;
            std::map::const_iterator t = mapBlockIndex.find(hash);
            if (t != mapBlockIndex.end())
                return t->second;
        }
        return NULL;
    }
}
legendary
Activity: 1008
Merit: 1022
Have you removed the old checkpoints and assigned the new?

litecoin/checkpoints.cpp
Code:
static MapCheckpoints mapCheckpoints =
        boost::assign::map_list_of
        (  1500, uint256("0x841a2965955dd288cfa707a755d05a54e45f8bd476835ec9af4402a2b59a2967"))
        (  4032, uint256("0x9ce90e427198fc0ef05e5905ce3503725b80e26afd35a987965fd7e3d9cf0846"))
        (  8064, uint256("0xeb984353fc5190f210651f150c40b8a4bab9eeeff0b729fcb3987da694430d70"))
        ( 16128, uint256("0x602edf1859b7f9a6af809f1d9b0e6cb66fdc1d4d9dcd7a4bec03e12a1ccd153d"))
        ( 23420, uint256("0xd80fdf9ca81afd0bd2b2a90ac3a9fe547da58f2530ec874e978fce0b5101b507"))
        ( 50000, uint256("0x69dc37eb029b68f075a5012dcc0419c127672adb4f3a32882b2b3e71d07a20a6"))
        ( 80000, uint256("0x4fcb7c02f676a300503f49c764a89955a8f920b46a8cbecb4867182ecdb2e90a"))
        (120000, uint256("0xbd9d26924f05f6daa7f0155f32828ec89e8e29cee9e7121b026a7a3552ac6131"))
        (161500, uint256("0xdbe89880474f4bb4f75c227c77ba1cdc024991123b28b8418dbbf7798471ff43"))
        (179620, uint256("0x2ad9c65c990ac00426d18e446e0fd7be2ffa69e9a7dcb28358a50b2b78b9f709"))
        (240000, uint256("0x7140d1c4b4c2157ca217ee7636f24c9c73db39c4590c4e6eab2e3ea1555088aa"))
        (383640, uint256("0x2b6809f094a9215bafc65eb3f110a35127a34be94b7d0590a096c3f126c6f364"))
        (409004, uint256("0x487518d663d9f1fa08611d9395ad74d982b667fbdc0e77e9cf39b4f1355908a3"))
        (456000, uint256("0xbf34f71cc6366cd487930d06be22f897e34ca6a40501ac7d401be32456372004"))
        (541794, uint256("0x1cbccbe6920e7c258bbce1f26211084efb19764aa3224bec3f4320d77d6a2fd2"))
        (585010, uint256("0xea9ea06840de20a18a66acb07c9102ee6374ad2cbafc71794e576354fea5df2d"))
        ;
    static const CCheckpointData data = {
        &mapCheckpoints,
        1402691751, // * UNIX timestamp of last checkpoint block
        4404988,    // * total number of transactions between genesis and last checkpoint
                    //   (the tx=... number in the SetBestChain debug.log lines)
        10000.0     // * estimated number of transactions per day after checkpoint
    };

    static MapCheckpoints mapCheckpointsTestnet =
        boost::assign::map_list_of
        (   546, uint256("0xa0fea99a6897f531600c8ae53367b126824fd6a847b2b2b73817a95b8e27e602"))
        ;
    static const CCheckpointData dataTestnet = {
        &mapCheckpointsTestnet,
        1365458829,
        547,
        576
    };

My other suggestion would be hash a new genesis block and see what the results are.

You could also give someone the const char* pszTimestamp and timestamp and see if they hash the same genesis block also to see if your doing it right.
member
Activity: 92
Merit: 10
I am playing around trying to create an altcoin. Not releasing another shitcoin don't worry. Just interested.

I think I have created the correct MerkleRoot and GenesisBlock however when I run I get a seg fault:

...
Code:
2014-09-09 16:37:44 Opened LevelDB successfully
2014-09-09 16:37:44 LoadBlockIndexDB(): last block file = 0
2014-09-09 16:37:44 LoadBlockIndexDB(): transaction index disabled
2014-09-09 16:37:44 Initializing databases...
2014-09-09 16:37:44 6be7c8f3be4e9d3f6f03a817b082018f8a18e93311f60ff34c62181a23ebb0a6
2014-09-09 16:37:44 6be7c8f3be4e9d3f6f03a817b082018f8a18e93311f60ff34c62181a23ebb0a6 = Genesis Block
2014-09-09 16:37:44 1f1ed2572f95affa5ec799aef6665551f1c7ebf064c854d0e0e569715942f877
2014-09-09 16:37:44 CBlock(hash=6be7c8f3be4e9d3f6f03a817b082018f8a18e93311f60ff34c62181a23ebb0a6, input=01000000000000000000000000000000000000000000000000000000000000000000000077f842597169e5e0d054c864f0ebc7f1515566f6ae99c75efaaf952f57d21e1f60090f54f0ff0f1ea6710800, PoW=00000b854221b600d67501f78cf3c72eda5782338e00fa493bb5f71f7f34c145, ver=1, hashPrevBlock=0000000000000000000000000000000000000000000000000000000000000000, hashMerkleRoot=1f1ed2572f95affa5ec799aef6665551f1c7ebf064c854d0e0e569715942f877, nTime=1410271584, nBits=1e0ffff0, nNonce=553382, vtx=1)
2014-09-09 16:37:44   CTransaction(hash=1f1ed2572f95affa5ec799aef6665551f1c7ebf064c854d0e0e569715942f877, ver=1, vin.size=1, vout.size=1, nLockTime=0)
    CTxIn(COutPoint(0000000000000000000000000000000000000000000000000000000000000000, 4294967295), coinbase 04ffff001d01044c744172636861656f6c6f676973747320696e204772656563652066696e642074776f206c61726765206d6172626c65207374617475657320617420616e6369656e7420746f6d62207769746820706f737369626c65206c696e6b20746f20416c6578616e646572207468652047726561742e2e2e21)
    CTxOut(nValue=50.00000000, scriptPubKey=040184710fa689ad5023690c80f3a4)
  vMerkleTree: 1f1ed2572f95affa5ec799aef6665551f1c7ebf064c854d0e0e569715942f877
2014-09-09 16:37:44 Pre-allocating up to position 0x1000000 in blk00000.dat
2014-09-09 16:37:44 Getting to connect best block DIAG
2014-09-09 16:37:44 ERROR: CTransaction::CheckTransaction() : coinbase script size
2014-09-09 16:37:44 ERROR: CheckBlock() : CheckTransaction failed
2014-09-09 16:37:44 InvalidChainFound: invalid block=6be7c8f3be4e9d3f6f03a817b082018f8a18e93311f60ff34c62181a23ebb0a6  height=0  log2_work=20.000022  date=2014-09-09 14:06:24

Using the latest source code from Litecoin github repository.

Ideas?
Jump to: