Skip to content

Commit

Permalink
Add block number to log (#2047)
Browse files Browse the repository at this point in the history
# Description
Print block number for each failure or success of the simulation.
  • Loading branch information
sunce86 authored Nov 7, 2023
1 parent 5bb6b2b commit 52b2fe4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
6 changes: 3 additions & 3 deletions crates/driver/src/domain/competition/solution/settlement.rs
Original file line number Diff line number Diff line change
Expand Up @@ -241,10 +241,10 @@ impl Settlement {
let tx = tx.set_access_list(access_list.clone());

// Simulate the settlement using the full access list and get the gas used.
let gas = simulator.gas(tx.clone()).await?;
let gas = simulator.gas(tx.clone()).await;

observe::simulated(&tx, gas);
Ok((access_list, gas))
observe::simulated(eth, &tx, &gas);
Ok((access_list, gas?))
}

/// The calldata for this settlement.
Expand Down
6 changes: 6 additions & 0 deletions crates/driver/src/domain/eth/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,12 @@ impl num::Zero for Ether {
#[derive(Debug, Clone, Copy)]
pub struct BlockNo(pub u64);

impl From<u64> for BlockNo {
fn from(value: u64) -> Self {
Self(value)
}
}

/// An onchain transaction which interacts with a smart contract.
#[derive(Debug, Clone, Eq, PartialEq)]
pub struct Interaction {
Expand Down
10 changes: 7 additions & 3 deletions crates/driver/src/infra/observe/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
//! and update the metrics, if the event is worth measuring.
use {
super::Mempool,
super::{simulator, Ethereum, Mempool},
crate::{
boundary,
domain::{
Expand Down Expand Up @@ -348,6 +348,10 @@ pub fn order_excluded_from_auction(
}

/// Observe that a settlement was simulated
pub fn simulated(tx: &eth::Tx, gas: Gas) {
tracing::debug!(gas = ?gas.0, ?tx, "simulated settlement");
pub fn simulated(eth: &Ethereum, tx: &eth::Tx, gas: &Result<Gas, simulator::Error>) {
let block: eth::BlockNo = eth.current_block().borrow().number.into();
match gas {
Ok(gas) => tracing::debug!(block = ?block, gas = ?gas.0, ?tx, "simulated settlement"),
Err(err) => tracing::debug!(block = ?block, ?err, "simulated settlement"),
}
}

0 comments on commit 52b2fe4

Please sign in to comment.