neo-go icon indicating copy to clipboard operation
neo-go copied to clipboard

improve feedback when using wrong file to restore db from

Open ixje opened this issue 7 months ago • 1 comments

Is your feature request related to a problem? Please describe.

I wanted to restore a database using one of the files from https://sync.ngd.network/ Since they "conveniently" call all their files chain.0.acc I accidentally renamed the mainnet dump to t5.bin. While this is obviously my fault I got no clear feedback that I was trying to restore from an incorrect dump file.

./bin/neo-go db restore -t -i t5.bin --incremental
2024-06-29T10:29:33.014+0200	INFO	MaxValidUntilBlockIncrement is not set or wrong, using default value	{"MaxValidUntilBlockIncrement": 5760}
2024-06-29T10:29:33.015+0200	INFO	no storage version found! creating genesis block
2024-06-29T10:29:33.015+0200	INFO	starting service	{"service": "Prometheus", "endpoint": ":2112"}
2024-06-29T10:29:33.015+0200	INFO	service hasn't started since it's disabled	{"service": "Pprof"}
2024-06-29T10:29:33.015+0200	INFO	initialize restore	{"start": 0, "height": 0, "skip": 0, "count": 5607836}
2024-06-29T10:29:33.016+0200	INFO	shutting down service	{"service": "Prometheus", "endpoint": "[::]:2112"}
2024-06-29T10:29:33.018+0200	INFO	persisted to disk	{"blocks": 0, "keys": 116, "headerHeight": 0, "blockHeight": 0, "took": "2.244293ms"}
failed to add block 1: previous header was not found: key not found

Now that I understand the mistake the error actually makes sense (for someone with a bit more in-depth knowledge) but I think we can improve upon this for the average user.

Describe the solution you'd like

Extend error message. I think we could at least say something along the lines of

Are you sure this dump is for the right network?

Ideally we would say something like

failed trying to restore dump file of network dump_network_magic to database of network config_network_magic. Networks must match"

Describe alternatives you've considered

Modify the dump format to include a header that includes the network magic. Requires the C# side to follow and breaks backwards compatibility.

ixje avatar Jun 29 '24 08:06 ixje