kowala-tech / kcoin

A stable cryptocurrency that algorithmically targets $1 USD using the Kowala Protocol
https://www.kowala.tech/
Other
18 stars 16 forks source link

Panic during sync #768

Closed acroca closed 5 years ago

acroca commented 5 years ago

Type:

Issue

What happened? / What do you need?:

I'm running a new docker node and I get panic while it syncs up with the rest of the nodes.

I get the following log:

> WARN [09-21|12:22:15.818] New version is available: 2.0.0 
WARN [09-21|12:23:08.684] Node data write error                    err="state node 0b676e…0d44c9 failed with all peers (4 tries, 4 peers)"
WARN [09-21|12:23:09.102] Rolled back headers                      count=2048 header=281678->279630 fast=281509->279630 block=0->0
WARN [09-21|12:23:09.103] Synchronisation failed, retrying         err="state node 0b676e…0d44c9 failed with all peers (4 tries, 4 peers)"
WARN [09-21|12:23:09.104] Failed to sync with network              err="FailedEvent received"
WARN [09-21|12:23:11.031] Discarded bad propagated block           number=281681 hash=7c239c…1b9686
WARN [09-21|12:23:11.051] Discarded bad propagated block           number=281681 hash=7c239c…1b9686
WARN [09-21|12:23:13.603] Rolled back headers                      count=2    header=281680->281678 fast=281616->281616 block=281680->281678
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x4723f4]

goroutine 5565 [running]:
github.com/kowala-tech/kcoin/client/core.(*HeaderChain).WriteHeader(0xc4201b4080, 0xc42b2f0000, 0xc42049e288, 0x9a4b268247f22a0b, 0xffadcdd387f8c5b8)
    /go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/core/headerchain.go:145 +0x59b
github.com/kowala-tech/kcoin/client/core.(*BlockChain).InsertHeaderChain.func1(0xc42b2f0000, 0x0, 0x0)
    /go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/core/blockchain.go:1412 +0x95
github.com/kowala-tech/kcoin/client/core.(*HeaderChain).InsertHeaderChain(0xc4201b4080, 0xc42bb5eb00, 0x1, 0x1, 0xc42ba5c220, 0xbee1568c63f2786c, 0x1b9d9b1bcd, 0x1c57480, 0xc42b2f0000, 0xc42bb5eb18, ...)
    /go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/core/headerchain.go:248 +0x180
github.com/kowala-tech/kcoin/client/core.(*BlockChain).InsertHeaderChain(0xc42049e000, 0xc42bb5eb00, 0x1, 0x1, 0x1, 0x0, 0x0, 0x0)
    /go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/core/blockchain.go:1416 +0x209
github.com/kowala-tech/kcoin/client/knode/downloader.(*Downloader).processHeaders(0xc420064ea0, 0x44c51, 0x44c10, 0xc421e9ddc0, 0x0, 0x0)
    /go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/knode/downloader/downloader.go:1253 +0x6dd
github.com/kowala-tech/kcoin/client/knode/downloader.(*Downloader).syncWithPeer.func6(0x8, 0x11ccf18)
    /go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/knode/downloader/downloader.go:445 +0x49
github.com/kowala-tech/kcoin/client/knode/downloader.(*Downloader).spawnSync.func1(0xc420064ea0, 0xc4210d3620, 0xc421970210)
    /go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/knode/downloader/downloader.go:462 +0x59
created by github.com/kowala-tech/kcoin/client/knode/downloader.(*Downloader).spawnSync
    /go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/knode/downloader/downloader.go:462 +0xb6

If it's an issue, how can we reproduce it?:

I tried again and now it didn't fail. All I'm running is:

docker run --rm -it kowalatech/kusd:2.0.0 --dev console

Affected servers or services:

Priority:

Medium

JekaMas commented 5 years ago

I saw it once... Will fix.

adamking commented 5 years ago

I just had the same issue syncing with the darwin binary

johnreitano commented 5 years ago

Me too

JekaMas commented 5 years ago

@adamking @johnreitano Guys, could you write here how did you start the client when it panics? Still trying to have a stable and reproducible result.

adamking commented 5 years ago

Using the darwin prebuilt binary I ran:

kcoin init && kcoin console

After a few minutes there was a panic.

JekaMas commented 5 years ago

Thanks! Got it:

INFO [09-24|19:15:36.026] Imported new block receipts              count=0    elapsed=4.643ms   number=2083357 hash=dfabcf…82b848 size=0.00B    ignored=347
INFO [09-24|19:15:36.819] Imported new state entries               count=4    elapsed=43.381µs  processed=18 pending=0 retry=0 duplicate=0 unexpected=0
INFO [09-24|19:15:36.819] Imported new block receipts              count=0    elapsed=31.33µs   number=2083358 hash=9de7a9…133f03 size=0.00B    ignored=1
INFO [09-24|19:15:36.819] Committed new head block                 number=2083358 hash=9de7a9…133f03
WARN [09-24|19:15:36.823] a blockchain reorganization needed: block parent hash 0xe3bdd1e433549ac618896a138fcf5806deef473d88c1a5a8abefb43efbd5ad24, current block hash 0x9de7a93b6e276d184cfcd00c80750485a36153d02dfa7ad9c6efe111fb133f03 
ERROR[09-24|19:15:36.823] Impossible reorg, please file an issue   oldnum=2083358 oldhash=9de7a9…133f03 len(oldChain)=0 newnum=2083358 newhash=9de7a9…133f03 len(newChain)=48
INFO [09-24|19:15:36.830] Imported new chain segment               blocks=67 txs=0 mgas=0.000 elapsed=10.831ms  mgasps=0.000 number=2083425 hash=bb2939…d5100b cache=133.58kB
ERROR[09-24|19:15:37.813] error processing block head              hash=50c75c…8285fd number=2083427
ERROR[09-24|19:15:37.814] error processing block head              headerByHash=<nil>
ERROR[09-24|19:15:37.814] error processing block head              headerByNumber=<nil>
WARN [09-24|19:15:37.815] Rolled back headers                      count=17   header=2083425->2083408 fast=2083358->2083358 block=2083425->2083408
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa08771]

goroutine 31447 [running]:
github.com/kowala-tech/kcoin/client/core.(*HeaderChain).WriteHeader(0xc0003b8380, 0xc0098be240, 0xc00076a288, 0xe2dc999f0ce007d5, 0xeb281497f2a5ae2e)
    /home/eugene/go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/core/headerchain.go:150 +0x4c1
github.com/kowala-tech/kcoin/client/core.(*BlockChain).InsertHeaderChain.func1(0xc0098be240, 0x0, 0x0)
    /home/eugene/go/src/github.com/kowala-tech/kcoin/client/build/_workspace/src/github.com/kowala-tech/kcoin/client/core/blockchain.go:1412 +0x8b
github.com/kowala-tech/kcoin/client/core.(*HeaderChain).InsertHeaderChain(0xc0003b8380, 0xc0074c8000, 0x1, 0x1, 0xc0005398f0, 0xbee2614a707e4ed1, 0x9daf64470a, 0x1e3fe40, 0xa00abd, 0xc0003b8380, ...)

For some reason StateDB branch is empty. Digging in.