-
Notifications
You must be signed in to change notification settings - Fork 302
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
dex: fix frontier cache incoherence #4283
Conversation
Added label. This means we'll need to write a migration in order to release this, and provide validators with instructions, right? |
Ooops thanks I missed that, no migration needed, it's an internal structure and only used during execution |
// | ||
// If so, skip the write, but more importantly, skip emitting an event, | ||
// so tooling doesn't get confused about a no-op execution. | ||
if prev_state == new_state { |
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.
Nit: state
is a bit overridden here and it took me a couple reads to understand that prev_state
/new_state
aren't instances of the position::State
enum but instead Position
s.
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
Can we fix #4123 as part of these changes? |
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 but we should fix #4123 while we're making these changes.
0fa692e
to
d088689
Compare
@hdevalence added a fix/event for #4123 |
Description
This PR fix a bug in the
Frontier
position cache that caused a position execution guard to be hit.Context
During routing execution, the DEX engine assemble frontiers of positions to execute against. It maintains an internal cache with a position stream for each hop in the path, along with the ids and state of the current loaded set. The position cache is persisted in its entirety when a round of routing execution has completed (via
Frontier::save
), and partially, if a position needs to be replaced (Frontier::replace_position
).Bug
The bug occurs when the following conditions align:
Closed
when recording its executionIn that case, since the position rotation logic does not update the internal state of the position, it will attempt to record execution of a stale position when saving the frontier.
Fix
The fix is two-fold, first,
PositionManager::position_execution
should make it clear that it can mutate its input and return the updated position state to allow callers to inspect its state. Once that's done, the position rotation logic will be able to immediately update its internal cache with the actual position state so that there are no incoherences between its internal view and the actual chain state.Checklist before requesting a review
If this code contains consensus-breaking changes, I have added the "consensus-breaking" label. Otherwise, I declare my belief that there are not consensus-breaking changes, for the following reason: