-
Notifications
You must be signed in to change notification settings - Fork 162
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: add binary trie #129
Merged
Conversation
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
Codecov Report
@@ Coverage Diff @@
## main #129 +/- ##
===========================================
Coverage 100.00% 100.00%
===========================================
Files 26 31 +5
Lines 1427 3571 +2144
===========================================
+ Hits 1427 3571 +2144
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
5c6301b
to
97d82d8
Compare
9776ef2
to
938bd76
Compare
bfe31b1
to
20a127b
Compare
26357f3
to
74a95fd
Compare
74a95fd
to
c0931d6
Compare
This also fixes an issue where deleting certain keys would not result in an updated commitment value.
4fac80a
to
083508f
Compare
Cater for the assumption that a key-value pair where the value is zero implies key deletion.
Simplify the Pedersen hash function by introducing panics for a broken contract and remove a check for a condition that never evaluates to true. This not only improves the efficiency of the function but also simplifies its signature to only return the digest instead of the digest and an error. This is made possible by the fact that the condition in the inner loop of pedersen.go that checks whether the shift point is compared to itself is never true as `pt2` will only ever the assigned to the points in the range 2..=505. The hexadecimal strings that represent the points are also hardcoded in the init function in order to reduce the memory footprint of the package along with other redundant global variables. BREAKING CHANGE: `Digest` and `ArrayDigest` now return a single argument Any previous calls to these functions should discard their error handling logic.
Introduce minor performance optimisations aimed at reducing the amount of time it takes to process a block. This is done by preferring much more efficient alternatives to some functions such as: - Comparing against the length field of a slice instead of the entire slice when querying the root node. - Replacing string formatting with appending raw bytes or using dedicated type formatting functions for basic types as the latter uses reflection and as a result is more costly.
daaded1
to
10bfb4b
Compare
Remove the test that checks whether the inputs are in the required field. This function now panics if that's the case as it is considered to be a broken contract.
This was
linked to
issues
May 17, 2022
Closed
Closed
Comment out the array digest benchmark which is currently failing.
Add a test for querying the commitment of an empty trie.
dea12a3
to
e665dcd
Compare
Closed
stdevMac
approved these changes
May 17, 2022
IronGauntlets
pushed a commit
that referenced
this pull request
Aug 18, 2022
* feat: create binary trie * refactor: implement delete method * docs: update documentation * test: add tests for exported methods * refactor: substitute recursive put with loop This also fixes an issue where deleting certain keys would not result in an updated commitment value. * test: satisfy code coverage tool * refactor: minor changes to improve clarity * fix: fix issue caused by overflow * test: add test for state commitment * test: improve test coverage Cater for the assumption that a key-value pair where the value is zero implies key deletion. * fix: fix typo * fix: fix erroneously reversed keys in trie.Put * refactor: update the Pedersen hash function Simplify the Pedersen hash function by introducing panics for a broken contract and remove a check for a condition that never evaluates to true. This not only improves the efficiency of the function but also simplifies its signature to only return the digest instead of the digest and an error. This is made possible by the fact that the condition in the inner loop of pedersen.go that checks whether the shift point is compared to itself is never true as `pt2` will only ever the assigned to the points in the range 2..=505. The hexadecimal strings that represent the points are also hardcoded in the init function in order to reduce the memory footprint of the package along with other redundant global variables. BREAKING CHANGE: `Digest` and `ArrayDigest` now return a single argument Any previous calls to these functions should discard their error handling logic. * refactor: minor optimisations Introduce minor performance optimisations aimed at reducing the amount of time it takes to process a block. This is done by preferring much more efficient alternatives to some functions such as: - Comparing against the length field of a slice instead of the entire slice when querying the root node. - Replacing string formatting with appending raw bytes or using dedicated type formatting functions for basic types as the latter uses reflection and as a result is more costly. * tests: delete Pedersen hash limit test Remove the test that checks whether the inputs are in the required field. This function now panics if that's the case as it is considered to be a broken contract. * tests: comment out array digest benchmark Comment out the array digest benchmark which is currently failing. * tests: satisfy coverage tool Add a test for querying the commitment of an empty trie. Co-authored-by: Marcos Antonio Maceo <35319980+stdevMac@users.noreply.github.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Trie representation versus the example in the StarkNet documentation for 3-bit keys.
Delete
method.Changes:
Types of changes
Testing
Requires testing
In case you checked yes, did you write tests??
Comments about testing , should you have some (optional)
Functional tests:
Debug trace: