-
Notifications
You must be signed in to change notification settings - Fork 47
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add hash set implementation which can be stored as account
We want to use hash sets as queues for nullifiers and address spaces. However, the `std` and `hashbrown` implementations are dynamically allocated and resized, which doesn't serve our purpose of storing the underlying data as Solana account. Therefore, we implement our own hash set with the following properties: * [Quadratic probing](https://en.wikipedia.org/wiki/Quadratic_probing) as a solution for hash collisions. * Load factor 0.7 (70%) - which means that the size of the structure always includes at least 70% of additional space (more than expected elements) for efficiency. * The final size is a prime number greather than the size of elements and size determined by low factor. To find the prime number, we probe 6k + 1 and 6k + 5 candidates. We check whether they are prime in a brute-force way, because we want to be sure there are no false positives.
- Loading branch information
1 parent
47269c3
commit fad346b
Showing
38 changed files
with
2,849 additions
and
1,470 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
cli/accounts/address_merkle_tree_queue_HNjtNrjt6irUPYEgxhx2Vcs42koK9fxzm3aFLHVaaRWz.json
Large diffs are not rendered by default.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
cli/accounts/indexed_array_pubkey_44J4oDXpjPAbzHCSc24q7NEiPekss4sAbLd8ka4gd9CZ.json
Large diffs are not rendered by default.
Oops, something went wrong.
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,21 @@ | ||
[package] | ||
name = "light-hash-set" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[features] | ||
solana = ["solana-program"] | ||
|
||
[dependencies] | ||
light-bounded-vec = { path = "../bounded-vec" } | ||
light-utils = { path = "../../utils" } | ||
memoffset = "0.9" | ||
num-bigint = "0.4" | ||
num-traits = "0.2" | ||
solana-program = { version = ">=1.17, <1.18", optional = true } | ||
thiserror = "1.0" | ||
|
||
[dev-dependencies] | ||
ark-bn254 = "0.4" | ||
ark-ff = "0.4" | ||
rand = "0.8" |
Oops, something went wrong.