-
Notifications
You must be signed in to change notification settings - Fork 211
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
CNS-311 fixation store prefix bug #339
Merged
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
Contributor
orenl-lava
commented
Mar 4, 2023
•
edited
Loading
edited
- Sanitize indices stored FixationStore (fix bug with entries that are prefix of other entries)
- Drop block arg from GetEntry()
- FindEntry() to skip stale entres
- Test whether stale based on time since refcount becomes zero
- Some code clean-up
Yaroms
requested changes
Mar 5, 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very clean code
orenl-lava
force-pushed
the
CNS-311-fixation-store-prefix-bug
branch
from
March 6, 2023 15:48
922f9d9
to
c892440
Compare
Yaroms
previously approved these changes
Mar 7, 2023
The FixationStore assumes that entries cannot have index's that are prefix of other entries' indices. However, this was not enforced, so for example: a user may create a project called "project" and another called "project2", breaking the logic that relies on unique prefixes. To fix, require entry names (index) to contain only visible ascii characters (ascii values 32-125), and use the ascii 'DEL' (invisible) character internally to terminate the index values when stored. This ensures that no two indices can ever overlap. This properly supports Bech32 addresses, which are limited to use only visible ascii characters as per https://en.bitcoin.it/wiki/BIP_0173#Specification.
GetEntry() essentially takes a snapshot of an latest version of an entry. The caller may not choose an earlier version to snapsho - so drop the block arg from its definition.
The garbage collection mechanism may leave entries with refcount zero for extended periods. However, after the STALE_ENTRY_TIME they should no longer be visible via FindEntry() calls - fix the function to enforce this behavior.
Remove unneeded functions, improve readability, fix comments.
Change the test whether an entry is stale (and needs to be deleted or ignored) to check the time since the entry's refcount becomes zero (and not since the entry's creation time).
orenl-lava
force-pushed
the
CNS-311-fixation-store-prefix-bug
branch
from
March 7, 2023 20:49
75701aa
to
f5dfcda
Compare
Yaroms
previously approved these changes
Mar 10, 2023
omerlavanet
requested changes
Mar 15, 2023
omerlavanet
approved these changes
Mar 15, 2023
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.