feat(standard-contracts): show expected-vs-actual diff in drift error#23710
Merged
Conversation
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.
… 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).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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)Backup jest test
One
expect().toEqual()per contract (every field, every contract surfaces — not just the first), plus a.nrtwins check.