@aztec/constants 0.0.1-commit.5daedc8 → 0.0.1-commit.6201a7b05

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,12 +3,14 @@ import { dirname, join } from 'path';
3
3
  import { fileURLToPath } from 'url';
4
4
  const NOIR_CONSTANTS_FILE = '../../../../noir-projects/noir-protocol-circuits/crates/types/src/constants.nr';
5
5
  const TS_CONSTANTS_FILE = '../constants.gen.ts';
6
- const CPP_AZTEC_CONSTANTS_FILE = '../../../../barretenberg/cpp/src/barretenberg/vm2/common/aztec_constants.hpp';
6
+ const CPP_AZTEC_CONSTANTS_FILE = '../../../../barretenberg/cpp/src/barretenberg/aztec/aztec_constants.hpp';
7
7
  const PIL_AZTEC_CONSTANTS_FILE = '../../../../barretenberg/cpp/pil/vm2/constants_gen.pil';
8
8
  const SOLIDITY_CONSTANTS_FILE = '../../../../l1-contracts/src/core/libraries/ConstantsGen.sol';
9
9
  // Whitelist of constants that will be copied to aztec_constants.hpp.
10
10
  // We don't copy everything as just a handful are needed, and updating them breaks the cache and triggers expensive bb builds.
11
11
  const CPP_CONSTANTS = [
12
+ 'MAX_ETH_ADDRESS_BIT_SIZE',
13
+ 'MAX_ETH_ADDRESS_VALUE',
12
14
  'GENESIS_BLOCK_HEADER_HASH',
13
15
  'GENESIS_ARCHIVE_ROOT',
14
16
  'MEM_TAG_U1',
@@ -24,7 +26,8 @@ const CPP_CONSTANTS = [
24
26
  'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
25
27
  'MULTI_CALL_ENTRYPOINT_ADDRESS',
26
28
  'FEE_JUICE_ADDRESS',
27
- 'ROUTER_ADDRESS',
29
+ 'TX_DA_GAS_OVERHEAD',
30
+ 'PUBLIC_CHECKS_ADDRESS',
28
31
  'FEE_JUICE_BALANCES_SLOT',
29
32
  'UPDATED_CLASS_IDS_SLOT',
30
33
  'UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN',
@@ -40,6 +43,7 @@ const CPP_CONSTANTS = [
40
43
  'MAX_NOTE_HASHES_PER_TX',
41
44
  'MAX_NULLIFIERS_PER_TX',
42
45
  'MAX_L2_TO_L1_MSGS_PER_TX',
46
+ 'MAX_PROCESSABLE_L2_GAS',
43
47
  'MAX_PUBLIC_LOGS_PER_TX',
44
48
  'MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX',
45
49
  'MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS',
@@ -107,23 +111,33 @@ const CPP_CONSTANTS = [
107
111
  'FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH',
108
112
  'PUBLIC_LOGS_LENGTH',
109
113
  'PUBLIC_LOG_HEADER_LENGTH',
114
+ 'PUBLIC_TX_L2_GAS_OVERHEAD',
110
115
  'MAX_PROTOCOL_CONTRACTS',
111
116
  'DEFAULT_MAX_DEBUG_LOG_MEMORY_READS'
112
117
  ];
113
118
  const CPP_GENERATORS = [
119
+ 'BLOCK_HEADER_HASH',
120
+ 'SALTED_INITIALIZATION_HASH',
114
121
  'PARTIAL_ADDRESS',
115
122
  'CONTRACT_ADDRESS_V1',
116
- 'CONTRACT_LEAF',
123
+ 'CONTRACT_CLASS_ID',
117
124
  'PUBLIC_KEYS_HASH',
118
125
  'NOTE_HASH_NONCE',
119
126
  'UNIQUE_NOTE_HASH',
120
127
  'SILOED_NOTE_HASH',
121
- 'OUTER_NULLIFIER',
122
- 'PUBLIC_LEAF_INDEX',
128
+ 'SILOED_NULLIFIER',
129
+ 'PUBLIC_LEAF_SLOT',
130
+ 'PUBLIC_STORAGE_MAP_SLOT',
123
131
  'PUBLIC_CALLDATA',
124
- 'PUBLIC_BYTECODE'
132
+ 'PUBLIC_BYTECODE',
133
+ 'MERKLE_HASH',
134
+ 'NULLIFIER_MERKLE',
135
+ 'PUBLIC_DATA_MERKLE',
136
+ 'WRITTEN_SLOTS_MERKLE',
137
+ 'RETRIEVED_BYTECODES_MERKLE'
125
138
  ];
126
139
  const PIL_CONSTANTS = [
140
+ 'MAX_ETH_ADDRESS_VALUE',
127
141
  'MEM_TAG_U1',
128
142
  'MEM_TAG_U8',
129
143
  'MEM_TAG_U16',
@@ -159,7 +173,7 @@ const PIL_CONSTANTS = [
159
173
  'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
160
174
  'MULTI_CALL_ENTRYPOINT_ADDRESS',
161
175
  'FEE_JUICE_ADDRESS',
162
- 'ROUTER_ADDRESS',
176
+ 'PUBLIC_CHECKS_ADDRESS',
163
177
  'FEE_JUICE_BALANCES_SLOT',
164
178
  'TIMESTAMP_OF_CHANGE_BIT_SIZE',
165
179
  'UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE',
@@ -243,10 +257,10 @@ const PIL_CONSTANTS = [
243
257
  'AVM_DYN_GAS_ID_RETURNDATACOPY',
244
258
  'AVM_DYN_GAS_ID_TORADIX',
245
259
  'AVM_DYN_GAS_ID_BITWISE',
246
- 'AVM_DYN_GAS_ID_EMITUNENCRYPTEDLOG',
260
+ 'AVM_DYN_GAS_ID_EMITPUBLICLOG',
247
261
  'AVM_DYN_GAS_ID_SSTORE',
248
262
  'AVM_SUBTRACE_ID_GETCONTRACTINSTANCE',
249
- 'AVM_SUBTRACE_ID_EMITUNENCRYPTEDLOG',
263
+ 'AVM_SUBTRACE_ID_EMITPUBLICLOG',
250
264
  'AVM_EXEC_OP_ID_GETENVVAR',
251
265
  'AVM_EXEC_OP_ID_MOV',
252
266
  'AVM_EXEC_OP_ID_JUMP',
@@ -295,21 +309,29 @@ const PIL_CONSTANTS = [
295
309
  'MAX_PROTOCOL_CONTRACTS'
296
310
  ];
297
311
  const PIL_GENERATORS = [
312
+ 'SALTED_INITIALIZATION_HASH',
298
313
  'PARTIAL_ADDRESS',
299
314
  'CONTRACT_ADDRESS_V1',
300
- 'CONTRACT_LEAF',
315
+ 'CONTRACT_CLASS_ID',
301
316
  'PUBLIC_KEYS_HASH',
302
317
  'NOTE_HASH_NONCE',
303
318
  'UNIQUE_NOTE_HASH',
304
319
  'SILOED_NOTE_HASH',
305
- 'OUTER_NULLIFIER',
306
- 'PUBLIC_LEAF_INDEX',
320
+ 'SILOED_NULLIFIER',
321
+ 'PUBLIC_LEAF_SLOT',
322
+ 'PUBLIC_STORAGE_MAP_SLOT',
307
323
  'PUBLIC_CALLDATA',
308
- 'PUBLIC_BYTECODE'
324
+ 'PUBLIC_BYTECODE',
325
+ 'MERKLE_HASH',
326
+ 'NULLIFIER_MERKLE',
327
+ 'PUBLIC_DATA_MERKLE',
328
+ 'WRITTEN_SLOTS_MERKLE',
329
+ 'RETRIEVED_BYTECODES_MERKLE'
309
330
  ];
310
331
  const SOLIDITY_CONSTANTS = [
311
332
  'MAX_FIELD_VALUE',
312
333
  'MAX_L2_TO_L1_MSGS_PER_TX',
334
+ 'EMPTY_EPOCH_OUT_HASH',
313
335
  'L1_TO_L2_MSG_SUBTREE_HEIGHT',
314
336
  'NUM_MSGS_PER_BASE_PARITY',
315
337
  'NUM_BASE_PARITY_PER_ROOT_PARITY',
@@ -318,7 +340,7 @@ const SOLIDITY_CONSTANTS = [
318
340
  'INITIAL_CHECKPOINT_NUMBER',
319
341
  'GENESIS_ARCHIVE_ROOT',
320
342
  'FEE_JUICE_ADDRESS',
321
- 'AZTEC_MAX_EPOCH_DURATION'
343
+ 'MAX_CHECKPOINTS_PER_EPOCH'
322
344
  ];
323
345
  /**
324
346
  * Processes a collection of constants and generates code to export them as TypeScript constants.
@@ -341,7 +363,7 @@ const SOLIDITY_CONSTANTS = [
341
363
  */ function processConstantsCpp(constants, generatorIndices) {
342
364
  const code = [];
343
365
  Object.entries(constants).forEach(([key, value])=>{
344
- if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_') && key !== 'AVM_VK_INDEX') {
366
+ if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')) {
345
367
  if (BigInt(value) <= 2n ** 31n - 1n) {
346
368
  code.push(`#define ${key} ${value}`);
347
369
  } else if (BigInt(value) <= 2n ** 64n - 1n) {
@@ -353,7 +375,7 @@ const SOLIDITY_CONSTANTS = [
353
375
  });
354
376
  Object.entries(generatorIndices).forEach(([key, value])=>{
355
377
  if (CPP_GENERATORS.includes(key)) {
356
- code.push(`#define GENERATOR_INDEX__${key} ${value}`);
378
+ code.push(`#define DOM_SEP__${key} ${value}UL`);
357
379
  }
358
380
  });
359
381
  return code.join('\n');
@@ -373,7 +395,7 @@ const SOLIDITY_CONSTANTS = [
373
395
  });
374
396
  Object.entries(generatorIndices).forEach(([key, value])=>{
375
397
  if (PIL_GENERATORS.includes(key)) {
376
- code.push(` pol GENERATOR_INDEX__${key} = ${value};`);
398
+ code.push(` pol DOM_SEP__${key} = ${value};`);
377
399
  }
378
400
  });
379
401
  return code.join('\n');
@@ -410,30 +432,30 @@ const SOLIDITY_CONSTANTS = [
410
432
  }
411
433
  /**
412
434
  * Generate the constants file in Typescript.
413
- */ function generateTypescriptConstants({ constants, generatorIndexEnum }, targetPath) {
435
+ */ function generateTypescriptConstants({ constants, domainSeparatorEnum }, targetPath) {
414
436
  const result = [
415
437
  '// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants',
416
438
  processConstantsTS(constants),
417
- processEnumTS('GeneratorIndex', generatorIndexEnum)
439
+ processEnumTS('DomainSeparator', domainSeparatorEnum)
418
440
  ].join('\n');
419
441
  fs.writeFileSync(targetPath, result);
420
442
  }
421
443
  /**
422
444
  * Generate the constants file in C++.
423
- */ function generateCppConstants({ constants, generatorIndexEnum }, targetPath) {
445
+ */ function generateCppConstants({ constants, domainSeparatorEnum }, targetPath) {
424
446
  const resultCpp = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
425
447
  #pragma once
426
448
 
427
- ${processConstantsCpp(constants, generatorIndexEnum)}
449
+ ${processConstantsCpp(constants, domainSeparatorEnum)}
428
450
  `;
429
451
  fs.writeFileSync(targetPath, resultCpp);
430
452
  }
431
453
  /**
432
454
  * Generate the constants file in PIL.
433
- */ function generatePilConstants({ constants, generatorIndexEnum }, targetPath) {
455
+ */ function generatePilConstants({ constants, domainSeparatorEnum }, targetPath) {
434
456
  const resultPil = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
435
457
  namespace constants;
436
- ${processConstantsPil(constants, generatorIndexEnum)}
458
+ ${processConstantsPil(constants, domainSeparatorEnum)}
437
459
  \n`;
438
460
  fs.writeFileSync(targetPath, resultPil);
439
461
  }
@@ -463,7 +485,7 @@ ${processConstantsSolidity(constants)}
463
485
  * Parse the content of the constants file in Noir.
464
486
  */ function parseNoirFile(fileContent) {
465
487
  const constantsExpressions = [];
466
- const generatorIndexEnum = {};
488
+ const domainSeparatorEnum = {};
467
489
  const emptyExpression = ()=>({
468
490
  name: '',
469
491
  content: []
@@ -482,10 +504,10 @@ ${processConstantsSolidity(constants)}
482
504
  {
483
505
  const [, name, _type, value, end] = line.match(/global\s+(\w+)(\s*:\s*\w+)?\s*=\s*([^;]*)(;)?/) || [];
484
506
  if (name && value) {
485
- const [, indexName] = name.match(/GENERATOR_INDEX__(\w+)/) || [];
507
+ const [, indexName] = name.match(/DOM_SEP__(\w+)/) || [];
486
508
  if (indexName) {
487
509
  // Generator index.
488
- generatorIndexEnum[indexName] = +value;
510
+ domainSeparatorEnum[indexName] = +value;
489
511
  } else if (end) {
490
512
  // A single line of expression.
491
513
  constantsExpressions.push([
@@ -533,7 +555,7 @@ ${processConstantsSolidity(constants)}
533
555
  const constants = evaluateExpressions(constantsExpressions);
534
556
  return {
535
557
  constants,
536
- generatorIndexEnum
558
+ domainSeparatorEnum
537
559
  };
538
560
  }
539
561
  /**
@@ -560,7 +582,11 @@ ${processConstantsSolidity(constants)}
560
582
  .replace(/\(/g, '( ').replace(/\)/g, ' )')// We also make some space around common operators
561
583
  .replace(/\+/g, ' + ').replace(/(?<!\/)\*(?!\/)/, ' * ')// We split the expression into terms...
562
584
  .split(/\s+/)// ...and then we convert each term to a BigInt if it is a number.
563
- .map((term)=>isNaN(+term) ? term : `BigInt('${term}')`)// .. also, we convert the known bigints to BigInts.
585
+ .map((term)=>{
586
+ // Remove underscores from numeric literals (e.g., 6_000_000 -> 6000000)
587
+ const termWithoutUnderscores = term.replace(/_/g, '');
588
+ return isNaN(+termWithoutUnderscores) ? term : `BigInt('${termWithoutUnderscores}')`;
589
+ })// .. also, we convert the known bigints to BigInts.
564
590
  .map((term)=>knownBigInts.includes(term) ? `BigInt(${term})` : term)// We join the terms back together.
565
591
  .join(' ');
566
592
  return `var ${name} = ${guardedRhs};`;
package/package.json CHANGED
@@ -1,28 +1,36 @@
1
1
  {
2
2
  "name": "@aztec/constants",
3
- "version": "0.0.1-commit.5daedc8",
3
+ "version": "0.0.1-commit.6201a7b05",
4
4
  "type": "module",
5
5
  "inherits": [
6
6
  "../package.common.json"
7
7
  ],
8
+ "typedocOptions": {
9
+ "entryPoints": [
10
+ "./src/constants.gen.ts"
11
+ ],
12
+ "name": "Constants",
13
+ "tsconfig": "./tsconfig.json"
14
+ },
8
15
  "exports": {
9
16
  ".": "./dest/constants.js"
10
17
  },
11
18
  "scripts": {
12
- "build": "yarn clean && tsgo -b",
13
- "build:dev": "tsgo -b --watch",
19
+ "build": "yarn clean && ../scripts/tsc.sh",
20
+ "build:dev": "../scripts/tsc.sh --watch",
14
21
  "clean": "rm -rf ./dest .tsbuildinfo",
15
22
  "remake-constants": "node --loader @swc-node/register/esm src/scripts/constants.in.ts && cd ../../l1-contracts && forge fmt",
16
23
  "test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
17
24
  },
18
25
  "dependencies": {
26
+ "@aztec/foundation": "0.0.1-commit.6201a7b05",
19
27
  "tslib": "^2.4.0"
20
28
  },
21
29
  "devDependencies": {
22
30
  "@jest/globals": "^30.0.0",
23
31
  "@types/jest": "^30.0.0",
24
32
  "@types/node": "^22.15.17",
25
- "@typescript/native-preview": "7.0.0-dev.20251126.1",
33
+ "@typescript/native-preview": "7.0.0-dev.20260113.1",
26
34
  "eslint": "^9.26.0",
27
35
  "jest": "^30.0.0",
28
36
  "prettier": "^3.5.3",