-
Notifications
You must be signed in to change notification settings - Fork 266
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: refactor StandardIndexedTree for abstract leaves and preimages …
…and optimized it (#3530) This PR prepares the standard indexed tree to be used for the public data tree. Changes: - Make StandardIndexedTree abstract in leaves in preparation to accomodate other trees than the nullifier tree - Removed the leaves in memory in the StandardIndexedTree and switch to db queries for low leaf finding (O(1)) - FindLeafIndex is now O(1) too
- Loading branch information
1 parent
5d3895a
commit 63b9cdc
Showing
39 changed files
with
811 additions
and
487 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
|
@@ -55,7 +55,5 @@ | |
"path": "../world-state" | ||
} | ||
], | ||
"include": [ | ||
"src" | ||
] | ||
"include": ["src"] | ||
} |
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 |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/** | ||
* A leaf of an indexed merkle tree. | ||
*/ | ||
export interface IndexedTreeLeaf { | ||
/** | ||
* Returns key of the leaf. It's used for indexing. | ||
*/ | ||
getKey(): bigint; | ||
/** | ||
* Serializes the leaf into a buffer. | ||
*/ | ||
toBuffer(): Buffer; | ||
/** | ||
* Returns true if the leaf is empty. | ||
*/ | ||
isEmpty(): boolean; | ||
} | ||
|
||
/** | ||
* Preimage of an indexed merkle tree leaf. | ||
*/ | ||
export interface IndexedTreeLeafPreimage { | ||
/** | ||
* Returns key of the leaf corresponding to this preimage. | ||
*/ | ||
getKey(): bigint; | ||
/** | ||
* Returns the key of the next leaf. | ||
*/ | ||
getNextKey(): bigint; | ||
/** | ||
* Returns the index of the next leaf. | ||
*/ | ||
getNextIndex(): bigint; | ||
|
||
/** | ||
* Returns the preimage as a leaf. | ||
*/ | ||
asLeaf(): IndexedTreeLeaf; | ||
/** | ||
* Serializes the preimage into a buffer. | ||
*/ | ||
toBuffer(): Buffer; | ||
/** | ||
* Serializes the preimage to an array of buffers for hashing. | ||
*/ | ||
toHashInputs(): Buffer[]; | ||
} |
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
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
Oops, something went wrong.