diff --git a/crates/driver/src/domain/mempools.rs b/crates/driver/src/domain/mempools.rs index 3d4ed86135..f0cedd26af 100644 --- a/crates/driver/src/domain/mempools.rs +++ b/crates/driver/src/domain/mempools.rs @@ -105,7 +105,7 @@ impl Mempools { // settlement. This way we only run iterations in blocks that can potentially // include the settlement. let mut block_stream = into_stream(self.ethereum.current_block().clone()); - block_stream.next().await; + let block = block_stream.next().await; // The tx is simulated before submitting the solution to the competition, but a // delay between that and the actual execution can cause the simulation to be @@ -116,7 +116,7 @@ impl Mempools { ?err, "settlement tx simulation reverted before submitting to the mempool" ); - return Err(Error::SimulationRevert); + return Err(Error::SimulationRevert(block.map(|block| block.number))); } else { tracing::warn!( ?err, @@ -142,7 +142,12 @@ impl Mempools { }); match receipt { TxStatus::Executed => return Ok(hash.clone()), - TxStatus::Reverted => return Err(Error::Revert(hash.clone())), + TxStatus::Reverted => { + return Err(Error::Revert { + tx_id: hash.clone(), + block_number: block.number, + }) + } TxStatus::Pending => { // Check if the current block reached the submission deadline block number if block.number >= submission_deadline { @@ -172,7 +177,7 @@ impl Mempools { ?err, "tx started failing in mempool, cancelling" ); - return Err(Error::SimulationRevert); + return Err(Error::SimulationRevert(Some(block.number))); } else { tracing::warn!(?hash, ?err, "couldn't re-simulate tx"); } @@ -235,10 +240,13 @@ pub enum RevertProtection { #[derive(Debug, thiserror::Error)] pub enum Error { - #[error("Mined reverted transaction: {0:?}")] - Revert(eth::TxId), - #[error("Simulation started reverting during submission")] - SimulationRevert, + #[error("Mined reverted transaction: {tx_id:?}, block number: {block_number}")] + Revert { + tx_id: eth::TxId, + block_number: BlockNo, + }, + #[error("Simulation started reverting during submission, block number: {0:?}")] + SimulationRevert(Option), #[error("Settlement did not get included in time")] Expired, #[error("Strategy disabled for this tx")] diff --git a/crates/driver/src/infra/notify/mod.rs b/crates/driver/src/infra/notify/mod.rs index 4f33f3e5e6..edb4c55458 100644 --- a/crates/driver/src/infra/notify/mod.rs +++ b/crates/driver/src/infra/notify/mod.rs @@ -105,8 +105,8 @@ pub fn executed( ) { let kind = match res { Ok(hash) => notification::Settlement::Success(hash.clone()), - Err(Error::Revert(hash)) => notification::Settlement::Revert(hash.clone()), - Err(Error::SimulationRevert) => notification::Settlement::SimulationRevert, + Err(Error::Revert { tx_id: hash, .. }) => notification::Settlement::Revert(hash.clone()), + Err(Error::SimulationRevert { .. }) => notification::Settlement::SimulationRevert, Err(Error::Expired) => notification::Settlement::Expired, Err(Error::Other(_) | Error::Disabled) => notification::Settlement::Fail, }; diff --git a/crates/driver/src/infra/observe/mod.rs b/crates/driver/src/infra/observe/mod.rs index f8c1394e54..0dff50d918 100644 --- a/crates/driver/src/infra/observe/mod.rs +++ b/crates/driver/src/infra/observe/mod.rs @@ -339,7 +339,7 @@ pub fn mempool_executed( } let result = match res { Ok(_) => "Success", - Err(mempools::Error::Revert(_) | mempools::Error::SimulationRevert) => "Revert", + Err(mempools::Error::Revert { .. } | mempools::Error::SimulationRevert { .. }) => "Revert", Err(mempools::Error::Expired) => "Expired", Err(mempools::Error::Other(_)) => "Other", Err(mempools::Error::Disabled) => "Disabled",