-
Notifications
You must be signed in to change notification settings - Fork 106
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
Limit the size and age of the ZIP-401 rejected transaction ID list #2932
Conversation
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.
This looks good, but I think contains_key
can return transaction IDs that have expired since the last insert
.
I also have a few minor suggestions, feel free to ignore them.
Co-authored-by: teor <teor@riseup.net>
…limit-age-rejected-list
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.
Nice catch that we might need to remove multiple entries in insert()
!
I think we might need to prune_old()
in len()
to meet our DoS performance goals.
(I didn't realise this until you fixed len()
.)
I also think we need to limit the length of ordered_entries
, even if its entries haven't expired.
Co-authored-by: teor <teor@riseup.net>
…limit-age-rejected-list
…limit-age-rejected-list
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.
We could merge this as-is, but we're waiting on #2889.
I have a few optional suggestions for comments and diagnostics.
(The assertions should never fail, so we might never see these messages.)
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.
There aren't any blockers for merging this PR.
It just needs to be rebased or merged with main
after PR #2889 merges.
…limit-age-rejected-list
Done |
Co-authored-by: teor <teor@riseup.net>
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.
Looks great, let's get it merged!
Motivation
ZIP-401 specifies that the list of TXIDs must have a maximum size and entries older than a specified threshold must be removed.
Specifications
https://zips.z.cash/zip-0401#specification
Designs
Some of the design was discussed in #2759
Solution
EvictedList
that encapsulates both behavioursEvictedList
for both rejected and expired transactionsStorage
design, and seems harmless (expired transactions will also have a timeout)I tried creating a generic
OrderedMap
data structure, thatEvictedList
would use, in order to organize the code. However I noticed it would be more work since it's tricky to handle/document the behavior that removing a item from the list might not really remove a item from the list (when a value was refreshed and an stale entry is left behind). So I left the entire logic insideEvictedList
(where the removal methods are not exposed).Closes #2759
Closes #2958
Review
Anyone can review. @teor2345 discussed the design.
This may require adjustments after #2889 so it may be better to wait for that to be merged first.
Reviewer Checklist
EvictList
for the expired transaction, or should changeStorage
so that only rejected list uses it?Follow Up Work