KomodoPlatform / komodo

Komodo
https://komodoplatform.com/
Other
118 stars 95 forks source link

[testnet] genesis block doesn't accept during reindex #573

Open DeckerSU opened 1 year ago

DeckerSU commented 1 year ago

Steps to reproduce:

  1. Compile komodod from latest dev branch, and launch it, for example, with the following params:
    -ac_name=INDXFAIL --testnet

    As you will see in debug.log, the genesis block will be accepted:

    2023-03-01 17:25:14 Pre-allocating up to position 0x1000000 in blk00000.dat
    2023-03-01 17:25:14 UpdateTip: new best=e46e999d6de5ef95427ea51b8242ef7949de22b340b6a484ff154b9991ec9452  height=0  log2_work=4.0874628  tx=1  date=2011-02-02 23:16:42 progress=1.000000  cache=0.0MiB(0tx)
    2023-03-01 17:25:14 init message: Rewinding blocks if needed...
    2023-03-01 17:25:14 init message: Verifying blocks...
  2. Change indexes in the ~/.komodo/INDXFAIL/INDXFAIL.conf to force reindex, for example, add the following lines into config:
    addressindex=1
    timestampindex=1
    spentindex=1

    As the previous indexes was only with txindex=1 it will trigger reindex:

    2023-03-01 17:26:55 Reindexing block file blk00000.dat...
  3. And then you will see in debug.log:
    2023-03-01 17:26:55 Waiting for genesis block to be imported...
    2023-03-01 17:26:55 Reindexing block file blk00000.dat...
    2023-03-01 17:26:55 ERROR: CheckBlock: proof of work failed
    2023-03-01 17:26:55 InvalidChainFound: invalid block=e46e999d6de5ef95427ea51b8242ef7949de22b340b6a484ff154b9991ec9452  height=0  log2_work=4.0874628  date=2011-02-02 23:16:42

    And in stdout:

    set addressindex, will reindex. could take a while.
    set spentindex, will reindex. could take a while.
    finished loading blocks INDXFAIL
    OS_loadfile null size.(/home/decker/.komodo/INDXFAIL/komodostate)
    komodo_faststateinit retval.-1
    fAddressIndex.1/0 fSpentIndex.1/0
    nLocalServices 30000005 1, 1
    e46e999d6de5ef95427ea51b8242ef7949de22b340b6a484ff154b9991ec9452 hash vs 0f0f0f0000000000000000000000000000000000000000000000000000000000 ht.1 special.0 special2.0 flag.0 notaryid.-1 mod.1 error
    04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb6 <- pubkey
    04678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb6 <- origpubkey
    e46e999d6de5ef95427ea51b8242ef7949de22b340b6a484ff154b9991ec9452 failed hash ht.0
    komodod: main.cpp:2647: void InvalidChainFound(CBlockIndex*): Assertion `tip' failed.
DeckerSU commented 1 year ago

It seems this happened because testnet genesis block selected by @jmjatlanta doesn't meet consensus.powLimit requirements, like: e46e999d6de5ef95427ea51b8242ef7949de22b340b6a484ff154b9991ec9452 is bigger than 0f0f0f000000000000000000000000000000000000000000000000000000000 and inside CheckProofOfWork condition

if ( UintToArith256(hash = blkHeader.GetHash()) > bnTarget )
{
...
}

leads to fail. The solution is to re-create the testnet with new, acceptable genesis block.

dimxy commented 1 year ago

yes I suggest we can use the mainnet genesis for testnet (like it was originally)