Skip to content

feat(standard-contracts): show expected-vs-actual diff in drift error#23710

Merged
dbanks12 merged 6 commits into
merge-train/fairiesfrom
dbanks12/drift-error-diff
May 29, 2026
Merged

feat(standard-contracts): show expected-vs-actual diff in drift error#23710
dbanks12 merged 6 commits into
merge-train/fairiesfrom
dbanks12/drift-error-diff

Conversation

@dbanks12
Copy link
Copy Markdown
Contributor

@dbanks12 dbanks12 commented May 29, 2026

When a standard contract's derived address/class data drifts, the build now reports exactly which consts changed (old → new), so you can read the new values without rebuilding locally.

Build-time generator error (generate_data.ts)

Standard contract addresses have changed. The following generated files were out of date and have been rewritten in-place with the freshly-derived values:
  - ./src/standard_contract_data.ts
  - ../../noir-projects/aztec-nr/aztec/src/standard_addresses.nr
  - ../../noir-projects/noir-contracts/contracts/protocol/aztec_sublib/src/standard_addresses.nr

Changed values (old → new):
  PublicChecks.address: 0x05d900a6ed1b4ad3ff52cbe5f98d9b291b0f35c6dd5c41b1642659344d234bfe → 0x157adf2a48199ba8f417358aa8d728c00ceb83923425694d7c738291b4fc8902
  PublicChecks.classId: 0x022bbd3c085d6a09ec500110852441419c7b1e6dc21a8d459233b72a84d03a1f → 0x11a1123d541845258225c31b116f5d0ebb2d83a020ac173096ea7eb2ece483e9
  PublicChecks.publicBytecodeCommitment: 0x013c4f854a5c87c9daf86c5f9bc07a42c2a061f1d924a5b3564ec7edc8e18cb7 → 0x185edf0f22857537a30a03eeb76f56b2c5b1cd49495294391d74f88ac6528e6b

  ...stale-bytecode note + recovery steps...

Backup jest test

One expect().toEqual() per contract (every field, every contract surfaces — not just the first), plus a .nr twins check.

● standard_contract_data drift › per-field derivation › AuthRegistry: all derived fields match committed values
    - Expected  - 1
    + Received  + 1
      Object {
    -   "address": "0x01de9d215d1845808cf388d3a88f9066af1e73ec280e979c3b1aec8ba6b149ea",
    +   "address": "0x1ad6c58d49414977725dbde2f5052708ca67548730d98adee2d3833c91348a24",
        "artifactHash": "0x0dd24a86cce5ff4ef33ca14f16359c5a154ce3f1ed91a9570dd5343569f5386f",
        "classId": "0x2cfbdd0ce7cc31b5cc5f4eb8f680e0e245882b2208bd67828e41a8bd24a19292",
        ...
      }

● standard_contract_data drift › committed standard_addresses.nr twins match re-rendered output
    - Expected  - 2
    + Received  + 2
      pub global STANDARD_AUTH_REGISTRY_ADDRESS: AztecAddress = AztecAddress::from_field(
    -     0x1ad6c58d49414977725dbde2f5052708ca67548730d98adee2d3833c91348a24,
    +     0x01de9d215d1845808cf388d3a88f9066af1e73ec280e979c3b1aec8ba6b149ea,
      );

dbanks12 added 2 commits May 29, 2026 17:36
When a standard contract's derived address/class data drifts, the generator
rewrote the stale files but the error only listed which files changed. Devs (and
CI log readers) then had to rebuild locally to discover the new values.

Render a compact unified diff (collapsing unchanged runs) of each rewritten file
into the error, so the freshly-derived values are readable straight off the '+'
lines without a local rebuild.
…d-editable

A context-free agent reading the drift error tried to find the source trigger by
diffing; add one line clarifying these are derived values (don't hand-edit) and
that drift comes from an upstream change — a modified contract, its
initialization parameters, or the bb/noir compiler.
@dbanks12 dbanks12 marked this pull request as ready for review May 29, 2026 18:55
dbanks12 added 4 commits May 29, 2026 19:04
… diff

Replace the hand-rolled LCS unified-diff renderer with a direct comparison of the
freshly-derived values against the committed ones, printing only the consts that
changed (e.g. `AuthRegistry.address: 0x… → 0x…`). This drops ~70 lines of generic
diff machinery from drift.ts (reverting writeIfChanged to its original boolean) in
favour of a small semantic comparison the reader actually wants.
…qual

Assemble every derived field per contract into one object and compare against the
committed values with a single `expect(...).toEqual(...)`, so a drift surfaces as
a standard jest expected/received object diff covering all fields at once, instead
of many granular per-field assertions.
The per-field comparison already covers every TS-side value, and the build-time
generator enforces file formatting — so the full-file standard_contract_data.ts
toEqual was redundant (and the noisy one). Keep only the standard_addresses.nr
twins check, which uniquely verifies the circuit-facing Noir address files (the
per-field block reads only the TS exports).
@dbanks12 dbanks12 requested a review from nchamo May 29, 2026 20:16
Copy link
Copy Markdown
Contributor

@nchamo nchamo left a comment

Choose a reason for hiding this comment

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

Thanks for doing this!

@dbanks12 dbanks12 merged commit 2f502d4 into merge-train/fairies May 29, 2026
17 checks passed
@dbanks12 dbanks12 deleted the dbanks12/drift-error-diff branch May 29, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants