From 435ee467d3c93f40313b88081254ed2780059843 Mon Sep 17 00:00:00 2001 From: Davidson Souza Date: Thu, 1 Oct 2026 12:41:43 -0300 Subject: [PATCH] fix: make Forest not Clone MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clonning a forest is unsound due to internal mutability issue (#151), and there isn't really a reason to clone an in-memory forest, since it can be huge — several GBs for Bitcoin's current UTXO set. This commit removes Clone derives for MemForest. --- src/mem_forest/mod.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/mem_forest/mod.rs b/src/mem_forest/mod.rs index 577ec5b..ca39b47 100644 --- a/src/mem_forest/mod.rs +++ b/src/mem_forest/mod.rs @@ -70,7 +70,6 @@ type Parent = RefCell>>; type Children = RefCell>>; /// A forest node that can either be a leaf or a branch. -#[derive(Clone)] pub struct Node { /// The type of this node. ty: NodeType, @@ -199,7 +198,7 @@ impl Node { /// The actual [`MemForest`] accumulator, it implements all methods required to update the forest /// and to prove/verify membership. -#[derive(Default, Clone)] +#[derive(Default)] pub struct MemForest { /// The roots of the forest, all leaves are children of these roots, and therefore /// owned by them.