Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: public data tree as indexed tree #3566

Merged
merged 54 commits into from
Dec 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
880b702
wip abstracting leaf and preimage in indexed
sirasistant Dec 1, 2023
ed471d4
feat: experiment with generic indexed trees
sirasistant Dec 1, 2023
38fcf05
chore: add test dep to devDependencies
sirasistant Dec 1, 2023
bc4915b
chore: remove old LeafData struct
sirasistant Dec 1, 2023
47a3aee
fix: getLatestLeafPreimage can return undefined
sirasistant Dec 1, 2023
064d7a8
feat: remove local leaf cache in indexed tree
sirasistant Dec 1, 2023
d458756
feat: optimize findLeafIndex for indexed tree
sirasistant Dec 1, 2023
ae6b6a0
docs: added jsdoc
sirasistant Dec 4, 2023
47bb7f0
refactor: low leaf getter returns option
sirasistant Dec 4, 2023
6d7fc7d
Merge branch 'master' into arv/public_data_tree_in
sirasistant Dec 4, 2023
7250939
fix: make sure low leaf in range
sirasistant Dec 4, 2023
240e8b5
fix: improve performance of getLeafIndex
sirasistant Dec 4, 2023
bcc8ae0
chore: cleanups
sirasistant Dec 4, 2023
1b7c9f8
style: fix formatting
sirasistant Dec 4, 2023
3848116
Merge branch 'master' into arv/public_data_tree_indexed
sirasistant Dec 4, 2023
08791c5
chore: reset file to master
sirasistant Dec 4, 2023
989ad09
Merge branch 'master' into arv/public_data_tree_indexed
sirasistant Dec 4, 2023
678bc75
feat: public data tree switch
sirasistant Dec 4, 2023
a7c2148
chore: update constants gen
sirasistant Dec 4, 2023
fd4ffde
Merge branch 'master' into arv/upsert_indexed_tree
sirasistant Dec 4, 2023
1d85666
feat: more work towards switching data tree
sirasistant Dec 5, 2023
edb4548
fix: addressed some PR comments
sirasistant Dec 5, 2023
e731f97
fix: avoid findLeafIndex in sparse trees
sirasistant Dec 5, 2023
037a479
refactor: avoid createTree helper
sirasistant Dec 5, 2023
a217fe2
fix: formatting
sirasistant Dec 5, 2023
3d6cfb4
feat: more work towards indexed pdt
sirasistant Dec 5, 2023
2a77b8b
Merge branch 'master' into arv/public_data_tree_indexed
sirasistant Dec 5, 2023
8be1d4a
Merge branch 'arv/public_data_tree_indexed' into arv/upsert_indexed_tree
sirasistant Dec 5, 2023
02d6e6b
fix: bugfixes in upsert and public data reads
sirasistant Dec 5, 2023
3337297
test: skipping a sol test for now
sirasistant Dec 5, 2023
3a95f1b
fix: formatting
sirasistant Dec 5, 2023
b4998e2
fix: getStorageAt returns zero if not inserted
sirasistant Dec 5, 2023
7f07897
fix: remove redundant writes
sirasistant Dec 5, 2023
32be31c
fix: sync properly the public data tree
sirasistant Dec 5, 2023
a6d10c7
fix: sync public data tree updates
sirasistant Dec 6, 2023
4897b98
feat: add function for verifying reads
sirasistant Dec 6, 2023
c186490
test: some unit test fixes
sirasistant Dec 12, 2023
bc021b9
test: fix block builder unit test
sirasistant Dec 12, 2023
4e603fc
feat: fix inclusion proofs
sirasistant Dec 12, 2023
65a4762
Merge branch 'master' into arv/upsert_indexed_tree
sirasistant Dec 12, 2023
dbd2c1e
fix: noir tests for public data tree
sirasistant Dec 13, 2023
af75d19
Merge branch 'master' into arv/upsert_indexed_tree
sirasistant Dec 13, 2023
1a8bc3d
test: add unit test for upsertion in indexed tree
sirasistant Dec 13, 2023
01e8b35
chore: cleanups and refactors
sirasistant Dec 13, 2023
0c416aa
chore: update snaps and doc
sirasistant Dec 13, 2023
f91c762
chore: docs
sirasistant Dec 13, 2023
1342ca5
test: re enable solidity test
sirasistant Dec 13, 2023
f191c2e
test: refactor noir tests
sirasistant Dec 13, 2023
98fa494
Merge branch 'master' into arv/upsert_indexed_tree
sirasistant Dec 13, 2023
4cf3644
Merge branch 'master' into arv/upsert_indexed_tree
sirasistant Dec 13, 2023
cc48e39
Merge branch 'arv/upsert_indexed_tree' of github.com:AztecProtocol/az…
sirasistant Dec 13, 2023
83e6adb
Merge branch 'master' into arv/upsert_indexed_tree
sirasistant Dec 13, 2023
40ba830
Merge branch 'master' into arv/upsert_indexed_tree
sirasistant Dec 14, 2023
14705ec
Merge branch 'master' into arv/upsert_indexed_tree
sirasistant Dec 14, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion l1-contracts/src/core/libraries/ConstantsGen.sol
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ library Constants {
uint256 internal constant FUNCTION_TREE_HEIGHT = 5;
uint256 internal constant CONTRACT_TREE_HEIGHT = 16;
uint256 internal constant NOTE_HASH_TREE_HEIGHT = 32;
uint256 internal constant PUBLIC_DATA_TREE_HEIGHT = 254;
uint256 internal constant PUBLIC_DATA_TREE_HEIGHT = 40;
uint256 internal constant NULLIFIER_TREE_HEIGHT = 20;
uint256 internal constant L1_TO_L2_MSG_TREE_HEIGHT = 16;
uint256 internal constant ROLLUP_VK_TREE_HEIGHT = 8;
Expand All @@ -56,8 +56,10 @@ library Constants {
uint256 internal constant NOTE_HASH_SUBTREE_HEIGHT = 7;
uint256 internal constant NOTE_HASH_SUBTREE_SIBLING_PATH_LENGTH = 25;
uint256 internal constant NULLIFIER_SUBTREE_HEIGHT = 7;
uint256 internal constant PUBLIC_DATA_SUBTREE_HEIGHT = 4;
uint256 internal constant ARCHIVE_HEIGHT = 16;
uint256 internal constant NULLIFIER_SUBTREE_SIBLING_PATH_LENGTH = 13;
uint256 internal constant PUBLIC_DATA_SUBTREE_SIBLING_PATH_LENGTH = 36;
uint256 internal constant L1_TO_L2_MSG_SUBTREE_HEIGHT = 4;
uint256 internal constant L1_TO_L2_MSG_SUBTREE_SIBLING_PATH_LENGTH = 12;
uint256 internal constant FUNCTION_SELECTOR_NUM_BYTES = 4;
Expand Down
70 changes: 36 additions & 34 deletions l1-contracts/src/core/libraries/Decoder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,39 +32,41 @@ import {Hash} from "./Hash.sol";
* | 0x00c4 | 0x04 | startNullifierTreeSnapshot.nextAvailableLeafIndex
* | 0x00c8 | 0x20 | startContractTreeSnapshot.root
* | 0x00e8 | 0x04 | startContractTreeSnapshot.nextAvailableLeafIndex
* | 0x00ec | 0x20 | startPublicDataTreeRoot
* | 0x010c | 0x20 | startL1ToL2MessageTreeSnapshot.root
* | 0x012c | 0x04 | startL1ToL2MessageTreeSnapshot.nextAvailableLeafIndex
* | 0x0130 | 0x20 | startArchiveSnapshot.root
* | 0x0150 | 0x04 | startArchiveSnapshot.nextAvailableLeafIndex
* | 0x0154 | 0x20 | endNoteHashTreeSnapshot.root
* | 0x0174 | 0x04 | endNoteHashTreeSnapshot.nextAvailableLeafIndex
* | 0x0178 | 0x20 | endNullifierTreeSnapshot.root
* | 0x0198 | 0x04 | endNullifierTreeSnapshot.nextAvailableLeafIndex
* | 0x019c | 0x20 | endContractTreeSnapshot.root
* | 0x01bc | 0x04 | endContractTreeSnapshot.nextAvailableLeafIndex
* | 0x01c0 | 0x20 | endPublicDataTreeRoot
* | 0x01e0 | 0x20 | endL1ToL2MessageTreeSnapshot.root
* | 0x0200 | 0x04 | endL1ToL2MessageTreeSnapshot.nextAvailableLeafIndex
* | 0x0204 | 0x20 | endArchiveSnapshot.root
* | 0x0224 | 0x04 | endArchiveSnapshot.nextAvailableLeafIndex
* | 0x0228 | 0x04 | len(newCommitments) (denoted a)
* | 0x022c | a * 0x20 | newCommitments
* | 0x022c + a * 0x20 | 0x04 | len(newNullifiers) (denoted b)
* | 0x0230 + a * 0x20 | b * 0x20 | newNullifiers
* | 0x0230 + a * 0x20 + b * 0x20 | 0x04 | len(newPublicDataWrites) (denoted c)
* | 0x0234 + a * 0x20 + b * 0x20 | c * 0x40 | newPublicDataWrites
* | 0x0234 + a * 0x20 + b * 0x20 + c * 0x40 | 0x04 | len(newL2ToL1Msgs) (denoted d)
* | 0x0238 + a * 0x20 + b * 0x20 + c * 0x40 | d * 0x20 | newL2ToL1Msgs
* | 0x0238 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 | 0x04 | len(contracts) (denoted e)
* | 0x023c + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 | e * 0x20 | newContracts
* | 0x023c + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x20 | e * 0x34 | newContractsData
* | 0x023c + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 | 0x04 | len(newL1ToL2Msgs) (denoted f)
* | 0x0240 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 | f * 0x20 | newL1ToL2Msgs
* | 0x0240 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 + f * 0x20 | 0x04 | byteLen(newEncryptedLogs) (denoted g)
* | 0x0244 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 + f * 0x20 | g | newEncryptedLogs
* | 0x0244 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 + f * 0x20 + g | 0x04 | byteLen(newUnencryptedLogs) (denoted h)
* | 0x0248 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 + f * 0x20 + g | h | newUnencryptedLogs
* | 0x00ec | 0x20 | startPublicDataTreeSnapshot.root
* | 0x010c | 0x04 | startPublicDataTreeSnapshot.nextAvailableLeafIndex
* | 0x0110 | 0x20 | startL1ToL2MessageTreeSnapshot.root
* | 0x0130 | 0x04 | startL1ToL2MessageTreeSnapshot.nextAvailableLeafIndex
* | 0x0134 | 0x20 | startArchiveSnapshot.root
* | 0x0154 | 0x04 | startArchiveSnapshot.nextAvailableLeafIndex
* | 0x0158 | 0x20 | endNoteHashTreeSnapshot.root
* | 0x0178 | 0x04 | endNoteHashTreeSnapshot.nextAvailableLeafIndex
* | 0x017c | 0x20 | endNullifierTreeSnapshot.root
* | 0x019c | 0x04 | endNullifierTreeSnapshot.nextAvailableLeafIndex
* | 0x01a0 | 0x20 | endContractTreeSnapshot.root
* | 0x01c0 | 0x04 | endContractTreeSnapshot.nextAvailableLeafIndex
* | 0x01c4 | 0x20 | endPublicDataTreeSnapshot.root
* | 0x01e4 | 0x04 | endPublicDataTreeSnapshot.nextAvailableLeafIndex
* | 0x01e8 | 0x20 | endL1ToL2MessageTreeSnapshot.root
* | 0x0208 | 0x04 | endL1ToL2MessageTreeSnapshot.nextAvailableLeafIndex
* | 0x020c | 0x20 | endArchiveSnapshot.root
* | 0x022c | 0x04 | endArchiveSnapshot.nextAvailableLeafIndex
* | 0x0230 | 0x04 | len(newCommitments) (denoted a)
* | 0x0234 | a * 0x20 | newCommitments
* | 0x0234 + a * 0x20 | 0x04 | len(newNullifiers) (denoted b)
* | 0x0238 + a * 0x20 | b * 0x20 | newNullifiers
* | 0x0238 + a * 0x20 + b * 0x20 | 0x04 | len(newPublicDataWrites) (denoted c)
* | 0x023c + a * 0x20 + b * 0x20 | c * 0x40 | newPublicDataWrites
* | 0x023c + a * 0x20 + b * 0x20 + c * 0x40 | 0x04 | len(newL2ToL1Msgs) (denoted d)
* | 0x0240 + a * 0x20 + b * 0x20 + c * 0x40 | d * 0x20 | newL2ToL1Msgs
* | 0x0240 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 | 0x04 | len(contracts) (denoted e)
* | 0x0244 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 | e * 0x20 | newContracts
* | 0x0244 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x20 | e * 0x34 | newContractsData
* | 0x0244 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 | 0x04 | len(newL1ToL2Msgs) (denoted f)
* | 0x0248 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 | f * 0x20 | newL1ToL2Msgs
* | 0x0248 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 + f * 0x20 | 0x04 | byteLen(newEncryptedLogs) (denoted g)
* | 0x024c + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 + f * 0x20 | g | newEncryptedLogs
* | 0x024c + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 + f * 0x20 + g | 0x04 | byteLen(newUnencryptedLogs) (denoted h)
* | 0x0250 + a * 0x20 + b * 0x20 + c * 0x40 + d * 0x20 + e * 0x54 + f * 0x20 + g | h | newUnencryptedLogs
* | --- | --- | ---
*/
library Decoder {
Expand Down Expand Up @@ -97,7 +99,7 @@ library Decoder {
uint256 private constant START_TREES_BLOCK_HEADER_OFFSET = 0x80;

// The size of the block header elements
uint256 private constant TREES_BLOCK_HEADER_SIZE = 0xd4;
uint256 private constant TREES_BLOCK_HEADER_SIZE = 0xd8;

// Where the end of trees metadata begins in the block
uint256 private constant END_TREES_BLOCK_HEADER_OFFSET =
Expand Down
Loading