From 68302586ea78c387c2ba21438bf98e0333b4bdfb Mon Sep 17 00:00:00 2001 From: oisupov Date: Wed, 11 Dec 2024 00:05:55 +0400 Subject: [PATCH] Update shardtree to 0.3.2 --- DEPS | 2 +- .../browser/zcash/rust/Cargo.toml | 2 +- .../rust/chromium_crates_io/Cargo.lock | 2 +- .../shardtree-0.3.1/.cargo_vcs_info.json | 6 --- .../.cargo-checksum.json | 0 .../shardtree-0.3.2/.cargo_vcs_info.json | 6 +++ .../CHANGELOG.md | 3 ++ .../Cargo.toml | 13 ++++- .../Cargo.toml.orig | 2 +- .../LICENSE-APACHE | 0 .../LICENSE-MIT | 0 .../README.md | 0 .../proptest-regressions/lib.txt | 0 .../src/batch.rs | 0 .../src/error.rs | 0 .../src/legacy.rs | 10 +++- .../src/lib.rs | 17 +++++-- .../src/prunable.rs | 51 ++++++++++++++----- .../src/store.rs | 0 .../src/store/caching.rs | 27 +++++++--- .../src/store/memory.rs | 0 .../src/testing.rs | 0 .../src/tree.rs | 15 ++++-- third_party/rust/shardtree/v0_3/BUILD.gn | 31 ++++++----- .../rust/shardtree/v0_3/README.chromium | 13 ++--- .../v0_12/README.chromium | 7 +-- 26 files changed, 145 insertions(+), 62 deletions(-) delete mode 100644 third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/.cargo_vcs_info.json rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/.cargo-checksum.json (100%) create mode 100644 third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/.cargo_vcs_info.json rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/CHANGELOG.md (92%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/Cargo.toml (90%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/Cargo.toml.orig (98%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/LICENSE-APACHE (100%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/LICENSE-MIT (100%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/README.md (100%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/proptest-regressions/lib.txt (100%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/batch.rs (100%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/error.rs (100%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/legacy.rs (97%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/lib.rs (98%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/prunable.rs (95%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/store.rs (100%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/store/caching.rs (97%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/store/memory.rs (100%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/testing.rs (100%) rename third_party/rust/chromium_crates_io/vendor/{shardtree-0.3.1 => shardtree-0.3.2}/src/tree.rs (95%) diff --git a/DEPS b/DEPS index 855d798f27d6..cba10dd75859 100644 --- a/DEPS +++ b/DEPS @@ -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@5b496c6ead39a0e0f32337f9b6bbf63e7ce92830", + "components/brave_wallet/browser/zcash/rust/librustzcash/src": "https://github.com/brave/librustzcash.git@127aacc83dc9ed12fc38c3c7f5b52f7f51011e4d", } recursedeps = [ diff --git a/components/brave_wallet/browser/zcash/rust/Cargo.toml b/components/brave_wallet/browser/zcash/rust/Cargo.toml index cb3ad11d2952..3cbfc762f8fb 100644 --- a/components/brave_wallet/browser/zcash/rust/Cargo.toml +++ b/components/brave_wallet/browser/zcash/rust/Cargo.toml @@ -12,7 +12,7 @@ rand = "0.8" zcash_primitives = { version = "0.15.1", default-features = false } zcash_note_encryption = "0.4" zcash_client_backend = { version = "0.12.1", default-features = false } -shardtree = { version="0.3", features=["legacy-api"] } +shardtree = { version="0.3.2", features=["legacy-api"] } [lib] name = "zcash" diff --git a/third_party/rust/chromium_crates_io/Cargo.lock b/third_party/rust/chromium_crates_io/Cargo.lock index c9077f1540c2..a2b14d1794e7 100644 --- a/third_party/rust/chromium_crates_io/Cargo.lock +++ b/third_party/rust/chromium_crates_io/Cargo.lock @@ -2240,7 +2240,7 @@ dependencies = [ [[package]] name = "shardtree" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 2.6.0", diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/.cargo_vcs_info.json deleted file mode 100644 index 3696c4bd55ee..000000000000 --- a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/.cargo_vcs_info.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "git": { - "sha1": "7c862c16b31aa3883fcbb61f30af9930eb01cc0b" - }, - "path_in_vcs": "shardtree" -} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/.cargo-checksum.json b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/.cargo-checksum.json similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/.cargo-checksum.json rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/.cargo-checksum.json diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/.cargo_vcs_info.json b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/.cargo_vcs_info.json new file mode 100644 index 000000000000..ca98603f04e9 --- /dev/null +++ b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/.cargo_vcs_info.json @@ -0,0 +1,6 @@ +{ + "git": { + "sha1": "63cbc0a223030838a9f68bd837da6f06497324aa" + }, + "path_in_vcs": "shardtree" +} \ No newline at end of file diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/CHANGELOG.md b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/CHANGELOG.md similarity index 92% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/CHANGELOG.md rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/CHANGELOG.md index ec396f469eb3..766a6a414b0b 100644 --- a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/CHANGELOG.md +++ b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to Rust's notion of ## Unreleased +## [0.3.2] - 2024-12-09 +- Replaces `unwrap` calls with `expect` calls & documents panics. + ## [0.3.1] - 2024-04-03 ### Fixed diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/Cargo.toml b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/Cargo.toml similarity index 90% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/Cargo.toml rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/Cargo.toml index f9b913eaf58d..a73573623f76 100644 --- a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/Cargo.toml +++ b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/Cargo.toml @@ -13,16 +13,23 @@ edition = "2021" rust-version = "1.60" name = "shardtree" -version = "0.3.1" +version = "0.3.2" authors = ["Kris Nuttycombe "] +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 @@ -31,6 +38,10 @@ rustdoc-args = [ "docsrs", ] +[lib] +name = "shardtree" +path = "src/lib.rs" + [dependencies.assert_matches] version = "1.5" optional = true diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/Cargo.toml.orig b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/Cargo.toml.orig similarity index 98% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/Cargo.toml.orig rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/Cargo.toml.orig index 6bae130f4380..ffdaeefbb9dc 100644 --- a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/Cargo.toml.orig +++ b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/Cargo.toml.orig @@ -1,6 +1,6 @@ [package] name = "shardtree" -version = "0.3.1" +version = "0.3.2" authors = [ "Kris Nuttycombe ", ] diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/LICENSE-APACHE b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/LICENSE-APACHE similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/LICENSE-APACHE rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/LICENSE-APACHE diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/LICENSE-MIT b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/LICENSE-MIT similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/LICENSE-MIT rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/LICENSE-MIT diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/README.md b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/README.md similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/README.md rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/README.md diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/proptest-regressions/lib.txt b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/proptest-regressions/lib.txt similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/proptest-regressions/lib.txt rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/proptest-regressions/lib.txt diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/batch.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/batch.rs similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/batch.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/batch.rs diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/error.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/error.rs similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/error.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/error.rs diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/legacy.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/legacy.rs similarity index 97% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/legacy.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/legacy.rs index 39570619c4fd..8db0442d623d 100644 --- a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/legacy.rs +++ b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/legacy.rs @@ -167,6 +167,10 @@ impl LocatedPrunableTree { /// /// Returns a copy of this tree updated to include the witness nodes, any partial supertree that is /// produced from nodes "higher" in the witness tree + /// + /// # Panics + /// + /// Panics if `witness` corresponds to the empty tree. pub fn insert_witness_nodes( &self, witness: IncrementalWitness, @@ -177,7 +181,11 @@ impl LocatedPrunableTree { // construct the subtree and cap based on the frontier containing the // witnessed position let (past_subtree, past_supertree) = self.insert_frontier_nodes::( - witness.tree().to_frontier().take().unwrap(), + witness + .tree() + .to_frontier() + .take() + .expect("IncrementalWitness must not be created from the empty tree."), &Retention::Marked, )?; diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/lib.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/lib.rs similarity index 98% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/lib.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/lib.rs index 1f4510af26a6..ce5686e8e6e9 100644 --- a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/lib.rs +++ b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/lib.rs @@ -391,14 +391,21 @@ impl< } /// Adds a checkpoint at the rightmost leaf state of the tree. + /// + /// # Panics + /// + /// Panics if `root` represents a parent node but `root_addr` is a depth-0 leaf address. pub fn checkpoint(&mut self, checkpoint_id: C) -> Result> { + /// Pre-condition: `root_addr` must be the address of `root`. fn go( root_addr: Address, root: &PrunableTree, ) -> Option<(PrunableTree, Position)> { match root { Tree(Node::Parent { ann, left, right }) => { - let (l_addr, r_addr) = root_addr.children().unwrap(); + let (l_addr, r_addr) = root_addr + .children() + .expect("has children because we checked `root` is a parent"); go(r_addr, right).map_or_else( || { go(l_addr, left).map(|(new_left, pos)| { @@ -750,7 +757,10 @@ impl< // Compute the roots of the left and right children and hash them together. // We skip computation in any subtrees that will not have data included in // the final result. - let (l_addr, r_addr) = cap.root_addr.children().unwrap(); + let (l_addr, r_addr) = cap + .root_addr + .children() + .expect("has children because we checked `cap.root` is a parent"); let l_result = if r_addr.contains(&target_addr) { None } else { @@ -1103,7 +1113,8 @@ impl< cur_addr = cur_addr.parent(); } - Ok(MerklePath::from_parts(witness, position).unwrap()) + Ok(MerklePath::from_parts(witness, position) + .expect("witness has length DEPTH because we extended it to the root")) } fn witness_internal( diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/prunable.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/prunable.rs similarity index 95% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/prunable.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/prunable.rs index 673a80116c56..31d56fbc40c2 100644 --- a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/prunable.rs +++ b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/prunable.rs @@ -120,7 +120,9 @@ impl PrunableTree { || { // Compute the roots of the left and right children and hash them // together. - let (l_addr, r_addr) = root_addr.children().unwrap(); + let (l_addr, r_addr) = root_addr + .children() + .expect("The root address of a parent node must have children."); accumulate_result_with( left.root_hash(l_addr, truncate_at), right.root_hash(r_addr, truncate_at), @@ -207,6 +209,7 @@ impl PrunableTree { /// would cause information loss or if a conflict between root hashes occurs at a node. The /// returned error contains the address of the node where such a conflict occurred. pub fn merge_checked(self, root_addr: Address, other: Self) -> Result { + /// Pre-condition: `root_addr` must be the address of `t0` and `t1`. #[allow(clippy::type_complexity)] fn go( addr: Address, @@ -261,7 +264,9 @@ impl PrunableTree { }), ) = (lparent, rparent) { - let (l_addr, r_addr) = addr.children().unwrap(); + let (l_addr, r_addr) = addr + .children() + .expect("The root address of a parent node must have children."); Ok(Tree::unite( addr.level() - 1, lann.or(rann), @@ -357,6 +362,7 @@ impl LocatedPrunableTree { /// Returns the positions of marked leaves in the tree. pub fn marked_positions(&self) -> BTreeSet { + /// Pre-condition: `root_addr` must be the address of `root`. fn go( root_addr: Address, root: &PrunableTree, @@ -364,7 +370,9 @@ impl LocatedPrunableTree { ) { match &root.0 { Node::Parent { left, right, .. } => { - let (l_addr, r_addr) = root_addr.children().unwrap(); + let (l_addr, r_addr) = root_addr + .children() + .expect("has children because we checked `root` is a parent"); go(l_addr, left.as_ref(), acc); go(r_addr, right.as_ref(), acc); } @@ -391,8 +399,10 @@ impl LocatedPrunableTree { /// Returns either the witness for the leaf at the specified position, or an error that /// describes the causes of failure. pub fn witness(&self, position: Position, truncate_at: Position) -> Result, QueryError> { - // traverse down to the desired leaf position, and then construct - // the authentication path on the way back up. + /// Traverse down to the desired leaf position, and then construct + /// the authentication path on the way back up. + // + /// Pre-condition: `root_addr` must be the address of `root`. fn go( root: &PrunableTree, root_addr: Address, @@ -401,7 +411,9 @@ impl LocatedPrunableTree { ) -> Result, Vec
> { match &root.0 { Node::Parent { left, right, .. } => { - let (l_addr, r_addr) = root_addr.children().unwrap(); + let (l_addr, r_addr) = root_addr + .children() + .expect("has children because we checked `root` is a parent"); if root_addr.level() > 1.into() { let r_start = r_addr.position_range_start(); if position < r_start { @@ -476,6 +488,7 @@ impl LocatedPrunableTree { /// subtree root with the specified position as its maximum position exists, or `None` /// otherwise. pub fn truncate_to_position(&self, position: Position) -> Option { + /// Pre-condition: `root_addr` must be the address of `root`. fn go( position: Position, root_addr: Address, @@ -483,7 +496,9 @@ impl LocatedPrunableTree { ) -> Option> { match &root.0 { Node::Parent { ann, left, right } => { - let (l_child, r_child) = root_addr.children().unwrap(); + let (l_child, r_child) = root_addr + .children() + .expect("has children because we checked `root` is a parent"); if position < r_child.position_range_start() { // we are truncating within the range of the left node, so recurse // to the left to truncate the left child and then reconstruct the @@ -537,8 +552,10 @@ impl LocatedPrunableTree { subtree: Self, contains_marked: bool, ) -> Result<(Self, Vec), InsertionError> { - // A function to recursively dig into the tree, creating a path downward and introducing - // empty nodes as necessary until we can insert the provided subtree. + /// A function to recursively dig into the tree, creating a path downward and introducing + /// empty nodes as necessary until we can insert the provided subtree. + /// + /// Pre-condition: `root_addr` must be the address of `into`. #[allow(clippy::type_complexity)] fn go( root_addr: Address, @@ -621,7 +638,9 @@ impl LocatedPrunableTree { Tree(Node::Parent { ann, left, right }) => { // In this case, we have an existing parent but we need to dig down farther // before we can insert the subtree that we're carrying for insertion. - let (l_addr, r_addr) = root_addr.children().unwrap(); + let (l_addr, r_addr) = root_addr + .children() + .expect("has children because we checked `into` is a parent"); if l_addr.contains(&subtree.root_addr) { let (new_left, incomplete) = go(l_addr, left.as_ref(), subtree, is_complete, contains_marked)?; @@ -696,7 +715,12 @@ impl LocatedPrunableTree { if r.remainder.next().is_some() { Err(InsertionError::TreeFull) } else { - Ok((r.subtree, r.max_insert_position.unwrap(), checkpoint_id)) + Ok(( + r.subtree, + r.max_insert_position + .expect("Batch insertion result position is never initialized to None"), + checkpoint_id, + )) } }) } @@ -820,6 +844,7 @@ impl LocatedPrunableTree { /// Clears the specified retention flags at all positions specified, pruning any branches /// that no longer need to be retained. pub fn clear_flags(&self, to_clear: BTreeMap) -> Self { + /// Pre-condition: `root_addr` must be the address of `root`. fn go( to_clear: &[(Position, RetentionFlags)], root_addr: Address, @@ -831,7 +856,9 @@ impl LocatedPrunableTree { } else { match root { Tree(Node::Parent { ann, left, right }) => { - let (l_addr, r_addr) = root_addr.children().unwrap(); + let (l_addr, r_addr) = root_addr + .children() + .expect("has children because we checked `root` is a parent"); let p = to_clear.partition_point(|(p, _)| p < &l_addr.position_range_end()); trace!( diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store.rs similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store.rs diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store/caching.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store/caching.rs similarity index 97% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store/caching.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store/caching.rs index ab898fe4a7df..74ce3b27a9cb 100644 --- a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store/caching.rs +++ b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store/caching.rs @@ -46,9 +46,11 @@ where let _ = cache.put_cap(backend.get_cap()?); backend.with_checkpoints(backend.checkpoint_count()?, |checkpoint_id, checkpoint| { + // TODO: Once MSRV is at least 1.82, replace this (and similar `expect()`s below) with: + // `let Ok(_) = cache.add_checkpoint(checkpoint_id.clone(), checkpoint.clone());` cache .add_checkpoint(checkpoint_id.clone(), checkpoint.clone()) - .unwrap(); + .expect("error type is Infallible"); Ok(()) })?; @@ -74,26 +76,37 @@ where } self.deferred_actions.clear(); - for shard_root in self.cache.get_shard_roots().unwrap() { + for shard_root in self + .cache + .get_shard_roots() + .expect("error type is Infallible") + { self.backend.put_shard( self.cache .get_shard(shard_root) - .unwrap() + .expect("error type is Infallible") .expect("known address"), )?; } - self.backend.put_cap(self.cache.get_cap().unwrap())?; + self.backend + .put_cap(self.cache.get_cap().expect("error type is Infallible"))?; - let mut checkpoints = Vec::with_capacity(self.cache.checkpoint_count().unwrap()); + let mut checkpoints = Vec::with_capacity( + self.cache + .checkpoint_count() + .expect("error type is Infallible"), + ); self.cache .with_checkpoints( - self.cache.checkpoint_count().unwrap(), + self.cache + .checkpoint_count() + .expect("error type is Infallible"), |checkpoint_id, checkpoint| { checkpoints.push((checkpoint_id.clone(), checkpoint.clone())); Ok(()) }, ) - .unwrap(); + .expect("error type is Infallible"); for (checkpoint_id, checkpoint) in checkpoints { self.backend.add_checkpoint(checkpoint_id, checkpoint)?; } diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store/memory.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store/memory.rs similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store/memory.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store/memory.rs diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/testing.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/testing.rs similarity index 100% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/testing.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/testing.rs diff --git a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/tree.rs b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/tree.rs similarity index 95% rename from third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/tree.rs rename to third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/tree.rs index 5a87eae25ce5..e873ba0eefe4 100644 --- a/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/tree.rs +++ b/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/tree.rs @@ -218,10 +218,13 @@ impl LocatedTree { /// Returns the value at the specified position, if any. pub fn value_at_position(&self, position: Position) -> Option<&V> { + /// Pre-condition: `addr` must be the address of `root`. fn go(pos: Position, addr: Address, root: &Tree) -> Option<&V> { match &root.0 { Node::Parent { left, right, .. } => { - let (l_addr, r_addr) = addr.children().unwrap(); + let (l_addr, r_addr) = addr + .children() + .expect("has children because we checked `root` is a parent"); if l_addr.position_range().contains(&pos) { go(pos, l_addr, left) } else { @@ -265,6 +268,7 @@ impl LocatedTree { /// if the tree is terminated by a [`Node::Nil`] or leaf node before the specified address can /// be reached. pub fn subtree(&self, addr: Address) -> Option { + /// Pre-condition: `root_addr` must be the address of `root`. fn go( root_addr: Address, root: &Tree, @@ -278,7 +282,9 @@ impl LocatedTree { } else { match &root.0 { Node::Parent { left, right, .. } => { - let (l_addr, r_addr) = root_addr.children().unwrap(); + let (l_addr, r_addr) = root_addr + .children() + .expect("has children because we checked `root` is a parent"); if l_addr.contains(&addr) { go(l_addr, left.as_ref(), addr) } else { @@ -302,6 +308,7 @@ impl LocatedTree { /// If this root address of this tree is lower down in the tree than the level specified, /// the entire tree is returned as the sole element of the result vector. pub fn decompose_to_level(self, level: Level) -> Vec { + /// Pre-condition: `root_addr` must be the address of `root`. fn go( level: Level, root_addr: Address, @@ -312,7 +319,9 @@ impl LocatedTree { } else { match root.0 { Node::Parent { left, right, .. } => { - let (l_addr, r_addr) = root_addr.children().unwrap(); + let (l_addr, r_addr) = root_addr + .children() + .expect("has children because we checked `root` is a parent"); let mut l_decomposed = go( level, l_addr, diff --git a/third_party/rust/shardtree/v0_3/BUILD.gn b/third_party/rust/shardtree/v0_3/BUILD.gn index e39ac5ac745f..4cae43c1375a 100644 --- a/third_party/rust/shardtree/v0_3/BUILD.gn +++ b/third_party/rust/shardtree/v0_3/BUILD.gn @@ -1,7 +1,6 @@ -# Copyright (c) 2024 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/. +# Copyright 2023 The Chromium Authors +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. # @generated from third_party/rust/chromium_crates_io/BUILD.gn.hbs by # tools/crates/gnrt. @@ -13,24 +12,24 @@ cargo_crate("lib") { crate_name = "shardtree" epoch = "0.3" crate_type = "rlib" - crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/lib.rs" + crate_root = "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/lib.rs" sources = [ - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/batch.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/error.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/legacy.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/lib.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/prunable.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store/caching.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/store/memory.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/testing.rs", - "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/src/tree.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/batch.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/error.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/legacy.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/lib.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/prunable.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store/caching.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/store/memory.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/testing.rs", + "//brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/src/tree.rs", ] inputs = [] build_native_rust_unit_tests = false edition = "2021" - cargo_pkg_version = "0.3.1" + cargo_pkg_version = "0.3.2" cargo_pkg_authors = "Kris Nuttycombe " cargo_pkg_name = "shardtree" cargo_pkg_description = "A space-efficient Merkle tree with witnessing of marked leaves, checkpointing & state restoration." diff --git a/third_party/rust/shardtree/v0_3/README.chromium b/third_party/rust/shardtree/v0_3/README.chromium index c684f6aa6733..cf0590a4cc79 100644 --- a/third_party/rust/shardtree/v0_3/README.chromium +++ b/third_party/rust/shardtree/v0_3/README.chromium @@ -1,9 +1,10 @@ Name: shardtree URL: https://crates.io/crates/shardtree -Description: A space-efficient Merkle tree with witnessing of marked leaves, checkpointing & state restoration. -Version: 0.3.1 -Security Critical: yes -Shipped: yes +Version: 0.3.2 +Revision: 63cbc0a223030838a9f68bd837da6f06497324aa License: Apache 2.0 -License File: //brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.1/LICENSE-APACHE -Revision: 7c862c16b31aa3883fcbb61f30af9930eb01cc0b +License File: //brave/third_party/rust/chromium_crates_io/vendor/shardtree-0.3.2/LICENSE-APACHE +Shipped: yes +Security Critical: yes + +Description: A space-efficient Merkle tree with witnessing of marked leaves, checkpointing & state restoration. diff --git a/third_party/rust/zcash_client_backend/v0_12/README.chromium b/third_party/rust/zcash_client_backend/v0_12/README.chromium index fc60e9e2d520..5827271b72ed 100644 --- a/third_party/rust/zcash_client_backend/v0_12/README.chromium +++ b/third_party/rust/zcash_client_backend/v0_12/README.chromium @@ -1,8 +1,9 @@ Name: zcash_client_backend URL: https://crates.io/crates/zcash_client_backend -Description: APIs for creating shielded Zcash light clients Version: 0.12.1 -Security Critical: yes -Shipped: yes License: Apache 2.0 License File: //brave/third_party/rust/chromium_crates_io/vendor/zcash_client_backend-0.12.1/../../../../../common/licenses/Apache-2.0 +Shipped: yes +Security Critical: yes + +Description: APIs for creating shielded Zcash light clients