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

CNS-311 fixation store prefix bug #339

Merged
merged 9 commits into from
Mar 15, 2023

Conversation

orenl-lava
Copy link
Contributor

@orenl-lava orenl-lava commented Mar 4, 2023

  1. Sanitize indices stored FixationStore (fix bug with entries that are prefix of other entries)
  2. Drop block arg from GetEntry()
  3. FindEntry() to skip stale entres
  4. Test whether stale based on time since refcount becomes zero
  5. Some code clean-up

@orenl-lava orenl-lava requested a review from Yaroms March 4, 2023 21:27
Copy link
Collaborator

@Yaroms Yaroms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

very clean code

common/fixation_entry.go Outdated Show resolved Hide resolved
common/fixation_entry.go Outdated Show resolved Hide resolved
@orenl-lava orenl-lava force-pushed the CNS-311-fixation-store-prefix-bug branch from 922f9d9 to c892440 Compare March 6, 2023 15:48
Yaroms
Yaroms previously approved these changes Mar 7, 2023
common/fixation_entry.go Outdated Show resolved Hide resolved
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 orenl-lava force-pushed the CNS-311-fixation-store-prefix-bug branch from 75701aa to f5dfcda Compare March 7, 2023 20:49
Yaroms
Yaroms previously approved these changes Mar 10, 2023
@Yaroms Yaroms requested a review from omerlavanet March 10, 2023 12:47
common/fixation_entry.go Show resolved Hide resolved
common/fixation_entry_index.go Outdated Show resolved Hide resolved
common/fixation_entry_index.go Show resolved Hide resolved
common/types/fixationEntry.go Show resolved Hide resolved
@omerlavanet omerlavanet merged commit eceb480 into main Mar 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants