Skip to content

chore: remove constant generation call for languages other than TS from yarn-project/constants - #24730

Merged
fcarreiro merged 32 commits into
merge-train/fairiesfrom
martin/constants-consumer-generation
Jul 27, 2026
Merged

chore: remove constant generation call for languages other than TS from yarn-project/constants#24730
fcarreiro merged 32 commits into
merge-train/fairiesfrom
martin/constants-consumer-generation

Conversation

@mverzilli

@mverzilli mverzilli commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Adds remake-constants scripts to barretenberg and l1-contracts so they control which constants are generated for themselves.

Conversely removes those from yarn-projects/constants.

Removes generated constant files from git, regenerating them on build based on constants.nr as the source of truth.

Closes F-817, F-813, F-818, F-820, F-816

@mverzilli
mverzilli requested a review from charlielye July 15, 2026 15:43
Comment thread barretenberg/cpp/bootstrap.sh Outdated
Comment thread Makefile Outdated
Comment thread yarn-project/constants/precommit.sh Outdated
@mverzilli
mverzilli marked this pull request as ready for review July 21, 2026 12:09
Base automatically changed from martin/constants-codegen-release to merge-train/fairies July 21, 2026 12:33
Comment thread l1-contracts/bootstrap.sh Outdated
@mverzilli mverzilli added the ci-release-pr Creates a development tag and runs the release suite label Jul 21, 2026
@AztecBot AztecBot removed the ci-release-pr Creates a development tag and runs the release suite label Jul 21, 2026
@mverzilli mverzilli added the ci-release-pr Creates a development tag and runs the release suite label Jul 21, 2026
@AztecBot AztecBot removed the ci-release-pr Creates a development tag and runs the release suite label Jul 21, 2026
@mverzilli
mverzilli requested a review from fcarreiro July 21, 2026 18:53
@mverzilli
mverzilli requested a review from charlielye July 21, 2026 19:59
Comment thread barretenberg/cpp/CMakeLists.txt
Comment thread barretenberg/cpp/CMakeLists.txt
Comment thread yarn-project/constants/scripts/remake-constants.sh

repo_root=$(git rev-parse --show-toplevel)
codegen_dir="$repo_root/protocol/constants-codegen"
additional_input="$repo_root/noir-projects/noir-protocol-circuits/crates/types/src/blob_data/tx_blob_data.nr:MAX_TX_BLOB_DATA_SIZE_IN_FIELDS"

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.

Ah well this is a bit of a curve ball. I was hoping we wouldn't need to directly reference the constants.nr or any other protocol file here (which otherwise implies we need to have it checked out). We might have the protocol circuits, but it seems wrong to need them just to be able to get some constants.

(this is not a criticism to your PR! it's moving everything in the right direction)

Do you have a plan?

@mverzilli mverzilli Jul 22, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, this would need to change. I don't have a detailed plan, more of a cursory idea:

  1. Move noir-protocol-circuits under protocol/ (this is of course more than just a simple move, there's true deps to be detangled).
  2. Embed constants.nr when packaging constants-codegen.
  3. Figure out what to do with MAX_TX_BLOB_DATA_SIZE_IN_FIELDS, maybe it just needs to be moved to constants.nr? Maybe we do need to embed more than one file? Didn't open that particular box yet.

The end state of this file should look just like running the constants-codegen cli from a published constants-codegen version, so no direct references to either .nr file.

Comment thread l1-contracts/scripts/remake-constants.sh
@@ -1,4 +1,6 @@
^l1-contracts/src/.*\.sol$
^l1-contracts/scripts/remake-constants\.sh$
^protocol/constants-codegen/

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.

I'm a bit torn about this one...

Locally, I'm tempted to think "rebuild if the ConstantsGen.sol file changed". Of course, that's tricky because it is the build script itself that generates the .sol file...

Also, if the constants.nr file changes, this probably wouldn't catch the change? (because it's not in that directory [unless the bootrstap file in that dir copies it over -- which it may if it gets embedded])

In any case, I guess what I'm trying to say, consider using the cache_contents_hash approach in the bootstrap file, for dependencies, and consider keeping the list of files here local: https://github.com/AztecProtocol/aztec-packages/blob/next/l1-contracts/bootstrap.sh#L42 . I'm not 100% sure what the convention is across the repo)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This comment sent me down a rabbit hole trying to determine the best way to go at this point. Here's what I found. There's two different questions here:

constants.nr not detected: it is being detected, but incidentally (via the verifier contract's deps). So I think it is a good call to be explicit about it.

Regarding not using this for external deps here: I'm using it in barretenberg for example, so a concern I have is to keep it consistent. More on that below.

I didn't find any specific docs on the intended usage of .rebuild_patterns, but there's a couple of crumbs that point at it being de-facto used as a way for a component C to refer to a component D rebuild conditions, since the cache_contents_hash doesn't cross component boundaries.

Eg 1: in barretenberg itself, ipc-codegen is referred to (d49dd8b).

Eg 2: https://github.com/AztecProtocol/aztec-packages/blob/next/noir-projects/noir-contracts/bootstrap.sh#L62 (and similarly in yarn-project/)

So I think at this point I would only add a specific reference to constants.nr in this file, which should be fine because noir-protocol-contracts will continue to be under Foundation's repo at the end of the day

if (!values.input) {
throw new Error('--input is required');
// Resolved relative to this file, so it exists only when the package sits inside the
// aztec-packages monorepo; the published npm package must be given --input explicitly.

@fcarreiro fcarreiro Jul 22, 2026

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.

Same comment about this. We may want the file embedded. (ok if in a later PR as well)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Agree. Sharing current thinking to check if we're in the same page:

  1. Embedding is only needed for dependants outside foundation repo, since inside foundation repo you most likely want to work with latest constants.nr.
  2. constants.nr will still live under noir-protocol-contracts (though untangling it from labs projects is pending work),
  3. constants.nr could then be embedded at packing time (this code should then be adjusted accordingly).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's now #24958, which embeds constants.nr at packing time but also adds some bash auxiliaries so that in-repo consumers of constants don't need to know where it comes from.

@mverzilli mverzilli added the ci-release-pr Creates a development tag and runs the release suite label Jul 24, 2026
@AztecBot AztecBot removed the ci-release-pr Creates a development tag and runs the release suite label Jul 24, 2026
@fcarreiro
fcarreiro merged commit 9b24ea5 into merge-train/fairies Jul 27, 2026
38 checks passed
@fcarreiro
fcarreiro deleted the martin/constants-consumer-generation branch July 27, 2026 10:18
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.

5 participants