Skip to content

refactor(rust-client): make NTL and chain syncing concurrent - #2453

Open
ricomateo wants to merge 37 commits into
nextfrom
ricomateo-concurrent-ntl-chain-sync
Open

refactor(rust-client): make NTL and chain syncing concurrent#2453
ricomateo wants to merge 37 commits into
nextfrom
ricomateo-concurrent-ntl-chain-sync

Conversation

@ricomateo

@ricomateo ricomateo commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Refactors Client::sync_state so the network fetching phase of the NTL and chain sync run concurrently.
This reduces the syncing time by ~25%, according to some benchmarks performed against devnet, syncing the client with 6 imported accounts.

In order to make the NTL and chain fetching concurrent, both syncs are split into a fetch phase (which makes the network requests to the RPC and NTL) and an apply phase (which applies the sync updates to the store). Client::sync_state then runs the two fetch phases under try_join! and applies the changes to the store afterwards, instead of running a full note transport sync before the chain sync.

It also adds a check for the nullifiers of the NTL delivered notes (closes #2422).

Closes #2361

@ricomateo ricomateo changed the title refactor(rust-client): split both syncs into fetch and apply phases refactor(rust-client): make NTL and on-chain syncing concurrent Aug 26, 2026
@ricomateo ricomateo changed the title refactor(rust-client): make NTL and on-chain syncing concurrent refactor(rust-client): make NTL and chain syncing concurrent Aug 31, 2026
@ricomateo
ricomateo marked this pull request as ready for review August 31, 2026 12:47
Comment thread crates/rust-client/src/note/import.rs Outdated
Comment thread crates/rust-client/src/note/import.rs
Comment thread crates/rust-client/src/note/import.rs
///
/// Covers the two node calls that depend on nothing but the sync input:
/// 1. Fetch sync data from the node (MMR delta, note inclusions, transactions).
/// 2. Update account states (fetch updated public accounts, flag mismatched private ones).

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This now sounds like something that should be done in the apply phase

@ricomateo ricomateo Sep 1, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved the apply_superseded_account_state call to the apply phase here 90ce893.
The derive_account_commitments step cannot be moved since it is required by the account_state_sync call, which performs RPC calls to the node.

Comment on lines +465 to +468
assert!(
note_blocks_awaiting_screening.is_empty(),
"note blocks must be screened before the update is built"
);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a check, not an assertion.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replaced the assertion with an error here d24f669

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants