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