kcc-community/kcc

Export and Import not work

Closed this issue · 1 comments

System information

Geth version: v1.0.4
OS & Version: Windows/Linux/OSX

Expected behaviour

Export and Import works.

Actual behaviour

Import not works.

Steps to reproduce the behaviour

geth export 20210920.gz --syncmode full

geth import 20210920.gz --syncmode full --gcmode archive

Backtrace

INFO [09-20|13:43:13.782] Maximum peer count                       ETH=50 LES=0 total=50
INFO [09-20|13:43:13.782] Smartcard socket not found, disabling    err="stat /run/pcscd/pcscd.comm: no such file or directory"
INFO [09-20|13:43:13.783] Set global gas cap                       cap=25000000
INFO [09-20|13:43:13.783] Allocated cache and file handles         database=/home/ubuntu/.ethereum/geth/chaindata cache=512.00MiB handles=524288
INFO [09-20|13:43:13.796] Opened ancient database                  database=/home/ubuntu/.ethereum/geth/chaindata/ancient
INFO [09-20|13:43:13.797] Disk storage enabled for ethash caches   dir=/home/ubuntu/.ethereum/geth/ethash count=3
INFO [09-20|13:43:13.797] Disk storage enabled for ethash DAGs     dir=/home/ubuntu/.ethash               count=2
INFO [09-20|13:43:13.797] Loaded most recent local header          number=0 hash="d179bc…6ca3fc" td=1 age=3mo3w6h
INFO [09-20|13:43:13.797] Loaded most recent local full block      number=0 hash="d179bc…6ca3fc" td=1 age=3mo3w6h
INFO [09-20|13:43:13.797] Loaded most recent local fast block      number=0 hash="d179bc…6ca3fc" td=1 age=3mo3w6h
INFO [09-20|13:43:13.798] Importing blockchain                     file=20210920.gz
INFO [09-20|13:43:13.820] Skip duplicated bad block                number=1 hash="6b5cb4…635f25"
ERROR[09-20|13:43:13.820] 
########## BAD BLOCK #########
Chain config: {ChainID: 321 Homestead: 0 DAO: <nil> DAOSupport: true EIP150: 0 EIP155: 0 EIP158: 0 Byzantium: 0 Constantinople: 0 Petersburg: 0 Istanbul: 0, Muir Glacier: 0, Berlin: 0, YOLO v3: <nil>, Engine: posa}

Number: 1
Hash: 0x6b5cb41e5dc9c94edd55b8aa958bbde2ee1d01a9d1485273c1fc9c506e635f25


Error: extra-data too long: 97 > 32
##############################
 
ERROR[09-20|13:43:13.820] Import error                             err="invalid block 2500: extra-data too long: 97 > 32"
INFO [09-20|13:43:13.820] Writing snapshot state to disk           root="8357c6…4c2c89"
INFO [09-20|13:43:13.820] Persisted trie from memory database      nodes=0 size=0.00B time="3.742µs" gcnodes=0 gcsize=0.00B gctime=0s livenodes=1 livesize=0.00B
INFO [09-20|13:43:13.820] Blockchain stopped 
Import done in 22.505486ms.

Compactions
 Level |   Tables   |    Size(MB)   |    Time(sec)  |    Read(MB)   |   Write(MB)
-------+------------+---------------+---------------+---------------+---------------
   1   |          1 |       0.01634 |       0.00000 |       0.00000 |       0.00000
-------+------------+---------------+---------------+---------------+---------------
 Total |          1 |       0.01634 |       0.00000 |       0.00000 |       0.00000

Read(MB):0.01343 Write(MB):0.00068
Object memory: 135.800 MB current, 130.539 MB peak
System memory: 279.841 MB current, 279.591 MB peak
Allocations:   0.098 million
GC pause:      301.152µs

Compacting entire database...
Compaction done in 10.860836ms.

Compactions
 Level |   Tables   |    Size(MB)   |    Time(sec)  |    Read(MB)   |   Write(MB)
-------+------------+---------------+---------------+---------------+---------------
   0   |          0 |       0.00000 |       0.00406 |       0.00000 |       0.00049
   1   |          1 |       0.01634 |       0.00384 |       0.01683 |       0.01634
-------+------------+---------------+---------------+---------------+---------------
 Total |          1 |       0.01634 |       0.00790 |       0.01683 |       0.01683

Read(MB):0.01724 Write(MB):0.01776
invalid block 2500: extra-data too long: 97 > 32

Review

The same issue still exists in v1.2.1. The root cause is in the Makechain function:

kcc/cmd/utils/flags.go

Lines 1731 to 1748 in 555b10c

var engine consensus.Engine
if config.Clique != nil {
engine = clique.New(config.Clique, chainDb)
} else {
engine = ethash.NewFaker()
if !ctx.GlobalBool(FakePoWFlag.Name) {
engine = ethash.New(ethash.Config{
CacheDir: stack.ResolvePath(ethconfig.Defaults.Ethash.CacheDir),
CachesInMem: ethconfig.Defaults.Ethash.CachesInMem,
CachesOnDisk: ethconfig.Defaults.Ethash.CachesOnDisk,
CachesLockMmap: ethconfig.Defaults.Ethash.CachesLockMmap,
DatasetDir: stack.ResolvePath(ethconfig.Defaults.Ethash.DatasetDir),
DatasetsInMem: ethconfig.Defaults.Ethash.DatasetsInMem,
DatasetsOnDisk: ethconfig.Defaults.Ethash.DatasetsOnDisk,
DatasetsLockMmap: ethconfig.Defaults.Ethash.DatasetsLockMmap,
}, nil, false)
}
}

In the Makechain function, the consensus engine is either ethash or clique. Whereas we need the posa engine to make it work.

The Makechain function has been heavily refactored and we will fix this issue based on a newer version.