Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 2d1a6ec

Browse files
committed
typo fix + a docstring for tree_bytes_uninitialized + removed unused import
1 parent b29681e commit 2d1a6ec

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

account-compression/programs/account-compression/src/concurrent_tree_wrapper.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,13 @@ pub fn merkle_tree_append_leaf(
8787
merkle_tree_apply_fn_mut!(header, tree_id, tree_bytes, append, *args)
8888
}
8989

90-
pub fn tree_bytes_unititialized(tree_bytes: &[u8]) -> bool {
90+
/// Checks whether the tree in not initialized yet without doing the deserialization. A rought
91+
/// equivalent to deserializing the tree and calling is_initialized() on it without the heavy
92+
/// lifting with macros. An empty account is a zero'd account. The tree is considered empty if the
93+
/// tree_bytes are all 0. A regular non-batch initialized tree is initialized early on when the
94+
/// init_empty_merkle_tree is called. A batch initialized tree stays uninitialized until the
95+
/// finalize_merkle_tree_with_root is called.
96+
pub fn tree_bytes_uninitialized(tree_bytes: &[u8]) -> bool {
9197
tree_bytes.iter().all(|&x| x == 0)
9298
}
9399

@@ -100,7 +106,7 @@ pub fn assert_tree_is_empty(
100106
// If the tree is batch initialized and not finalized yet, we can treat it as empty.
101107
// Before the tree is finalized, the tree_bytes will be all 0 as only the header will be
102108
// initialized at that point, so we may skip the deserialization.
103-
if header.get_is_batch_initialized() && tree_bytes_unititialized(tree_bytes) {
109+
if header.get_is_batch_initialized() && tree_bytes_uninitialized(tree_bytes) {
104110
return Ok(());
105111
}
106112
// check the tree is empty

account-compression/programs/account-compression/src/lib.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ use crate::noop::wrap_event;
5151
use crate::state::{
5252
merkle_tree_get_size, ConcurrentMerkleTreeHeader, CONCURRENT_MERKLE_TREE_HEADER_SIZE_V1,
5353
};
54-
use crate::zero_copy::ZeroCopy;
5554

5655
/// Exported for Anchor / Solita
5756
pub use spl_concurrent_merkle_tree::{
@@ -267,7 +266,7 @@ pub mod spl_account_compression {
267266
let (tree_bytes, canopy_bytes) = rest.split_at_mut(merkle_tree_size);
268267
// ensure the tree is not initialized, the hacky way
269268
require!(
270-
tree_bytes_unititialized(tree_bytes),
269+
tree_bytes_uninitialized(tree_bytes),
271270
AccountCompressionError::TreeAlreadyInitialized
272271
);
273272
set_canopy_leaf_nodes(

0 commit comments

Comments
 (0)