Skip to content

chore: add noirfmt.toml to noir-contracts and run nargo fmt#22971

Merged
benesjan merged 1 commit into
merge-train/fairiesfrom
claudebox/noir-contracts-fmt-config
May 6, 2026
Merged

chore: add noirfmt.toml to noir-contracts and run nargo fmt#22971
benesjan merged 1 commit into
merge-train/fairiesfrom
claudebox/noir-contracts-fmt-config

Conversation

@AztecBot

@AztecBot AztecBot commented May 5, 2026

Copy link
Copy Markdown
Collaborator

Summary

nargo fmt was using compiler defaults on noir-projects/noir-contracts/ (no noirfmt.toml), so long comments stayed unwrapped and the directory drifted stylistically from aztec-nr/, which already opts into max_width=120 + wrap_comments=true.

This PR:

  1. Adds noir-projects/noir-contracts/noirfmt.toml mirroring aztec-nr/noirfmt.toml:
    max_width=120
    wrap_comments=true
    comment_width=120
    
  2. Runs nargo fmt over the workspace — 116 .nr files reformatted (mostly collapsing previously 100-col-wrapped use { ... } blocks and method chains onto single lines, plus comment wrapping at 120).
  3. Cleans up six files' C-style block comments. nargo fmt has an idempotency bug under wrap_comments=true where /** ... */ and /****/ blocks at non-zero indent gain 4 cols of indentation on every fmt run; converting them removes the foot-gun. Per CLAUDE.md's formatting rules, /** doc */ blocks become /// line comments, banner-style section dividers (/****** Storage ******/) are deleted entirely, and "what" comments that just restate the function name are dropped. Files touched: schnorr_account_contract, nft_contract, private_token_contract, token_contract, avm_test_contract, avm_initializer_test_contract. Noir issue filed here nargo fmt drifts /** */ inner lines with whitespace when wrap_comments=true noir-lang/noir#12552

Verification

  • nargo fmt --check clean and idempotent in noir-projects/noir-contracts/.
  • All file changes are confined to noir-projects/noir-contracts/ (.nr files + the new noirfmt.toml).

Full analysis: https://gist.github.com/AztecBot/5192169a50b51fdc887f05eeed354e43

@AztecBot AztecBot added ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR. labels May 5, 2026
@vezenovm vezenovm changed the base branch from next to merge-train/fairies May 5, 2026 19:56

@vezenovm vezenovm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is an instance where https://linear.app/aztec-labs/issue/F-607/adopt-cargo-insta-for-noir-contract-snapshot-testing would be useful. We are only change the formatting and thus should see no differences in our snapshots.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Only non-fmt change in this PR

@vezenovm vezenovm marked this pull request as ready for review May 5, 2026 20:32
@vezenovm vezenovm requested review from benesjan, nchamo and nventuro May 5, 2026 20:32

@benesjan benesjan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nice

@benesjan benesjan merged commit 6a1a4a9 into merge-train/fairies May 6, 2026
31 checks passed
@benesjan benesjan deleted the claudebox/noir-contracts-fmt-config branch May 6, 2026 06:22
@AztecBot

AztecBot commented May 6, 2026

Copy link
Copy Markdown
Collaborator Author

❌ Failed to cherry-pick to v4-next due to conflicts. (🤖) View backport run.

benesjan added a commit that referenced this pull request May 6, 2026
Backport of #22971 to `backport-to-v4-next-staging`.

Auto cherry-pick failed on 5 files due to v4-next semantic drift from
`merge-train/fairies`. Resolved manually using the 3-commit backport
pattern.

## Conflicts resolved

| File | Resolution |
|---|---|
| `nft_contract/src/types/nft_note.nr` | keep v4-next (no
`compute_note_hash` direct usage) |
| `protocol/auth_registry_contract/src/main.nr` | keep v4-next
(expanded-macro form) |
| `protocol/contract_class_registry_contract/src/validate_bytecode.nr` |
keep v4-next (PR base has additional tests not yet here) |
| `test/note_hash_and_nullifier/.../test_note.nr` | keep v4-next (uses
`poseidon2_hash_with_separator` directly) |
| `test/test_log_contract/src/test/tx_effects.nr` | keep deleted
(already removed on v4-next) |

The PR is fmt-only, so wherever v4-next has different content, that
content is preserved and `nargo fmt` is re-run with the new
`noirfmt.toml` so the result is internally consistent.

## Commits (preserved per backport rules)

1. `chore: add noirfmt.toml to noir-contracts and run nargo fmt
(cherry-pick #22971)` — cherry-pick AS-IS with conflict markers (does
not compile by design)
2. `fix: resolve cherry-pick conflicts by keeping v4-next-staging
content`
3. `chore: re-run nargo fmt with new noirfmt.toml config`

## Verification

- `nargo fmt --check` clean in `noir-projects/noir-contracts/`
- 117 files changed (matches PR scope: noirfmt.toml + 116 .nr files)
- No conflict markers, `.rej`, or `.orig` files remain

Detailed analysis:
https://gist.github.com/AztecBot/dabe6018f40af2369cec56de821510f3

ClaudeBox log: https://claudebox.work/s/a0fd76c8e05d8ddb?run=1
benesjan added a commit that referenced this pull request May 7, 2026
This PR accumulates backport commits and will be auto-merged overnight.

Backports included:
- #22977 - chore: backport noirfmt.toml + nargo fmt (#22971) to v4-next
- #22958 - chore: backport pxe db schema compatibility test (#22872) to
v4-next

> Created manually because the auto-cherry-pick step failed for both
source PRs (#22971, #22872) due to conflicts; the manual fix-up PRs
bypassed the script that normally opens this PR.

🤖 This PR is normally managed automatically by the backport workflow.
rangozd pushed a commit to rangozd/aztec-packages that referenced this pull request May 16, 2026
BEGIN_COMMIT_OVERRIDE
refactor: `getPackageVersion` fn cleanup (AztecProtocol#22941)
fix(ci): skip acceptance test for canary -commit. tags (AztecProtocol#22951)
fix: closing db, correct stub side effects (AztecProtocol#22939)
feat: wallet-sdk heartbeat (AztecProtocol#22948)
chore: pxe db schema compatibility test (AztecProtocol#22872)
feat: stamping aztec version into contract artifacts (AztecProtocol#22550)
fix: add aztecVersion to PXE schema_tests fixture (AztecProtocol#22960)
feat(pxe): deduplicate class ID verification per contract (AztecProtocol#22966)
chore: add noirfmt.toml to noir-contracts and run nargo fmt (AztecProtocol#22971)
feat(aztec-nr): Initial handshake registry contract with non interactive
handshake function (AztecProtocol#22854)
chore: merge next into merge-train/fairies (AztecProtocol#22991)
fix(aztec-up): Aztec installer does not shadow user installed binaries
on PATH (AztecProtocol#22902)
test(ci): drop e2e_kernelless_simulation from backwards-compat e2e
(AztecProtocol#23005)
feat(ci): notify #team-fairies when backwards-compat e2e fails on
nightly (AztecProtocol#23006)
chore: merge next into merge-train/fairies (AztecProtocol#23021)
fix: better DeployMethod (AztecProtocol#22985)
refactor(pxe): batch RPC calls for note and event validation (AztecProtocol#22988)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-to-v4-next ci-draft Run CI on draft PRs. claudebox Owned by claudebox. it can push to this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants