@aztec/constants 0.0.1-commit.fce3e4f → 0.0.1-commit.ffe5b04ea

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.
package/dest/constants.js CHANGED
@@ -1,4 +1,26 @@
1
+ import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
2
+ import { Fr } from '@aztec/foundation/curves/bn254';
3
+ // Re-export L2 block number constants with proper BlockNumber type
4
+ // Note: The generated constants are plain numbers, but we provide typed versions here
5
+ import { GENESIS_BLOCK_HEADER_HASH as GENESIS_BLOCK_HEADER_HASH_BIGINT, INITIAL_CHECKPOINT_NUMBER as INITIAL_CHECKPOINT_NUM_RAW, INITIAL_L2_BLOCK_NUM as INITIAL_L2_BLOCK_NUM_RAW, MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT, MAX_PROCESSABLE_L2_GAS } from './constants.gen.js';
1
6
  // Typescript-land-only constants
2
7
  export const SPONSORED_FPC_SALT = BigInt(0);
3
8
  // Autogenerated constants loaded from noir-land
9
+ // eslint-disable-next-line import-x/export
4
10
  export * from './constants.gen.js';
11
+ /** The initial L2 block number (typed as BlockNumber). This is the first block number in the Aztec L2 chain. */ // eslint-disable-next-line import-x/export
12
+ export const INITIAL_L2_BLOCK_NUM = BlockNumber(INITIAL_L2_BLOCK_NUM_RAW);
13
+ /** The initial L2 checkpoint number (typed as CheckpointNumber). This is the first checkpoint number in the Aztec L2 chain. */ // eslint-disable-next-line import-x/export
14
+ export const INITIAL_CHECKPOINT_NUMBER = CheckpointNumber(INITIAL_CHECKPOINT_NUM_RAW);
15
+ /** The block header hash for the genesis block 0. */ // eslint-disable-next-line import-x/export
16
+ export const GENESIS_BLOCK_HEADER_HASH = new Fr(GENESIS_BLOCK_HEADER_HASH_BIGINT);
17
+ // Override the default gas limits set in noir-protocol-circuit constants with saner ones
18
+ // Note that these values are not used in noir-land and are only for use in TypeScript code, so we can set them to whatever we want.
19
+ // eslint-disable-next-line import-x/export
20
+ export const DEFAULT_L2_GAS_LIMIT = MAX_PROCESSABLE_L2_GAS;
21
+ // eslint-disable-next-line import-x/export
22
+ export const DEFAULT_TEARDOWN_L2_GAS_LIMIT = DEFAULT_L2_GAS_LIMIT / 8;
23
+ // eslint-disable-next-line import-x/export
24
+ export const DEFAULT_DA_GAS_LIMIT = MAX_PROCESSABLE_DA_GAS_PER_CHECKPOINT / 4;
25
+ // eslint-disable-next-line import-x/export
26
+ export const DEFAULT_TEARDOWN_DA_GAS_LIMIT = DEFAULT_DA_GAS_LIMIT / 2;
@@ -9,6 +9,8 @@ const SOLIDITY_CONSTANTS_FILE = '../../../../l1-contracts/src/core/libraries/Con
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,27 @@ 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',
114
120
  'PARTIAL_ADDRESS',
115
121
  'CONTRACT_ADDRESS_V1',
116
- 'CONTRACT_LEAF',
122
+ 'CONTRACT_CLASS_ID',
117
123
  'PUBLIC_KEYS_HASH',
118
124
  'NOTE_HASH_NONCE',
119
125
  'UNIQUE_NOTE_HASH',
120
126
  'SILOED_NOTE_HASH',
121
- 'OUTER_NULLIFIER',
122
- 'PUBLIC_LEAF_INDEX',
127
+ 'SILOED_NULLIFIER',
128
+ 'PUBLIC_LEAF_SLOT',
129
+ 'PUBLIC_STORAGE_MAP_SLOT',
123
130
  'PUBLIC_CALLDATA',
124
131
  'PUBLIC_BYTECODE'
125
132
  ];
126
133
  const PIL_CONSTANTS = [
134
+ 'MAX_ETH_ADDRESS_VALUE',
127
135
  'MEM_TAG_U1',
128
136
  'MEM_TAG_U8',
129
137
  'MEM_TAG_U16',
@@ -159,7 +167,7 @@ const PIL_CONSTANTS = [
159
167
  'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
160
168
  'MULTI_CALL_ENTRYPOINT_ADDRESS',
161
169
  'FEE_JUICE_ADDRESS',
162
- 'ROUTER_ADDRESS',
170
+ 'PUBLIC_CHECKS_ADDRESS',
163
171
  'FEE_JUICE_BALANCES_SLOT',
164
172
  'TIMESTAMP_OF_CHANGE_BIT_SIZE',
165
173
  'UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE',
@@ -243,10 +251,10 @@ const PIL_CONSTANTS = [
243
251
  'AVM_DYN_GAS_ID_RETURNDATACOPY',
244
252
  'AVM_DYN_GAS_ID_TORADIX',
245
253
  'AVM_DYN_GAS_ID_BITWISE',
246
- 'AVM_DYN_GAS_ID_EMITUNENCRYPTEDLOG',
254
+ 'AVM_DYN_GAS_ID_EMITPUBLICLOG',
247
255
  'AVM_DYN_GAS_ID_SSTORE',
248
256
  'AVM_SUBTRACE_ID_GETCONTRACTINSTANCE',
249
- 'AVM_SUBTRACE_ID_EMITUNENCRYPTEDLOG',
257
+ 'AVM_SUBTRACE_ID_EMITPUBLICLOG',
250
258
  'AVM_EXEC_OP_ID_GETENVVAR',
251
259
  'AVM_EXEC_OP_ID_MOV',
252
260
  'AVM_EXEC_OP_ID_JUMP',
@@ -297,19 +305,21 @@ const PIL_CONSTANTS = [
297
305
  const PIL_GENERATORS = [
298
306
  'PARTIAL_ADDRESS',
299
307
  'CONTRACT_ADDRESS_V1',
300
- 'CONTRACT_LEAF',
308
+ 'CONTRACT_CLASS_ID',
301
309
  'PUBLIC_KEYS_HASH',
302
310
  'NOTE_HASH_NONCE',
303
311
  'UNIQUE_NOTE_HASH',
304
312
  'SILOED_NOTE_HASH',
305
- 'OUTER_NULLIFIER',
306
- 'PUBLIC_LEAF_INDEX',
313
+ 'SILOED_NULLIFIER',
314
+ 'PUBLIC_LEAF_SLOT',
315
+ 'PUBLIC_STORAGE_MAP_SLOT',
307
316
  'PUBLIC_CALLDATA',
308
317
  'PUBLIC_BYTECODE'
309
318
  ];
310
319
  const SOLIDITY_CONSTANTS = [
311
320
  'MAX_FIELD_VALUE',
312
321
  'MAX_L2_TO_L1_MSGS_PER_TX',
322
+ 'EMPTY_EPOCH_OUT_HASH',
313
323
  'L1_TO_L2_MSG_SUBTREE_HEIGHT',
314
324
  'NUM_MSGS_PER_BASE_PARITY',
315
325
  'NUM_BASE_PARITY_PER_ROOT_PARITY',
@@ -318,7 +328,7 @@ const SOLIDITY_CONSTANTS = [
318
328
  'INITIAL_CHECKPOINT_NUMBER',
319
329
  'GENESIS_ARCHIVE_ROOT',
320
330
  'FEE_JUICE_ADDRESS',
321
- 'AZTEC_MAX_EPOCH_DURATION'
331
+ 'MAX_CHECKPOINTS_PER_EPOCH'
322
332
  ];
323
333
  /**
324
334
  * Processes a collection of constants and generates code to export them as TypeScript constants.
@@ -341,7 +351,7 @@ const SOLIDITY_CONSTANTS = [
341
351
  */ function processConstantsCpp(constants, generatorIndices) {
342
352
  const code = [];
343
353
  Object.entries(constants).forEach(([key, value])=>{
344
- if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_') && key !== 'AVM_VK_INDEX') {
354
+ if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')) {
345
355
  if (BigInt(value) <= 2n ** 31n - 1n) {
346
356
  code.push(`#define ${key} ${value}`);
347
357
  } else if (BigInt(value) <= 2n ** 64n - 1n) {
@@ -353,7 +363,7 @@ const SOLIDITY_CONSTANTS = [
353
363
  });
354
364
  Object.entries(generatorIndices).forEach(([key, value])=>{
355
365
  if (CPP_GENERATORS.includes(key)) {
356
- code.push(`#define GENERATOR_INDEX__${key} ${value}`);
366
+ code.push(`#define DOM_SEP__${key} ${value}UL`);
357
367
  }
358
368
  });
359
369
  return code.join('\n');
@@ -373,7 +383,7 @@ const SOLIDITY_CONSTANTS = [
373
383
  });
374
384
  Object.entries(generatorIndices).forEach(([key, value])=>{
375
385
  if (PIL_GENERATORS.includes(key)) {
376
- code.push(` pol GENERATOR_INDEX__${key} = ${value};`);
386
+ code.push(` pol DOM_SEP__${key} = ${value};`);
377
387
  }
378
388
  });
379
389
  return code.join('\n');
@@ -410,30 +420,30 @@ const SOLIDITY_CONSTANTS = [
410
420
  }
411
421
  /**
412
422
  * Generate the constants file in Typescript.
413
- */ function generateTypescriptConstants({ constants, generatorIndexEnum }, targetPath) {
423
+ */ function generateTypescriptConstants({ constants, domainSeparatorEnum }, targetPath) {
414
424
  const result = [
415
425
  '// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants',
416
426
  processConstantsTS(constants),
417
- processEnumTS('GeneratorIndex', generatorIndexEnum)
427
+ processEnumTS('DomainSeparator', domainSeparatorEnum)
418
428
  ].join('\n');
419
429
  fs.writeFileSync(targetPath, result);
420
430
  }
421
431
  /**
422
432
  * Generate the constants file in C++.
423
- */ function generateCppConstants({ constants, generatorIndexEnum }, targetPath) {
433
+ */ function generateCppConstants({ constants, domainSeparatorEnum }, targetPath) {
424
434
  const resultCpp = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
425
435
  #pragma once
426
436
 
427
- ${processConstantsCpp(constants, generatorIndexEnum)}
437
+ ${processConstantsCpp(constants, domainSeparatorEnum)}
428
438
  `;
429
439
  fs.writeFileSync(targetPath, resultCpp);
430
440
  }
431
441
  /**
432
442
  * Generate the constants file in PIL.
433
- */ function generatePilConstants({ constants, generatorIndexEnum }, targetPath) {
443
+ */ function generatePilConstants({ constants, domainSeparatorEnum }, targetPath) {
434
444
  const resultPil = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
435
445
  namespace constants;
436
- ${processConstantsPil(constants, generatorIndexEnum)}
446
+ ${processConstantsPil(constants, domainSeparatorEnum)}
437
447
  \n`;
438
448
  fs.writeFileSync(targetPath, resultPil);
439
449
  }
@@ -463,7 +473,7 @@ ${processConstantsSolidity(constants)}
463
473
  * Parse the content of the constants file in Noir.
464
474
  */ function parseNoirFile(fileContent) {
465
475
  const constantsExpressions = [];
466
- const generatorIndexEnum = {};
476
+ const domainSeparatorEnum = {};
467
477
  const emptyExpression = ()=>({
468
478
  name: '',
469
479
  content: []
@@ -482,10 +492,10 @@ ${processConstantsSolidity(constants)}
482
492
  {
483
493
  const [, name, _type, value, end] = line.match(/global\s+(\w+)(\s*:\s*\w+)?\s*=\s*([^;]*)(;)?/) || [];
484
494
  if (name && value) {
485
- const [, indexName] = name.match(/GENERATOR_INDEX__(\w+)/) || [];
495
+ const [, indexName] = name.match(/DOM_SEP__(\w+)/) || [];
486
496
  if (indexName) {
487
497
  // Generator index.
488
- generatorIndexEnum[indexName] = +value;
498
+ domainSeparatorEnum[indexName] = +value;
489
499
  } else if (end) {
490
500
  // A single line of expression.
491
501
  constantsExpressions.push([
@@ -533,7 +543,7 @@ ${processConstantsSolidity(constants)}
533
543
  const constants = evaluateExpressions(constantsExpressions);
534
544
  return {
535
545
  constants,
536
- generatorIndexEnum
546
+ domainSeparatorEnum
537
547
  };
538
548
  }
539
549
  /**
@@ -560,7 +570,11 @@ ${processConstantsSolidity(constants)}
560
570
  .replace(/\(/g, '( ').replace(/\)/g, ' )')// We also make some space around common operators
561
571
  .replace(/\+/g, ' + ').replace(/(?<!\/)\*(?!\/)/, ' * ')// We split the expression into terms...
562
572
  .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.
573
+ .map((term)=>{
574
+ // Remove underscores from numeric literals (e.g., 6_000_000 -> 6000000)
575
+ const termWithoutUnderscores = term.replace(/_/g, '');
576
+ return isNaN(+termWithoutUnderscores) ? term : `BigInt('${termWithoutUnderscores}')`;
577
+ })// .. also, we convert the known bigints to BigInts.
564
578
  .map((term)=>knownBigInts.includes(term) ? `BigInt(${term})` : term)// We join the terms back together.
565
579
  .join(' ');
566
580
  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.fce3e4f",
3
+ "version": "0.0.1-commit.ffe5b04ea",
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.ffe5b04ea",
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",