Skip to content

Commit

Permalink
using the stackoverflow-safe version of the initialize_with_root call…
Browse files Browse the repository at this point in the history
… + minor fmt
  • Loading branch information
StanChe committed Jun 25, 2024
1 parent 3ec1114 commit 2191e25
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
2 changes: 1 addition & 1 deletion account-compression/Cargo.lock

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

15 changes: 6 additions & 9 deletions account-compression/programs/account-compression/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 1 addition & 2 deletions libraries/concurrent-merkle-tree/src/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,8 @@ pub fn empty_node_cached<const N: usize>(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<const N: usize>(level: u32, cache: &mut[Node; N]) -> Node {
pub fn empty_node_cached_mut<const N: usize>(level: u32, cache: &mut [Node; N]) -> Node {
let mut data = EMPTY;
if level != 0 {
let target = (level - 1) as usize;
Expand Down

0 comments on commit 2191e25

Please sign in to comment.