mit-dci / lit

Lightning Network node software
MIT License
551 stars 119 forks source link

Re-orging is still broken - breaks testnet sync #240

Closed metalicjames closed 6 years ago

metalicjames commented 6 years ago
2018/06/27 21:11:55.777661 asking for headers due to inv block
2018/06/27 21:11:55.777695 got header tip height 1327070
2018/06/27 21:11:55.778185 get headers message has 18 header hashes, first one is 0000000029caccca59f6ea2e2e87870fd4c5f42e77cd7237071c30d7112b03ac
2018/06/27 21:11:55.891456 got 3 headers. Range:
00000000264c664adf909677141b6a039f004c02c6047becbccb7b97b3a72325 - 000000002128c5b8fbe782216cca37e3cb8de8ff5278e703cfe801af397461a0
2018/06/27 21:11:55.891481 header file position: 5688160
2018/06/27 21:11:55.891494 made 2017 header slice
2018/06/27 21:11:55.900810 Header 00000000264c664adf909677141b6a039f004c02c6047becbccb7b97b3a72325 attaches at height 1327068
2018/06/27 21:11:55.900817 reorg from height 1327070 to 1327071
2018/06/27 21:11:55.900903 Added 3 headers OK.
2018/06/27 21:11:55.900914 got header tip height 1327071
2018/06/27 21:11:55.900973 HeightHandler: oh no, reorg!
2018/06/27 21:11:55.901038 Rollback height 1327068
2018/06/27 21:11:55.901059 get headers message has 18 header hashes, first one is 000000002128c5b8fbe782216cca37e3cb8de8ff5278e703cfe801af397461a0
2018/06/27 21:11:55.901072 tx height 1326447
2018/06/27 21:11:55.901090 tx height 1326447
2018/06/27 21:11:55.901105 tx height 1326447
2018/06/27 21:11:55.901121 tx height 1326449
2018/06/27 21:11:55.901137 tx height 1326526
2018/06/27 21:11:55.901154 tx height 0
2018/06/27 21:11:55.901170 tx height 1326450
2018/06/27 21:11:55.901186 tx height 1326450
2018/06/27 21:11:55.901202 tx height 0
2018/06/27 21:11:55.901216 tx height 1326449
2018/06/27 21:11:55.901228 Rollback db.  0 utxos lost
2018/06/27 21:11:56.031270 got inv.  Contains:
2018/06/27 21:11:56.031317  0)MSG_BLOCK : 000000007cb9d64cf2dd08ba972e178a6890b55b7855cc0ee04aa3ab4d886655
2018/06/27 21:11:56.031336 inv block but ignoring; not synced
2018/06/27 21:11:56.031454 got 1 headers. Range:
000000007cb9d64cf2dd08ba972e178a6890b55b7855cc0ee04aa3ab4d886655 - 000000007cb9d64cf2dd08ba972e178a6890b55b7855cc0ee04aa3ab4d886655
2018/06/27 21:11:56.031480 header file position: 5688240
2018/06/27 21:11:56.031516 made 2017 header slice
2018/06/27 21:11:56.051182 Header error: Block 1327072 000000007cb9d64cf2dd08ba972e178a6890b55b7855cc0ee04aa3ab4d886655 incorrect difficuly.  Read 1d00ffff, expect 0
2018/06/27 21:11:56.709197 got inv.  Contains:
2018/06/27 21:11:56.709232  0)MSG_BLOCK : 000000005779bbbc817059287e58e57a612076cedabbf85a9b7c7bb1eda125a1
2018/06/27 21:11:56.709271 inv block but ignoring; not synced
2018/06/27 21:11:57.094705 got inv.  Contains:
2018/06/27 21:11:57.094753  0)MSG_BLOCK : 0000000074d3dbd58b98e1e73aee62e63219756b59a9c2fa4a687c811d8cef7a
2018/06/27 21:11:57.094764 inv block but ignoring; not synced
2018/06/27 21:11:57.487509 got inv.  Contains:
2018/06/27 21:11:57.487548  0)MSG_BLOCK : 00000000603f92a6baa9991c1cde22814f4f5e1f7b327dfa836c067b358d9f35

Reorgs can cause the difficulty to be calculated incorrectly. @Varunram

metalicjames commented 6 years ago

In fact, syncing testnet is now impossible due to this bug.

Varunram commented 6 years ago

I hit another reorg a while back and it seemed to work, so the problem seems to be much deeper than I initially expected:

2018/06/28 11:33:55.457393 reorg from height 1335735 to 1335736
2018/06/28 11:33:55.457403 TEMPCUR.BITS 469827583
2018/06/28 11:33:55.457409 TEMPCUR.BITS 469827583
2018/06/28 11:33:55.459122 HeightHandler: oh no, reorg!
2018/06/28 11:33:55.459169 Rollback height 1335734
2018/06/28 11:33:55.459188 tx height 1316917
2018/06/28 11:33:55.459194 tx height 1326486
2018/06/28 11:33:55.459199 tx height 1326486
2018/06/28 11:33:55.459202 tx height 0
2018/06/28 11:33:55.459207 tx height 1287022
2018/06/28 11:33:55.459210 tx height 1316917
2018/06/28 11:33:55.459214 tx height 1320430
2018/06/28 11:33:55.459218 tx height 0
2018/06/28 11:33:55.459222 tx height 1291926
2018/06/28 11:33:55.459226 tx height 1291926
2018/06/28 11:33:55.459231 Rollback db.  0 utxos lost
2018/06/28 11:33:55.459352 Added 2 headers OK.
2018/06/28 11:33:55.459378 got header tip height 1335736
2018/06/28 11:33:55.459983 get headers message has 18 header hashes, first one is 000000000000847058257d2fc0caf4ad04ac8886d947654f967e9010c42abaa2
2018/06/28 11:33:55.572999 got 0 headers, we're probably synced up
2018/06/28 11:33:55.573049 blockTip to 1335734 headerTip 1335736
Varunram commented 6 years ago

Looks like 1 block re-orgs do work fine, two block re-orgs seem to not:

2018/06/28 11:28:09.299412 reorg from height 1335639 to 1335640
2018/06/28 11:28:09.299425 TEMPCUR.BITS 469827583
2018/06/28 11:28:09.299435 TEMPCUR.BITS 469827583
2018/06/28 11:28:09.301285 HeightHandler: oh no, reorg!
2018/06/28 11:28:09.301330 Rollback height 1335638
2018/06/28 11:28:09.301356 tx height 1316917
2018/06/28 11:28:09.301365 tx height 1326486
2018/06/28 11:28:09.301370 tx height 1326486
2018/06/28 11:28:09.301375 tx height 0
2018/06/28 11:28:09.301380 tx height 1287022
2018/06/28 11:28:09.301384 tx height 1316917
2018/06/28 11:28:09.301389 tx height 1320430
2018/06/28 11:28:09.301393 tx height 0
2018/06/28 11:28:09.301398 tx height 1291926
2018/06/28 11:28:09.301402 tx height 1291926
2018/06/28 11:28:09.301407 Rollback db.  0 utxos lost
2018/06/28 11:28:09.301474 Added 2 headers OK.
2018/06/28 11:28:09.301491 got header tip height 1335640
adiabat commented 6 years ago

Fixed (hopefully) in #248