zebra icon indicating copy to clipboard operation
zebra copied to clipboard

Add `zebrad migrate-from-zcashd` command

Open str4d opened this issue 6 months ago • 3 comments

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 zcashd saves 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 zcashd block 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.

str4d avatar Apr 29 '25 21:04 str4d

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.

oxarbitrage avatar May 02 '25 11:05 oxarbitrage

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.

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.

arya2 avatar May 02 '25 21:05 arya2

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.

arya2 avatar Jun 10 '25 22:06 arya2