Skip to content

Commit

Permalink
refactor: Remove array fields from Merkle tree accounts
Browse files Browse the repository at this point in the history
One more step towards making Merkle trees dynamic!

* Stop hard coding the array sizes in accounts. This way, we don't have
  to re-compile the program to .
* Don't store the pointers in the account. Instead, just store primitive
  fields we are interested in and manually restore vectors.
  • Loading branch information
vadorovsky committed Apr 2, 2024
1 parent 90f4746 commit b0475ce
Show file tree
Hide file tree
Showing 13 changed files with 542 additions and 673 deletions.
18 changes: 3 additions & 15 deletions merkle-tree/concurrent/src/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,8 @@ pub enum ConcurrentMerkleTreeError {
"Found an empty node in the Merkle path buffer, where we expected all nodes to be filled"
)]
MerklePathsEmptyNode,
#[error("Invalid struct buffer size, expected {0}, got {1}")]
StructBufferSize(usize, usize),
#[error("Invalid filled subtrees buffer size, expected {0}, got {1}")]
FilledSubtreesBufferSize(usize, usize),
#[error("Invalid changelog buffer size, expected {0}, got {1}")]
ChangelogBufferSize(usize, usize),
#[error("Invalid root buffer size, expected {0}, got {1}")]
RootBufferSize(usize, usize),
#[error("Invalid canopy buffer size, expected {0}, got {1}")]
CanopyBufferSize(usize, usize),
#[error("Invalid buffer size, expected {0}, got {1}")]
BufferSize(usize, usize),
#[error("Hasher error: {0}")]
Hasher(#[from] HasherError),
#[error("Bounded vector error: {0}")]
Expand Down Expand Up @@ -73,11 +65,7 @@ impl From<ConcurrentMerkleTreeError> for u32 {
ConcurrentMerkleTreeError::EmptyLeaves => 2013,
ConcurrentMerkleTreeError::EmptyChangelogEntries => 2014,
ConcurrentMerkleTreeError::MerklePathsEmptyNode => 2015,
ConcurrentMerkleTreeError::StructBufferSize(_, _) => 2016,
ConcurrentMerkleTreeError::FilledSubtreesBufferSize(_, _) => 2017,
ConcurrentMerkleTreeError::ChangelogBufferSize(_, _) => 2018,
ConcurrentMerkleTreeError::RootBufferSize(_, _) => 2019,
ConcurrentMerkleTreeError::CanopyBufferSize(_, _) => 2020,
ConcurrentMerkleTreeError::BufferSize(_, _) => 2016,
ConcurrentMerkleTreeError::Hasher(e) => e.into(),
ConcurrentMerkleTreeError::BoundedVec(e) => e.into(),
}
Expand Down
Loading

0 comments on commit b0475ce

Please sign in to comment.