zcash / lightwalletd

Lightwalletd is a backend service that provides a bandwidth-efficient interface to the Zcash blockchain

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

lightwalletd block cache ahead of syncing zcashd height causes reorg fatal error

LarryRuane opened this issue · comments

This isn't a severe bug, and has an easy workaround.

I ran into this problem accidentally. My zcashd node is syncing, and I started lightwalletd. But its block cache is more recent than the height the zcashd is currently synced to. Lightwalletd died a few seconds after starting up:

{"app":"lightwalletd","level":"info","msg":"Got sapling height 419200 block height 1268622 chain main branchID e9ff75a6","time":"2021-07-23T11:13:46-06:00"}
{"app":"lightwalletd","level":"info","msg":"Found 905942 blocks in cache","time":"2021-07-23T11:13:54-06:00"}
{"app":"lightwalletd","level":"info","msg":"Ingestor waiting for block: 1325142","time":"2021-07-23T11:13:54-06:00"}
{"app":"lightwalletd","height":1325141,"level":"warning","msg":"REORG","phash":"0000000001f9bb7865b3a7fca01c9ab028f9bcd9b234e95b65af16b4f8ed5880","reorg":2,"time":"2021-07-23T11:13:56-06:00"}
{"app":"lightwalletd","height":1325140,"level":"warning","msg":"REORG","phash":"00000000028f23b51fd56baea2e784a05b270423f8c0503a0d5274d7589e92cd","reorg":3,"time":"2021-07-23T11:13:56-06:00"}
(...)
{"app":"lightwalletd","height":1325044,"level":"warning","msg":"REORG","phash":"00000000009dbcd4834eea887d3ef2f52fce12ff3d0d1bd2a636fbe0c8472472","reorg":99,"time":"2021-07-23T11:13:57-06:00"}
{"app":"lightwalletd","height":1325043,"level":"warning","msg":"REORG","phash":"0000000001a09c98b4bd4202cd64504f0a8d84178f45a2f560beb30221164b66","reorg":100,"time":"2021-07-23T11:13:57-06:00"}
{"app":"lightwalletd","level":"fatal","msg":"Reorg exceeded max of 100 blocks! Help!","time":"2021-07-23T11:13:58-06:00"}
Lightwalletd died with a Fatal error. Check logfile for details.

The problem is, lightwalletd thinks it's seeing a reorg, and since reorgs of more than 100 blocks are not allowed, it gives up. The best solution may be to simply remove the 100 block reorg limit -- this isn't something that lightwalletd needs to enforce since it's enforced by zcashd. But if we do that, we'll probably want to limit the amount of logging; currently, it prints a log message for each block that's be reorged out (as you can see).

The workaround is to wait for zcashd to finish syncing before starting lightwalletd. @adityapk00

Fixed by #363.