zebra
zebra copied to clipboard
Add `zebrad migrate-from-zcashd` command
Motivation
If a user already has a zcashd node, they should be able to use its local block data to bootstrap a Zebra node, instead of requiring a fresh download.
Solution
This PR adds a command that parses the blkNNNNN.dat files from a zcashd datadir, and replays them to the Zebra state as if it just received them from the network.
Tests
Currently WIP, tested with my local zcashd node and it doesn't work due to Zebra not implementing large parts of the historic Zcash protocol spec.
Specifications & References
Follow-up Work
Needs advice on how to alter Zebra to enable this. We either need:
- some way to alter Zebra so we can leverage its most-work chain-following logic while skipping all validation for old blocks in a way that also ensures it never persists orphan blocks (because
zcashdsaves all blocks as-received, even if they are later orphaned) or invalid blocks to state (which can exist in the block files on disk, if they were individually valid but contextually invalid). - a LevelDB dependency (which would enable Zebra to read the
zcashdblock index and directly find the main chain blocks, ignoring orphans.
PR Checklist
- [ ] The PR name is suitable for the release notes.
- [ ] The solution is tested.
- [ ] The documentation is up to date.
Note: During the Arborist call, there was a suggestion to move this code to the zebra-utils crate as a new binary instead of a new zebrad command.
Note: During the Arborist call, there was a suggestion to move this code to the
zebra-utilscrate as a new binary instead of a new zebrad command.
It would be nice to avoid adding a dependency to zebrad, especially one like levelsdb, but if that can be avoided, having a command in zebrad seems like a better UX while needing fewer modifications.
We need to check that zebra's lookahead limit is at least as high as the one in zcashd so that it can handle as many unordered blocks as can be expected.
Alternatively, we could try, at least partially, sorting them in the command. Credits to @str4d for the idea.
I'll make one of these changes.