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

Add shardtree crate #26966

Merged
merged 3 commits into from
Dec 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ deps = {
"url": "https://github.com/ronaldoussoren/macholib.git@36a6777ccd0891c5d1b44ba885573d7c90740015",
"condition": "checkout_mac",
},
"components/brave_wallet/browser/zcash/rust/librustzcash/src": "https://github.com/brave/librustzcash.git@4d44f5dc3429dce7df37359b8b3c4716807770ea",
"components/brave_wallet/browser/zcash/rust/librustzcash/src": "https://github.com/brave/librustzcash.git@127aacc83dc9ed12fc38c3c7f5b52f7f51011e4d", # v2
}

recursedeps = [
Expand Down
2 changes: 2 additions & 0 deletions components/brave_wallet/browser/zcash/rust/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,15 @@ rust_static_library("rust_lib") {
cxx_bindings = [ "lib.rs" ]

deps = [
"librustzcash:zcash_client_backend",
"librustzcash:zcash_primitives",
"//brave/components/brave_wallet/rust:rust_lib",
"//brave/third_party/rust/incrementalmerkletree/v0_5:lib",
"//brave/third_party/rust/memuse/v0_2:lib",
"//brave/third_party/rust/nonempty/v0_7:lib",
"//brave/third_party/rust/orchard/v0_8:lib",
"//brave/third_party/rust/rand/v0_8:lib",
"//brave/third_party/rust/shardtree/v0_3:lib",
"//brave/third_party/rust/zcash_note_encryption/v0_4:lib",
"//third_party/rust/byteorder/v1:lib",
]
Expand Down
4 changes: 3 additions & 1 deletion components/brave_wallet/browser/zcash/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ cxx = { version = "1" }
orchard = { version = "0.8.0", default-features = false }
rand = "0.8"
zcash_primitives = { version = "0.15.1", default-features = false }
zcash_note_encryption = "0.4"
zcash_note_encryption = "0.4"
zcash_client_backend = { version = "0.12.1", default-features = false }
shardtree = { version="0.3.2", features=["legacy-api"] }

[lib]
name = "zcash"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ rust_static_library("zcash_protocol") {
}

rust_static_library("zcash_encoding") {
visibility = [ ":zcash_primitives" ]
visibility = [
":zcash_client_backend",
":zcash_primitives",
]
crate_name = "zcash_encoding"
crate_root = "src/components/zcash_encoding/src/lib.rs"
sources = [ "src/components/zcash_encoding/src/lib.rs" ]
Expand All @@ -36,6 +39,7 @@ rust_static_library("zcash_encoding") {

rust_static_library("zcash_primitives") {
visibility = [
":zcash_client_backend",
"//brave/components/brave_wallet/browser/zcash/rust:rust_lib",
"//brave/components/brave_wallet/browser/zcash/rust:rust_lib_cxx_generated",
]
Expand All @@ -58,3 +62,23 @@ rust_static_library("zcash_primitives") {
"//third_party/rust/byteorder/v1:lib",
]
}

rust_static_library("zcash_client_backend") {
visibility = [
"//brave/components/brave_wallet/browser/zcash/rust:rust_lib",
"//brave/components/brave_wallet/browser/zcash/rust:rust_lib_cxx_generated",
]
crate_name = "zcash_client_backend"
crate_root = "src/zcash_client_backend/src/lib.rs"
sources = [
"src/zcash_client_backend/src/lib.rs",
"src/zcash_client_backend/src/serialization.rs",
"src/zcash_client_backend/src/serialization/shardtree.rs",
]
deps = [
":zcash_encoding",
":zcash_primitives",
"//brave/third_party/rust/byteorder/v1:lib",
"//brave/third_party/rust/shardtree/v0_3:lib",
]
}
3 changes: 2 additions & 1 deletion script/brave_license_helper.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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/.

import os
import re
Expand Down Expand Up @@ -60,6 +60,7 @@ def AddBraveCredits(root, prune_paths, special_cases, prune_dirs,
os.path.join('brave', 'third_party', 'rust', 'anyhow'),
os.path.join('brave', 'third_party', 'rust', 'base64'),
os.path.join('brave', 'third_party', 'rust', 'bitflags'),
os.path.join('brave', 'third_party', 'rust', 'bitflags', 'v2'),
os.path.join('brave', 'third_party', 'rust', 'byteorder', 'v1'),
os.path.join('brave', 'third_party', 'rust', 'cfg_if'),
os.path.join('brave', 'third_party', 'rust', 'cxx'),
Expand Down
23 changes: 23 additions & 0 deletions third_party/rust/chromium_crates_io/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions third_party/rust/chromium_crates_io/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -242,3 +242,8 @@ package = "zerocopy"
[patch.crates-io.zerocopy_derive_v0_7]
path = "../../../../third_party/rust/chromium_crates_io/vendor/zerocopy-derive-0.7.35"
package = "zerocopy-derive"

[patch.crates-io.zcash_client_backend_v0_12]
path = "../../../components/brave_wallet/browser/zcash/rust/librustzcash/src/zcash_client_backend"
package = "zcash_client_backend"

3 changes: 3 additions & 0 deletions third_party/rust/chromium_crates_io/gnrt_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -453,3 +453,6 @@ license_files = ['../../../../../common/licenses/Apache-2.0']

[crate.zcash_protocol]
license_files = ['../../../../../common/licenses/Apache-2.0']

[crate.zcash_client_backend]
license_files = ['../../../../../common/licenses/Apache-2.0']
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"files":{}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"git": {
"sha1": "63cbc0a223030838a9f68bd837da6f06497324aa"
},
"path_in_vcs": "shardtree"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to Rust's notion of
[Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Unreleased

## [0.3.2] - 2024-12-09
- Replaces `unwrap` calls with `expect` calls & documents panics.

## [0.3.1] - 2024-04-03

### Fixed
- Fixes a missing transitive dependency when using the `test-dependencies` feature flag.

## [0.3.0] - 2024-03-25

### Added
- `ShardTree::{store, store_mut}`
- `ShardTree::insert_frontier`

### Changed
- `shardtree::error::InsertionError` has new variant `MarkedRetentionInvalid`

## [0.2.0] - 2023-11-07

### Added
- `ShardTree::{root_at_checkpoint_id, root_at_checkpoint_id_caching}`
- `ShardTree::{witness_at_checkpoint_id, witness_at_checkpoint_id_caching}`

### Changed
- `ShardTree::root_at_checkpoint` and `ShardTree::root_at_checkpoint_caching` have
been renamed to `root_at_checkpoint_depth` and `root_at_checkpoint_depth_caching`,
respectively.
- `ShardTree::witness` and `ShardTree::witness_caching` have
been renamed to `witness_at_checkpoint_depth` and `witness_at_checkpoint_depth_caching`,
respectively.

## [0.1.0] - 2023-09-08

Initial release!
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.

[package]
edition = "2021"
rust-version = "1.60"
name = "shardtree"
version = "0.3.2"
authors = ["Kris Nuttycombe <[email protected]>"]
build = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
description = "A space-efficient Merkle tree with witnessing of marked leaves, checkpointing & state restoration."
homepage = "https://github.com/zcash/incrementalmerkletree"
readme = "README.md"
categories = [
"algorithms",
"data-structures",
]
license = "MIT OR Apache-2.0"
repository = "https://github.com/zcash/incrementalmerkletree"
resolver = "1"

[package.metadata.docs.rs]
all-features = true
rustdoc-args = [
"--cfg",
"docsrs",
]

[lib]
name = "shardtree"
path = "src/lib.rs"

[dependencies.assert_matches]
version = "1.5"
optional = true

[dependencies.bitflags]
version = "2"

[dependencies.either]
version = "1.8"

[dependencies.incrementalmerkletree]
version = "0.5"

[dependencies.proptest]
version = "1.0.0"
optional = true

[dependencies.tracing]
version = "0.1"

[dev-dependencies.assert_matches]
version = "1.5"

[dev-dependencies.incrementalmerkletree]
version = "0.5"
features = ["test-dependencies"]

[dev-dependencies.proptest]
version = "1.0.0"

[features]
legacy-api = ["incrementalmerkletree/legacy-api"]
test-dependencies = [
"proptest",
"assert_matches",
"incrementalmerkletree/test-dependencies",
]

[target."cfg(unix)".dev-dependencies.tempfile]
version = ">=3, <3.7.0"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading