Closed dillonrg closed 3 months ago
Attention: Patch coverage is 77.77778%
with 2 lines
in your changes missing coverage. Please review.
Project coverage is 88.03%. Comparing base (
3ce5335
) to head (5818ea1
). Report is 17 commits behind head on main.
Files | Patch % | Lines |
---|---|---|
akd/src/directory.rs | 60.00% | 2 Missing :warning: |
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Bug In the
key_history
API exposed indirectory.rs
, it is possible that states read from storage are not fully committed yet (i.e. the transaction has not been committed), but the associated epoch in the states is higher than what is seen in theaZKS
entry read from storage. In fact, we explicitly account for that scenario when inspecting versions across the states: https://github.com/facebook/akd/blob/main/akd/src/directory.rs#L484-L490.Prior to this patch, we always initiated the
end_version
variable at 0. However, theend_version
variable should never be 0 since it will panic in downstream API calls: https://github.com/facebook/akd/blob/main/akd_core/src/utils.rs#L182-L184. The bug in this case is simply that we defaultend_version
to 0, but do not update it in the event that we have performed a dirty read for states.To resolve the bug, we default
end_version
to the same value asstart_version
.Verification Prior to updating
directory.rs
, the added tests to repro cases where a dirty read is performed and a newer epoch is returned as part of theKeyData
fails with the expected panic:After updating
directory.rs
, the panic no longer occurs.