ethereum-optimism / ethereum-optimism/optimism
op-reth: --all-features test/lint runs exit(1) on hosts without an invariant TSC (tracy)
- Dominant language
- Go
- Stars
- 6.5k
- Forks
- 4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 145
Description
## Symptom
On a host whose CPU lacks an invariant TSC, running the op-reth CLI tests with all features exits before any test runs:
```
CPU doesn't support invariant TSC.
Define TRACY_NO_INVARIANT_CHECK=1 to ignore this error, *if you know what you are doing*.
```
Setting `TRACY_NO_INVARIANT_CHECK=1` makes it go away. Nothing in the repo sets it — the string appears nowhere in `.circleci/`, `.github/`, `mise.toml`, `rust/justfile`, `rust/.cargo/config.toml`, `rust/.config/nextest.toml` or `docs/ai/rust-dev.md`.
## Precondition — it is an `--all-features` problem
`tracy` is *not* a default feature: `rust/op-reth/crates/cli/Cargo.toml` has `default = []` and [`tracy = ["reth-tracing/tracy", "reth-node-core/tracy"]`](https://github.com/ethereum-optimism/optimism/blob/68b009443f67cf830990e913bcbde8536cb15327/rust/op-reth/crates/cli/Cargo.toml#L116). `cargo tree -p reth-optimism-cli -i tracy-client-sys` reports the package is not in the graph at all; adding `--all-features` resolves it via `reth-tracing` → `tracy-client 0.18.4` → `tracy-client-sys 0.28.0`.
That matters, because `--all-features` is exactly what every repo-standard recipe uses — [`just test-unit`](https://github.com/ethereum-optimism/optimism/blob/68b009443f67cf830990e913bcbde8536cb15327/rust/justfile#L99-L100), `just test-docs`, `just lint-clippy`. So the issue is not "the `-p reth-optimism-cli` tests", it is "any `--all-features` build on such a host".
The workspace does not enable `tracy-client/manual-lifetime`, so Tracy initialises **before `main`** in every binary that links it — including test binaries that never touch tracy. The check itself is in the vendored C profiler (`tracy-client-sys-0.28.0/tracy/client/TracyProfiler.cpp`, `CheckHardwareSupportsInvariantTSC`), and its failure path ends in `exit(1)`, not `abort()`. Two details: the env var must literally *start with* `'1'`, and the guard is skipped entirely when the C lib is built with `TRACY_TIMER_FALLBACK`, which we do not do.
## Fix assessment
**(a) `[env]` in `rust/.cargo/config.toml` — recommended.** Three lines:
```toml
[env]
TRACY_NO_INVARIANT_CHECK = "1"
```
The file currently has only `[alias]` and two Windows `[target.*]` blocks, so this is additive. Verified empirically with a throwaway crate that both **`cargo test` and `cargo nextest`** pick it up — nextest reads it from *Cargo's* config, so `rust/.config/nextest.toml` is not the lever. Cargo `[env]` entries are non-forced by default, so an explicit `TRACY_NO_INVARIANT_CHECK=0` in the shell still wins and anyone who genuinely wants the guard keeps it. Cost: on an affected host, a real tracy profiling run now produces garbage timestamps instead of refusing to start — narrow, and worth a one-line `why` comment next to the setting.
**(b) Make tracy non-default / not enabled in tests — not viable cheaply.** Cargo's `--all-features` has no exclusion mechanism (the denylist idea belongs to the separate `cargo-all-features` tool, which this repo does not use). The alternatives are dropping the `tracy` feature from `rust/op-reth/crates/cli/Cargo.toml` and `rust/op-reth/bin/Cargo.toml` — removing a real capability — or replacing `--all-features` with explicit feature lists in every recipe, which is high-churn and drifts. Forcing `tracy-client/manual-lifetime` would require an in-tree crate to depend on `tracy-client` purely to unify the feature on, and would change semantics for genuine profiling users.
**(c) Document it in [`docs/ai/rust-dev.md`](https://github.com/ethereum-optimism/optimism/blob/68b009443f67cf830990e913bcbde8536cb15327/docs/ai/rust-dev.md#L58-L72).** 2–4 lines under "Running Tests". Not sufficient alone — a fresh clone on an affected host hits the wall before reading docs — but worth doing alongside (a) so the setting is discoverable and its rationale recorded.
**Verdict: (a) + (c).** ~3 lines of config, ~3 lines of docs, no build-graph change.
Unrelated finding while tracing this: `rust/Cargo.toml` declares `tracy-client = "0.18.4"` in `[workspace.dependencies]` but no in-tree crate references it (`tracy-client.workspace = true` appears nowhere) — `reth-tracing` resolves its own copy. Probably a leftover from a reth shared-dependency sync; worth a glance at the next `update-reth`.
🤖 *Co-created with Claude Fable 5*
Contributor guide
Research direction
Start with rust/.cargo/config.toml and the Running Tests section of docs/ai/rust-dev.md. Add the documented Tracy environment setting and its rationale, then run the repository's all-features cargo test and cargo nextest commands on a host without invariant TSC. Done means the tests no longer exit before running and the workaround is discoverable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- build-system, documentation, testing
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 88/100