-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
account-compression: fix for a stack overflow issue on macro usage (#…
…6827) * account-compression: fix for a stack overflow issue on macro usage * clippy: removed unnecessary references * update cmt tests * fix rustfmt * bump spl-concurrent-merkle-tree to 0.3.0 for API changes --------- Co-authored-by: ngundotra <[email protected]> Co-authored-by: Noah Gundotra <[email protected]>
- Loading branch information
1 parent
61794be
commit d85ea9f
Showing
8 changed files
with
301 additions
and
173 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
account-compression/programs/account-compression/src/concurrent_tree_wrapper.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
//! This module provides a wrapper around the `ConcurrentMerkleTree` struct from | ||
//! the `spl_concurrent_merkle_tree` crate. It provides a set of functions that | ||
//! can be called from the Anchor program to interact with the tree. | ||
//! The functions are used to initialize the tree, set a leaf, fill empty or | ||
//! append a leaf, and prove a leaf. As the tree is generic over the depth and | ||
//! buffer size, the functions are implemented using macros that infer the depth | ||
//! and buffer size from the header information stored on-chain. Usage of the | ||
//! macros directly is discouraged, as they have huge match statements with | ||
//! every case taking it's own stack frame. Instead, use the exported functions | ||
//! from this module and refenrece or Box the arguments to the functions to | ||
//! avoid the stack frame explosion. | ||
pub use crate::error::AccountCompressionError; | ||
/// Exported for Anchor / Solita | ||
pub use spl_concurrent_merkle_tree::{ | ||
concurrent_merkle_tree::{ | ||
ConcurrentMerkleTree, FillEmptyOrAppendArgs, InitializeWithRootArgs, ProveLeafArgs, | ||
SetLeafArgs, | ||
}, | ||
error::ConcurrentMerkleTreeError, | ||
node::Node, | ||
node::EMPTY, | ||
}; | ||
use { | ||
crate::{ | ||
events::ChangeLogEvent, macros::*, state::ConcurrentMerkleTreeHeader, zero_copy::ZeroCopy, | ||
}, | ||
anchor_lang::prelude::*, | ||
}; | ||
|
||
pub fn merkle_tree_initialize_with_root( | ||
header: &ConcurrentMerkleTreeHeader, | ||
tree_id: Pubkey, | ||
tree_bytes: &mut [u8], | ||
args: &InitializeWithRootArgs, | ||
) -> Result<Box<ChangeLogEvent>> { | ||
merkle_tree_apply_fn_mut!(header, tree_id, tree_bytes, initialize_with_root, args) | ||
} | ||
|
||
pub fn merkle_tree_set_leaf( | ||
header: &ConcurrentMerkleTreeHeader, | ||
tree_id: Pubkey, | ||
tree_bytes: &mut [u8], | ||
args: &SetLeafArgs, | ||
) -> Result<Box<ChangeLogEvent>> { | ||
merkle_tree_apply_fn_mut!(header, tree_id, tree_bytes, set_leaf, args) | ||
} | ||
|
||
pub fn merkle_tree_fill_empty_or_append( | ||
header: &ConcurrentMerkleTreeHeader, | ||
tree_id: Pubkey, | ||
tree_bytes: &mut [u8], | ||
args: &FillEmptyOrAppendArgs, | ||
) -> Result<Box<ChangeLogEvent>> { | ||
merkle_tree_apply_fn_mut!(header, tree_id, tree_bytes, fill_empty_or_append, args) | ||
} | ||
|
||
pub fn merkle_tree_prove_leaf( | ||
header: &ConcurrentMerkleTreeHeader, | ||
tree_id: Pubkey, | ||
tree_bytes: &[u8], | ||
args: &ProveLeafArgs, | ||
) -> Result<Box<ChangeLogEvent>> { | ||
merkle_tree_apply_fn!(header, tree_id, tree_bytes, prove_leaf, args) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "spl-concurrent-merkle-tree" | ||
version = "0.2.0" | ||
version = "0.3.0" | ||
description = "Solana Program Library Concurrent Merkle Tree" | ||
authors = ["Solana Labs Maintainers <[email protected]>"] | ||
repository = "https://github.com/solana-labs/solana-program-library" | ||
|
@@ -9,7 +9,7 @@ edition = "2021" | |
|
||
[features] | ||
log = [] | ||
sol-log = [ "log" ] | ||
sol-log = ["log"] | ||
|
||
[dependencies] | ||
solana-program = "1.16" | ||
|
Oops, something went wrong.