From 2191e255470da3c1b28588c27a4afb2378a859ff Mon Sep 17 00:00:00 2001 From: Stanislav Cherviakov Date: Tue, 25 Jun 2024 12:41:57 +0100 Subject: [PATCH] using the stackoverflow-safe version of the initialize_with_root call + minor fmt --- account-compression/Cargo.lock | 2 +- .../programs/account-compression/src/lib.rs | 15 ++++++--------- libraries/concurrent-merkle-tree/src/node.rs | 3 +-- 3 files changed, 8 insertions(+), 12 deletions(-) diff --git a/account-compression/Cargo.lock b/account-compression/Cargo.lock index 9bba33c66b7..530e13fe227 100644 --- a/account-compression/Cargo.lock +++ b/account-compression/Cargo.lock @@ -1574,7 +1574,7 @@ dependencies = [ [[package]] name = "spl-concurrent-merkle-tree" -version = "0.2.0" +version = "0.3.0" dependencies = [ "bytemuck", "solana-program", diff --git a/account-compression/programs/account-compression/src/lib.rs b/account-compression/programs/account-compression/src/lib.rs index 8a26783e624..92cf112833c 100644 --- a/account-compression/programs/account-compression/src/lib.rs +++ b/account-compression/programs/account-compression/src/lib.rs @@ -308,17 +308,14 @@ pub mod spl_account_compression { assert_eq!(proof.len(), header.get_max_depth() as usize); let id = ctx.accounts.merkle_tree.key(); - // A call is made to ConcurrentMerkleTree::initialize_with_root(root, rightmost_leaf, proof, rightmost_index) - let change_log = merkle_tree_apply_fn_mut!( - header, - id, - tree_bytes, - initialize_with_root, + // A call is made to ConcurrentMerkleTree::initialize_with_root + let args = &InitializeWithRootArgs { root, rightmost_leaf, - &proof, - rightmost_index - )?; + proof_vec: proof, + index: rightmost_index, + }; + let change_log = merkle_tree_initialize_with_root(&header, id, tree_bytes, args)?; update_canopy(canopy_bytes, header.get_max_depth(), Some(&change_log))?; wrap_event( &AccountCompressionEvent::ChangeLog(*change_log), diff --git a/libraries/concurrent-merkle-tree/src/node.rs b/libraries/concurrent-merkle-tree/src/node.rs index f7fdeb8973c..e04613a4f6b 100644 --- a/libraries/concurrent-merkle-tree/src/node.rs +++ b/libraries/concurrent-merkle-tree/src/node.rs @@ -27,9 +27,8 @@ pub fn empty_node_cached(level: u32, cache: &[Node; N]) -> Node data } - /// Calculates and caches the hash of empty nodes up to level i -pub fn empty_node_cached_mut(level: u32, cache: &mut[Node; N]) -> Node { +pub fn empty_node_cached_mut(level: u32, cache: &mut [Node; N]) -> Node { let mut data = EMPTY; if level != 0 { let target = (level - 1) as usize;