Skip to content

Commit

Permalink
added some more illustration for what the chunk accumulator looks like
Browse files Browse the repository at this point in the history
  • Loading branch information
dubbelosix committed Oct 11, 2023
1 parent 022ceed commit 22a9ab2
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions adapters/solana/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,23 @@ pub struct Chunk {
* The specific logic for merkelization can be seen in the `accumulate` function in [lib.rs](solana_da_programs/programs/blockroot/src/lib.rs)
* The code also makes use of the `hashv` syscall.
* For odd numbered levels, the un-paired leaves are promoted to the next level. (This logic needs to be audited since its custom)
```
Root
|
+-----+----------+
| |
Parent1 Parent2 [X]
| |
+--+--+ +-----+------+
| | | |
Chunk1 Chunk2 Chunk3 Chunk4
[ ] [ ] [X] [X]
```
* The above diagram illustrates what the `ChunkAccumulator` might look like at a point in time when `Chunk3` and `Chunk4` have arrived
* `Chunk3` arrives first and everything else in the tree is empty.
* `Parent2` is calculated once `Chunk4` arrives
* `Chunk1`, `Chunk2`, `Parent1` and `Root` are still incomplete
* Chunks can arrive in any order since they get inserted into the right slots of the tree in the `ChunkAccumulator` account's on-chain space
* Once the final chunk arrives and the merkle root is available, the root is "accumulated" into the `BlocksRoot` PDA account
* This accumulation takes the form of a hashlist (since we don't really need merkelization here)
Expand Down

0 comments on commit 22a9ab2

Please sign in to comment.