@aztec/constants 0.0.1-commit.24de95ac → 0.0.1-commit.2606882
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 +9 -1
- package/dest/constants.d.ts.map +1 -1
- package/dest/constants.gen.d.ts +234 -197
- package/dest/constants.gen.d.ts.map +1 -1
- package/dest/constants.gen.js +234 -197
- package/dest/constants.js +12 -0
- package/dest/scripts/constants.in.d.ts +1 -1
- package/dest/scripts/constants.in.js +60 -37
- package/package.json +12 -3
- package/src/constants.gen.ts +233 -196
- package/src/constants.ts +24 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmluLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2NyaXB0cy9jb25zdGFudHMuaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -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/
|
|
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',
|
|
@@ -19,12 +21,10 @@ const CPP_CONSTANTS = [
|
|
|
19
21
|
'MEM_TAG_U128',
|
|
20
22
|
'MEM_TAG_FF',
|
|
21
23
|
'MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS',
|
|
22
|
-
'CANONICAL_AUTH_REGISTRY_ADDRESS',
|
|
23
24
|
'CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS',
|
|
24
25
|
'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
|
|
25
|
-
'MULTI_CALL_ENTRYPOINT_ADDRESS',
|
|
26
26
|
'FEE_JUICE_ADDRESS',
|
|
27
|
-
'
|
|
27
|
+
'TX_DA_GAS_OVERHEAD',
|
|
28
28
|
'FEE_JUICE_BALANCES_SLOT',
|
|
29
29
|
'UPDATED_CLASS_IDS_SLOT',
|
|
30
30
|
'UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN',
|
|
@@ -40,6 +40,7 @@ const CPP_CONSTANTS = [
|
|
|
40
40
|
'MAX_NOTE_HASHES_PER_TX',
|
|
41
41
|
'MAX_NULLIFIERS_PER_TX',
|
|
42
42
|
'MAX_L2_TO_L1_MSGS_PER_TX',
|
|
43
|
+
'MAX_PROCESSABLE_L2_GAS',
|
|
43
44
|
'MAX_PUBLIC_LOGS_PER_TX',
|
|
44
45
|
'MAX_PUBLIC_DATA_UPDATE_REQUESTS_PER_TX',
|
|
45
46
|
'MAX_PUBLIC_CALLS_TO_UNIQUE_CONTRACT_CLASS_IDS',
|
|
@@ -107,23 +108,34 @@ const CPP_CONSTANTS = [
|
|
|
107
108
|
'FLAT_PUBLIC_LOGS_PAYLOAD_LENGTH',
|
|
108
109
|
'PUBLIC_LOGS_LENGTH',
|
|
109
110
|
'PUBLIC_LOG_HEADER_LENGTH',
|
|
111
|
+
'PUBLIC_TX_L2_GAS_OVERHEAD',
|
|
110
112
|
'MAX_PROTOCOL_CONTRACTS',
|
|
111
113
|
'DEFAULT_MAX_DEBUG_LOG_MEMORY_READS'
|
|
112
114
|
];
|
|
113
115
|
const CPP_GENERATORS = [
|
|
116
|
+
'BLOCK_HEADER_HASH',
|
|
117
|
+
'SALTED_INITIALIZATION_HASH',
|
|
114
118
|
'PARTIAL_ADDRESS',
|
|
115
|
-
'
|
|
116
|
-
'
|
|
119
|
+
'CONTRACT_ADDRESS_V2',
|
|
120
|
+
'CONTRACT_CLASS_ID',
|
|
117
121
|
'PUBLIC_KEYS_HASH',
|
|
122
|
+
'SINGLE_PUBLIC_KEY_HASH',
|
|
118
123
|
'NOTE_HASH_NONCE',
|
|
119
124
|
'UNIQUE_NOTE_HASH',
|
|
120
125
|
'SILOED_NOTE_HASH',
|
|
121
|
-
'
|
|
122
|
-
'
|
|
126
|
+
'SILOED_NULLIFIER',
|
|
127
|
+
'PUBLIC_LEAF_SLOT',
|
|
128
|
+
'PUBLIC_STORAGE_MAP_SLOT',
|
|
123
129
|
'PUBLIC_CALLDATA',
|
|
124
|
-
'PUBLIC_BYTECODE'
|
|
130
|
+
'PUBLIC_BYTECODE',
|
|
131
|
+
'MERKLE_HASH',
|
|
132
|
+
'NULLIFIER_MERKLE',
|
|
133
|
+
'PUBLIC_DATA_MERKLE',
|
|
134
|
+
'WRITTEN_SLOTS_MERKLE',
|
|
135
|
+
'RETRIEVED_BYTECODES_MERKLE'
|
|
125
136
|
];
|
|
126
137
|
const PIL_CONSTANTS = [
|
|
138
|
+
'MAX_ETH_ADDRESS_VALUE',
|
|
127
139
|
'MEM_TAG_U1',
|
|
128
140
|
'MEM_TAG_U8',
|
|
129
141
|
'MEM_TAG_U16',
|
|
@@ -136,6 +148,9 @@ const PIL_CONSTANTS = [
|
|
|
136
148
|
'AVM_BITWISE_XOR_OP_ID',
|
|
137
149
|
'AVM_KECCAKF1600_NUM_ROUNDS',
|
|
138
150
|
'AVM_KECCAKF1600_STATE_SIZE',
|
|
151
|
+
'AVM_TX_PHASE_VALUE_START',
|
|
152
|
+
'AVM_TX_PHASE_VALUE_SETUP',
|
|
153
|
+
'AVM_TX_PHASE_VALUE_LAST',
|
|
139
154
|
'AVM_HIGHEST_MEM_ADDRESS',
|
|
140
155
|
'AVM_MEMORY_NUM_BITS',
|
|
141
156
|
'AVM_MEMORY_SIZE',
|
|
@@ -151,12 +166,9 @@ const PIL_CONSTANTS = [
|
|
|
151
166
|
'L1_TO_L2_MSG_TREE_HEIGHT',
|
|
152
167
|
'UPDATED_CLASS_IDS_SLOT',
|
|
153
168
|
'UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN',
|
|
154
|
-
'CANONICAL_AUTH_REGISTRY_ADDRESS',
|
|
155
169
|
'CONTRACT_INSTANCE_REGISTRY_CONTRACT_ADDRESS',
|
|
156
170
|
'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
|
|
157
|
-
'MULTI_CALL_ENTRYPOINT_ADDRESS',
|
|
158
171
|
'FEE_JUICE_ADDRESS',
|
|
159
|
-
'ROUTER_ADDRESS',
|
|
160
172
|
'FEE_JUICE_BALANCES_SLOT',
|
|
161
173
|
'TIMESTAMP_OF_CHANGE_BIT_SIZE',
|
|
162
174
|
'UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE',
|
|
@@ -240,10 +252,10 @@ const PIL_CONSTANTS = [
|
|
|
240
252
|
'AVM_DYN_GAS_ID_RETURNDATACOPY',
|
|
241
253
|
'AVM_DYN_GAS_ID_TORADIX',
|
|
242
254
|
'AVM_DYN_GAS_ID_BITWISE',
|
|
243
|
-
'
|
|
255
|
+
'AVM_DYN_GAS_ID_EMITPUBLICLOG',
|
|
244
256
|
'AVM_DYN_GAS_ID_SSTORE',
|
|
245
257
|
'AVM_SUBTRACE_ID_GETCONTRACTINSTANCE',
|
|
246
|
-
'
|
|
258
|
+
'AVM_SUBTRACE_ID_EMITPUBLICLOG',
|
|
247
259
|
'AVM_EXEC_OP_ID_GETENVVAR',
|
|
248
260
|
'AVM_EXEC_OP_ID_MOV',
|
|
249
261
|
'AVM_EXEC_OP_ID_JUMP',
|
|
@@ -292,32 +304,39 @@ const PIL_CONSTANTS = [
|
|
|
292
304
|
'MAX_PROTOCOL_CONTRACTS'
|
|
293
305
|
];
|
|
294
306
|
const PIL_GENERATORS = [
|
|
307
|
+
'SALTED_INITIALIZATION_HASH',
|
|
295
308
|
'PARTIAL_ADDRESS',
|
|
296
|
-
'
|
|
297
|
-
'
|
|
309
|
+
'CONTRACT_ADDRESS_V2',
|
|
310
|
+
'CONTRACT_CLASS_ID',
|
|
298
311
|
'PUBLIC_KEYS_HASH',
|
|
312
|
+
'SINGLE_PUBLIC_KEY_HASH',
|
|
299
313
|
'NOTE_HASH_NONCE',
|
|
300
314
|
'UNIQUE_NOTE_HASH',
|
|
301
315
|
'SILOED_NOTE_HASH',
|
|
302
|
-
'
|
|
303
|
-
'
|
|
316
|
+
'SILOED_NULLIFIER',
|
|
317
|
+
'PUBLIC_LEAF_SLOT',
|
|
318
|
+
'PUBLIC_STORAGE_MAP_SLOT',
|
|
304
319
|
'PUBLIC_CALLDATA',
|
|
305
|
-
'PUBLIC_BYTECODE'
|
|
320
|
+
'PUBLIC_BYTECODE',
|
|
321
|
+
'MERKLE_HASH',
|
|
322
|
+
'NULLIFIER_MERKLE',
|
|
323
|
+
'PUBLIC_DATA_MERKLE',
|
|
324
|
+
'WRITTEN_SLOTS_MERKLE',
|
|
325
|
+
'RETRIEVED_BYTECODES_MERKLE'
|
|
306
326
|
];
|
|
307
327
|
const SOLIDITY_CONSTANTS = [
|
|
308
328
|
'MAX_FIELD_VALUE',
|
|
309
329
|
'MAX_L2_TO_L1_MSGS_PER_TX',
|
|
330
|
+
'EMPTY_EPOCH_OUT_HASH',
|
|
310
331
|
'L1_TO_L2_MSG_SUBTREE_HEIGHT',
|
|
311
332
|
'NUM_MSGS_PER_BASE_PARITY',
|
|
312
333
|
'NUM_BASE_PARITY_PER_ROOT_PARITY',
|
|
313
|
-
'PROPOSED_BLOCK_HEADER_LENGTH_BYTES',
|
|
314
334
|
'BLS12_POINT_COMPRESSED_BYTES',
|
|
315
335
|
'ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH',
|
|
316
|
-
'
|
|
317
|
-
'INITIAL_L2_BLOCK_NUM',
|
|
336
|
+
'INITIAL_CHECKPOINT_NUMBER',
|
|
318
337
|
'GENESIS_ARCHIVE_ROOT',
|
|
319
338
|
'FEE_JUICE_ADDRESS',
|
|
320
|
-
'
|
|
339
|
+
'MAX_CHECKPOINTS_PER_EPOCH'
|
|
321
340
|
];
|
|
322
341
|
/**
|
|
323
342
|
* Processes a collection of constants and generates code to export them as TypeScript constants.
|
|
@@ -340,7 +359,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
340
359
|
*/ function processConstantsCpp(constants, generatorIndices) {
|
|
341
360
|
const code = [];
|
|
342
361
|
Object.entries(constants).forEach(([key, value])=>{
|
|
343
|
-
if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')
|
|
362
|
+
if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')) {
|
|
344
363
|
if (BigInt(value) <= 2n ** 31n - 1n) {
|
|
345
364
|
code.push(`#define ${key} ${value}`);
|
|
346
365
|
} else if (BigInt(value) <= 2n ** 64n - 1n) {
|
|
@@ -352,7 +371,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
352
371
|
});
|
|
353
372
|
Object.entries(generatorIndices).forEach(([key, value])=>{
|
|
354
373
|
if (CPP_GENERATORS.includes(key)) {
|
|
355
|
-
code.push(`#define
|
|
374
|
+
code.push(`#define DOM_SEP__${key} ${value}UL`);
|
|
356
375
|
}
|
|
357
376
|
});
|
|
358
377
|
return code.join('\n');
|
|
@@ -372,7 +391,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
372
391
|
});
|
|
373
392
|
Object.entries(generatorIndices).forEach(([key, value])=>{
|
|
374
393
|
if (PIL_GENERATORS.includes(key)) {
|
|
375
|
-
code.push(` pol
|
|
394
|
+
code.push(` pol DOM_SEP__${key} = ${value};`);
|
|
376
395
|
}
|
|
377
396
|
});
|
|
378
397
|
return code.join('\n');
|
|
@@ -409,30 +428,30 @@ const SOLIDITY_CONSTANTS = [
|
|
|
409
428
|
}
|
|
410
429
|
/**
|
|
411
430
|
* Generate the constants file in Typescript.
|
|
412
|
-
*/ function generateTypescriptConstants({ constants,
|
|
431
|
+
*/ function generateTypescriptConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
413
432
|
const result = [
|
|
414
433
|
'// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants',
|
|
415
434
|
processConstantsTS(constants),
|
|
416
|
-
processEnumTS('
|
|
435
|
+
processEnumTS('DomainSeparator', domainSeparatorEnum)
|
|
417
436
|
].join('\n');
|
|
418
437
|
fs.writeFileSync(targetPath, result);
|
|
419
438
|
}
|
|
420
439
|
/**
|
|
421
440
|
* Generate the constants file in C++.
|
|
422
|
-
*/ function generateCppConstants({ constants,
|
|
441
|
+
*/ function generateCppConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
423
442
|
const resultCpp = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
424
443
|
#pragma once
|
|
425
444
|
|
|
426
|
-
${processConstantsCpp(constants,
|
|
445
|
+
${processConstantsCpp(constants, domainSeparatorEnum)}
|
|
427
446
|
`;
|
|
428
447
|
fs.writeFileSync(targetPath, resultCpp);
|
|
429
448
|
}
|
|
430
449
|
/**
|
|
431
450
|
* Generate the constants file in PIL.
|
|
432
|
-
*/ function generatePilConstants({ constants,
|
|
451
|
+
*/ function generatePilConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
433
452
|
const resultPil = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
434
453
|
namespace constants;
|
|
435
|
-
${processConstantsPil(constants,
|
|
454
|
+
${processConstantsPil(constants, domainSeparatorEnum)}
|
|
436
455
|
\n`;
|
|
437
456
|
fs.writeFileSync(targetPath, resultPil);
|
|
438
457
|
}
|
|
@@ -462,7 +481,7 @@ ${processConstantsSolidity(constants)}
|
|
|
462
481
|
* Parse the content of the constants file in Noir.
|
|
463
482
|
*/ function parseNoirFile(fileContent) {
|
|
464
483
|
const constantsExpressions = [];
|
|
465
|
-
const
|
|
484
|
+
const domainSeparatorEnum = {};
|
|
466
485
|
const emptyExpression = ()=>({
|
|
467
486
|
name: '',
|
|
468
487
|
content: []
|
|
@@ -481,10 +500,10 @@ ${processConstantsSolidity(constants)}
|
|
|
481
500
|
{
|
|
482
501
|
const [, name, _type, value, end] = line.match(/global\s+(\w+)(\s*:\s*\w+)?\s*=\s*([^;]*)(;)?/) || [];
|
|
483
502
|
if (name && value) {
|
|
484
|
-
const [, indexName] = name.match(/
|
|
503
|
+
const [, indexName] = name.match(/DOM_SEP__(\w+)/) || [];
|
|
485
504
|
if (indexName) {
|
|
486
505
|
// Generator index.
|
|
487
|
-
|
|
506
|
+
domainSeparatorEnum[indexName] = +value;
|
|
488
507
|
} else if (end) {
|
|
489
508
|
// A single line of expression.
|
|
490
509
|
constantsExpressions.push([
|
|
@@ -532,7 +551,7 @@ ${processConstantsSolidity(constants)}
|
|
|
532
551
|
const constants = evaluateExpressions(constantsExpressions);
|
|
533
552
|
return {
|
|
534
553
|
constants,
|
|
535
|
-
|
|
554
|
+
domainSeparatorEnum
|
|
536
555
|
};
|
|
537
556
|
}
|
|
538
557
|
/**
|
|
@@ -559,7 +578,11 @@ ${processConstantsSolidity(constants)}
|
|
|
559
578
|
.replace(/\(/g, '( ').replace(/\)/g, ' )')// We also make some space around common operators
|
|
560
579
|
.replace(/\+/g, ' + ').replace(/(?<!\/)\*(?!\/)/, ' * ')// We split the expression into terms...
|
|
561
580
|
.split(/\s+/)// ...and then we convert each term to a BigInt if it is a number.
|
|
562
|
-
.map((term)=>
|
|
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.
|
|
563
586
|
.map((term)=>knownBigInts.includes(term) ? `BigInt(${term})` : term)// We join the terms back together.
|
|
564
587
|
.join(' ');
|
|
565
588
|
return `var ${name} = ${guardedRhs};`;
|
package/package.json
CHANGED
|
@@ -1,27 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/constants",
|
|
3
|
-
"version": "0.0.1-commit.
|
|
3
|
+
"version": "0.0.1-commit.2606882",
|
|
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 && tsc
|
|
13
|
-
"build:dev": "tsc
|
|
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.2606882",
|
|
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",
|
|
33
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
25
34
|
"eslint": "^9.26.0",
|
|
26
35
|
"jest": "^30.0.0",
|
|
27
36
|
"prettier": "^3.5.3",
|