@aztec/constants 0.0.1-commit.e3c1de76 → 0.0.1-commit.e57c76e

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,7 +3,7 @@ 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.
@@ -21,12 +21,10 @@ const CPP_CONSTANTS = [
21
21
  'MEM_TAG_U128',
22
22
  'MEM_TAG_FF',
23
23
  'MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS',
24
- 'CANONICAL_AUTH_REGISTRY_ADDRESS',
25
24
  'CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS',
26
25
  'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
27
- 'MULTI_CALL_ENTRYPOINT_ADDRESS',
28
26
  'FEE_JUICE_ADDRESS',
29
- 'PUBLIC_CHECKS_ADDRESS',
27
+ 'TX_DA_GAS_OVERHEAD',
30
28
  'FEE_JUICE_BALANCES_SLOT',
31
29
  'UPDATED_CLASS_IDS_SLOT',
32
30
  'UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN',
@@ -42,6 +40,7 @@ const CPP_CONSTANTS = [
42
40
  'MAX_NOTE_HASHES_PER_TX',
43
41
  'MAX_NULLIFIERS_PER_TX',
44
42
  'MAX_L2_TO_L1_MSGS_PER_TX',
43
+ 'MAX_PROCESSABLE_L2_GAS',
45
44
  'MAX_PUBLIC_LOGS_PER_TX',
46
45
  'MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX',
47
46
  'MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS',
@@ -109,15 +108,18 @@ const CPP_CONSTANTS = [
109
108
  'FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH',
110
109
  'PUBLIC_LOGS_LENGTH',
111
110
  'PUBLIC_LOG_HEADER_LENGTH',
111
+ 'PUBLIC_TX_L2_GAS_OVERHEAD',
112
112
  'MAX_PROTOCOL_CONTRACTS',
113
113
  'DEFAULT_MAX_DEBUG_LOG_MEMORY_READS'
114
114
  ];
115
115
  const CPP_GENERATORS = [
116
116
  'BLOCK_HEADER_HASH',
117
+ 'SALTED_INITIALIZATION_HASH',
117
118
  'PARTIAL_ADDRESS',
118
- 'CONTRACT_ADDRESS_V1',
119
+ 'CONTRACT_ADDRESS_V2',
119
120
  'CONTRACT_CLASS_ID',
120
121
  'PUBLIC_KEYS_HASH',
122
+ 'SINGLE_PUBLIC_KEY_HASH',
121
123
  'NOTE_HASH_NONCE',
122
124
  'UNIQUE_NOTE_HASH',
123
125
  'SILOED_NOTE_HASH',
@@ -125,7 +127,12 @@ const CPP_GENERATORS = [
125
127
  'PUBLIC_LEAF_SLOT',
126
128
  'PUBLIC_STORAGE_MAP_SLOT',
127
129
  'PUBLIC_CALLDATA',
128
- 'PUBLIC_BYTECODE'
130
+ 'PUBLIC_BYTECODE',
131
+ 'MERKLE_HASH',
132
+ 'NULLIFIER_MERKLE',
133
+ 'PUBLIC_DATA_MERKLE',
134
+ 'WRITTEN_SLOTS_MERKLE',
135
+ 'RETRIEVED_BYTECODES_MERKLE'
129
136
  ];
130
137
  const PIL_CONSTANTS = [
131
138
  'MAX_ETH_ADDRESS_VALUE',
@@ -159,12 +166,9 @@ const PIL_CONSTANTS = [
159
166
  'L1_TO_L2_MSG_TREE_HEIGHT',
160
167
  'UPDATED_CLASS_IDS_SLOT',
161
168
  'UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN',
162
- 'CANONICAL_AUTH_REGISTRY_ADDRESS',
163
169
  'CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS',
164
170
  'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
165
- 'MULTI_CALL_ENTRYPOINT_ADDRESS',
166
171
  'FEE_JUICE_ADDRESS',
167
- 'PUBLIC_CHECKS_ADDRESS',
168
172
  'FEE_JUICE_BALANCES_SLOT',
169
173
  'TIMESTAMP_OF_CHANGE_BIT_SIZE',
170
174
  'UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE',
@@ -248,10 +252,10 @@ const PIL_CONSTANTS = [
248
252
  'AVM_DYN_GAS_ID_RETURNDATACOPY',
249
253
  'AVM_DYN_GAS_ID_TORADIX',
250
254
  'AVM_DYN_GAS_ID_BITWISE',
251
- 'AVM_DYN_GAS_ID_EMITUNENCRYPTEDLOG',
255
+ 'AVM_DYN_GAS_ID_EMITPUBLICLOG',
252
256
  'AVM_DYN_GAS_ID_SSTORE',
253
257
  'AVM_SUBTRACE_ID_GETCONTRACTINSTANCE',
254
- 'AVM_SUBTRACE_ID_EMITUNENCRYPTEDLOG',
258
+ 'AVM_SUBTRACE_ID_EMITPUBLICLOG',
255
259
  'AVM_EXEC_OP_ID_GETENVVAR',
256
260
  'AVM_EXEC_OP_ID_MOV',
257
261
  'AVM_EXEC_OP_ID_JUMP',
@@ -300,10 +304,12 @@ const PIL_CONSTANTS = [
300
304
  'MAX_PROTOCOL_CONTRACTS'
301
305
  ];
302
306
  const PIL_GENERATORS = [
307
+ 'SALTED_INITIALIZATION_HASH',
303
308
  'PARTIAL_ADDRESS',
304
- 'CONTRACT_ADDRESS_V1',
309
+ 'CONTRACT_ADDRESS_V2',
305
310
  'CONTRACT_CLASS_ID',
306
311
  'PUBLIC_KEYS_HASH',
312
+ 'SINGLE_PUBLIC_KEY_HASH',
307
313
  'NOTE_HASH_NONCE',
308
314
  'UNIQUE_NOTE_HASH',
309
315
  'SILOED_NOTE_HASH',
@@ -311,7 +317,12 @@ const PIL_GENERATORS = [
311
317
  'PUBLIC_LEAF_SLOT',
312
318
  'PUBLIC_STORAGE_MAP_SLOT',
313
319
  'PUBLIC_CALLDATA',
314
- 'PUBLIC_BYTECODE'
320
+ 'PUBLIC_BYTECODE',
321
+ 'MERKLE_HASH',
322
+ 'NULLIFIER_MERKLE',
323
+ 'PUBLIC_DATA_MERKLE',
324
+ 'WRITTEN_SLOTS_MERKLE',
325
+ 'RETRIEVED_BYTECODES_MERKLE'
315
326
  ];
316
327
  const SOLIDITY_CONSTANTS = [
317
328
  'MAX_FIELD_VALUE',
@@ -325,7 +336,7 @@ const SOLIDITY_CONSTANTS = [
325
336
  'INITIAL_CHECKPOINT_NUMBER',
326
337
  'GENESIS_ARCHIVE_ROOT',
327
338
  'FEE_JUICE_ADDRESS',
328
- 'AZTEC_MAX_EPOCH_DURATION'
339
+ 'MAX_CHECKPOINTS_PER_EPOCH'
329
340
  ];
330
341
  /**
331
342
  * Processes a collection of constants and generates code to export them as TypeScript constants.
@@ -417,30 +428,30 @@ const SOLIDITY_CONSTANTS = [
417
428
  }
418
429
  /**
419
430
  * Generate the constants file in Typescript.
420
- */ function generateTypescriptConstants({ constants, generatorIndexEnum }, targetPath) {
431
+ */ function generateTypescriptConstants({ constants, domainSeparatorEnum }, targetPath) {
421
432
  const result = [
422
433
  '// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants',
423
434
  processConstantsTS(constants),
424
- processEnumTS('GeneratorIndex', generatorIndexEnum)
435
+ processEnumTS('DomainSeparator', domainSeparatorEnum)
425
436
  ].join('\n');
426
437
  fs.writeFileSync(targetPath, result);
427
438
  }
428
439
  /**
429
440
  * Generate the constants file in C++.
430
- */ function generateCppConstants({ constants, generatorIndexEnum }, targetPath) {
441
+ */ function generateCppConstants({ constants, domainSeparatorEnum }, targetPath) {
431
442
  const resultCpp = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
432
443
  #pragma once
433
444
 
434
- ${processConstantsCpp(constants, generatorIndexEnum)}
445
+ ${processConstantsCpp(constants, domainSeparatorEnum)}
435
446
  `;
436
447
  fs.writeFileSync(targetPath, resultCpp);
437
448
  }
438
449
  /**
439
450
  * Generate the constants file in PIL.
440
- */ function generatePilConstants({ constants, generatorIndexEnum }, targetPath) {
451
+ */ function generatePilConstants({ constants, domainSeparatorEnum }, targetPath) {
441
452
  const resultPil = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
442
453
  namespace constants;
443
- ${processConstantsPil(constants, generatorIndexEnum)}
454
+ ${processConstantsPil(constants, domainSeparatorEnum)}
444
455
  \n`;
445
456
  fs.writeFileSync(targetPath, resultPil);
446
457
  }
@@ -470,7 +481,7 @@ ${processConstantsSolidity(constants)}
470
481
  * Parse the content of the constants file in Noir.
471
482
  */ function parseNoirFile(fileContent) {
472
483
  const constantsExpressions = [];
473
- const generatorIndexEnum = {};
484
+ const domainSeparatorEnum = {};
474
485
  const emptyExpression = ()=>({
475
486
  name: '',
476
487
  content: []
@@ -492,7 +503,7 @@ ${processConstantsSolidity(constants)}
492
503
  const [, indexName] = name.match(/DOM_SEP__(\w+)/) || [];
493
504
  if (indexName) {
494
505
  // Generator index.
495
- generatorIndexEnum[indexName] = +value;
506
+ domainSeparatorEnum[indexName] = +value;
496
507
  } else if (end) {
497
508
  // A single line of expression.
498
509
  constantsExpressions.push([
@@ -540,7 +551,7 @@ ${processConstantsSolidity(constants)}
540
551
  const constants = evaluateExpressions(constantsExpressions);
541
552
  return {
542
553
  constants,
543
- generatorIndexEnum
554
+ domainSeparatorEnum
544
555
  };
545
556
  }
546
557
  /**
@@ -567,7 +578,11 @@ ${processConstantsSolidity(constants)}
567
578
  .replace(/\(/g, '( ').replace(/\)/g, ' )')// We also make some space around common operators
568
579
  .replace(/\+/g, ' + ').replace(/(?<!\/)\*(?!\/)/, ' * ')// We split the expression into terms...
569
580
  .split(/\s+/)// ...and then we convert each term to a BigInt if it is a number.
570
- .map((term)=>isNaN(+term) ? term : `BigInt('${term}')`)// .. also, we convert the known bigints to BigInts.
581
+ .map((term)=>{
582
+ // Remove underscores from numeric literals (e.g., 6_000_000 -> 6000000)
583
+ const termWithoutUnderscores = term.replace(/_/g, '');
584
+ return isNaN(+termWithoutUnderscores) ? term : `BigInt('${termWithoutUnderscores}')`;
585
+ })// .. also, we convert the known bigints to BigInts.
571
586
  .map((term)=>knownBigInts.includes(term) ? `BigInt(${term})` : term)// We join the terms back together.
572
587
  .join(' ');
573
588
  return `var ${name} = ${guardedRhs};`;
package/package.json CHANGED
@@ -1,10 +1,17 @@
1
1
  {
2
2
  "name": "@aztec/constants",
3
- "version": "0.0.1-commit.e3c1de76",
3
+ "version": "0.0.1-commit.e57c76e",
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
  },
@@ -16,7 +23,7 @@
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": {
19
- "@aztec/foundation": "0.0.1-commit.e3c1de76",
26
+ "@aztec/foundation": "0.0.1-commit.e57c76e",
20
27
  "tslib": "^2.4.0"
21
28
  },
22
29
  "devDependencies": {