Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

roasbeef/btcd does not start with chain data created by btcsuite/btcd #21

Open
offerm opened this issue Apr 7, 2018 · 1 comment
Open

Comments

@offerm
Copy link

offerm commented Apr 7, 2018

Background
I'm trying to setup LND for mainnet. For that I setup a btcd server. By mistake I used btcsuite/btcd to download the blockchain.
To use it with LND I setup roasbeef/btcd using the data directory created by btcsuite/btcd. I was expected that it will work without any problem.
However, when I start roasbeef/btcd it fails with the following:

2018-04-07 23:19:36.566 [INF] BTCD: Version 0.12.0-beta
2018-04-07 23:19:36.602 [INF] BTCD: Loading block database from '/Users/admin/Library/Application Support/Btcd/data/mainnet/blocks_ffldb'
2018-04-07 23:19:37.366 [INF] BTCD: Block database loaded
2018-04-07 23:19:37.376 [INF] INDX: cf index is enabled
2018-04-07 23:19:37.377 [INF] CHAN: Loading block index. This might take a while...
2018-04-07 23:19:37.486 [INF] BTCD: Gracefully shutting down the database...
2018-04-07 23:19:37.487 [INF] BTCD: Shutdown complete
panic: runtime error: slice bounds out of range [recovered]
panic: runtime error: slice bounds out of range

goroutine 1 [running]:
github.com/roasbeef/btcd/database/ffldb.rollbackOnPanic(0xc4201b4120)
/Users/admin/gocode/src/github.com/roasbeef/btcd/database/ffldb/db.go:1889 +0x77
panic(0x159e840, 0x1ab3070)
/usr/local/Cellar/go/1.10/libexec/src/runtime/panic.go:505 +0x229
github.com/roasbeef/btcd/database/ffldb.(*transaction).FetchBlockHeader(0xc4201b4120, 0xc420150160, 0x373a7f0, 0x20, 0xc420150140, 0xc420154080, 0xc420150160)
/Users/admin/gocode/src/github.com/roasbeef/btcd/database/ffldb/db.go:1278 +0x2bc
github.com/roasbeef/btcd/blockchain.dbFetchHeaderByHash(0x17ff6c0, 0xc4201b4120, 0xc420150160, 0xc420150160, 0x0, 0x0)
/Users/admin/gocode/src/github.com/roasbeef/btcd/blockchain/chainio.go:1231 +0x3f
github.com/roasbeef/btcd/blockchain.dbFetchHeaderByHeight(0x17ff6c0, 0xc4201b4120, 0x0, 0xc422470000, 0x7e3c9, 0x7e3c9)
/Users/admin/gocode/src/github.com/roasbeef/btcd/blockchain/chainio.go:1253 +0x8f
github.com/roasbeef/btcd/blockchain.(*BlockChain).initChainState.func1(0x17ff6c0, 0xc4201b4120, 0xc4201b4120, 0x0)
/Users/admin/gocode/src/github.com/roasbeef/btcd/blockchain/chainio.go:1159 +0x37d
github.com/roasbeef/btcd/database/ffldb.(*db).View(0xc42002e700, 0xc42015e220, 0x0, 0x0)
/Users/admin/gocode/src/github.com/roasbeef/btcd/database/ffldb/db.go:1912 +0x9b
github.com/roasbeef/btcd/blockchain.(*BlockChain).initChainState(0xc4204f4f00, 0xc4204f4f00, 0xc420571728)
/Users/admin/gocode/src/github.com/roasbeef/btcd/blockchain/chainio.go:1134 +0x99
github.com/roasbeef/btcd/blockchain.New(0xc42050a310, 0xc42050a310, 0x12, 0x0)
/Users/admin/gocode/src/github.com/roasbeef/btcd/blockchain/chain.go:1600 +0x528
main.newServer(0xc42014a190, 0x1, 0x1, 0x17fc0e0, 0xc42002e700, 0x1abbd20, 0xc42009a120, 0xc42015e600, 0xc42015e5e0, 0xc420152650)
/Users/admin/gocode/src/github.com/roasbeef/btcd/server.go:2412 +0x8d9
main.btcdMain(0x0, 0x0, 0x0)
/Users/admin/gocode/src/github.com/roasbeef/btcd/btcd.go:148 +0x686
main.main()
/Users/admin/gocode/src/github.com/roasbeef/btcd/btcd.go:330 +0xd0

Process finished with exit code 2

Your environment
Running on Darwin admins-MacBook-Pro-2.local 16.7.0 Darwin Kernel Version 16.7.0: Thu Jun 15 17:36:27 PDT 2017; root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64
btcd version 0.12.0-beta

Steps to reproduce
Very easy for me to reproduce. Just start btcd.
If I use btcsuite/btcd it will start successfully.

Expected behaviour
Should start without errors

Actual behaviour
See above.

From debugging:
When loading block index at chainio.go
calling dbFetchHeaderByHeight with height=0 (first block)
getting correct has for height =0
calling dbFetchHeaderByHash with hash
calling FetchBlockHeader with hash
calling fetchBlockRow with hash
getting a blockrow from hash table using the Hash

               returned blockrow has length of 12 which is causing a failure at db.go:1278
@Roasbeef
Copy link
Owner

The index formats of my fork, and upstream btcd have diverged. As a result, the chain indexes are currently incompatible. If you're not using neutrino, then you can safely use upstream btcd .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants