@aztec/constants 0.0.1-commit.fce3e4f → 0.0.1-commit.ff7989d6c
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 +167 -168
- package/dest/constants.gen.d.ts.map +1 -1
- package/dest/constants.gen.js +167 -168
- package/dest/constants.js +14 -0
- package/dest/scripts/constants.in.js +31 -24
- package/package.json +12 -4
- package/src/constants.gen.ts +170 -179
- package/src/constants.ts +27 -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,7 @@ const CPP_CONSTANTS = [
|
|
|
24
26
|
'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
|
|
25
27
|
'MULTI_CALL_ENTRYPOINT_ADDRESS',
|
|
26
28
|
'FEE_JUICE_ADDRESS',
|
|
27
|
-
'
|
|
29
|
+
'PUBLIC_CHECKS_ADDRESS',
|
|
28
30
|
'FEE_JUICE_BALANCES_SLOT',
|
|
29
31
|
'UPDATED_CLASS_IDS_SLOT',
|
|
30
32
|
'UPDATES_DELAYED_PUBLIC_MUTABLE_VALUES_LEN',
|
|
@@ -111,19 +113,22 @@ const CPP_CONSTANTS = [
|
|
|
111
113
|
'DEFAULT_MAX_DEBUG_LOG_MEMORY_READS'
|
|
112
114
|
];
|
|
113
115
|
const CPP_GENERATORS = [
|
|
116
|
+
'BLOCK_HEADER_HASH',
|
|
114
117
|
'PARTIAL_ADDRESS',
|
|
115
118
|
'CONTRACT_ADDRESS_V1',
|
|
116
|
-
'
|
|
119
|
+
'CONTRACT_CLASS_ID',
|
|
117
120
|
'PUBLIC_KEYS_HASH',
|
|
118
121
|
'NOTE_HASH_NONCE',
|
|
119
122
|
'UNIQUE_NOTE_HASH',
|
|
120
123
|
'SILOED_NOTE_HASH',
|
|
121
|
-
'
|
|
122
|
-
'
|
|
124
|
+
'SILOED_NULLIFIER',
|
|
125
|
+
'PUBLIC_LEAF_SLOT',
|
|
126
|
+
'PUBLIC_STORAGE_MAP_SLOT',
|
|
123
127
|
'PUBLIC_CALLDATA',
|
|
124
128
|
'PUBLIC_BYTECODE'
|
|
125
129
|
];
|
|
126
130
|
const PIL_CONSTANTS = [
|
|
131
|
+
'MAX_ETH_ADDRESS_VALUE',
|
|
127
132
|
'MEM_TAG_U1',
|
|
128
133
|
'MEM_TAG_U8',
|
|
129
134
|
'MEM_TAG_U16',
|
|
@@ -159,7 +164,7 @@ const PIL_CONSTANTS = [
|
|
|
159
164
|
'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
|
|
160
165
|
'MULTI_CALL_ENTRYPOINT_ADDRESS',
|
|
161
166
|
'FEE_JUICE_ADDRESS',
|
|
162
|
-
'
|
|
167
|
+
'PUBLIC_CHECKS_ADDRESS',
|
|
163
168
|
'FEE_JUICE_BALANCES_SLOT',
|
|
164
169
|
'TIMESTAMP_OF_CHANGE_BIT_SIZE',
|
|
165
170
|
'UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE',
|
|
@@ -243,10 +248,10 @@ const PIL_CONSTANTS = [
|
|
|
243
248
|
'AVM_DYN_GAS_ID_RETURNDATACOPY',
|
|
244
249
|
'AVM_DYN_GAS_ID_TORADIX',
|
|
245
250
|
'AVM_DYN_GAS_ID_BITWISE',
|
|
246
|
-
'
|
|
251
|
+
'AVM_DYN_GAS_ID_EMITPUBLICLOG',
|
|
247
252
|
'AVM_DYN_GAS_ID_SSTORE',
|
|
248
253
|
'AVM_SUBTRACE_ID_GETCONTRACTINSTANCE',
|
|
249
|
-
'
|
|
254
|
+
'AVM_SUBTRACE_ID_EMITPUBLICLOG',
|
|
250
255
|
'AVM_EXEC_OP_ID_GETENVVAR',
|
|
251
256
|
'AVM_EXEC_OP_ID_MOV',
|
|
252
257
|
'AVM_EXEC_OP_ID_JUMP',
|
|
@@ -297,19 +302,21 @@ const PIL_CONSTANTS = [
|
|
|
297
302
|
const PIL_GENERATORS = [
|
|
298
303
|
'PARTIAL_ADDRESS',
|
|
299
304
|
'CONTRACT_ADDRESS_V1',
|
|
300
|
-
'
|
|
305
|
+
'CONTRACT_CLASS_ID',
|
|
301
306
|
'PUBLIC_KEYS_HASH',
|
|
302
307
|
'NOTE_HASH_NONCE',
|
|
303
308
|
'UNIQUE_NOTE_HASH',
|
|
304
309
|
'SILOED_NOTE_HASH',
|
|
305
|
-
'
|
|
306
|
-
'
|
|
310
|
+
'SILOED_NULLIFIER',
|
|
311
|
+
'PUBLIC_LEAF_SLOT',
|
|
312
|
+
'PUBLIC_STORAGE_MAP_SLOT',
|
|
307
313
|
'PUBLIC_CALLDATA',
|
|
308
314
|
'PUBLIC_BYTECODE'
|
|
309
315
|
];
|
|
310
316
|
const SOLIDITY_CONSTANTS = [
|
|
311
317
|
'MAX_FIELD_VALUE',
|
|
312
318
|
'MAX_L2_TO_L1_MSGS_PER_TX',
|
|
319
|
+
'EMPTY_EPOCH_OUT_HASH',
|
|
313
320
|
'L1_TO_L2_MSG_SUBTREE_HEIGHT',
|
|
314
321
|
'NUM_MSGS_PER_BASE_PARITY',
|
|
315
322
|
'NUM_BASE_PARITY_PER_ROOT_PARITY',
|
|
@@ -318,7 +325,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
318
325
|
'INITIAL_CHECKPOINT_NUMBER',
|
|
319
326
|
'GENESIS_ARCHIVE_ROOT',
|
|
320
327
|
'FEE_JUICE_ADDRESS',
|
|
321
|
-
'
|
|
328
|
+
'MAX_CHECKPOINTS_PER_EPOCH'
|
|
322
329
|
];
|
|
323
330
|
/**
|
|
324
331
|
* Processes a collection of constants and generates code to export them as TypeScript constants.
|
|
@@ -341,7 +348,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
341
348
|
*/ function processConstantsCpp(constants, generatorIndices) {
|
|
342
349
|
const code = [];
|
|
343
350
|
Object.entries(constants).forEach(([key, value])=>{
|
|
344
|
-
if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')
|
|
351
|
+
if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')) {
|
|
345
352
|
if (BigInt(value) <= 2n ** 31n - 1n) {
|
|
346
353
|
code.push(`#define ${key} ${value}`);
|
|
347
354
|
} else if (BigInt(value) <= 2n ** 64n - 1n) {
|
|
@@ -353,7 +360,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
353
360
|
});
|
|
354
361
|
Object.entries(generatorIndices).forEach(([key, value])=>{
|
|
355
362
|
if (CPP_GENERATORS.includes(key)) {
|
|
356
|
-
code.push(`#define
|
|
363
|
+
code.push(`#define DOM_SEP__${key} ${value}UL`);
|
|
357
364
|
}
|
|
358
365
|
});
|
|
359
366
|
return code.join('\n');
|
|
@@ -373,7 +380,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
373
380
|
});
|
|
374
381
|
Object.entries(generatorIndices).forEach(([key, value])=>{
|
|
375
382
|
if (PIL_GENERATORS.includes(key)) {
|
|
376
|
-
code.push(` pol
|
|
383
|
+
code.push(` pol DOM_SEP__${key} = ${value};`);
|
|
377
384
|
}
|
|
378
385
|
});
|
|
379
386
|
return code.join('\n');
|
|
@@ -410,30 +417,30 @@ const SOLIDITY_CONSTANTS = [
|
|
|
410
417
|
}
|
|
411
418
|
/**
|
|
412
419
|
* Generate the constants file in Typescript.
|
|
413
|
-
*/ function generateTypescriptConstants({ constants,
|
|
420
|
+
*/ function generateTypescriptConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
414
421
|
const result = [
|
|
415
422
|
'// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants',
|
|
416
423
|
processConstantsTS(constants),
|
|
417
|
-
processEnumTS('
|
|
424
|
+
processEnumTS('DomainSeparator', domainSeparatorEnum)
|
|
418
425
|
].join('\n');
|
|
419
426
|
fs.writeFileSync(targetPath, result);
|
|
420
427
|
}
|
|
421
428
|
/**
|
|
422
429
|
* Generate the constants file in C++.
|
|
423
|
-
*/ function generateCppConstants({ constants,
|
|
430
|
+
*/ function generateCppConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
424
431
|
const resultCpp = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
425
432
|
#pragma once
|
|
426
433
|
|
|
427
|
-
${processConstantsCpp(constants,
|
|
434
|
+
${processConstantsCpp(constants, domainSeparatorEnum)}
|
|
428
435
|
`;
|
|
429
436
|
fs.writeFileSync(targetPath, resultCpp);
|
|
430
437
|
}
|
|
431
438
|
/**
|
|
432
439
|
* Generate the constants file in PIL.
|
|
433
|
-
*/ function generatePilConstants({ constants,
|
|
440
|
+
*/ function generatePilConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
434
441
|
const resultPil = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
435
442
|
namespace constants;
|
|
436
|
-
${processConstantsPil(constants,
|
|
443
|
+
${processConstantsPil(constants, domainSeparatorEnum)}
|
|
437
444
|
\n`;
|
|
438
445
|
fs.writeFileSync(targetPath, resultPil);
|
|
439
446
|
}
|
|
@@ -463,7 +470,7 @@ ${processConstantsSolidity(constants)}
|
|
|
463
470
|
* Parse the content of the constants file in Noir.
|
|
464
471
|
*/ function parseNoirFile(fileContent) {
|
|
465
472
|
const constantsExpressions = [];
|
|
466
|
-
const
|
|
473
|
+
const domainSeparatorEnum = {};
|
|
467
474
|
const emptyExpression = ()=>({
|
|
468
475
|
name: '',
|
|
469
476
|
content: []
|
|
@@ -482,10 +489,10 @@ ${processConstantsSolidity(constants)}
|
|
|
482
489
|
{
|
|
483
490
|
const [, name, _type, value, end] = line.match(/global\s+(\w+)(\s*:\s*\w+)?\s*=\s*([^;]*)(;)?/) || [];
|
|
484
491
|
if (name && value) {
|
|
485
|
-
const [, indexName] = name.match(/
|
|
492
|
+
const [, indexName] = name.match(/DOM_SEP__(\w+)/) || [];
|
|
486
493
|
if (indexName) {
|
|
487
494
|
// Generator index.
|
|
488
|
-
|
|
495
|
+
domainSeparatorEnum[indexName] = +value;
|
|
489
496
|
} else if (end) {
|
|
490
497
|
// A single line of expression.
|
|
491
498
|
constantsExpressions.push([
|
|
@@ -533,7 +540,7 @@ ${processConstantsSolidity(constants)}
|
|
|
533
540
|
const constants = evaluateExpressions(constantsExpressions);
|
|
534
541
|
return {
|
|
535
542
|
constants,
|
|
536
|
-
|
|
543
|
+
domainSeparatorEnum
|
|
537
544
|
};
|
|
538
545
|
}
|
|
539
546
|
/**
|
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.ff7989d6c",
|
|
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.ff7989d6c",
|
|
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",
|