-
Notifications
You must be signed in to change notification settings - Fork 93
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
Filter in-flight orders #2123
Filter in-flight orders #2123
Conversation
@@ -54,6 +55,7 @@ pub struct RunLoop { | |||
pub score_cap: U256, | |||
pub max_settlement_transaction_wait: Duration, | |||
pub solve_deadline: Duration, | |||
pub in_flight_orders: Arc<Mutex<InFlightOrders>>, |
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.
Why do we need synchronisation here?
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.
Because we populate the data in a method that takes a shared reference to self
.
/// to fill an order a second time. | ||
async fn remove_in_flight_orders(&self, mut auction: Auction) -> Auction { | ||
let prev_settlement = self.in_flight_orders.lock().unwrap().tx_hash; | ||
let tx_receipt = self.web3.eth().transaction_receipt(prev_settlement).await; |
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.
What happens if in the first iteration the tx_hash
is initialized with Default::default()
?
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.
Then transaction_receipt()
would try to find the block that contains tx_hash 0x000...
which does not exist so we fallback to assuming the previous auction was settled in block u64::MAX
so we discard all in-flight orders we have at the time (which are 0 due to Default::default()
).
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.
lg
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
Description
Although the
autopilot
currently waits until thedriver
reports that the settlement was mined the auction of the next run loop might not yet be aware that the orders of the previous settlement were solved.If a solver then tries to solve those orders again it will run into simulation failures.
Changes
We now filter out in-flight orders from the auction if it was built before the block where the in-flight orders were settled.