Skip to content

Commit

Permalink
Merge branch 'main' into small-refactor-settlement
Browse files Browse the repository at this point in the history
  • Loading branch information
sunce86 authored Aug 9, 2024
2 parents a5e98fb + 95ecc4e commit 406f5fc
Show file tree
Hide file tree
Showing 11 changed files with 372 additions and 25 deletions.
2 changes: 2 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[build]
rustflags = ["--cfg", "tokio_unstable"]
147 changes: 147 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ tempfile = "3.10.1"
time = { version = "0.3.36", features = ["macros"] }
thiserror = "1.0.61"
toml = "0.8.14"
tokio = "1.38.0"
tokio = { version = "1.38.0", features = ["tracing"] }
tokio-stream = { version = "0.1.15", features = ["sync"] }
tracing = "0.1.40"
tracing-subscriber = "0.3.18"
Expand Down
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,27 @@ ANVIL_IP_ADDR=0.0.0.0 anvil \
--timestamp 1577836800
```

### Profiling

The most important binaries support [tokio-console](https://github.com/tokio-rs/console) to allow you a could look inside the tokio runtime.

Simply enable the feature by passing `--enable-tokio-console true` when running a binary and then in another shell, run

```
cargo install --locked tokio-console
tokio-console
```


### Changing Log Filters

It's possible to change the tracing log filter while the process is running. This can be useful to debug an error that requires more verbose logs but which might no longer appear after restarting the system.

Each process opens a UNIX socket at `/tmp/log_filter_override_<program_name>_<pid>.sock`. To change the log filter connect to it with `nc -U <path>` and enter a new log filter.
You can also reset the log filter to the filter the program was initially started with by entering `reset`.

See [here](https://docs.rs/tracing-subscriber/latest/tracing_subscriber/filter/struct.EnvFilter.html#directives) for documentation on the supported log filter format.

## Running the Services Locally

### Prerequisites
Expand Down
13 changes: 9 additions & 4 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ use {
::observe::metrics,
anyhow::Result,
database::order_events::OrderEventLabel,
itertools::Itertools,
model::solver_competition::{
CompetitionAuction,
Order,
Expand Down Expand Up @@ -130,6 +131,14 @@ impl RunLoop {
};
let competition_simulation_block = self.eth.current_block().borrow().number;

let considered_orders = solutions
.iter()
.flat_map(|solution| solution.solution.order_ids().copied())
.unique()
.collect();
self.persistence
.store_order_events(considered_orders, OrderEventLabel::Considered);

// TODO: Keep going with other solutions until some deadline.
if let Some(Participant { driver, solution }) = solutions.last() {
tracing::info!(driver = %driver.name, solution = %solution.id(), "winner");
Expand All @@ -146,10 +155,6 @@ impl RunLoop {
}
};

let order_uids = solution.order_ids().copied().collect();
self.persistence
.store_order_events(order_uids, OrderEventLabel::Considered);

let winner = solution.solver().into();
let winning_score = solution.score().get().0;
let reference_score = solutions
Expand Down
3 changes: 2 additions & 1 deletion crates/observe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ edition = "2021"
license = "MIT OR Apache-2.0"

[dependencies]
atty = "0.2.14"
atty = "0.2"
console-subscriber = "0.3.0"
futures = { workspace = true }
once_cell = { workspace = true }
pin-project-lite = "0.2.14"
Expand Down
4 changes: 4 additions & 0 deletions crates/observe/build.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
fn main() {
// Make build system aware of custom config flags to avoid clippy warnings
println!("cargo::rustc-check-cfg=cfg(tokio_unstable)");
}
3 changes: 3 additions & 0 deletions crates/observe/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,6 @@ pub mod metrics;
pub mod panic_hook;
pub mod request_id;
pub mod tracing;

#[cfg(unix)]
mod tracing_reload_handler;
Loading

0 comments on commit 406f5fc

Please sign in to comment.