@aztec/constants 0.0.1-commit.b655e406 → 0.0.1-commit.c0b82b2
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 +191 -184
- package/dest/constants.gen.d.ts.map +1 -1
- package/dest/constants.gen.js +191 -184
- package/dest/constants.js +14 -0
- package/dest/scripts/constants.in.d.ts +1 -1
- package/dest/scripts/constants.in.js +43 -28
- package/package.json +12 -3
- package/src/constants.gen.ts +190 -183
- package/src/constants.ts +27 -0
package/dest/constants.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
import { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
+
// Re-export L2 block number constants with proper BlockNumber type
|
|
4
|
+
// Note: The generated constants are plain numbers, but we provide typed versions here
|
|
5
|
+
import { GENESIS_BLOCK_HEADER_HASH as GENESIS_BLOCK_HEADER_HASH_BIGINT, INITIAL_CHECKPOINT_NUMBER as INITIAL_CHECKPOINT_NUM_RAW, INITIAL_L2_BLOCK_NUM as INITIAL_L2_BLOCK_NUM_RAW } from './constants.gen.js';
|
|
1
6
|
// Typescript-land-only constants
|
|
2
7
|
export const SPONSORED_FPC_SALT = BigInt(0);
|
|
3
8
|
// Autogenerated constants loaded from noir-land
|
|
9
|
+
// eslint-disable-next-line import-x/export
|
|
4
10
|
export * from './constants.gen.js';
|
|
11
|
+
/** The initial L2 block number (typed as BlockNumber). This is the first block number in the Aztec L2 chain. */ // Shadow the export from constants.gen above
|
|
12
|
+
// eslint-disable-next-line import-x/export
|
|
13
|
+
export const INITIAL_L2_BLOCK_NUM = BlockNumber(INITIAL_L2_BLOCK_NUM_RAW);
|
|
14
|
+
/** The initial L2 checkpoint number (typed as CheckpointNumber). This is the first checkpoint number in the Aztec L2 chain. */ // Shadow the export from constants.gen above
|
|
15
|
+
export const INITIAL_L2_CHECKPOINT_NUM = CheckpointNumber(INITIAL_CHECKPOINT_NUM_RAW);
|
|
16
|
+
/** The block header hash for the genesis block 0. */ // Shadow the export from constants.gen above
|
|
17
|
+
// eslint-disable-next-line import-x/export
|
|
18
|
+
export const GENESIS_BLOCK_HEADER_HASH = new Fr(GENESIS_BLOCK_HEADER_HASH_BIGINT);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export {};
|
|
2
|
-
//# sourceMappingURL=
|
|
2
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RhbnRzLmluLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvc2NyaXB0cy9jb25zdGFudHMuaW4udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IiJ9
|
|
@@ -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,27 @@ 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
131
|
'PUBLIC_BYTECODE'
|
|
125
132
|
];
|
|
126
133
|
const PIL_CONSTANTS = [
|
|
134
|
+
'MAX_ETH_ADDRESS_VALUE',
|
|
127
135
|
'MEM_TAG_U1',
|
|
128
136
|
'MEM_TAG_U8',
|
|
129
137
|
'MEM_TAG_U16',
|
|
@@ -136,6 +144,9 @@ const PIL_CONSTANTS = [
|
|
|
136
144
|
'AVM_BITWISE_XOR_OP_ID',
|
|
137
145
|
'AVM_KECCAKF1600_NUM_ROUNDS',
|
|
138
146
|
'AVM_KECCAKF1600_STATE_SIZE',
|
|
147
|
+
'AVM_TX_PHASE_VALUE_START',
|
|
148
|
+
'AVM_TX_PHASE_VALUE_SETUP',
|
|
149
|
+
'AVM_TX_PHASE_VALUE_LAST',
|
|
139
150
|
'AVM_HIGHEST_MEM_ADDRESS',
|
|
140
151
|
'AVM_MEMORY_NUM_BITS',
|
|
141
152
|
'AVM_MEMORY_SIZE',
|
|
@@ -156,7 +167,7 @@ const PIL_CONSTANTS = [
|
|
|
156
167
|
'CONTRACT_CLASS_REGISTRY_CONTRACT_ADDRESS',
|
|
157
168
|
'MULTI_CALL_ENTRYPOINT_ADDRESS',
|
|
158
169
|
'FEE_JUICE_ADDRESS',
|
|
159
|
-
'
|
|
170
|
+
'PUBLIC_CHECKS_ADDRESS',
|
|
160
171
|
'FEE_JUICE_BALANCES_SLOT',
|
|
161
172
|
'TIMESTAMP_OF_CHANGE_BIT_SIZE',
|
|
162
173
|
'UPDATES_DELAYED_PUBLIC_MUTABLE_METADATA_BIT_SIZE',
|
|
@@ -240,10 +251,10 @@ const PIL_CONSTANTS = [
|
|
|
240
251
|
'AVM_DYN_GAS_ID_RETURNDATACOPY',
|
|
241
252
|
'AVM_DYN_GAS_ID_TORADIX',
|
|
242
253
|
'AVM_DYN_GAS_ID_BITWISE',
|
|
243
|
-
'
|
|
254
|
+
'AVM_DYN_GAS_ID_EMITPUBLICLOG',
|
|
244
255
|
'AVM_DYN_GAS_ID_SSTORE',
|
|
245
256
|
'AVM_SUBTRACE_ID_GETCONTRACTINSTANCE',
|
|
246
|
-
'
|
|
257
|
+
'AVM_SUBTRACE_ID_EMITPUBLICLOG',
|
|
247
258
|
'AVM_EXEC_OP_ID_GETENVVAR',
|
|
248
259
|
'AVM_EXEC_OP_ID_MOV',
|
|
249
260
|
'AVM_EXEC_OP_ID_JUMP',
|
|
@@ -294,30 +305,30 @@ const PIL_CONSTANTS = [
|
|
|
294
305
|
const PIL_GENERATORS = [
|
|
295
306
|
'PARTIAL_ADDRESS',
|
|
296
307
|
'CONTRACT_ADDRESS_V1',
|
|
297
|
-
'
|
|
308
|
+
'CONTRACT_CLASS_ID',
|
|
298
309
|
'PUBLIC_KEYS_HASH',
|
|
299
310
|
'NOTE_HASH_NONCE',
|
|
300
311
|
'UNIQUE_NOTE_HASH',
|
|
301
312
|
'SILOED_NOTE_HASH',
|
|
302
|
-
'
|
|
303
|
-
'
|
|
313
|
+
'SILOED_NULLIFIER',
|
|
314
|
+
'PUBLIC_LEAF_SLOT',
|
|
315
|
+
'PUBLIC_STORAGE_MAP_SLOT',
|
|
304
316
|
'PUBLIC_CALLDATA',
|
|
305
317
|
'PUBLIC_BYTECODE'
|
|
306
318
|
];
|
|
307
319
|
const SOLIDITY_CONSTANTS = [
|
|
308
320
|
'MAX_FIELD_VALUE',
|
|
309
321
|
'MAX_L2_TO_L1_MSGS_PER_TX',
|
|
322
|
+
'EMPTY_EPOCH_OUT_HASH',
|
|
310
323
|
'L1_TO_L2_MSG_SUBTREE_HEIGHT',
|
|
311
324
|
'NUM_MSGS_PER_BASE_PARITY',
|
|
312
325
|
'NUM_BASE_PARITY_PER_ROOT_PARITY',
|
|
313
|
-
'PROPOSED_BLOCK_HEADER_LENGTH_BYTES',
|
|
314
326
|
'BLS12_POINT_COMPRESSED_BYTES',
|
|
315
327
|
'ROOT_ROLLUP_PUBLIC_INPUTS_LENGTH',
|
|
316
|
-
'
|
|
317
|
-
'INITIAL_L2_BLOCK_NUM',
|
|
328
|
+
'INITIAL_CHECKPOINT_NUMBER',
|
|
318
329
|
'GENESIS_ARCHIVE_ROOT',
|
|
319
330
|
'FEE_JUICE_ADDRESS',
|
|
320
|
-
'
|
|
331
|
+
'MAX_CHECKPOINTS_PER_EPOCH'
|
|
321
332
|
];
|
|
322
333
|
/**
|
|
323
334
|
* Processes a collection of constants and generates code to export them as TypeScript constants.
|
|
@@ -340,7 +351,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
340
351
|
*/ function processConstantsCpp(constants, generatorIndices) {
|
|
341
352
|
const code = [];
|
|
342
353
|
Object.entries(constants).forEach(([key, value])=>{
|
|
343
|
-
if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')
|
|
354
|
+
if (CPP_CONSTANTS.includes(key) || key.startsWith('AVM_')) {
|
|
344
355
|
if (BigInt(value) <= 2n ** 31n - 1n) {
|
|
345
356
|
code.push(`#define ${key} ${value}`);
|
|
346
357
|
} else if (BigInt(value) <= 2n ** 64n - 1n) {
|
|
@@ -352,7 +363,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
352
363
|
});
|
|
353
364
|
Object.entries(generatorIndices).forEach(([key, value])=>{
|
|
354
365
|
if (CPP_GENERATORS.includes(key)) {
|
|
355
|
-
code.push(`#define
|
|
366
|
+
code.push(`#define DOM_SEP__${key} ${value}UL`);
|
|
356
367
|
}
|
|
357
368
|
});
|
|
358
369
|
return code.join('\n');
|
|
@@ -372,7 +383,7 @@ const SOLIDITY_CONSTANTS = [
|
|
|
372
383
|
});
|
|
373
384
|
Object.entries(generatorIndices).forEach(([key, value])=>{
|
|
374
385
|
if (PIL_GENERATORS.includes(key)) {
|
|
375
|
-
code.push(` pol
|
|
386
|
+
code.push(` pol DOM_SEP__${key} = ${value};`);
|
|
376
387
|
}
|
|
377
388
|
});
|
|
378
389
|
return code.join('\n');
|
|
@@ -409,30 +420,30 @@ const SOLIDITY_CONSTANTS = [
|
|
|
409
420
|
}
|
|
410
421
|
/**
|
|
411
422
|
* Generate the constants file in Typescript.
|
|
412
|
-
*/ function generateTypescriptConstants({ constants,
|
|
423
|
+
*/ function generateTypescriptConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
413
424
|
const result = [
|
|
414
425
|
'// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants',
|
|
415
426
|
processConstantsTS(constants),
|
|
416
|
-
processEnumTS('
|
|
427
|
+
processEnumTS('DomainSeparator', domainSeparatorEnum)
|
|
417
428
|
].join('\n');
|
|
418
429
|
fs.writeFileSync(targetPath, result);
|
|
419
430
|
}
|
|
420
431
|
/**
|
|
421
432
|
* Generate the constants file in C++.
|
|
422
|
-
*/ function generateCppConstants({ constants,
|
|
433
|
+
*/ function generateCppConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
423
434
|
const resultCpp = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
424
435
|
#pragma once
|
|
425
436
|
|
|
426
|
-
${processConstantsCpp(constants,
|
|
437
|
+
${processConstantsCpp(constants, domainSeparatorEnum)}
|
|
427
438
|
`;
|
|
428
439
|
fs.writeFileSync(targetPath, resultCpp);
|
|
429
440
|
}
|
|
430
441
|
/**
|
|
431
442
|
* Generate the constants file in PIL.
|
|
432
|
-
*/ function generatePilConstants({ constants,
|
|
443
|
+
*/ function generatePilConstants({ constants, domainSeparatorEnum }, targetPath) {
|
|
433
444
|
const resultPil = `// GENERATED FILE - DO NOT EDIT, RUN yarn remake-constants in yarn-project/constants
|
|
434
445
|
namespace constants;
|
|
435
|
-
${processConstantsPil(constants,
|
|
446
|
+
${processConstantsPil(constants, domainSeparatorEnum)}
|
|
436
447
|
\n`;
|
|
437
448
|
fs.writeFileSync(targetPath, resultPil);
|
|
438
449
|
}
|
|
@@ -462,7 +473,7 @@ ${processConstantsSolidity(constants)}
|
|
|
462
473
|
* Parse the content of the constants file in Noir.
|
|
463
474
|
*/ function parseNoirFile(fileContent) {
|
|
464
475
|
const constantsExpressions = [];
|
|
465
|
-
const
|
|
476
|
+
const domainSeparatorEnum = {};
|
|
466
477
|
const emptyExpression = ()=>({
|
|
467
478
|
name: '',
|
|
468
479
|
content: []
|
|
@@ -481,10 +492,10 @@ ${processConstantsSolidity(constants)}
|
|
|
481
492
|
{
|
|
482
493
|
const [, name, _type, value, end] = line.match(/global\s+(\w+)(\s*:\s*\w+)?\s*=\s*([^;]*)(;)?/) || [];
|
|
483
494
|
if (name && value) {
|
|
484
|
-
const [, indexName] = name.match(/
|
|
495
|
+
const [, indexName] = name.match(/DOM_SEP__(\w+)/) || [];
|
|
485
496
|
if (indexName) {
|
|
486
497
|
// Generator index.
|
|
487
|
-
|
|
498
|
+
domainSeparatorEnum[indexName] = +value;
|
|
488
499
|
} else if (end) {
|
|
489
500
|
// A single line of expression.
|
|
490
501
|
constantsExpressions.push([
|
|
@@ -532,7 +543,7 @@ ${processConstantsSolidity(constants)}
|
|
|
532
543
|
const constants = evaluateExpressions(constantsExpressions);
|
|
533
544
|
return {
|
|
534
545
|
constants,
|
|
535
|
-
|
|
546
|
+
domainSeparatorEnum
|
|
536
547
|
};
|
|
537
548
|
}
|
|
538
549
|
/**
|
|
@@ -559,7 +570,11 @@ ${processConstantsSolidity(constants)}
|
|
|
559
570
|
.replace(/\(/g, '( ').replace(/\)/g, ' )')// We also make some space around common operators
|
|
560
571
|
.replace(/\+/g, ' + ').replace(/(?<!\/)\*(?!\/)/, ' * ')// We split the expression into terms...
|
|
561
572
|
.split(/\s+/)// ...and then we convert each term to a BigInt if it is a number.
|
|
562
|
-
.map((term)=>
|
|
573
|
+
.map((term)=>{
|
|
574
|
+
// Remove underscores from numeric literals (e.g., 6_000_000 -> 6000000)
|
|
575
|
+
const termWithoutUnderscores = term.replace(/_/g, '');
|
|
576
|
+
return isNaN(+termWithoutUnderscores) ? term : `BigInt('${termWithoutUnderscores}')`;
|
|
577
|
+
})// .. also, we convert the known bigints to BigInts.
|
|
563
578
|
.map((term)=>knownBigInts.includes(term) ? `BigInt(${term})` : term)// We join the terms back together.
|
|
564
579
|
.join(' ');
|
|
565
580
|
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.c0b82b2",
|
|
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.c0b82b2",
|
|
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",
|