@aztec/constants 0.0.1-commit.9b94fc1 → 0.0.1-commit.9badcec54
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 +192 -181
- package/dest/constants.gen.d.ts.map +1 -1
- package/dest/constants.gen.js +192 -181
- package/dest/constants.js +12 -0
- package/dest/scripts/constants.in.js +51 -27
- package/package.json +12 -4
- package/src/constants.gen.ts +193 -180
- package/src/constants.ts +24 -0
|
@@ -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
|
-
'
|
|
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,32 @@ 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
|
-
'
|
|
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
|
-
'
|
|
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',
|
|
@@ -159,7 +172,7 @@ const PIL_CONSTANTS = [
|
|
|
159
172
|
'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
|
|
160
173
|
'MULTI_CALL_ENTRYPOINT_ADDRESS',
|
|
161
174
|
'FEE_JUICE_ADDRESS',
|
|
162
|
-
'
|
|
175
|
+
'PUBLIC_CHECKS_ADDRESS',
|
|
163
176
|
'FEE_JUICE_BALANCES_SLOT',
|
|
164
177
|
'TIMESTAMP_OF_CHANGE_BIT_SIZE',
|
|
165
178
|
'UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE',
|
|
@@ -243,10 +256,10 @@ const PIL_CONSTANTS = [
|
|
|
243
256
|
'AVM_DYN_GAS_ID_RETURNDATACOPY',
|
|
244
257
|
'AVM_DYN_GAS_ID_TORADIX',
|
|
245
258
|
'AVM_DYN_GAS_ID_BITWISE',
|
|
246
|
-
'
|
|
259
|
+
'AVM_DYN_GAS_ID_EMITPUBLICLOG',
|
|
247
260
|
'AVM_DYN_GAS_ID_SSTORE',
|
|
248
261
|
'AVM_SUBTRACE_ID_GETCONTRACTINSTANCE',
|
|
249
|
-
'
|
|
262
|
+
'AVM_SUBTRACE_ID_EMITPUBLICLOG',
|
|
250
263
|
'AVM_EXEC_OP_ID_GETENVVAR',
|
|
251
264
|
'AVM_EXEC_OP_ID_MOV',
|
|
252
265
|
'AVM_EXEC_OP_ID_JUMP',
|
|
@@ -297,19 +310,26 @@ const PIL_CONSTANTS = [
|
|
|
297
310
|
const PIL_GENERATORS = [
|
|
298
311
|
'PARTIAL_ADDRESS',
|
|
299
312
|
'CONTRACT_ADDRESS_V1',
|
|
300
|
-
'
|
|
313
|
+
'CONTRACT_CLASS_ID',
|
|
301
314
|
'PUBLIC_KEYS_HASH',
|
|
302
315
|
'NOTE_HASH_NONCE',
|
|
303
316
|
'UNIQUE_NOTE_HASH',
|
|
304
317
|
'SILOED_NOTE_HASH',
|
|
305
|
-
'
|
|
306
|
-
'
|
|
318
|
+
'SILOED_NULLIFIER',
|
|
319
|
+
'PUBLIC_LEAF_SLOT',
|
|
320
|
+
'PUBLIC_STORAGE_MAP_SLOT',
|
|
307
321
|
'PUBLIC_CALLDATA',
|
|
308
|
-
'PUBLIC_BYTECODE'
|
|
322
|
+
'PUBLIC_BYTECODE',
|
|
323
|
+
'MERKLE_HASH',
|
|
324
|
+
'NULLIFIER_MERKLE',
|
|
325
|
+
'PUBLIC_DATA_MERKLE',
|
|
326
|
+
'WRITTEN_SLOTS_MERKLE',
|
|
327
|
+
'RETRIEVED_BYTECODES_MERKLE'
|
|
309
328
|
];
|
|
310
329
|
const SOLIDITY_CONSTANTS = [
|
|
311
330
|
'MAX_FIELD_VALUE',
|
|
312
331
|
'MAX_L2_TO_L1_MSGS_PER_TX',
|
|
332
|
+
'EMPTY_EPOCH_OUT_HASH',
|
|
313
333
|
'L1_TO_L2_MSG_SUBTREE_HEIGHT',
|
|
314
334
|
'NUM_MSGS_PER_BASE_PARITY',
|
|
315
335
|
'NUM_BASE_PARITY_PER_ROOT_PARITY',
|
|
@@ -318,7 +338,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
318
338
|
'INITIAL_CHECKPOINT_NUMBER',
|
|
319
339
|
'GENESIS_ARCHIVE_ROOT',
|
|
320
340
|
'FEE_JUICE_ADDRESS',
|
|
321
|
-
'
|
|
341
|
+
'MAX_CHECKPOINTS_PER_EPOCH'
|
|
322
342
|
];
|
|
323
343
|
/**
|
|
324
344
|
* Processes a collection of constants and generates code to export them as TypeScript constants.
|
|
@@ -341,7 +361,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
341
361
|
*/ function processConstantsCpp(constants, generatorIndices) {
|
|
342
362
|
const code = [];
|
|
343
363
|
Object.entries(constants).forEach(([key, value])=>{
|
|
344
|
-
if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')
|
|
364
|
+
if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')) {
|
|
345
365
|
if (BigInt(value) <= 2n ** 31n - 1n) {
|
|
346
366
|
code.push(`#define ${key} ${value}`);
|
|
347
367
|
} else if (BigInt(value) <= 2n ** 64n - 1n) {
|
|
@@ -353,7 +373,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
353
373
|
});
|
|
354
374
|
Object.entries(generatorIndices).forEach(([key, value])=>{
|
|
355
375
|
if (CPP_GENERATORS.includes(key)) {
|
|
356
|
-
code.push(`#define
|
|
376
|
+
code.push(`#define DOM_SEP__${key} ${value}UL`);
|
|
357
377
|
}
|
|
358
378
|
});
|
|
359
379
|
return code.join('\n');
|
|
@@ -373,7 +393,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
373
393
|
});
|
|
374
394
|
Object.entries(generatorIndices).forEach(([key, value])=>{
|
|
375
395
|
if (PIL_GENERATORS.includes(key)) {
|
|
376
|
-
code.push(` pol
|
|
396
|
+
code.push(` pol DOM_SEP__${key} = ${value};`);
|
|
377
397
|
}
|
|
378
398
|
});
|
|
379
399
|
return code.join('\n');
|
|
@@ -410,30 +430,30 @@ const SOLIDITY_CONSTANTS = [
|
|
|
410
430
|
}
|
|
411
431
|
/**
|
|
412
432
|
* Generate the constants file in Typescript.
|
|
413
|
-
*/ function generateTypescriptConstants({ constants,
|
|
433
|
+
*/ function generateTypescriptConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
414
434
|
const result = [
|
|
415
435
|
'// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants',
|
|
416
436
|
processConstantsTS(constants),
|
|
417
|
-
processEnumTS('
|
|
437
|
+
processEnumTS('DomainSeparator', domainSeparatorEnum)
|
|
418
438
|
].join('\n');
|
|
419
439
|
fs.writeFileSync(targetPath, result);
|
|
420
440
|
}
|
|
421
441
|
/**
|
|
422
442
|
* Generate the constants file in C++.
|
|
423
|
-
*/ function generateCppConstants({ constants,
|
|
443
|
+
*/ function generateCppConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
424
444
|
const resultCpp = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
425
445
|
#pragma once
|
|
426
446
|
|
|
427
|
-
${processConstantsCpp(constants,
|
|
447
|
+
${processConstantsCpp(constants, domainSeparatorEnum)}
|
|
428
448
|
`;
|
|
429
449
|
fs.writeFileSync(targetPath, resultCpp);
|
|
430
450
|
}
|
|
431
451
|
/**
|
|
432
452
|
* Generate the constants file in PIL.
|
|
433
|
-
*/ function generatePilConstants({ constants,
|
|
453
|
+
*/ function generatePilConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
434
454
|
const resultPil = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
435
455
|
namespace constants;
|
|
436
|
-
${processConstantsPil(constants,
|
|
456
|
+
${processConstantsPil(constants, domainSeparatorEnum)}
|
|
437
457
|
\n`;
|
|
438
458
|
fs.writeFileSync(targetPath, resultPil);
|
|
439
459
|
}
|
|
@@ -463,7 +483,7 @@ ${processConstantsSolidity(constants)}
|
|
|
463
483
|
* Parse the content of the constants file in Noir.
|
|
464
484
|
*/ function parseNoirFile(fileContent) {
|
|
465
485
|
const constantsExpressions = [];
|
|
466
|
-
const
|
|
486
|
+
const domainSeparatorEnum = {};
|
|
467
487
|
const emptyExpression = ()=>({
|
|
468
488
|
name: '',
|
|
469
489
|
content: []
|
|
@@ -482,10 +502,10 @@ ${processConstantsSolidity(constants)}
|
|
|
482
502
|
{
|
|
483
503
|
const [, name, _type, value, end] = line.match(/global\s+(\w+)(\s*:\s*\w+)?\s*=\s*([^;]*)(;)?/) || [];
|
|
484
504
|
if (name && value) {
|
|
485
|
-
const [, indexName] = name.match(/
|
|
505
|
+
const [, indexName] = name.match(/DOM_SEP__(\w+)/) || [];
|
|
486
506
|
if (indexName) {
|
|
487
507
|
// Generator index.
|
|
488
|
-
|
|
508
|
+
domainSeparatorEnum[indexName] = +value;
|
|
489
509
|
} else if (end) {
|
|
490
510
|
// A single line of expression.
|
|
491
511
|
constantsExpressions.push([
|
|
@@ -533,7 +553,7 @@ ${processConstantsSolidity(constants)}
|
|
|
533
553
|
const constants = evaluateExpressions(constantsExpressions);
|
|
534
554
|
return {
|
|
535
555
|
constants,
|
|
536
|
-
|
|
556
|
+
domainSeparatorEnum
|
|
537
557
|
};
|
|
538
558
|
}
|
|
539
559
|
/**
|
|
@@ -560,7 +580,11 @@ ${processConstantsSolidity(constants)}
|
|
|
560
580
|
.replace(/\(/g, '( ').replace(/\)/g, ' )')// We also make some space around common operators
|
|
561
581
|
.replace(/\+/g, ' + ').replace(/(?<!\/)\*(?!\/)/, ' * ')// We split the expression into terms...
|
|
562
582
|
.split(/\s+/)// ...and then we convert each term to a BigInt if it is a number.
|
|
563
|
-
.map((term)=>
|
|
583
|
+
.map((term)=>{
|
|
584
|
+
// Remove underscores from numeric literals (e.g., 6_000_000 -> 6000000)
|
|
585
|
+
const termWithoutUnderscores = term.replace(/_/g, '');
|
|
586
|
+
return isNaN(+termWithoutUnderscores) ? term : `BigInt('${termWithoutUnderscores}')`;
|
|
587
|
+
})// .. also, we convert the known bigints to BigInts.
|
|
564
588
|
.map((term)=>knownBigInts.includes(term) ? `BigInt(${term})` : term)// We join the terms back together.
|
|
565
589
|
.join(' ');
|
|
566
590
|
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.
|
|
3
|
+
"version": "0.0.1-commit.9badcec54",
|
|
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 &&
|
|
13
|
-
"build:dev": "
|
|
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.9badcec54",
|
|
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.
|
|
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",
|