Skip to content

Commit 63e8535

Browse files
authored
feat: merge-train/fairies (#24994)
BEGIN_COMMIT_OVERRIDE chore: remove constant generation call for languages other than TS from yarn-project/constants (#24730) chore: consumer driven constant selection (#24734) chore: turn constants codegen into a formal dependency (#24958) chore!: move protocol contracts out of noir-contracts.js (#24998) END_COMMIT_OVERRIDE
2 parents e352885 + 9cb41f6 commit 63e8535

65 files changed

Lines changed: 758 additions & 1746 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

barretenberg/cpp/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,5 @@ android-sysroot/
2828
# without scripts/flavor-codegen/.gitignore still hides the on-disk artifacts.
2929
scripts/flavor-codegen/dist/
3030
scripts/flavor-codegen/node_modules/
31+
pil/vm2/constants_gen.pil
32+
src/barretenberg/aztec/aztec_constants.hpp

barretenberg/cpp/.rebuild_patterns

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@
88
^barretenberg/cpp/CMakePresets.json
99
^ipc-codegen/src/.*\.ts$
1010
^ipc-codegen/templates/cpp/
11+
^protocol/constants-codegen/
12+
^noir-projects/noir-protocol-circuits/crates/types/src/constants\.nr$

barretenberg/cpp/CLAUDE.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -122,15 +122,18 @@ When making changes that affect proof sizes (e.g., pairing points encoding, publ
122122

123123
1. **C++ static_asserts** in `dsl/acir_format/mock_verifier_inputs.test.cpp` - These catch size changes at compile time
124124
2. **Noir constants** in `noir-projects/noir-protocol-circuits/crates/types/src/constants.nr`
125-
3. **TypeScript constants** - Run `yarn remake-constants` from `yarn-project/constants` to regenerate
125+
3. **Generated constants** - All projections (`aztec_constants.hpp`, `constants.gen.ts`, `ConstantsGen.sol`,
126+
`constants_gen.pil`) regenerate automatically at build time; none need a manual step. If AVM-related constants
127+
changed, also run `scripts/avm2_gen.sh` and commit the resulting `vm2/generated` changes.
126128

127129
Key constants to watch:
128130
- `RECURSIVE_PROOF_LENGTH` - UltraHonk proof + DefaultIO public inputs
129131
- `CHONK_PROOF_LENGTH` - ChonkProof + HidingKernelIO public inputs
130132
- `PAIRING_POINTS_SIZE` - Size of pairing points in public inputs
131133
- `HIDING_KERNEL_PUBLIC_INPUTS_SIZE` - Size of HidingKernelIO
132134

133-
If C++ static_asserts fail after your changes, update both the assert values AND the corresponding Noir constants, then run `yarn remake-constants`.
135+
If C++ static_asserts fail after your changes, update both the assert values and the corresponding Noir constants, then
136+
run the generation commands above.
134137

135138
## Prover.toml Fixtures
136139

barretenberg/cpp/CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,21 @@ project(
99
LANGUAGES CXX C
1010
)
1111

12+
# aztec_constants.hpp is generated from the protocol's Noir constant definitions. Generation
13+
# needs the surrounding monorepo; a checkout without it must provide the header by other means.
14+
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../protocol/constants-codegen/src/cli.ts")
15+
set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS
16+
"${CMAKE_CURRENT_SOURCE_DIR}/../../noir-projects/noir-protocol-circuits/crates/types/src/constants.nr"
17+
)
18+
execute_process(
19+
COMMAND "${CMAKE_CURRENT_SOURCE_DIR}/scripts/remake-constants.sh"
20+
RESULT_VARIABLE AZTEC_CONSTANTS_GEN_RESULT
21+
)
22+
if(NOT AZTEC_CONSTANTS_GEN_RESULT EQUAL 0)
23+
message(FATAL_ERROR "aztec_constants.hpp generation failed")
24+
endif()
25+
endif()
26+
1227
# === Platform Guard Reference ===
1328
# __wasm__ : Compiler-defined for WebAssembly. Guards threading, file I/O, networking.
1429
# _WIN32 : Compiler-defined for Windows. Guards POSIX APIs (mmap, signals, IPC).

barretenberg/cpp/bootstrap.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,8 @@ export -f cmake_build preset_cache_paths build_preset build_format_check build_n
246246
function build {
247247
echo_header "bb cpp build"
248248

249+
denoise ./scripts/remake-constants.sh
250+
249251
if [ "$CI_FULL" -eq 1 ]; then
250252
# Deletes all build dirs and build bb and wasms from scratch.
251253
rm -rf build*

barretenberg/cpp/pil/vm2/constants_gen.pil

Lines changed: 0 additions & 182 deletions
This file was deleted.
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
#!/usr/bin/env bash
22
current_dir="$(dirname "$(readlink -f "$0")")"
33
cd $current_dir/../
4+
5+
repo_root=$(git rev-parse --show-toplevel)
6+
"$repo_root/protocol/constants-codegen/scripts/generate.sh" --pil pil/vm2/constants_gen.pil \
7+
--selection "$repo_root/barretenberg/cpp/scripts/constants-codegen/pil.json"
8+
49
../../bb-pilcom/target/release/bb_pil pil/vm2/tx.pil \
510
--name Avm2 -y -o src/barretenberg/vm2/generated \
611
&& ./format.sh changed

barretenberg/cpp/scripts/bump_avm_proof_length.sh

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
# 1. Discover the new computed length from the C++ flavor and (if it differs
1313
# from constants.nr) print instructions for the user to update constants.nr,
1414
# then exit. The user updates constants.nr by hand and re-runs the script.
15-
# 2. Once constants.nr is in sync: run yarn remake-constants (propagates to
16-
# aztec_constants.hpp / constants.gen.ts / ConstantsGen.sol / constants_gen.pil),
15+
# 2. Once constants.nr is in sync: regenerate each consumer's constants,
1716
# renew the pinned public-base-rollup VKs (see renew-pins below), rebuild Noir
1817
# (which also regenerates the remaining circuit VKs as a byproduct of bb write_vk
1918
# during the bootstrap), and regenerate Prover.toml fixtures via the e2e full.test
@@ -139,7 +138,7 @@ Update $(realpath --relative-to="$ROOT" "$CONSTANTS_NR"):
139138
pub global AVM_V2_PROOF_LENGTH_IN_FIELDS: u32 = $computed;
140139
141140
Then re-run barretenberg/cpp/scripts/bump_avm_proof_length.sh to finish the cascade
142-
(yarn remake-constants → noir rebuild → Prover.toml regen).
141+
(constant regeneration → noir rebuild → Prover.toml regen).
143142
EOF
144143
exit 0
145144
}
@@ -215,13 +214,17 @@ renew_base_public_pins() {
215214
phase2_cascade() {
216215
step "Phase 2: propagating to mirrors and rebuilding…"
217216

218-
step "yarn remake-constants (constants.nr → aztec_constants.hpp, constants.gen.ts, ConstantsGen.sol, constants_gen.pil)"
219-
if ! (cd "$ROOT/yarn-project" && yarn workspace @aztec/constants remake-constants); then
217+
step "Regenerating constants for TypeScript and Barretenberg"
218+
if ! (
219+
cd "$ROOT/yarn-project"
220+
yarn workspace @aztec/constants generate
221+
"$ROOT/barretenberg/cpp/scripts/remake-constants.sh"
222+
); then
220223
cat >&2 <<EOF
221224
222-
ERROR: yarn remake-constants failed. Make sure yarn-project is bootstrapped:
225+
ERROR: constants regeneration failed. Make sure the repository is bootstrapped:
223226
224-
./bootstrap.sh build yarn-project
227+
./bootstrap.sh build constants-codegen
225228
226229
Then re-run barretenberg/cpp/scripts/bump_avm_proof_length.sh.
227230
EOF
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
[
2+
"MAX_ETH_ADDRESS_BIT_SIZE",
3+
"MAX_ETH_ADDRESS_VALUE",
4+
"ARCHIVE_HEIGHT",
5+
"NOTE_HASH_TREE_HEIGHT",
6+
"PUBLIC_DATA_TREE_HEIGHT",
7+
"NULLIFIER_TREE_HEIGHT",
8+
"L1_TO_L2_MSG_TREE_HEIGHT",
9+
"NOTE_HASH_TREE_LEAF_COUNT",
10+
"L1_TO_L2_MSG_TREE_LEAF_COUNT",
11+
"NULLIFIER_SUBTREE_HEIGHT",
12+
"MAX_NOTE_HASHES_PER_TX",
13+
"MAX_NULLIFIERS_PER_TX",
14+
"MAX_ENQUEUED_CALLS_PER_TX",
15+
"MAX_TOTAL_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX",
16+
"MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX",
17+
"MAX_L2_TO_L1_MSGS_PER_TX",
18+
"GENESIS_BLOCK_HEADER_HASH",
19+
"GENESIS_ARCHIVE_ROOT",
20+
"MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS",
21+
"MAX_PROTOCOL_CONTRACTS",
22+
"CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS",
23+
"CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS",
24+
"FEE_JUICE_ADDRESS",
25+
"FEE_JUICE_BALANCES_SLOT",
26+
"UPDATED_CLASS_IDS_SLOT",
27+
"FLAT_PUBLIC_LOGS_HEADER_LENGTH",
28+
"FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH",
29+
"PUBLIC_LOGS_LENGTH",
30+
"PUBLIC_LOG_HEADER_LENGTH",
31+
"MAX_PUBLIC_LOG_SIZE_IN_FIELDS",
32+
"AVM_.*",
33+
"MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS",
34+
"MEM_TAG_FF",
35+
"MEM_TAG_U1",
36+
"MEM_TAG_U8",
37+
"MEM_TAG_U16",
38+
"MEM_TAG_U32",
39+
"MEM_TAG_U64",
40+
"MEM_TAG_U128",
41+
"TX_DA_GAS_OVERHEAD",
42+
"PUBLIC_TX_L2_GAS_OVERHEAD",
43+
"MAX_PROCESSABLE_L2_GAS",
44+
"TIMESTAMP_OF_CHANGE_BIT_SIZE",
45+
"UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN",
46+
"UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE",
47+
"DEFAULT_MAX_DEBUG_LOG_MEMORY_READS",
48+
"DOM_SEP__SILOED_NOTE_HASH",
49+
"DOM_SEP__UNIQUE_NOTE_HASH",
50+
"DOM_SEP__NOTE_HASH_NONCE",
51+
"DOM_SEP__SILOED_NULLIFIER",
52+
"DOM_SEP__PUBLIC_LEAF_SLOT",
53+
"DOM_SEP__PUBLIC_STORAGE_MAP_SLOT",
54+
"DOM_SEP__MERKLE_HASH",
55+
"DOM_SEP__NULLIFIER_MERKLE",
56+
"DOM_SEP__PUBLIC_DATA_MERKLE",
57+
"DOM_SEP__WRITTEN_SLOTS_MERKLE",
58+
"DOM_SEP__RETRIEVED_BYTECODES_MERKLE",
59+
"DOM_SEP__PUBLIC_BYTECODE",
60+
"DOM_SEP__CONTRACT_CLASS_ID",
61+
"DOM_SEP__SALTED_INITIALIZATION_HASH",
62+
"DOM_SEP__PUBLIC_KEYS_HASH",
63+
"DOM_SEP__SINGLE_PUBLIC_KEY_HASH",
64+
"DOM_SEP__PARTIAL_ADDRESS",
65+
"DOM_SEP__CONTRACT_ADDRESS_V2",
66+
"DOM_SEP__BLOCK_HEADER_HASH",
67+
"DOM_SEP__PUBLIC_CALLDATA"
68+
]

0 commit comments

Comments
 (0)