BACKUP.md raw

chain-data backup

A synced light client holds the chain it verified: block headers, filter headers and compact filters. That is the expensive part of setting up a second instance or restoring one, and on mainnet the filters are 10 to 15 GB for both chains. A backup is how a user moves that work to another machine instead of repeating it.

what a backup is

A directory:

manifest.json
headers-00000001.nsbk
headers-00200001.nsbk
filter_headers-00000001.nsbk
filters-00000001.nsbk
...

payload length, payload. pkg/backup writes and reads it, and refuses a payload whose length disagrees with its records.

filter header, 64 bytes) and filters (height, block hash, filter hash, length, filter bytes).

records the anchor, the tip and the totals. Manifest.Validate refuses a backup with a hole, a chunk from another range, a wrong file name, or totals that do not add up. That matters more than it looks: a manifest that promises more than the directory holds is a restore that silently verifies less than the user thinks.

split a record. Nothing here is one 20 GB file, and nothing here needs one.

what a backup trusts

The anchor is the trust: a backup begins above the checkpoint the profile already carries, so restoring it is exactly as trusting as a first sync from that checkpoint. Inside that range nothing is trusted:

the store, by the same code the network sync uses;

be the stored header's;

So a hostile or damaged backup cannot make the wallet accept a chain it did not verify: the worst it can do is fail.

exporting

Export reads ranges straight out of the store: the same bytes the sync wrote, no re-encoding. The export is resumable by construction — it is a function of the store's verified tip, so a paused sync exports exactly what it verified.

importing

Import walks the chunks in ascending height per kind and refuses anything that does not continue the store it is going into. A fresh store with the profile's checkpoint accepts a backup whose anchor matches; a store that already has a tip accepts only the part above it, so restoring a backup twice is a no-op rather than a corruption.

the page

The page owns the files, because a worker cannot write to disk:

where that is unavailable), then pulls chunks from each chain's worker, computes each chunk's SHA-256 while writing it, and finally writes manifest.json.

every file against it, and feeds the chunks to the chain worker, which verifies them against the store as it goes.

buttons: a user who has to stop a multi-hour sync should be able to keep what it cost.

what is implemented

chunk from another range and totals that do not add up.

the filter export is bounded by bytes and always makes progress.

stored chain before storing it, with the same checks the network sync makes, and skip heights the store already holds so a restore is resumable and idempotent.

manifest, restore into a fresh store, compare every filter byte for byte, run a script match, and refuse an edited filter (both at the digest and at the commitment) and an edited header.

height and count, and MethodRestore answers how many records it applied. The byte budget is the caller's, so a page chooses a file size rather than inheriting one.

what is not implemented yet

The wallet worker's proxy for the two methods, and the page's file handling. Those are the next slices; docs/STATUS.md records them as gaps until they land.