0

ERROR: ConnectBlock() : coinbase pays too much (actual=20000000 vs limit=20000000)

I got this error at my debug.log

anyone know how to fix this issue? I am coding a new coin, changing its rewards, which parametter I need change to increase the limit.

on the line:

 if (vtx[0].GetValueOut() > GetBlockValue(pindex->nHeight, nFees, pindex->nBits))
        return state.DoS(100, error("ConnectBlock() : coinbase pays too much (actual=%"PRI64d" vs limit=%"PRI64d")", vtx[0].GetV$

I changed my nsubsidy for the code

int getrandint(int min, int max)
{
    int num;
    num=rand();
    num=num%(max-min+1)+min;
    return num;
}



int64 static GetBlockValue(int nHeight, int64 nFees, unsigned int nBits)
{
    if (nHeight == 0)
    {
        return nGenesisBlockRewardCoin;
    }

   unsigned int i, iMax, iMin;


   iMin = 1;
   iMax = 50;

if(nHeight<500)
{
iMax = 3;
}
if(nHeight > 8000)
{
iMax = 30;
}
if(nHeight > 20000)
{
iMax = 20;
}
if(nHeight > 100000)
{
iMax = 10;
}


  i = getrandint(iMin, iMax);
    int64 nSubsidy = nBlockRewardStartCoin * i ;



    // Subsidy is cut in half every 60480 blocks (21 days)
    //nSubsidy >>= (nHeight / 60480);

    // Minimum subsidy
    if (nSubsidy < nBlockRewardMinimumCoin)
    {
        nSubsidy = nBlockRewardMinimumCoin;
    }

    return nSubsidy + nFees;

}

The code originally was

int64 static GetBlockValue(int nHeight, int64 nFees, unsigned int nBits)
{
    if (nHeight == 0)
    {
        return nGenesisBlockRewardCoin;
    }

    int64 nSubsidy = nBlockRewardStartCoin;

    // Subsidy is cut in half every 60480 blocks (21 days)
    nSubsidy >>= (nHeight / 60480);

    // Minimum subsidy
    if (nSubsidy < nBlockRewardMinimumCoin)
    {
        nSubsidy = nBlockRewardMinimumCoin;
    }

    return nSubsidy + nFees;
}

Because of what I change, my code give the error coinbase pays too much

root@eatSushi1:~/dogequark/src$ ./dogequarkd
dogequark server starting
root@eatSushi1:~/dogequark/src$ terminate called after throwing an instance of 'std::runtime_error'
  what():  CreateNewBlock() : ConnectBlock failed

I also got this error when I run the coind at another server after cloning through github.

  • @GregHewgill, what you mention made sense and helps me, but I got a issue is how should I change my code so It can work with my new nSubsidy.. – user1595932 Mar 4 '14 at 6:54
  • Your code can't work with your nSubsidy for the reason JoelKatz explained. – Nik Bougalis Mar 4 '14 at 11:02
  • This question appears to be off-topic because it is about basic programming. – Stéphane Gimenez Mar 5 '14 at 11:55
4

You should not be tampering with any code that has anything to do with determining block validity if you don't thoroughly understand the security model that proof of work coins use.

i = getrandint(iMin, iMax);
int64 nSubsidy = nBlockRewardStartCoin * i ;

You can't use any randomness in any code that involves block validation! The entire security model of the blockchain absolutely requires that servers agree on whether blocks are valid or not. Whatever it is you are trying to do, this is not how you do it.

| improve this answer | |
  • you mean if I want to use randomness, I only can use in Scrypt algorithm? I was thinking to do a concept like doge coin where rewards is a range of 1-500000 for the first 10000 blocks etc for quark fork. – user1595932 Mar 4 '14 at 13:08
  • If you do not fully understand the security model for proof of work coins, you should not be tampering with the block validity logic. It is absolutely not simple. The block reward must be known at the time the coinbase transaction is formed, before hashing begins. – David Schwartz Mar 4 '14 at 13:12
  • okay . I understood what you meant. If i set nsubsidy base on nHeight and is known to all nodes before the transaction is form, then its suppose be valid ? By taking away randomness and just put a constant int base on nHeight to determine nSubsidy and then reward proof of work – user1595932 Mar 4 '14 at 13:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.