Skip to content

Commit

Permalink
Project canopy (solana-labs#118)
Browse files Browse the repository at this point in the history
* Initial implementation of project canopy (lots of magic numbers, no comments, no tests) WIP

* Finalized canopy changes and fixed a number of bugs in concurrent merkle tree lib

* revert indexer to main

* Don't worry guys, I added some comments

* Support up to 2^30 tree size
  • Loading branch information
jarry-xiao authored and ngundotra committed Sep 8, 2022
1 parent a05723c commit 67cd9ab
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions contracts/sdk/gummyroll/accounts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,18 @@ export function decodeMerkleRoll(buffer: Buffer): OnChainMerkleRoll {

export function getMerkleRollAccountSize(
maxDepth: number,
maxBufferSize: number
maxBufferSize: number,
canopyDepth?: number
): number {
let headerSize = 8 + 32 + 32;
let changeLogSize = (maxDepth * 32 + 32 + 4 + 4) * maxBufferSize;
let rightMostPathSize = maxDepth * 32 + 32 + 4 + 4;
let merkleRollSize = 8 + 8 + 16 + changeLogSize + rightMostPathSize;
return merkleRollSize + headerSize;
let canopySize = 0;
if (canopyDepth) {
canopySize = ((1 << canopyDepth + 1) - 2) * 32
}
return merkleRollSize + headerSize + canopySize;
}

export async function assertOnChainMerkleRollProperties(
Expand Down

0 comments on commit 67cd9ab

Please sign in to comment.