-
Notifications
You must be signed in to change notification settings - Fork 893
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 shard tree and shard storage #26477
Conversation
9192b28
to
a3ccf60
Compare
2eb3bc5
to
2d67e9d
Compare
a3ccf60
to
284506d
Compare
2d67e9d
to
6f8de17
Compare
@@ -312,10 +312,14 @@ static_library("browser") { | |||
|
|||
if (enable_orchard) { | |||
sources += [ | |||
"zcash/orchard_shard_tree_delegate_impl.cc", |
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.
these really need to move into their own BUILD.gn file in zcash directory
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.
meaning all of the files here, not just the new ones
@@ -57,6 +70,17 @@ source_set("orchard_impl") { | |||
] | |||
} | |||
|
|||
source_set("shard_store") { | |||
visibility = [ ":*" ] | |||
sources = [ "cxx/src/shard_store.h" ] |
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.
we don't want to use cxx directories anymore and it's not clear to me why this would go somewhere other than the existing ochrard_impl
target. In a separate PR we should move all the files in orchard_impl
into an internal
directory
Also generally speaking you shouldn't create a target in one directory that includes files in a subdirectory, especially if those are the only files it includes.
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.
it's not clear to me why this would go somewhere other than the existing ochrard_impl target.
There will be cycle dependency otherwise rust_lib depends on shard_store.h and orchard_impl depends on rust_lib
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.
I would use qr_code_generator
as an example to follow for this which would probably mean shard_store.h moves into this directory.
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.
it's a bit confusing that this directory is called rust
and also contains cpp files, but we should probably rename it in a separate PR
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.
Moved to the zcash/rust directory
components/brave_wallet/browser/zcash/rust/orchard_shard_tree_impl.cc
Outdated
Show resolved
Hide resolved
components/brave_wallet/browser/zcash/rust/cxx/src/shard_store.h
Outdated
Show resolved
Hide resolved
// Note witness is a Merkle path in the Orchard commitment tree from the | ||
// note to the tree root according some selected anchor(selected right border in | ||
// the commitment tree). | ||
struct OrchardNoteWitness { |
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.
This entire file is a problem, we should not just be dumping a bunch of structs in here like this. You don't necessarily need a file for each, but they should be organized in some sensible way because this file is a mess
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.
it seems like these probably belong with https://github.com/brave/brave-core/pull/26477/files#r1840956570
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.
Moved
std::vector<uint8_t> frontier; | ||
}; | ||
|
||
class OrchardShardTreeDelegate { |
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.
This definitely should go in its own file
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.
Moved to separate file
3964309
to
9e7ed49
Compare
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.
we'll follow-up as discussed in DM
Resolves brave/brave-browser#39314 Rename ShardStoreContext Switch to using class instead of functions in lib.rs Get rid of clone in impl_result::unwrap Review fix #1 Review fix #2 Review fix#3 Use result wrappers for cpp->rust callbacks Add macro for rust result wrappers Get rid of OrchardShardTreeDelegateImpl Rename ShardTreeDelegate Merge OrchardShardTreeManager to ZCashOrchardSyncState Remove OrchardShardTreeDelegate Review fix Review fix Rename ZCashOrchardStorage Extract CxxOrchardShardTreeDelegate to the separate file Rename CXX generated structs Remove some rust-wrapper impl files Rename rust wrapper types Fix presubmit Rename rust types Review fix Review fix Review fix Rust-related types renaming Add more comments Review fix
638fc9f
to
3be9e86
Compare
[puLL-Merge] - brave/brave-core@26477 DescriptionThis PR makes significant changes to the Brave Wallet's ZCash implementation, particularly focusing on the Orchard protocol. It introduces new structures and classes for handling Orchard-specific operations, refactors existing code, and improves the overall architecture of the ZCash wallet component. Possible Issues
Security Hotspots
ChangesChanges
sequenceDiagram
participant User
participant ZCashWalletService
participant ZCashShieldSyncService
participant OrchardSyncState
participant OrchardBlockScanner
participant OrchardStorage
User->>ZCashWalletService: Request balance
ZCashWalletService->>ZCashShieldSyncService: Start syncing
ZCashShieldSyncService->>OrchardSyncState: GetAccountMeta
OrchardSyncState->>OrchardStorage: Fetch account data
OrchardStorage-->>OrchardSyncState: Return account data
OrchardSyncState-->>ZCashShieldSyncService: Return account meta
ZCashShieldSyncService->>OrchardBlockScanner: ScanBlocks
OrchardBlockScanner->>OrchardSyncState: ApplyScanResults
OrchardSyncState->>OrchardStorage: Update notes and state
OrchardStorage-->>OrchardSyncState: Confirm update
OrchardSyncState-->>ZCashShieldSyncService: Return updated state
ZCashShieldSyncService-->>ZCashWalletService: Return balance
ZCashWalletService-->>User: Display balance
|
78df8ea
to
6617615
Compare
Released in v1.75.101 |
Resolves brave/brave-browser#39314
Crate pr : #26966
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: