Skip to content

feat: log broken invariant as soon as it is found#14433

Merged
zerosnacks merged 3 commits intomasterfrom
steven/log-invariant-failures
Apr 24, 2026
Merged

feat: log broken invariant as soon as it is found#14433
zerosnacks merged 3 commits intomasterfrom
steven/log-invariant-failures

Conversation

@stevencartavia
Copy link
Copy Markdown
Collaborator

Motivation

closes #13285

Solution

  • Emit a structured "failure" JSON event immediately when an invariant breaks, with timestamp, invariant name, target contract, and revert reason
  • Add failures and unique_failures counters to periodic pulse metrics (will be non-zero once feat(invariant): assert all invariants on continuous_run #12587 lands)
  • Add "event": "pulse" field to periodic metrics for uniform event dispatch

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

Copy link
Copy Markdown
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, ty, minor nit re payload to match proposed one

Comment thread crates/evm/evm/src/executors/invariant/mod.rs Outdated
Copy link
Copy Markdown
Collaborator

@mablr mablr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, just a minor concern

#[derive(Debug, Default)]
struct InvariantFailureMetrics {
failures: u64,
unique_failures: HashSet<String>,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to dedup by invariant name, what if two different have an invariant with the same name ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there can be invariants with same name but only in different contracts (an invariant is defined by solidity fn) but since we run each invariant campaign independently per (contract, function) pair, then they cannot collide

@grandizzy grandizzy self-requested a review April 24, 2026 08:45
Copy link
Copy Markdown
Collaborator

@grandizzy grandizzy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm!

@zerosnacks zerosnacks merged commit a9c67c2 into master Apr 24, 2026
15 of 19 checks passed
@zerosnacks zerosnacks deleted the steven/log-invariant-failures branch April 24, 2026 11:32
@github-project-automation github-project-automation Bot moved this to Done in Foundry Apr 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Log broken invariant as soon as it is found

4 participants