0x-mesh
0x-mesh copied to clipboard
Emit helpful error when db needs to be cleared
Context
When running Mesh with 0xorg/ganache-cli, I sometimes encounter an obscure blockWatcher
error. The underlying cause is that Mesh still has the old blocks stored, that are at a higher block height than the snapshot.
It would be nice to emit a helpful error recommending that the user deletes their db folder.
Steps to Reproduce
Please provide detailed steps for reproducing the issue.
It's hard to reproduce, but I first encountered it when restarting ganache without removing the db folder.
This might work:
- Run mesh + ganache:5.1.0 together (e.g. with docker) and persist the
db
folder from mesh - Stop the processes, update ganache to 6.0.0 and rerun without removing the
db
folder
Failure Logs
mesh_1_2553ba194d8f | {"error_string":"timed out waiting for first block to be processed by Mesh node. Check your backing Ethereum RPC endpoint","level":"error","msg":"core app exited with error","myPeerID":"16Uiu2HAmN6BkBp9mDZCDt2ptXBVa9Jb3dukTUGa8oumNBaZhNgzx","time":"2020-02-25T21:02:55Z"}
I think this was coming from this section of the code:
// If Mesh is not caught up with the latest block found via Ethereum RPC, ensure orderWatcher
// has processed at least one recent block before starting the P2P node and completing app start,
// so that Mesh does not validate any orders at outdated block heights
isCaughtUp := app.IsCaughtUpToLatestBlock(innerCtx)
if !isCaughtUp {
if err := app.orderWatcher.WaitForAtLeastOneBlockToBeProcessed(ctx); err != nil {
return err
}
}