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

[Zcash] Add shardtree crate #25092

Closed
wants to merge 1 commit into from
Closed

[Zcash] Add shardtree crate #25092

wants to merge 1 commit into from

Conversation

cypt4
Copy link
Collaborator

@cypt4 cypt4 commented Aug 12, 2024

Resolves brave/brave-browser#40408
Adds shardtree crate + zcash_client_backend part which is used for shard tree seriazation ( https://github.com/brave/librustzcash/tree/zcash_client_backend_for_shielding )

Audit : https://github.com/brave/reviews/issues/1724

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@cypt4 cypt4 requested review from a team and bridiver as code owners August 12, 2024 17:29
@github-actions github-actions bot added CI/run-audit-deps Check for known npm/cargo vulnerabilities (audit_deps) feature/web3/wallet feature/web3/wallet/core labels Aug 12, 2024
@brave-builds
Copy link
Collaborator

A Storybook has been deployed to preview UI for the latest push

crate_name = "bitflags"
epoch = "2"
crate_type = "rlib"
crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/bitflags-2.6.0/src/lib.rs"
Copy link
Contributor

Choose a reason for hiding this comment

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

bitflags v2.6.0 is already vendored in chromium. You should be able to use that version instead. See //brave/third_party/rust/base64/v0_13/BUILD.gn for a forwarding example.

Copy link
Member

@fmarier fmarier left a comment

Choose a reason for hiding this comment

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

script/brave_license_helper.py change 👍

@@ -1,7 +1,7 @@
# Copyright (c) 2019 The Brave Authors. All rights reserved.
# Copyright (c) 2016 The Brave Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

@fmarier can you take a look at the changes happening here?

Copy link
Member

Choose a reason for hiding this comment

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

Hm, that's a bit weird. 2019 is the correct date.

Suggested change
# Copyright (c) 2016 The Brave Authors. All rights reserved.
# Copyright (c) 2019 The Brave Authors. All rights reserved.

@@ -1,7 +1,7 @@
# Copyright (c) 2019 The Brave Authors. All rights reserved.
# Copyright (c) 2016 The Brave Authors. All rights reserved.
Copy link
Member

Choose a reason for hiding this comment

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

Hm, that's a bit weird. 2019 is the correct date.

Suggested change
# Copyright (c) 2016 The Brave Authors. All rights reserved.
# Copyright (c) 2019 The Brave Authors. All rights reserved.

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this file,
# You can obtain one at https://mozilla.org/MPL/2.0/. */
# You can obtain one at https://mozilla.org/MPL/2.0/.
Copy link
Member

Choose a reason for hiding this comment

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

That's fine.

Copy link
Member

@kdenhartog kdenhartog left a comment

Choose a reason for hiding this comment

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

I took a dig through this dependency and not overly concerned with it. However there are two things that I think we should consider here:

  1. Reducing the usage of unwraps as there's quite a few and each is going to have to be individually reviewed to make sure it won't lead to browser crashes
  2. It would be useful to get cargo audit running in their CI pipeline to automatically detect reported vulnerabilities in their dependencies

Other than that, I'm not overly concerned with this dependency

// construct the subtree and cap based on the frontier containing the
// witnessed position
let (past_subtree, past_supertree) = self.insert_frontier_nodes::<C>(
witness.tree().to_frontier().take().unwrap(),
Copy link
Member

Choose a reason for hiding this comment

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

I'm surprised at the number of unwrap fn calls in this library that aren't in tests. From what I'm seeing with a crude search is 22 instances of calls to unwrap that are not in tests. This is concerning that we're going to introduce unintentional panics which could crash the browser unless we can verify these code paths won't be hit.

I know previously we've accepted certain instances in limited circumstances, but this is a lot more than what we've brought in previously. Could we request that they update this to reduce our risk of crashes?

@cypt4 cypt4 closed this Nov 11, 2024
@cypt4 cypt4 mentioned this pull request Dec 10, 2024
24 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CI/run-audit-deps Check for known npm/cargo vulnerabilities (audit_deps) feature/web3/wallet/core feature/web3/wallet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ZCash] Add shardtree crate
5 participants