Skip to content
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

[EASY] Improve mempool submission expired logs #3272

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 17 additions & 5 deletions crates/driver/src/domain/mempools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,13 @@ impl Mempools {
}

let hash = mempool.submit(tx.clone(), settlement.gas, solver).await?;
tracing::debug!(?hash, "submitted tx to the mempool");
let submitted_at_block = self.ethereum.current_block().borrow().number;
tracing::debug!(?hash, current_block = ?submitted_at_block, "submitted tx to the mempool");

// Wait for the transaction to be mined, expired or failing.
let result = async {
while let Some(block) = block_stream.next().await {
tracing::debug!(?hash, "checking if tx is confirmed");
tracing::debug!(?hash, current_block = ?block.number, "checking if tx is confirmed");
let receipt = self
.ethereum
.transaction_status(&hash)
Expand Down Expand Up @@ -162,7 +163,11 @@ impl Mempools {
?cancellation_tx_hash,
"tx not confirmed in time, cancelling",
);
return Err(Error::Expired);
return Err(Error::Expired {
tx_id: hash.clone(),
submitted_at_block,
submission_deadline,
});
}
// Check if transaction still simulates
if let Err(err) = self.ethereum.estimate_gas(tx).await {
Expand Down Expand Up @@ -247,8 +252,15 @@ pub enum Error {
},
#[error("Simulation started reverting during submission, block number: {0:?}")]
SimulationRevert(Option<BlockNo>),
#[error("Settlement did not get included in time")]
Expired,
#[error(
"Settlement did not get included in time: submitted at block: {submitted_at_block}, \
submission deadline: {submission_deadline}, tx: {tx_id:?}"
)]
Expired {
tx_id: eth::TxId,
submitted_at_block: BlockNo,
submission_deadline: BlockNo,
},
#[error("Strategy disabled for this tx")]
Disabled,
#[error("Failed to submit: {0:?}")]
Expand Down
2 changes: 1 addition & 1 deletion crates/driver/src/infra/notify/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ pub fn executed(
Ok(hash) => notification::Settlement::Success(hash.clone()),
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::Expired { .. }) => notification::Settlement::Expired,
Err(Error::Other(_) | Error::Disabled) => notification::Settlement::Fail,
};

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 @@ -340,7 +340,7 @@ pub fn mempool_executed(
let result = match res {
Ok(_) => "Success",
Err(mempools::Error::Revert { .. } | mempools::Error::SimulationRevert { .. }) => "Revert",
Err(mempools::Error::Expired) => "Expired",
Err(mempools::Error::Expired { .. }) => "Expired",
Err(mempools::Error::Other(_)) => "Other",
Err(mempools::Error::Disabled) => "Disabled",
};
Expand Down
Loading