Skip to content

sync with pruned bitcoind: getblock ... false exited with status 1 #1502

Closed

Description

@egodigitus

root@vultr:~/lightning# bitcoin-cli getchaintips
[
{
"height": 522620,
"hash": "0000000000000000003615437297ff5e6b359363fde52156c9c22a7e2218498a",
"branchlen": 135101,
"status": "headers-only"
},
{
"height": 387519,
"hash": "000000000000000007e281f7fd570b848c639fbb59281c192d9e4d653e414175",
"branchlen": 0,
"status": "active"
}
]

root@vultr:~/lightning# lightningd/lightningd --bitcoin-datadir /root/.bitcoin/ --log-level debug --mainnet
2018-05-14T09:13:56.261Z lightningd(12665): testing /root/lightning/lightningd/lightning_channeld
2018-05-14T09:13:56.266Z lightningd(12665): testing /root/lightning/lightningd/lightning_closingd
2018-05-14T09:13:56.271Z lightningd(12665): testing /root/lightning/lightningd/lightning_gossipd
2018-05-14T09:13:56.274Z lightningd(12665): testing /root/lightning/lightningd/lightning_hsmd
2018-05-14T09:13:56.278Z lightningd(12665): testing /root/lightning/lightningd/lightning_onchaind
2018-05-14T09:13:56.282Z lightningd(12665): testing /root/lightning/lightningd/lightning_openingd
2018-05-14T09:13:56.318Z lightningd(12665): Client: Received message 11 from client
2018-05-14T09:13:56.319Z lightningd(12665): Client: Received message 9 from client
2018-05-14T09:13:56.319Z lightning_gossipd(12673): pid 12673, msgfd 12
2018-05-14T09:13:56.320Z lightningd(12665): Loaded 0 channels from DB
2018-05-14T09:13:56.369Z lightning_gossipd(12673): gossip_store: Read 0/0/0/0 cannounce/cupdate/nannounce/cdelete from store in 1 bytes
2018-05-14T09:14:00.726Z lightningd(12665): bitcoin-cli -datadir=/root/.bitcoin/ getblock 00000000000000000033e79243292ed910a36ff17d31e5e7f9ea6bd4df423d8d false exited with status 1

Using ubuntu 16.04, bitcoin core 0.16 and lightningd v0.5.2-2016-11-21-2716-g1125682
Lighningd is catching up until block #307718 than I got the error above.
I'm running bitcoind in pruned mode, was reading that the elements implementation could handle this.

Activity

  1. Saibato commented on May 14, 2018

    @Saibato
    Contributor

    @egodigitus have not used pruning lately but it's some important part.
    and #1398 is a step forward, but we still state in README.md that pruned bitcoind is not supported.
    also @Sjors wanted to test, no idea how far that is?

  2. Sjors commented on May 14, 2018

    @Sjors
    Contributor

    I've been running c-lightning with a pruned node for a while now. It seems to work fine, but I also make sure c-lightning doesn't get shut down for prolonged periods of time (beyond the prune horizon).

  3. egodigitus commented on May 14, 2018

    @egodigitus
    Author

    Oh I initially started a bitcoind --prune and waited for complete sync.
    Afterwards I installed and started lightningd
    So it should work if:

    1. sync bitcoind without pruning
    2. sync lightningd
    3. activate pruning

    Mmmh this eliminates the advantages of a pruned node somehow, like not needing a big harddrive...

  4. ZmnSCPxj commented on May 15, 2018

    @ZmnSCPxj
    Contributor

    What happens when you execute the given command directly?

    bitcoin-cli -datadir=/root/.bitcoin/ getblock 00000000000000000033e79243292ed910a36ff17d31e5e7f9ea6bd4df423d8d false
    
  5. egodigitus commented on May 15, 2018

    @egodigitus
    Author
    root@vultr:~# bitcoin-cli -datadir=/root/.bitcoin/ getblock 00000000000000000033e79243292ed910a36ff17d31e5e7f9ea6bd4df423d8d false
    error code: -1
    error message:
    Block not available (pruned data)
    
  6. ZmnSCPxj commented on May 15, 2018

    @ZmnSCPxj
    Contributor

    Well, there is the issue: bitcoind pruned it before lightningd could process it. While lightningd "can" be made to work with pruned bitcoind, it requires extreme care not to let bitcoind go forward sp fast that lightningd drops below the pruning horizon. This is one reason why we still officially do not support pruned bitcoind: there is a significant amount of extra work you need to do (e.g. have a monitor program that checks that lightningd is alive and if it dies, kill bitcoind).

    Unfortunately it seems your only remaining option is to scrap your bitcoin directory and re-download from scratch, let bitcoindrun in non-pruning mode to catch up, let lightningd catch up, and then prune. Which still requires that you have extra disk space.

    Alternately if you are willing to lose all the money you have in the lightningd you could just delete your .lightning dir, then run a new lightningd (which again you need to keep up-to-date with the pruned bitcoind).

    We do not officially support pruned bitcoind yet, and while it is "possible" to get it running with pruned bitcoind, it is highly not recommended due to issues like this.

  7. egodigitus commented on May 15, 2018

    @egodigitus
    Author

    Ok thanks @ZmnSCPxj
    Guess this issue can be closed

  8. Sjors commented on May 15, 2018

    @Sjors
    Contributor

    @egodigitus:

    So it should work if:

    1. sync bitcoind without pruning
    2. sync lightningd
    3. activate pruning
      Mmmh this eliminates the advantages of a pruned node somehow, like not needing a big harddrive...

    In step (1) you can sync with pruning enabled, so need need for a big disk (although it's a bit slow).

    You can even start lightningd right away, as long as it stays on top of the initial blockchain download. However it's easier to start lightningd after the sync is done, and I get the impression (not measured) that lightningd slows down IBD.

    To recover from a situation where your lightningd fell behind bitcoind's prune horizon, I found it easiest to connect to another remote full node that I had, using a reverse SSH proxy for port 8882 (RPC).

  9. ZmnSCPxj commented on May 15, 2018

    @ZmnSCPxj
    Contributor

    @egodigitus , @Sjors probably has more experience actually using pruned bitcoin with lightningd than us devs at this point, so if you have access to a trustable non-pruned full node, you could sync using that, then switch back to your pruned full node.

  10. cdecker commented on May 17, 2018

    @cdecker
    Member

    Theoretically it should be possible to sync in pruned mode and then start lightningd with a small --rescan value, and it should work. If however you run bitcoind without lightningd alongside for a prolonged time, it'll end up discarding blocks that lightningd hasn't seen yet and they run out of sync.

  11. Sjors commented on May 21, 2018

    @Sjors
    Contributor

    @cdecker would it be useful if bitcoind sent a ZMQ message when it’s about to prune? Perhaps consumers could register themselves via an RPC call and, before each prune, bitcoind would wait until all consumers say they’re done.

  12. cdecker commented on May 21, 2018

    @cdecker
    Member

    @Sjors I don't think so, ZMQ does not have any concept of a session, so we'd have to bolt on that on both sides, so that bitcoind knows when everybody has signed off. Also lightningd doesn't include ZMQ because it is incompatible with our event loop. The issue is also more prominent when lightningd isn't running, while bitcoind is, so it couldn't tell bitcoind not to prune.

    We don't have a good story for pruned nodes just yet, maybe the only way of fixing that is to implement the bitcoin P2P protocol and ask peers for blocks that our bitcoind doesn't have.

  13. Sjors commented on May 24, 2018

    @Sjors
    Contributor

    I just saw this Block not available (pruned data) crash on a testnet node that I spinned up a few hours ago.

    It was trying to fetch a block from 2018-03-21. It showed several thousand getblock 0000000...8df exited with status 1 messages before without crashing*. What could explain this block to be special?

    I was careful to spin up the bitcoind node first and wait for its IBD to finish before launching c-lightning. I then opened a channel to it from another node and successfully made a payment to this node from the other node. The crash happened a little bit after that.

    I was able to restart the node, generate a fresh invoice and pay that, so whatever the crash was didn't really seem fatal.

    * = I didn't check for duplicates, but maybe it should remember these and not try again?

  14. Sjors commented on May 24, 2018

    @Sjors
    Contributor

    I didn't check for duplicates, but maybe it should remember these and not try again?

    I assume this would lead to partial blindness to channels created before the node was launched. How bad is that exactly? In particular, does it hinder the ability to receive payments or only to spend? I only care about receiving funds for these nodes and don't mind opening fresh channels to facilitate the few times they need to spend.

  15. cdecker commented on May 24, 2018

    @cdecker
    Member

    What could explain this block to be special?

    My best guess is that it just is trying to sync, but that block was pruned away under its feet, so it'll try indefinitely. Possibly this has also something to do with IBD, i.e., the header is present but the block isn't yet. Later the block was pruned away under it and then it crashed since the behavior changed to a failing return code.

  16. Sjors commented on May 25, 2018

    @Sjors
    Contributor

    But afaik it was already synced, otherwise it wouldn't have accepted the channel. So why is still looking at ancient blocks?

  17. cdecker commented on May 26, 2018

    @cdecker
    Member

    Must have missed that you had an active channel working in the daemon before the crash. In that case it might be because of an incoming gossip message, telling you about a channel that was anchored in that block, so that explains why the failure is non-fatal as well.

  18. jb55 commented on Dec 8, 2018

    @jb55
    Collaborator

    I find my node keeps falling out of the prune window because the getrawblock loop is realllly slow. I haven't used bitcoin's zmqpubrawblock before but perhaps it would be faster?

  19. jb55 commented on Dec 8, 2018

    @jb55
    Collaborator

    When testing on a 100Mbps connection, clightning fell out of range at block 35499 while bitcoin was at 245694 with a 10GB prune window

  20. jb55 commented on Dec 8, 2018

    @jb55
    Collaborator

    or perhaps something like bitcoin-iterate on the raw blockfiles? or would that be tricky to maintain @rustyrussell ?

    at the very least it should speed up initial sync even for non-prune mode...

  21. Sjors commented on Dec 8, 2018

    @Sjors
    Contributor

    I heard rumours that in Bolt 1.1 SPV proofs are available via the p2p lightning gossip network, in which case you would never need historical blocks (since you node already checked the consensus rules).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions