From e35a197b673293b62b7fa4c4ebb065c7e9cb2f3c Mon Sep 17 00:00:00 2001 From: Harsh Bajpai Date: Sat, 20 Jul 2024 13:14:25 +0800 Subject: [PATCH 1/3] fix: fix typo, `ForgettenSubtree` -> `ForgottenSubtree` --- merkle_tree/src/gadgets/mod.rs | 2 +- merkle_tree/src/internal.rs | 42 +++++++++++++++++----------------- merkle_tree/src/macros.rs | 2 +- 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/merkle_tree/src/gadgets/mod.rs b/merkle_tree/src/gadgets/mod.rs index 17dc74ee8..b97d6ae2d 100644 --- a/merkle_tree/src/gadgets/mod.rs +++ b/merkle_tree/src/gadgets/mod.rs @@ -602,7 +602,7 @@ mod test { if let MerkleNode::Branch { value: _, children } = &mut bad_proof.proof[1] { let left_sib = if uid % 3 == 0 { 1 } else { 0 }; - children[left_sib] = Arc::new(MerkleNode::ForgettenSubtree { value: F::zero() }); + children[left_sib] = Arc::new(MerkleNode::ForgottenSubtree { value: F::zero() }); } let path_vars: Merkle3AryMembershipProofVar = MerkleTreeGadget::>::create_membership_proof_variable( diff --git a/merkle_tree/src/internal.rs b/merkle_tree/src/internal.rs index d07f9e22f..c763888c6 100644 --- a/merkle_tree/src/internal.rs +++ b/merkle_tree/src/internal.rs @@ -46,7 +46,7 @@ pub enum MerkleNode { elem: E, }, /// The subtree is forgotten from the memory - ForgettenSubtree { + ForgottenSubtree { /// Merkle hash value of this forgotten subtree #[serde(with = "canonical")] value: T, @@ -70,13 +70,13 @@ where elem: _, } => *value, Self::Branch { value, children: _ } => *value, - Self::ForgettenSubtree { value } => *value, + Self::ForgottenSubtree { value } => *value, } } #[inline] pub(crate) fn is_forgotten(&self) -> bool { - matches!(self, Self::ForgettenSubtree { .. }) + matches!(self, Self::ForgottenSubtree { .. }) } } @@ -311,7 +311,7 @@ where .map(|(pos, elem)| { let pos = pos as u64; Ok(if pos < num_leaves - 1 { - Arc::new(MerkleNode::ForgettenSubtree { + Arc::new(MerkleNode::ForgottenSubtree { value: H::digest_leaf(&pos, elem.borrow())?, }) } else { @@ -331,7 +331,7 @@ where }) .collect::, MerkleTreeError>>()?; for i in 1..cur_nodes.len() - 1 { - cur_nodes[i] = Arc::new(MerkleNode::ForgettenSubtree { + cur_nodes[i] = Arc::new(MerkleNode::ForgottenSubtree { value: cur_nodes[i].value(), }) } @@ -351,7 +351,7 @@ where }) .collect::, MerkleTreeError>>()?; for i in 1..cur_nodes.len() - 1 { - cur_nodes[i] = Arc::new(MerkleNode::ForgettenSubtree { + cur_nodes[i] = Arc::new(MerkleNode::ForgottenSubtree { value: cur_nodes[i].value(), }) } @@ -411,7 +411,7 @@ where if let MerkleNode::Empty = **child { Arc::new(MerkleNode::Empty) } else { - Arc::new(MerkleNode::ForgettenSubtree { + Arc::new(MerkleNode::ForgottenSubtree { value: child.value(), }) } @@ -422,11 +422,11 @@ where if children.iter().all(|child| { matches!( **child, - MerkleNode::Empty | MerkleNode::ForgettenSubtree { .. } + MerkleNode::Empty | MerkleNode::ForgottenSubtree { .. } ) }) { ( - Arc::new(MerkleNode::ForgettenSubtree { value: *value }), + Arc::new(MerkleNode::ForgottenSubtree { value: *value }), LookupResult::Ok(elem, proof), ) } else { @@ -451,7 +451,7 @@ where if let MerkleNode::Empty = **child { Arc::new(MerkleNode::Empty) } else { - Arc::new(MerkleNode::ForgettenSubtree { + Arc::new(MerkleNode::ForgottenSubtree { value: child.value(), }) } @@ -473,7 +473,7 @@ where elem: elem.clone(), }]; ( - Arc::new(MerkleNode::ForgettenSubtree { value: *value }), + Arc::new(MerkleNode::ForgottenSubtree { value: *value }), LookupResult::Ok(elem, proof), ) }, @@ -503,7 +503,7 @@ where } match (self, &proof[height]) { - (Self::ForgettenSubtree { value }, Self::Branch { children, .. }) => { + (Self::ForgottenSubtree { value }, Self::Branch { children, .. }) => { // Recurse into the appropriate sub-tree to remember the rest of the path. let mut children = children.clone(); children[traversal_path[height - 1]] = children[traversal_path[height - 1]] @@ -519,7 +519,7 @@ where children, })) }, - (Self::ForgettenSubtree { .. }, node) => { + (Self::ForgottenSubtree { .. }, node) => { // Replace forgotten sub-tree with a hopefully-less-forgotten sub-tree from the // proof. Safe because we already checked our hash value matches the proof. Ok(Arc::new(node.clone())) @@ -575,7 +575,7 @@ where if let MerkleNode::Empty = **child { Arc::new(MerkleNode::Empty) } else { - Arc::new(MerkleNode::ForgettenSubtree { + Arc::new(MerkleNode::ForgottenSubtree { value: child.value(), }) } @@ -594,7 +594,7 @@ where if let MerkleNode::Empty = **child { Arc::new(MerkleNode::Empty) } else { - Arc::new(MerkleNode::ForgettenSubtree { + Arc::new(MerkleNode::ForgottenSubtree { value: child.value(), }) } @@ -662,7 +662,7 @@ where )?; let mut children = children.clone(); children[branch] = result.0; - if matches!(*children[branch], MerkleNode::ForgettenSubtree { .. }) { + if matches!(*children[branch], MerkleNode::ForgottenSubtree { .. }) { // If the branch containing the update was forgotten by // user, the update failed and nothing was changed, so we // can short-circuit without recomputing this node's value. @@ -740,7 +740,7 @@ where } } }, - MerkleNode::ForgettenSubtree { .. } => Err(MerkleTreeError::ForgottenLeaf), + MerkleNode::ForgottenSubtree { .. } => Err(MerkleTreeError::ForgottenLeaf), } } } @@ -837,7 +837,7 @@ where } }, MerkleNode::Leaf { .. } => Err(MerkleTreeError::ExistingLeaf), - MerkleNode::ForgettenSubtree { .. } => Err(MerkleTreeError::ForgottenLeaf), + MerkleNode::ForgottenSubtree { .. } => Err(MerkleTreeError::ForgottenLeaf), } } @@ -871,7 +871,7 @@ where while data.peek().is_some() && frontier < cap { if frontier > 0 && !children[frontier - 1].is_forgotten() { children[frontier - 1] = - Arc::new(MerkleNode::::ForgettenSubtree { + Arc::new(MerkleNode::::ForgottenSubtree { value: children[frontier - 1].value(), }); } @@ -915,7 +915,7 @@ where while data.peek().is_some() && frontier < cap { if frontier > 0 && !children[frontier - 1].is_forgotten() { children[frontier - 1] = - Arc::new(MerkleNode::::ForgettenSubtree { + Arc::new(MerkleNode::::ForgottenSubtree { value: children[frontier - 1].value(), }); } @@ -942,7 +942,7 @@ where } }, MerkleNode::Leaf { .. } => Err(MerkleTreeError::ExistingLeaf), - MerkleNode::ForgettenSubtree { .. } => Err(MerkleTreeError::ForgottenLeaf), + MerkleNode::ForgottenSubtree { .. } => Err(MerkleTreeError::ForgottenLeaf), } } } diff --git a/merkle_tree/src/macros.rs b/merkle_tree/src/macros.rs index 9f372ca72..8693bb2c9 100644 --- a/merkle_tree/src/macros.rs +++ b/merkle_tree/src/macros.rs @@ -143,7 +143,7 @@ macro_rules! impl_forgetable_merkle_tree_scheme { fn from_commitment(com: impl Borrow) -> Self { let com = com.borrow(); $name { - root: Arc::new(MerkleNode::ForgettenSubtree { + root: Arc::new(MerkleNode::ForgottenSubtree { value: com.digest(), }), height: com.height(), From 5f06cf39b7ed13d5a4a4854a2fd946692db1250a Mon Sep 17 00:00:00 2001 From: Harsh Bajpai Date: Sat, 20 Jul 2024 13:23:51 +0800 Subject: [PATCH 2/3] add changelog --- CHANGELOG_OLD.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG_OLD.md b/CHANGELOG_OLD.md index 2573af827..89331a8ba 100644 --- a/CHANGELOG_OLD.md +++ b/CHANGELOG_OLD.md @@ -20,6 +20,7 @@ We take inspiration from [keep changelog](https://keepachangelog.com/en/1.0.0/) ### Changed - [#559](https://github.com/EspressoSystems/jellyfish/pull/559) (`jf-primitives`) GPU-accelerated `batch_commit()` now doesn't require the input polynomials to be of the same degree. +- [#636](https://github.com/EspressoSystems/jellyfish/pull/637) (`jf-merkle-tree`) Fix typo, `ForgettenSubtree` to `ForgottenSubtree` ### Removed From d054663b129a87ab253a233bb568029cd2dec131 Mon Sep 17 00:00:00 2001 From: Harsh Bajpai Date: Sat, 20 Jul 2024 13:28:02 +0800 Subject: [PATCH 3/3] dev: update changelog --- CHANGELOG_OLD.md | 1 - merkle_tree/CHANGELOG.md | 3 ++- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG_OLD.md b/CHANGELOG_OLD.md index 89331a8ba..2573af827 100644 --- a/CHANGELOG_OLD.md +++ b/CHANGELOG_OLD.md @@ -20,7 +20,6 @@ We take inspiration from [keep changelog](https://keepachangelog.com/en/1.0.0/) ### Changed - [#559](https://github.com/EspressoSystems/jellyfish/pull/559) (`jf-primitives`) GPU-accelerated `batch_commit()` now doesn't require the input polynomials to be of the same degree. -- [#636](https://github.com/EspressoSystems/jellyfish/pull/637) (`jf-merkle-tree`) Fix typo, `ForgettenSubtree` to `ForgottenSubtree` ### Removed diff --git a/merkle_tree/CHANGELOG.md b/merkle_tree/CHANGELOG.md index ccd9ce510..398cab4f7 100644 --- a/merkle_tree/CHANGELOG.md +++ b/merkle_tree/CHANGELOG.md @@ -5,6 +5,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## 0.1.0 -- Initial release. +- Initial release. - Various (including namespace) Merkle tree trait definitions and implementations. - Turn on `gadgets` for circuit implementations. +- Fix typo, `ForgettenSubtree` to `ForgottenSubtree`