Skip to content

Commit

Permalink
[Easy] Only void solutions that fail due to reverts (#2154)
Browse files Browse the repository at this point in the history
# 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.
  • Loading branch information
fleupold authored and ahhda committed Dec 12, 2023
1 parent 03ed19b commit dc66229
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
12 changes: 10 additions & 2 deletions crates/driver/src/domain/competition/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/driver/src/infra/observe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}

Expand Down

0 comments on commit dc66229

Please sign in to comment.