-
Notifications
You must be signed in to change notification settings - Fork 895
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
[ZCash] Implement ShardTree sync process #27255
base: master
Are you sure you want to change the base?
Conversation
[puLL-Merge] - brave/brave-core@27255 DescriptionThis pull request implements significant changes to the Brave Wallet's ZCash functionality, particularly focusing on enhancing the Orchard protocol support and improving the shield sync process. The changes include new tasks for batch scanning blocks, verifying chain state, and managing sync operations more efficiently. Possible Issues
Security Hotspots
ChangesChanges
sequenceDiagram
participant User
participant ZCashWalletService
participant ZCashScanBlocksTask
participant ZCashBlocksBatchScanTask
participant ZCashVerifyChainStateTask
participant OrchardSyncState
participant ZCashRpc
User->>ZCashWalletService: StartShieldSync
ZCashWalletService->>ZCashVerifyChainStateTask: VerifyChainState
ZCashVerifyChainStateTask->>ZCashRpc: GetLatestBlock
ZCashRpc-->>ZCashVerifyChainStateTask: BlockInfo
ZCashVerifyChainStateTask->>OrchardSyncState: GetAccountMeta
OrchardSyncState-->>ZCashVerifyChainStateTask: AccountMeta
ZCashVerifyChainStateTask->>ZCashRpc: GetTreeState
ZCashRpc-->>ZCashVerifyChainStateTask: TreeState
ZCashVerifyChainStateTask-->>ZCashWalletService: ChainStateVerified
ZCashWalletService->>ZCashScanBlocksTask: StartBlockScanning
loop For each block range
ZCashScanBlocksTask->>ZCashBlocksBatchScanTask: ScanRange
ZCashBlocksBatchScanTask->>ZCashRpc: GetCompactBlocks
ZCashRpc-->>ZCashBlocksBatchScanTask: CompactBlocks
ZCashBlocksBatchScanTask->>OrchardSyncState: ApplyScanResults
OrchardSyncState-->>ZCashBlocksBatchScanTask: ScanResultsApplied
ZCashBlocksBatchScanTask-->>ZCashScanBlocksTask: RangeScanned
end
ZCashScanBlocksTask-->>ZCashWalletService: ScanCompleted
ZCashWalletService-->>User: SyncCompleted
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ Wallet Front-end
A Storybook has been deployed to preview UI for the latest push |
Part of #27018
Implements shard tree state sync process.
Entry point for the sync process is the per-account ZCashShieldSyncService class.
Sync process includes:
Verifying chain state. In some cases chain reorg may happen so we need to check whether latest scanned block hash hasn't been changed. Otherwise we need to clean OrchardStorage to remove notes, nullifiers and commitments that are not valid.
Preparing a set of scan ranges to scan. Each scan range ends with updating of OrchardSyncState with the discovered data.
Scanning ranges one-by-one. This includes reading compact blocks from the gRPC node and extracting related incoming notes and nullifiers for spends along with a set of commitment tree leafs to be inserted to the shard tree in the future. Extracting is done on a separate sequence. This is done using OrchardBlockScanner class.
Inserting extracted leafs to the shard tree(OrchardSyncState::ApplyScanResults).
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: