lightninglabs / neutrino

Privacy-Preserving Bitcoin Light Client
MIT License
907 stars 182 forks source link

Header doesn't pass sanity check: block target difficulty of 0000000000000000000eb1560000000000000000000000000000000000000000 is higher than max of 0000000000000000000000000000000000000000000000000000000000000000 -- disconnecting peer #211

Closed JaviLib closed 3 years ago

JaviLib commented 3 years ago

My LND is unable to sync using Neutrino. I get this error for ever and ever:

2021-01-09 21:35:19.326 [INF] BTCN: Syncing to block height 665317 from peer 13.91.246.35:8333
2021-01-09 21:35:19.326 [INF] BTCN: Fetching set of headers from tip (height=659260) from peer 13.91.246.35:8333
2021-01-09 21:35:22.294 [WRN] BTCN: Header doesn't pass sanity check: block target difficulty of 0000000000000000000eb1560000000000000000000000000000000000000000 is higher than max of 0000000000000000000000000000000000000000000000000000000000000000 -- disconnecting peer

Obviusly something is wrong in the code, as the maximum difficulty cannot be zero.

lnd version 0.12.0-beta.rc5 commit=v0.12.0-beta.rc5

Relevant lnd.conf is:

bitcoin.node=neutrino
routing.assumechanvalid=1
neutrino.addpeer=btcd-mainnet.lightning.computer
neutrino.addpeer=btcd0.lightning.engineering
neutrino.addpeer=neutrino.shock.network
neutrino.addpeer=mainnet1-btcd.zaphq.io
neutrino.addpeer=mainnet2-btcd.zaphq.io
neutrino.addpeer=mainnet3-btcd.zaphq.io
neutrino.addpeer=mainnet4-btcd.zaphq.io
neutrino.banduration=1s
neutrino.banthreshold=100000
neutrino.maxpeers=256
neutrino.feeurl=https://nodes.lightning.computer/fees/v1/btc-fee-estimates.json
guggero commented 3 years ago

Does the problem persist? Do you also get the error if you comment out the first neutrino.addpeer, because 13.91.246.35 is btcd-mainnet.lightning.computer. I assume you have bitcoin.mainnet=1 in the config as well? Or is this your complete config file?

This sounds like it could be related to a block reorg? It looks to me like calcNextRequiredDifficulty returns 0: https://github.com/lightninglabs/neutrino/blob/master/blockmanager.go#L2826

guggero commented 3 years ago

@JavierRSobrino I looked at the code again and tried a few things to reproduce, but no luck. Did you ever run into this again? Or were you able to resolve it?

If this continues to happen, can you please turn on debug log for Neutrino? Or just debuglevel=debug in general.

Roasbeef commented 3 years ago

@guggero feel free to close this is we're unable to reproduce for now.

guggero commented 3 years ago

Closing due to inactivity and inability to reproduce.

buck54321 commented 1 year ago

I've seen this two days in a row running a simnet client against a bitcoind peer added using ConnectNode. Example logs

2023-03-25 09:22:39.546 [INF] NTRNO: Fetching set of checkpointed cfheaders filters from height=2000, hash=2c936520ef7411e92a68aca0a5fb08c4576f6a7bede50f4836026ac31da77189
2023-03-25 09:22:39.546 [INF] NTRNO: Starting to query for cfheaders from checkpoint_interval=2, checkpoints=4
2023-03-25 09:22:39.546 [INF] NTRNO: Attempting to query for 1 cfheader batches
2023-03-25 09:22:39.546 [DBG] NTRNO: Sending getcfheaders (start_height=2001, stop_hash=6f42d71b22ab141a2b9834b433f20f76d4ff5aaa013b4b444b8a850fd09000f8) to 127.0.0.1:20575 (outbound)
2023-03-25 09:22:39.547 [DBG] NTRNO: Difficulty retarget at block height 4032
2023-03-25 09:22:39.547 [DBG] NTRNO: Old target 207fffff (7fffff0000000000000000000000000000000000000000000000000000000000)
2023-03-25 09:22:39.547 [DBG] NTRNO: New target 201fffff (1fffff0000000000000000000000000000000000000000000000000000000000)
2023-03-25 09:22:39.547 [DBG] NTRNO: Actual timespan 8h24m8s, adjusted timespan 84h0m0s, target timespan 336h0m0s
2023-03-25 09:22:39.547 [WRN] NTRNO: Header doesn't pass sanity check: block target difficulty of 7fffff0000000000000000000000000000000000000000000000000000000000 is higher than max of 1fffff0000000000000000000000000000000000000000000000000000000000 -- disconnecting peer
2023-03-25 09:22:39.547 [WRN] CHAIN: Query(1) from peer 127.0.0.1:20575 failed, rescheduling: peer disconnected
2023-03-25 09:22:39.547 [DBG] NTRNO: Removed peer 127.0.0.1:20575 (outbound)
2023-03-25 09:22:39.547 [DBG] NTRNO: Disconnected from 127.0.0.1:20575 (reqid 1)

I have that bitcoind node running on an auto-miner, so lots of empty blocks being created.