Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Quick sync for freshly generated wallets #1278

Closed
Tracked by #1376
turbocrime opened this issue Jun 11, 2024 · 7 comments
Closed
Tracked by #1376

Quick sync for freshly generated wallets #1278

turbocrime opened this issue Jun 11, 2024 · 7 comments
Assignees
Labels
performance Related to speed improvements sync V2 features required after mainnet

Comments

@turbocrime
Copy link
Contributor

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
Copy link
Member

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
Copy link
Contributor

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
Copy link
Contributor

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

@TalDerei TalDerei added the performance Related to speed improvements label Jun 12, 2024
@plaidfinch
Copy link

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.

@TalDerei
Copy link
Contributor

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.

would we need to implement penumbra-zone/penumbra#1082 and penumbra-zone/penumbra#1131?

@plaidfinch
Copy link

plaidfinch commented Jun 30, 2024 via email

@turbocrime
Copy link
Contributor Author

turbocrime commented Jul 8, 2024

more specifically

diff --git a/packages/wasm/crate/src/view_server.rs b/packages/wasm/crate/src/view_server.rs
index af5240690..ac1b83be3 100644
--- a/packages/wasm/crate/src/view_server.rs
+++ b/packages/wasm/crate/src/view_server.rs
@@ -111,7 +111,11 @@ impl ViewServer {
     /// Use `flush_updates()` to get the scan results
     /// Returns: `bool`
     #[wasm_bindgen]
-    pub async fn scan_block(&mut self, compact_block: &[u8]) -> WasmResult<bool> {
+    pub async fn scan_block(
+        &mut self,
+        compact_block: &[u8],
+        skip_trial_decrypt: bool,
+    ) -> WasmResult<bool> {
         utils::set_panic_hook();
 
         let block = CompactBlock::decode(compact_block)?;
@@ -123,7 +127,9 @@ impl ViewServer {
 
             match state_payload {
                 StatePayload::Note { note: payload, .. } => {
-                    match payload.trial_decrypt(&self.fvk) {
+                    match bool::then_some(!skip_trial_decrypt, payload.trial_decrypt(&self.fvk))
+                        .flatten()
+                    {
                         Some(note) => {
                             let note_position = self.sct.insert(Keep, payload.note_commitment)?;
 
@@ -159,7 +165,9 @@ impl ViewServer {
                     }
                 }
                 StatePayload::Swap { swap: payload, .. } => {
-                    match payload.trial_decrypt(&self.fvk) {
+                    match bool::then_some(!skip_trial_decrypt, payload.trial_decrypt(&self.fvk))
+                        .flatten()
+                    {
                         Some(swap) => {
                             let swap_position = self.sct.insert(Keep, payload.commitment)?;
                             let batch_data =

plus

  • onboarding save creation height
  • constructor params to block processor or call params on sync to indicate wallet creation height

should be enough to achieve some benefit

@TalDerei TalDerei added the sync label Jul 25, 2024
@TalDerei TalDerei self-assigned this Jul 27, 2024
@TalDerei TalDerei added the V2 features required after mainnet label Jul 27, 2024
@TalDerei TalDerei moved this to 🗄️ Backlog in Labs web Aug 16, 2024
@TalDerei TalDerei moved this from 🗄️ Backlog to 📝 Todo in Labs web Aug 16, 2024
@TalDerei TalDerei closed this as completed Sep 4, 2024
@github-project-automation github-project-automation bot moved this from 🗄️ Backlog to ✅ Done in Penumbra web Sep 4, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Labs web Sep 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Related to speed improvements sync V2 features required after mainnet
Projects
Archived in project
Development

No branches or pull requests

5 participants