penumbra-zone / web

Apache License 2.0
10 stars 7 forks source link

Quick sync for freshly generated wallets #1278

Open turbocrime opened 2 weeks ago

turbocrime commented 2 weeks ago

If a user onboards prax with a passphrase, they may have existing activity on chain.

But if a user generates a new wallet in onboarding, there will be no activity on the chain, so the block processor can skip trial decryption until the present height.

This would greatly accelerate initial sync for many new users.

hdevalence commented 2 weeks ago

this is a great idea and would be a big ux boost. we'd need to figure out what data is necessary to store -- one thing that comes to mind is the SCT state, which would ideally be initialized with a bare root (as if the user had synced and then forgotten all internal nodes). maybe @plaidfinch would know if there's a way to initialize an SCT with just the root like that.

Valentine1898 commented 2 weeks ago

Theoretically, it is even possible not to scan with skip trial decryption, but to use a snapshot of view service data for the last epoch (if there will be a service that will provide these snapshots)

TalDerei commented 2 weeks ago

some relevant helper functions:

querying the latest block height const latestHeight = await this.querier.tendermint.latestBlockHeight();

fetching merkle root associated with the latest height let root = await this.querier.cnidarium.fetchRemoteRoot(latestHeight!);

fetching epoch index from compact block associated with latest height let epochIndex = this.querier.compactBlock.compactBlockRange(latestHeight).epochIndex

plaidfinch commented 1 day ago

The TCT cannot be initialized just as a bare root, or else no updates could be performed to it. It always needs to have a frontier. The smallest TCT is the one when an epoch has just ended, which contains only a path down from the root to an epoch root.