-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'bat/shielded-sync' (#377)
Added shielded sync documentation
- Loading branch information
Showing
6 changed files
with
91 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
packages/docs/pages/users/shielded-accounts/shielded-sync.mdx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import { Callout } from 'nextra-theme-docs' | ||
|
||
# Shielded Sync | ||
|
||
In order to interact with the MASP, users need a local copy of all of the notes. This is | ||
necessary to create new notes with the correct zk-proofs. Additionally, it is the only way | ||
for a client to find out which notes are owned by the user, which is necessary for calculating balances. | ||
|
||
Shielded sync is the command that downloads and processes a local view of the MASP (up to | ||
a given block height) and then stores it locally in a `shielded context`. This command must be | ||
run periodically to stay in sync with the tip of the chain. | ||
|
||
## Running shielded sync | ||
|
||
The simplest way to run shielded sync is via the command: | ||
```bash copy | ||
namadac shielded-sync | ||
``` | ||
This assumes several things by default. It will look into the user's wallet and import any MASP | ||
keys into the shielded context. These will be the keys used to attempt to decrypt the downloaded | ||
MASP notes. Additional keys can be provided via: | ||
```bash copy | ||
namadac shielded-sync --spending-keys $SPENDING_KEY | ||
``` | ||
and / or | ||
```bash copy | ||
namadac shielded-sync --viewing-keys $VIEWING_KEY | ||
``` | ||
|
||
<Callout> | ||
The first time you wish to check the balance of a spending/viewing key, you must provide it to the shielded context with | ||
the `--spending-keys|--viewing-keys` argument. On subsequent runs, you can simply use `namadac shielded-sync`, as these | ||
keys will be stored in the shielded context. | ||
</Callout> | ||
|
||
Shielded sync also assumes by default that the user wishes to sync to the tip of the chain. If this is not | ||
the case, a maximal height to sync to can be provided: | ||
```bash copy | ||
namadac shielded-sync --to-height $BLOCKHEIGHT | ||
``` | ||
|
||
## Interrupting | ||
|
||
If the shielded context is sufficiently behind the tip of the chain, the amount of data to be downloaded | ||
and the computational load of processing it can be cumbersome. This is one reason why a user might | ||
wish to specify a maximal height to which to sync. | ||
|
||
Additionally, the user can interrupt shielded sync at anytime by pressing `CTRL-C` or similar stop | ||
command. Shielded sync will receive this signal and save its work before stopping. This avoids | ||
losing work and can be resumed the next time shielded sync is run. | ||
|
||
## Using a MASP indexer | ||
|
||
A MASP indexer can do a lot of the processing of MASP data and make it available to users via a | ||
web server that can handle large downloads and many requests. This is in contrast to syncing | ||
by calling the RPC endpoints of node operators. | ||
|
||
Thus, the preferred and most efficient way to run shielded sync is by using an indexer: | ||
```bash copy | ||
namadac shielded-sync --with-indexer $INDEXER_API_URL | ||
``` | ||
The api endpoint `$INDEXER_API_URL` will be a url to the indexer ending with `/api/v1`. | ||
|
||
## Recovering from data corruption | ||
|
||
If, for some reason, the shielded context gets corrupted and shielded sync cannot function correctly, | ||
a user can try to remove all local data and sync again from scratch. The shielded context is stored | ||
in the user's chain directory and the generated files have the following names: | ||
* `shielded.dat` | ||
* `shielded.tmp` | ||
* `speculative_shielded.dat` | ||
* `shielded_sync.cache` | ||
* `shielded_sync.cache.tmp` | ||
|
||
If these files are deleted, shielded sync can be run in order to resync from scratch. | ||
|
||
<Callout> | ||
Removing or modifying these files is not recommended and should only be done as a last resort. | ||
Also note that the user will need to provided the necessary viewing and spending keys to | ||
shielded sync again. | ||
</Callout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters