-
Notifications
You must be signed in to change notification settings - Fork 218
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
Fix seek in TrieDB iterator #13
Conversation
Looking at the parity-common/patricia_trie/src/lib.rs Line 205 in 4481687
So, I'm not sure whether it was a typo in the |
Hm, yeah there are two contradicting comments... IMO |
Nice find @ngotchac ! I think that not a bug, since the comment found by @ordian and tests are good evidences of otherwise, and this is more of a documentation issue. And I agree with you that UPDATE To clarify: there is actually code in polkadot that relies on parity-common/patricia_trie/src/triedb.rs Line 338 in 4481687
The use-case is to delete a range of entries keys of which share the given common prefix. E.g. the trie contains the following keys:
If I deleted keys with prefix |
I fully agree with you @pepyakin ! And actually the current implementation is still broken with |
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.
I agree that >=
is the more natural logic, but I am worried about breakage in code relying on the ==
behavior. Did you review other code in parity-ethereum
that calls seek
? If yes, lgtm.
So the only uses of |
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.
LGTM, although I don't fully understand the implementation.
Lower hex and couple of cleanups
Lower hex and couple of cleanups
It seems to me that the behavior of
seek
on aTrieDB
iterator was broken, looking at the tests.Seeking to "A" which is in the Trie, calling
next
should return "A" and not the next value.This was particularly broken when in a trie with
[16, 8]
and[16, 16]
, seeking to[16, 0]
would start the iterator at[16, 16]
.