From dc66229c1cdc15ce1a8e09c9a3e3b4fb854998fc Mon Sep 17 00:00:00 2001 From: Felix Leupold Date: Mon, 11 Dec 2023 19:34:43 +0100 Subject: [PATCH] [Easy] Only void solutions that fail due to reverts (#2154) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit # Description Once a solver is done merging and post-processing solutions, we continue simulating their best solution candidate upon arrival of new blocks to make sure they are still valid. We void the solution candidate if simulation fails. However, simulation may fail for two reasons: 1. An actual revert 2. Some other error (e.g. HTTP errors or the like) While both are lethal for generating to solution candidate in the first place (as we need to get the gas estimate from the simulation for ranking), only actual reverts should cause a solution to be evicted in the final phase. In case we have a network error, we can just be "optimistic" and assume the outcome of the simulation hasn't changed. # Changes - [ ] Only void solution if simulation error is an actual revert ## How to test CI and 🤞 as we don't have a way to test/mock simulations as part of e2e tests and this issue seems to be too narrow to warrant its own high level test. --- crates/driver/src/domain/competition/mod.rs | 12 ++++++++++-- crates/driver/src/infra/observe/mod.rs | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/crates/driver/src/domain/competition/mod.rs b/crates/driver/src/domain/competition/mod.rs index 18fd581bb3..e120c61465 100644 --- a/crates/driver/src/domain/competition/mod.rs +++ b/crates/driver/src/domain/competition/mod.rs @@ -202,12 +202,20 @@ impl Competition { let mut stream = ethrpc::current_block::into_stream(self.eth.current_block().clone()); while let Some(block) = stream.next().await { - if let Err(err) = self.simulate_settlement(&settlement).await { + if let Err(infra::simulator::Error::Revert(err)) = + self.simulate_settlement(&settlement).await + { observe::winner_voided(block, &err); *score_ref = None; *self.settlement.lock().unwrap() = None; if let Some(id) = settlement.notify_id() { - notify::simulation_failed(&self.solver, auction.id(), id, &err, true); + notify::simulation_failed( + &self.solver, + auction.id(), + id, + &infra::simulator::Error::Revert(err), + true, + ); } return; } diff --git a/crates/driver/src/infra/observe/mod.rs b/crates/driver/src/infra/observe/mod.rs index b18e29c4e9..8863bf07f6 100644 --- a/crates/driver/src/infra/observe/mod.rs +++ b/crates/driver/src/infra/observe/mod.rs @@ -167,7 +167,7 @@ pub fn score(settlement: &Settlement, score: &competition::Score) { // Observe that the winning settlement started failing upon arrival of a new // block -pub fn winner_voided(block: BlockInfo, err: &simulator::Error) { +pub fn winner_voided(block: BlockInfo, err: &simulator::RevertError) { tracing::warn!(block = block.number, ?err, "solution reverts on new block"); }