-
Notifications
You must be signed in to change notification settings - Fork 76
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: correct request validation #942
Conversation
@GG2002 Convert your pr to draft since CI failed |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #942 +/- ##
==========================================
+ Coverage 75.55% 75.84% +0.28%
==========================================
Files 180 188 +8
Lines 26938 27990 +1052
Branches 26938 27990 +1052
==========================================
+ Hits 20353 21228 +875
- Misses 5366 5454 +88
- Partials 1219 1308 +89 ☔ View full report in Codecov by Sentry. |
@GG2002 Convert your pr to draft since CI failed |
Signed-off-by: feathercyc <[email protected]>
@GG2002 Your PR is in conflict and cannot be merged. |
Please briefly answer these questions:
[Bug]:
check_intervals
will not validate correctly in certain nested txn scenarios #410Corrected the behavior of request validation. Please refer to this proposal for the general idea. The specific code behavior is slightly different from what is stated in the proposal, but the idea of finding out LCA is the same.
No.
Let me explain what I do.
Firstly, we need to confirm that
put
anddel
/put
on the same branch (success or failure) are prohibited from overlapping. Being on the same branch means that the LCA ofput
anddel
/put
are the success or failure branch node, while not being on the same branch means that the LCA ofput
anddel
/put
are the RequestTxn node. In fact, the LCA ofput
anddel
can only be on one of RequestTxn, success, or failure branch.After understanding this, we can easily conclude that when the depth of LCA for two nodes % 2 == 0 means that these two nodes are on the same branch (this is also related to the code processing flow, because
fn check_intervals
initially receives the success or failure branch, not a RequestTxn. If it is the latter, then when LCA.depth % 2 == 1, it means that these two nodes are on the same branch).The first step is
fn build_interval_tree
, which traverses the entire txn structure and represents each op with an LCA node (which records its parent and depth). It will establishe two data structures:dels
contains all the LCA nodes ofdel
op and their corresponding intervalsputs
contains all the LCA nodes ofput
opBecause the same interval may correspond to different LCA nodes, both data structures store
vec<usize>
. This step also checks whether differentput
overlap to return Err earlier. Note that even if allput
do not overlap,HashMap<&[u8], vec<usize>>
is still needed to store allput
, because the second step is to iterate through allput
to check if they intersect withdel
.The second and final step is to directly iterate through
puts
and check whether allput
intersect with thedel
in thedels
. The detection rule is as described above.Done.