@aztec/constants 0.0.1-commit.2ed92850 → 0.0.1-commit.2f68f620
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.d.ts +2 -2
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.gen.d.ts +167 -133
- package/dest/constants.gen.d.ts.map +1 -1
- package/dest/constants.gen.js +167 -133
- package/dest/constants.js +4 -6
- package/dest/scripts/constants.in.js +48 -29
- package/package.json +9 -2
- package/src/constants.gen.ts +167 -133
- package/src/constants.ts +2 -5
|
@@ -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/
|
|
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
|
-
'
|
|
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,21 +108,32 @@ const CPP_CONSTANTS = [
|
|
|
109
108
|
'FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH',
|
|
110
109
|
'PUBLIC_LOGS_LENGTH',
|
|
111
110
|
'PUBLIC_LOG_HEADER_LENGTH',
|
|
111
|
+
'MAX_PUBLIC_LOG_SIZE_IN_FIELDS',
|
|
112
|
+
'PUBLIC_TX_L2_GAS_OVERHEAD',
|
|
112
113
|
'MAX_PROTOCOL_CONTRACTS',
|
|
113
114
|
'DEFAULT_MAX_DEBUG_LOG_MEMORY_READS'
|
|
114
115
|
];
|
|
115
116
|
const CPP_GENERATORS = [
|
|
117
|
+
'BLOCK_HEADER_HASH',
|
|
118
|
+
'SALTED_INITIALIZATION_HASH',
|
|
116
119
|
'PARTIAL_ADDRESS',
|
|
117
|
-
'
|
|
120
|
+
'CONTRACT_ADDRESS_V2',
|
|
118
121
|
'CONTRACT_CLASS_ID',
|
|
119
122
|
'PUBLIC_KEYS_HASH',
|
|
123
|
+
'SINGLE_PUBLIC_KEY_HASH',
|
|
120
124
|
'NOTE_HASH_NONCE',
|
|
121
125
|
'UNIQUE_NOTE_HASH',
|
|
122
126
|
'SILOED_NOTE_HASH',
|
|
123
|
-
'
|
|
124
|
-
'
|
|
127
|
+
'SILOED_NULLIFIER',
|
|
128
|
+
'PUBLIC_LEAF_SLOT',
|
|
129
|
+
'PUBLIC_STORAGE_MAP_SLOT',
|
|
125
130
|
'PUBLIC_CALLDATA',
|
|
126
|
-
'PUBLIC_BYTECODE'
|
|
131
|
+
'PUBLIC_BYTECODE',
|
|
132
|
+
'MERKLE_HASH',
|
|
133
|
+
'NULLIFIER_MERKLE',
|
|
134
|
+
'PUBLIC_DATA_MERKLE',
|
|
135
|
+
'WRITTEN_SLOTS_MERKLE',
|
|
136
|
+
'RETRIEVED_BYTECODES_MERKLE'
|
|
127
137
|
];
|
|
128
138
|
const PIL_CONSTANTS = [
|
|
129
139
|
'MAX_ETH_ADDRESS_VALUE',
|
|
@@ -157,12 +167,9 @@ const PIL_CONSTANTS = [
|
|
|
157
167
|
'L1_TO_L2_MSG_TREE_HEIGHT',
|
|
158
168
|
'UPDATED_CLASS_IDS_SLOT',
|
|
159
169
|
'UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN',
|
|
160
|
-
'CANONICAL_AUTH_REGISTRY_ADDRESS',
|
|
161
170
|
'CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS',
|
|
162
171
|
'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
|
|
163
|
-
'MULTI_CALL_ENTRYPOINT_ADDRESS',
|
|
164
172
|
'FEE_JUICE_ADDRESS',
|
|
165
|
-
'PUBLIC_CHECKS_ADDRESS',
|
|
166
173
|
'FEE_JUICE_BALANCES_SLOT',
|
|
167
174
|
'TIMESTAMP_OF_CHANGE_BIT_SIZE',
|
|
168
175
|
'UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE',
|
|
@@ -246,10 +253,10 @@ const PIL_CONSTANTS = [
|
|
|
246
253
|
'AVM_DYN_GAS_ID_RETURNDATACOPY',
|
|
247
254
|
'AVM_DYN_GAS_ID_TORADIX',
|
|
248
255
|
'AVM_DYN_GAS_ID_BITWISE',
|
|
249
|
-
'
|
|
256
|
+
'AVM_DYN_GAS_ID_EMITPUBLICLOG',
|
|
250
257
|
'AVM_DYN_GAS_ID_SSTORE',
|
|
251
258
|
'AVM_SUBTRACE_ID_GETCONTRACTINSTANCE',
|
|
252
|
-
'
|
|
259
|
+
'AVM_SUBTRACE_ID_EMITPUBLICLOG',
|
|
253
260
|
'AVM_EXEC_OP_ID_GETENVVAR',
|
|
254
261
|
'AVM_EXEC_OP_ID_MOV',
|
|
255
262
|
'AVM_EXEC_OP_ID_JUMP',
|
|
@@ -298,17 +305,25 @@ const PIL_CONSTANTS = [
|
|
|
298
305
|
'MAX_PROTOCOL_CONTRACTS'
|
|
299
306
|
];
|
|
300
307
|
const PIL_GENERATORS = [
|
|
308
|
+
'SALTED_INITIALIZATION_HASH',
|
|
301
309
|
'PARTIAL_ADDRESS',
|
|
302
|
-
'
|
|
310
|
+
'CONTRACT_ADDRESS_V2',
|
|
303
311
|
'CONTRACT_CLASS_ID',
|
|
304
312
|
'PUBLIC_KEYS_HASH',
|
|
313
|
+
'SINGLE_PUBLIC_KEY_HASH',
|
|
305
314
|
'NOTE_HASH_NONCE',
|
|
306
315
|
'UNIQUE_NOTE_HASH',
|
|
307
316
|
'SILOED_NOTE_HASH',
|
|
308
|
-
'
|
|
309
|
-
'
|
|
317
|
+
'SILOED_NULLIFIER',
|
|
318
|
+
'PUBLIC_LEAF_SLOT',
|
|
319
|
+
'PUBLIC_STORAGE_MAP_SLOT',
|
|
310
320
|
'PUBLIC_CALLDATA',
|
|
311
|
-
'PUBLIC_BYTECODE'
|
|
321
|
+
'PUBLIC_BYTECODE',
|
|
322
|
+
'MERKLE_HASH',
|
|
323
|
+
'NULLIFIER_MERKLE',
|
|
324
|
+
'PUBLIC_DATA_MERKLE',
|
|
325
|
+
'WRITTEN_SLOTS_MERKLE',
|
|
326
|
+
'RETRIEVED_BYTECODES_MERKLE'
|
|
312
327
|
];
|
|
313
328
|
const SOLIDITY_CONSTANTS = [
|
|
314
329
|
'MAX_FIELD_VALUE',
|
|
@@ -322,7 +337,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
322
337
|
'INITIAL_CHECKPOINT_NUMBER',
|
|
323
338
|
'GENESIS_ARCHIVE_ROOT',
|
|
324
339
|
'FEE_JUICE_ADDRESS',
|
|
325
|
-
'
|
|
340
|
+
'MAX_CHECKPOINTS_PER_EPOCH'
|
|
326
341
|
];
|
|
327
342
|
/**
|
|
328
343
|
* Processes a collection of constants and generates code to export them as TypeScript constants.
|
|
@@ -357,7 +372,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
357
372
|
});
|
|
358
373
|
Object.entries(generatorIndices).forEach(([key, value])=>{
|
|
359
374
|
if (CPP_GENERATORS.includes(key)) {
|
|
360
|
-
code.push(`#define DOM_SEP__${key} ${value}`);
|
|
375
|
+
code.push(`#define DOM_SEP__${key} ${value}UL`);
|
|
361
376
|
}
|
|
362
377
|
});
|
|
363
378
|
return code.join('\n');
|
|
@@ -414,30 +429,30 @@ const SOLIDITY_CONSTANTS = [
|
|
|
414
429
|
}
|
|
415
430
|
/**
|
|
416
431
|
* Generate the constants file in Typescript.
|
|
417
|
-
*/ function generateTypescriptConstants({ constants,
|
|
432
|
+
*/ function generateTypescriptConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
418
433
|
const result = [
|
|
419
434
|
'// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants',
|
|
420
435
|
processConstantsTS(constants),
|
|
421
|
-
processEnumTS('
|
|
436
|
+
processEnumTS('DomainSeparator', domainSeparatorEnum)
|
|
422
437
|
].join('\n');
|
|
423
438
|
fs.writeFileSync(targetPath, result);
|
|
424
439
|
}
|
|
425
440
|
/**
|
|
426
441
|
* Generate the constants file in C++.
|
|
427
|
-
*/ function generateCppConstants({ constants,
|
|
442
|
+
*/ function generateCppConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
428
443
|
const resultCpp = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
429
444
|
#pragma once
|
|
430
445
|
|
|
431
|
-
${processConstantsCpp(constants,
|
|
446
|
+
${processConstantsCpp(constants, domainSeparatorEnum)}
|
|
432
447
|
`;
|
|
433
448
|
fs.writeFileSync(targetPath, resultCpp);
|
|
434
449
|
}
|
|
435
450
|
/**
|
|
436
451
|
* Generate the constants file in PIL.
|
|
437
|
-
*/ function generatePilConstants({ constants,
|
|
452
|
+
*/ function generatePilConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
438
453
|
const resultPil = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
439
454
|
namespace constants;
|
|
440
|
-
${processConstantsPil(constants,
|
|
455
|
+
${processConstantsPil(constants, domainSeparatorEnum)}
|
|
441
456
|
\n`;
|
|
442
457
|
fs.writeFileSync(targetPath, resultPil);
|
|
443
458
|
}
|
|
@@ -467,7 +482,7 @@ ${processConstantsSolidity(constants)}
|
|
|
467
482
|
* Parse the content of the constants file in Noir.
|
|
468
483
|
*/ function parseNoirFile(fileContent) {
|
|
469
484
|
const constantsExpressions = [];
|
|
470
|
-
const
|
|
485
|
+
const domainSeparatorEnum = {};
|
|
471
486
|
const emptyExpression = ()=>({
|
|
472
487
|
name: '',
|
|
473
488
|
content: []
|
|
@@ -489,7 +504,7 @@ ${processConstantsSolidity(constants)}
|
|
|
489
504
|
const [, indexName] = name.match(/DOM_SEP__(\w+)/) || [];
|
|
490
505
|
if (indexName) {
|
|
491
506
|
// Generator index.
|
|
492
|
-
|
|
507
|
+
domainSeparatorEnum[indexName] = +value;
|
|
493
508
|
} else if (end) {
|
|
494
509
|
// A single line of expression.
|
|
495
510
|
constantsExpressions.push([
|
|
@@ -537,7 +552,7 @@ ${processConstantsSolidity(constants)}
|
|
|
537
552
|
const constants = evaluateExpressions(constantsExpressions);
|
|
538
553
|
return {
|
|
539
554
|
constants,
|
|
540
|
-
|
|
555
|
+
domainSeparatorEnum
|
|
541
556
|
};
|
|
542
557
|
}
|
|
543
558
|
/**
|
|
@@ -564,7 +579,11 @@ ${processConstantsSolidity(constants)}
|
|
|
564
579
|
.replace(/\(/g, '( ').replace(/\)/g, ' )')// We also make some space around common operators
|
|
565
580
|
.replace(/\+/g, ' + ').replace(/(?<!\/)\*(?!\/)/, ' * ')// We split the expression into terms...
|
|
566
581
|
.split(/\s+/)// ...and then we convert each term to a BigInt if it is a number.
|
|
567
|
-
.map((term)=>
|
|
582
|
+
.map((term)=>{
|
|
583
|
+
// Remove underscores from numeric literals (e.g., 6_000_000 -> 6000000)
|
|
584
|
+
const termWithoutUnderscores = term.replace(/_/g, '');
|
|
585
|
+
return isNaN(+termWithoutUnderscores) ? term : `BigInt('${termWithoutUnderscores}')`;
|
|
586
|
+
})// .. also, we convert the known bigints to BigInts.
|
|
568
587
|
.map((term)=>knownBigInts.includes(term) ? `BigInt(${term})` : term)// We join the terms back together.
|
|
569
588
|
.join(' ');
|
|
570
589
|
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.
|
|
3
|
+
"version": "0.0.1-commit.2f68f620",
|
|
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.
|
|
26
|
+
"@aztec/foundation": "0.0.1-commit.2f68f620",
|
|
20
27
|
"tslib": "^2.4.0"
|
|
21
28
|
},
|
|
22
29
|
"devDependencies": {
|