-
Notifications
You must be signed in to change notification settings - Fork 307
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: hotfix for 2025-01-18 chain halt (alternative) #4994
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -211,10 +211,37 @@ pub trait PositionManager: StateWrite + PositionRead { | |
} | ||
|
||
/// Queues a position to be closed at the end of the block, after batch execution. | ||
fn queue_close_position(&mut self, id: position::Id) { | ||
let mut to_close = self.pending_position_closures(); | ||
to_close.push_back(id); | ||
self.object_put(state_key::pending_position_closures(), to_close); | ||
async fn queue_close_position(&mut self, id: position::Id) -> Result<()> { | ||
tracing::debug!( | ||
?id, | ||
"checking current position state before queueing for closure" | ||
); | ||
let current_state = self | ||
.position_by_id(&id) | ||
.await | ||
.expect("fetching position should not fail") | ||
.ok_or_else(|| anyhow::anyhow!("could not find position {} to close", id))? | ||
.tap(|lp| tracing::trace!(prev_state = ?lp, "retrieved previous lp state")); | ||
|
||
if current_state.state == position::State::Opened { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ACK. short-circuit on queueing. |
||
tracing::debug!( | ||
?current_state.state, | ||
"queueing opened position for closure" | ||
); | ||
let mut to_close = self.pending_position_closures(); | ||
to_close.push_back(id); | ||
self.object_put(state_key::pending_position_closures(), to_close); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ACK. queuing gated on valid state antecedent. |
||
|
||
// queue position close you will... | ||
self.record_proto(event::EventQueuePositionClose { position_id: id }.to_proto()); | ||
} else { | ||
tracing::debug!( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ACK. no-op on contentious state antecedent. |
||
?current_state.state, | ||
"skipping queueing for closure of non-opened position" | ||
); | ||
} | ||
|
||
Ok(()) | ||
} | ||
|
||
/// Close all positions that have been queued for closure. | ||
|
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.
ACK.