@aztec/foundation 0.0.1-commit.03f7ef2 → 0.0.1-commit.0b941701
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/array/index.d.ts +2 -1
- package/dest/array/index.d.ts.map +1 -1
- package/dest/array/index.js +1 -0
- package/dest/array/sorted_array.d.ts +10 -0
- package/dest/array/sorted_array.d.ts.map +1 -0
- package/dest/array/sorted_array.js +106 -0
- package/dest/branded-types/block_number.d.ts +4 -1
- package/dest/branded-types/block_number.d.ts.map +1 -1
- package/dest/branded-types/block_number.js +3 -0
- package/dest/branded-types/checkpoint_number.d.ts +10 -2
- package/dest/branded-types/checkpoint_number.d.ts.map +1 -1
- package/dest/branded-types/checkpoint_number.js +17 -8
- package/dest/branded-types/index.d.ts +3 -2
- package/dest/branded-types/index.d.ts.map +1 -1
- package/dest/branded-types/index.js +2 -1
- package/dest/branded-types/index_within_checkpoint.d.ts +42 -0
- package/dest/branded-types/index_within_checkpoint.d.ts.map +1 -0
- package/dest/branded-types/index_within_checkpoint.js +59 -0
- package/dest/buffer/buffer16.d.ts +4 -1
- package/dest/buffer/buffer16.d.ts.map +1 -1
- package/dest/buffer/buffer16.js +3 -1
- package/dest/buffer/buffer32.d.ts +4 -1
- package/dest/buffer/buffer32.d.ts.map +1 -1
- package/dest/buffer/buffer32.js +3 -1
- package/dest/collection/array.d.ts +6 -1
- package/dest/collection/array.d.ts.map +1 -1
- package/dest/collection/array.js +27 -0
- package/dest/config/env_var.d.ts +2 -2
- package/dest/config/env_var.d.ts.map +1 -1
- package/dest/config/index.d.ts +6 -3
- package/dest/config/index.d.ts.map +1 -1
- package/dest/config/index.js +16 -7
- package/dest/config/parse-env.d.ts +3 -0
- package/dest/config/parse-env.d.ts.map +1 -0
- package/dest/config/parse-env.js +7 -0
- package/dest/config/secret_value.js +3 -1
- package/dest/crypto/ecdsa/signature.d.ts +10 -1
- package/dest/crypto/ecdsa/signature.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.d.ts +1 -2
- package/dest/crypto/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/poseidon/index.js +0 -9
- package/dest/crypto/random/randomness_singleton.d.ts +2 -2
- package/dest/crypto/random/randomness_singleton.d.ts.map +1 -1
- package/dest/crypto/random/randomness_singleton.js +3 -3
- package/dest/crypto/sync/poseidon/index.d.ts +1 -2
- package/dest/crypto/sync/poseidon/index.d.ts.map +1 -1
- package/dest/crypto/sync/poseidon/index.js +0 -8
- package/dest/curves/bls12/field.js +6 -3
- package/dest/curves/bls12/point.d.ts +10 -1
- package/dest/curves/bls12/point.d.ts.map +1 -1
- package/dest/curves/bls12/point.js +3 -1
- package/dest/curves/bn254/field.d.ts +2 -1
- package/dest/curves/bn254/field.d.ts.map +1 -1
- package/dest/curves/bn254/field.js +8 -2
- package/dest/curves/grumpkin/point.d.ts +11 -2
- package/dest/curves/grumpkin/point.d.ts.map +1 -1
- package/dest/error/index.d.ts +4 -4
- package/dest/error/index.d.ts.map +1 -1
- package/dest/eth-address/index.js +4 -2
- package/dest/eth-signature/eth_signature.d.ts +4 -1
- package/dest/eth-signature/eth_signature.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.d.ts +1 -1
- package/dest/json-rpc/client/undici.d.ts.map +1 -1
- package/dest/json-rpc/client/undici.js +21 -4
- package/dest/json-rpc/fixtures/class_a.d.ts +3 -3
- package/dest/json-rpc/fixtures/class_a.d.ts.map +1 -1
- package/dest/json-rpc/fixtures/class_b.d.ts +3 -3
- package/dest/json-rpc/fixtures/class_b.d.ts.map +1 -1
- package/dest/json-rpc/server/safe_json_rpc_server.js +1 -1
- package/dest/log/pino-logger.d.ts +1 -1
- package/dest/log/pino-logger.d.ts.map +1 -1
- package/dest/log/pino-logger.js +1 -1
- package/dest/retry/index.d.ts +11 -1
- package/dest/retry/index.d.ts.map +1 -1
- package/dest/retry/index.js +11 -0
- package/dest/serialize/buffer_reader.d.ts +7 -4
- package/dest/serialize/buffer_reader.d.ts.map +1 -1
- package/dest/serialize/buffer_reader.js +13 -4
- package/dest/trees/balanced_merkle_tree_root.d.ts +17 -0
- package/dest/trees/balanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/{balanced_merkle_tree.js → balanced_merkle_tree_root.js} +2 -17
- package/dest/trees/hasher.d.ts +3 -1
- package/dest/trees/hasher.d.ts.map +1 -1
- package/dest/trees/hasher.js +10 -5
- package/dest/trees/index.d.ts +4 -4
- package/dest/trees/index.d.ts.map +1 -1
- package/dest/trees/index.js +3 -3
- package/dest/trees/membership_witness.d.ts +11 -1
- package/dest/trees/membership_witness.d.ts.map +1 -1
- package/dest/trees/membership_witness.js +9 -0
- package/dest/trees/merkle_tree_calculator.d.ts +1 -1
- package/dest/trees/merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/merkle_tree_calculator.js +2 -2
- package/dest/trees/sibling_path.d.ts +2 -1
- package/dest/trees/sibling_path.d.ts.map +1 -1
- package/dest/trees/sibling_path.js +2 -2
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts +2 -3
- package/dest/trees/unbalanced_merkle_tree_calculator.d.ts.map +1 -1
- package/dest/trees/unbalanced_merkle_tree_calculator.js +1 -5
- package/dest/trees/{unbalanced_merkle_tree.d.ts → unbalanced_merkle_tree_root.d.ts} +3 -5
- package/dest/trees/unbalanced_merkle_tree_root.d.ts.map +1 -0
- package/dest/trees/{unbalanced_merkle_tree.js → unbalanced_merkle_tree_root.js} +11 -49
- package/dest/trees/unbalanced_tree_store.d.ts +5 -1
- package/dest/trees/unbalanced_tree_store.d.ts.map +1 -1
- package/dest/trees/unbalanced_tree_store.js +49 -1
- package/dest/types/index.d.ts +1 -1
- package/package.json +4 -4
- package/src/array/index.ts +1 -0
- package/src/array/sorted_array.ts +133 -0
- package/src/branded-types/block_number.ts +5 -0
- package/src/branded-types/checkpoint_number.ts +22 -7
- package/src/branded-types/index.ts +2 -1
- package/src/branded-types/index_within_checkpoint.ts +88 -0
- package/src/collection/array.ts +31 -0
- package/src/config/env_var.ts +21 -9
- package/src/config/index.ts +19 -4
- package/src/config/parse-env.ts +4 -0
- package/src/crypto/poseidon/index.ts +0 -10
- package/src/crypto/random/randomness_singleton.ts +2 -4
- package/src/crypto/sync/poseidon/index.ts +0 -9
- package/src/curves/bn254/field.ts +4 -0
- package/src/eth-address/index.ts +1 -1
- package/src/json-rpc/client/undici.ts +21 -3
- package/src/json-rpc/server/safe_json_rpc_server.ts +1 -1
- package/src/log/pino-logger.ts +2 -1
- package/src/retry/index.ts +18 -0
- package/src/serialize/buffer_reader.ts +21 -9
- package/src/trees/{balanced_merkle_tree.ts → balanced_merkle_tree_root.ts} +2 -18
- package/src/trees/hasher.ts +9 -0
- package/src/trees/index.ts +3 -3
- package/src/trees/membership_witness.ts +8 -0
- package/src/trees/merkle_tree_calculator.ts +2 -2
- package/src/trees/sibling_path.ts +2 -2
- package/src/trees/unbalanced_merkle_tree_calculator.ts +1 -12
- package/src/trees/{unbalanced_merkle_tree.ts → unbalanced_merkle_tree_root.ts} +17 -61
- package/src/trees/unbalanced_tree_store.ts +57 -2
- package/src/types/index.ts +1 -1
- package/dest/json-rpc/server/telemetry.d.ts +0 -2
- package/dest/json-rpc/server/telemetry.d.ts.map +0 -1
- package/dest/json-rpc/server/telemetry.js +0 -0
- package/dest/trees/balanced_merkle_tree.d.ts +0 -22
- package/dest/trees/balanced_merkle_tree.d.ts.map +0 -1
- package/dest/trees/unbalanced_merkle_tree.d.ts.map +0 -1
- package/src/json-rpc/server/telemetry.ts +0 -0
|
@@ -85,16 +85,31 @@ CheckpointNumber.isValid = function (value: unknown): value is CheckpointNumber
|
|
|
85
85
|
return typeof value === 'number' && Number.isInteger(value) && value >= 0;
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
/**
|
|
89
|
-
* The zero checkpoint value.
|
|
90
|
-
*/
|
|
88
|
+
/** The zero checkpoint value. */
|
|
91
89
|
CheckpointNumber.ZERO = CheckpointNumber(0);
|
|
92
90
|
|
|
91
|
+
/** Initial checkpoint. */
|
|
92
|
+
CheckpointNumber.INITIAL = CheckpointNumber(1);
|
|
93
|
+
|
|
93
94
|
/**
|
|
94
95
|
* Zod schema for parsing and validating CheckpointNumber values.
|
|
95
96
|
* Accepts numbers, bigints, or strings and coerces them to CheckpointNumber.
|
|
96
97
|
*/
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
98
|
+
function makeCheckpointNumberSchema(minValue: number) {
|
|
99
|
+
return z
|
|
100
|
+
.union([z.number(), z.bigint(), z.string()])
|
|
101
|
+
.pipe(z.coerce.number().int().min(minValue))
|
|
102
|
+
.transform(value => CheckpointNumber(value));
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Zod schema for parsing and validating Checkpoint values.
|
|
107
|
+
* Accepts numbers, bigints, or strings and coerces them to CheckpointNumber.
|
|
108
|
+
*/
|
|
109
|
+
export const CheckpointNumberSchema = makeCheckpointNumberSchema(0);
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Zod schema for parsing and validating CheckpointNumber values that are strictly positive.
|
|
113
|
+
* Accepts numbers, bigints, or strings and coerces them to CheckpointNumber.
|
|
114
|
+
*/
|
|
115
|
+
export const CheckpointNumberPositiveSchema = makeCheckpointNumberSchema(1);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { BlockNumber, BlockNumberSchema, BlockNumberPositiveSchema } from './block_number.js';
|
|
2
|
-
export { CheckpointNumber, CheckpointNumberSchema } from './checkpoint_number.js';
|
|
2
|
+
export { CheckpointNumber, CheckpointNumberSchema, CheckpointNumberPositiveSchema } from './checkpoint_number.js';
|
|
3
3
|
export { EpochNumber, EpochNumberSchema } from './epoch.js';
|
|
4
|
+
export { IndexWithinCheckpoint, IndexWithinCheckpointSchema } from './index_within_checkpoint.js';
|
|
4
5
|
export { SlotNumber, SlotNumberSchema } from './slot.js';
|
|
5
6
|
|
|
6
7
|
export type { Branded } from './types.js';
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
|
|
3
|
+
import type { Branded } from './types.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A branded type representing the index of a block within a checkpoint.
|
|
7
|
+
* The first block in a checkpoint has index 0, the second has index 1, etc.
|
|
8
|
+
*
|
|
9
|
+
* This is a nominal type backed by a number, but TypeScript will treat it as
|
|
10
|
+
* incompatible with plain numbers and other branded numeric types.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const index = IndexWithinCheckpoint(0);
|
|
15
|
+
* const plainNumber: number = index; // OK - IndexWithinCheckpoint is assignable to number
|
|
16
|
+
* const indexFromNumber: IndexWithinCheckpoint = 0; // ERROR - number is not assignable to IndexWithinCheckpoint
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export type IndexWithinCheckpoint = Branded<number, 'IndexWithinCheckpoint'>;
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Creates an IndexWithinCheckpoint from a number.
|
|
23
|
+
* @param value - The index (must be a non-negative integer)
|
|
24
|
+
* @returns The branded IndexWithinCheckpoint value
|
|
25
|
+
* @throws If the value is negative or not an integer
|
|
26
|
+
*/
|
|
27
|
+
export function IndexWithinCheckpoint(value: number): IndexWithinCheckpoint {
|
|
28
|
+
if (!Number.isInteger(value)) {
|
|
29
|
+
throw new Error(`IndexWithinCheckpoint must be an integer, got ${value}`);
|
|
30
|
+
}
|
|
31
|
+
if (value < 0) {
|
|
32
|
+
throw new Error(`IndexWithinCheckpoint must be non-negative, got ${value}`);
|
|
33
|
+
}
|
|
34
|
+
return value as IndexWithinCheckpoint;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Creates an IndexWithinCheckpoint from a bigint.
|
|
39
|
+
* @param value - The index as bigint (must be a non-negative integer within safe integer range)
|
|
40
|
+
* @returns The branded IndexWithinCheckpoint value
|
|
41
|
+
* @throws If the value is negative or exceeds Number.MAX_SAFE_INTEGER
|
|
42
|
+
*/
|
|
43
|
+
IndexWithinCheckpoint.fromBigInt = function (value: bigint): IndexWithinCheckpoint {
|
|
44
|
+
if (value < 0n) {
|
|
45
|
+
throw new Error(`IndexWithinCheckpoint must be non-negative, got ${value}`);
|
|
46
|
+
}
|
|
47
|
+
if (value > BigInt(Number.MAX_SAFE_INTEGER)) {
|
|
48
|
+
throw new Error(`IndexWithinCheckpoint ${value} exceeds MAX_SAFE_INTEGER`);
|
|
49
|
+
}
|
|
50
|
+
return Number(value) as IndexWithinCheckpoint;
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Creates an IndexWithinCheckpoint from a string.
|
|
55
|
+
* @param value - The index as a string
|
|
56
|
+
* @returns The branded IndexWithinCheckpoint value
|
|
57
|
+
* @throws If the string cannot be parsed as a valid index
|
|
58
|
+
*/
|
|
59
|
+
IndexWithinCheckpoint.fromString = function (value: string): IndexWithinCheckpoint {
|
|
60
|
+
const parsed = parseInt(value, 10);
|
|
61
|
+
if (isNaN(parsed)) {
|
|
62
|
+
throw new Error(`Cannot parse IndexWithinCheckpoint from string: ${value}`);
|
|
63
|
+
}
|
|
64
|
+
return IndexWithinCheckpoint(parsed);
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* Type guard to check if a value is a valid IndexWithinCheckpoint.
|
|
69
|
+
* Note: At runtime, an IndexWithinCheckpoint is just a number, so this checks if the value
|
|
70
|
+
* is a non-negative integer.
|
|
71
|
+
*/
|
|
72
|
+
IndexWithinCheckpoint.isValid = function (value: unknown): value is IndexWithinCheckpoint {
|
|
73
|
+
return typeof value === 'number' && Number.isInteger(value) && value >= 0;
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The zero index value (first block in checkpoint).
|
|
78
|
+
*/
|
|
79
|
+
IndexWithinCheckpoint.ZERO = IndexWithinCheckpoint(0);
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Zod schema for parsing and validating IndexWithinCheckpoint values.
|
|
83
|
+
* Accepts numbers, bigints, or strings and coerces them to IndexWithinCheckpoint.
|
|
84
|
+
*/
|
|
85
|
+
export const IndexWithinCheckpointSchema = z
|
|
86
|
+
.union([z.number(), z.bigint(), z.string()])
|
|
87
|
+
.pipe(z.coerce.number().int().min(0))
|
|
88
|
+
.transform(value => IndexWithinCheckpoint(value));
|
package/src/collection/array.ts
CHANGED
|
@@ -250,6 +250,37 @@ export function chunk<T>(items: T[], chunkSize: number): T[][] {
|
|
|
250
250
|
return chunks;
|
|
251
251
|
}
|
|
252
252
|
|
|
253
|
+
const UNINITIALIZED = Symbol('uninitialized');
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Splits the given iterable into chunks based on the key returned by the given function.
|
|
257
|
+
* Items must be contiguous to be included in the same chunk.
|
|
258
|
+
*/
|
|
259
|
+
export function chunkBy<T, U>(items: T[], fn: (item: T) => U): T[][] {
|
|
260
|
+
const chunks: T[][] = [];
|
|
261
|
+
let currentChunk: T[] = [];
|
|
262
|
+
let currentKey: U | typeof UNINITIALIZED = UNINITIALIZED;
|
|
263
|
+
|
|
264
|
+
for (const item of items) {
|
|
265
|
+
const key = fn(item);
|
|
266
|
+
if (currentKey === UNINITIALIZED || key !== currentKey) {
|
|
267
|
+
if (currentChunk.length > 0) {
|
|
268
|
+
chunks.push(currentChunk);
|
|
269
|
+
}
|
|
270
|
+
currentChunk = [item];
|
|
271
|
+
currentKey = key;
|
|
272
|
+
} else {
|
|
273
|
+
currentChunk.push(item);
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (currentChunk.length > 0) {
|
|
278
|
+
chunks.push(currentChunk);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return chunks;
|
|
282
|
+
}
|
|
283
|
+
|
|
253
284
|
/** Partitions the given iterable into two arrays based on the predicate. */
|
|
254
285
|
export function partition<T>(items: T[], predicate: (item: T) => boolean): [T[], T[]] {
|
|
255
286
|
const pass: T[] = [];
|
package/src/config/env_var.ts
CHANGED
|
@@ -21,14 +21,13 @@ export type EnvVar =
|
|
|
21
21
|
| 'BB_NUM_IVC_VERIFIERS'
|
|
22
22
|
| 'BB_IVC_CONCURRENCY'
|
|
23
23
|
| 'BOOTSTRAP_NODES'
|
|
24
|
-
| '
|
|
25
|
-
| 'BLOB_SINK_PORT'
|
|
26
|
-
| 'BLOB_SINK_URL'
|
|
24
|
+
| 'BLOB_ARCHIVE_API_URL'
|
|
27
25
|
| 'BLOB_FILE_STORE_URLS'
|
|
28
26
|
| 'BLOB_FILE_STORE_UPLOAD_URL'
|
|
27
|
+
| 'BLOB_HEALTHCHECK_UPLOAD_INTERVAL_MINUTES'
|
|
29
28
|
| 'BOT_DA_GAS_LIMIT'
|
|
30
29
|
| 'BOT_FEE_PAYMENT_METHOD'
|
|
31
|
-
| '
|
|
30
|
+
| 'BOT_MIN_FEE_PADDING'
|
|
32
31
|
| 'BOT_FLUSH_SETUP_TRANSACTIONS'
|
|
33
32
|
| 'BOT_FOLLOW_CHAIN'
|
|
34
33
|
| 'BOT_L2_GAS_LIMIT'
|
|
@@ -134,8 +133,7 @@ export type EnvVar =
|
|
|
134
133
|
| 'P2P_TRUSTED_PEERS'
|
|
135
134
|
| 'P2P_PRIVATE_PEERS'
|
|
136
135
|
| 'P2P_PREFERRED_PEERS'
|
|
137
|
-
| '
|
|
138
|
-
| 'P2P_TX_POOL_OVERFLOW_FACTOR'
|
|
136
|
+
| 'P2P_MAX_PENDING_TX_COUNT'
|
|
139
137
|
| 'P2P_SEEN_MSG_CACHE_SIZE'
|
|
140
138
|
| 'P2P_DROP_TX'
|
|
141
139
|
| 'P2P_DROP_TX_CHANCE'
|
|
@@ -153,6 +151,7 @@ export type EnvVar =
|
|
|
153
151
|
| 'PROVER_BROKER_BATCH_INTERVAL_MS'
|
|
154
152
|
| 'PROVER_BROKER_BATCH_SIZE'
|
|
155
153
|
| 'PROVER_BROKER_MAX_EPOCHS_TO_KEEP_RESULTS_FOR'
|
|
154
|
+
| 'PROVER_CANCEL_JOBS_ON_STOP'
|
|
156
155
|
| 'PROVER_COORDINATION_NODE_URLS'
|
|
157
156
|
| 'PROVER_FAILED_PROOF_STORE'
|
|
158
157
|
| 'PROVER_NODE_FAILED_EPOCH_STORE'
|
|
@@ -177,6 +176,7 @@ export type EnvVar =
|
|
|
177
176
|
| 'PROVER_TEST_VERIFICATION_DELAY_MS'
|
|
178
177
|
| 'PXE_L2_BLOCK_BATCH_SIZE'
|
|
179
178
|
| 'PXE_PROVER_ENABLED'
|
|
179
|
+
| 'PXE_SYNC_CHAIN_TIP'
|
|
180
180
|
| 'RPC_MAX_BATCH_SIZE'
|
|
181
181
|
| 'RPC_MAX_BODY_SIZE'
|
|
182
182
|
| 'RPC_SIMULATE_PUBLIC_MAX_GAS_LIMIT'
|
|
@@ -248,7 +248,6 @@ export type EnvVar =
|
|
|
248
248
|
| 'VALIDATOR_ADDRESSES'
|
|
249
249
|
| 'ROLLUP_VERSION'
|
|
250
250
|
| 'WS_BLOCK_CHECK_INTERVAL_MS'
|
|
251
|
-
| 'WS_PROVEN_BLOCKS_ONLY'
|
|
252
251
|
| 'WS_BLOCK_REQUEST_BATCH_SIZE'
|
|
253
252
|
| 'L1_READER_VIEM_POLLING_INTERVAL_MS'
|
|
254
253
|
| 'WS_DATA_DIRECTORY'
|
|
@@ -259,12 +258,14 @@ export type EnvVar =
|
|
|
259
258
|
| 'AZTEC_TARGET_COMMITTEE_SIZE'
|
|
260
259
|
| 'AZTEC_LAG_IN_EPOCHS_FOR_VALIDATOR_SET'
|
|
261
260
|
| 'AZTEC_LAG_IN_EPOCHS_FOR_RANDAO'
|
|
261
|
+
| 'AZTEC_INBOX_LAG'
|
|
262
262
|
| 'AZTEC_PROOF_SUBMISSION_EPOCHS'
|
|
263
263
|
| 'AZTEC_ACTIVATION_THRESHOLD'
|
|
264
264
|
| 'AZTEC_EJECTION_THRESHOLD'
|
|
265
265
|
| 'AZTEC_LOCAL_EJECTION_THRESHOLD'
|
|
266
266
|
| 'AZTEC_MANA_TARGET'
|
|
267
267
|
| 'AZTEC_PROVING_COST_PER_MANA'
|
|
268
|
+
| 'AZTEC_INITIAL_ETH_PER_FEE_ASSET'
|
|
268
269
|
| 'AZTEC_SLASHING_QUORUM'
|
|
269
270
|
| 'AZTEC_SLASHING_ROUND_SIZE_IN_EPOCHS'
|
|
270
271
|
| 'AZTEC_SLASHING_LIFETIME_IN_ROUNDS'
|
|
@@ -278,6 +279,7 @@ export type EnvVar =
|
|
|
278
279
|
| 'AZTEC_SLASHER_FLAVOR'
|
|
279
280
|
| 'AZTEC_GOVERNANCE_PROPOSER_QUORUM'
|
|
280
281
|
| 'AZTEC_GOVERNANCE_PROPOSER_ROUND_SIZE'
|
|
282
|
+
| 'AZTEC_GOVERNANCE_VOTING_DURATION'
|
|
281
283
|
| 'AZTEC_EXIT_DELAY_SECONDS'
|
|
282
284
|
| 'L1_GAS_LIMIT_BUFFER_PERCENTAGE'
|
|
283
285
|
| 'L1_GAS_PRICE_MAX'
|
|
@@ -304,7 +306,6 @@ export type EnvVar =
|
|
|
304
306
|
| 'K8S_POD_UID'
|
|
305
307
|
| 'K8S_NAMESPACE_NAME'
|
|
306
308
|
| 'VALIDATOR_REEXECUTE_DEADLINE_MS'
|
|
307
|
-
| 'ALWAYS_REEXECUTE_BLOCK_PROPOSALS'
|
|
308
309
|
| 'AUTO_UPDATE'
|
|
309
310
|
| 'AUTO_UPDATE_URL'
|
|
310
311
|
| 'WEB3_SIGNER_URL'
|
|
@@ -313,4 +314,15 @@ export type EnvVar =
|
|
|
313
314
|
| 'FISHERMAN_MODE'
|
|
314
315
|
| 'MAX_ALLOWED_ETH_CLIENT_DRIFT_SECONDS'
|
|
315
316
|
| 'LEGACY_BLS_CLI'
|
|
316
|
-
| 'DEBUG_FORCE_TX_PROOF_VERIFICATION'
|
|
317
|
+
| 'DEBUG_FORCE_TX_PROOF_VERIFICATION'
|
|
318
|
+
| 'VALIDATOR_HA_SIGNING_ENABLED'
|
|
319
|
+
| 'VALIDATOR_HA_NODE_ID'
|
|
320
|
+
| 'VALIDATOR_HA_POLLING_INTERVAL_MS'
|
|
321
|
+
| 'VALIDATOR_HA_SIGNING_TIMEOUT_MS'
|
|
322
|
+
| 'VALIDATOR_HA_MAX_STUCK_DUTIES_AGE_MS'
|
|
323
|
+
| 'VALIDATOR_HA_DATABASE_URL'
|
|
324
|
+
| 'VALIDATOR_HA_RUN_MIGRATIONS'
|
|
325
|
+
| 'VALIDATOR_HA_POOL_MAX'
|
|
326
|
+
| 'VALIDATOR_HA_POOL_MIN'
|
|
327
|
+
| 'VALIDATOR_HA_POOL_IDLE_TIMEOUT_MS'
|
|
328
|
+
| 'VALIDATOR_HA_POOL_CONNECTION_TIMEOUT_MS';
|
package/src/config/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { Fq, Fr } from '../curves/bn254/field.js';
|
|
|
2
2
|
import { createConsoleLogger } from '../log/console.js';
|
|
3
3
|
import type { EnvVar } from './env_var.js';
|
|
4
4
|
import { type NetworkNames, getActiveNetworkName } from './network_name.js';
|
|
5
|
+
import { parseBooleanEnv } from './parse-env.js';
|
|
5
6
|
import { SecretValue } from './secret_value.js';
|
|
6
7
|
|
|
7
8
|
export { SecretValue, getActiveNetworkName };
|
|
@@ -148,6 +149,23 @@ export function floatConfigHelper(
|
|
|
148
149
|
};
|
|
149
150
|
}
|
|
150
151
|
|
|
152
|
+
/**
|
|
153
|
+
* Parses an environment variable to a 0-1 percentage value
|
|
154
|
+
*/
|
|
155
|
+
export function percentageConfigHelper(defaultVal: number): Pick<ConfigMapping, 'parseEnv' | 'defaultValue'> {
|
|
156
|
+
return {
|
|
157
|
+
parseEnv: (val: string): number => {
|
|
158
|
+
const parsed = safeParseFloat(val, defaultVal);
|
|
159
|
+
if (parsed < 0 || parsed > 1) {
|
|
160
|
+
throw new TypeError(`Invalid percentage value: ${parsed} should be between 0 and 1`);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return parsed;
|
|
164
|
+
},
|
|
165
|
+
defaultValue: defaultVal,
|
|
166
|
+
};
|
|
167
|
+
}
|
|
168
|
+
|
|
151
169
|
/**
|
|
152
170
|
* Generates parseEnv and default values for a numerical config value.
|
|
153
171
|
* @param defaultVal - The default numerical value to use if the environment variable is not set or is invalid
|
|
@@ -231,10 +249,7 @@ export function secretValueConfigHelper<T>(parse: (val: string | undefined) => T
|
|
|
231
249
|
};
|
|
232
250
|
}
|
|
233
251
|
|
|
234
|
-
|
|
235
|
-
export function parseBooleanEnv(val: string | undefined): boolean {
|
|
236
|
-
return val !== undefined && ['1', 'true', 'TRUE'].includes(val);
|
|
237
|
-
}
|
|
252
|
+
export { parseBooleanEnv } from './parse-env.js';
|
|
238
253
|
|
|
239
254
|
export function secretStringConfigHelper(): Required<
|
|
240
255
|
Pick<ConfigMapping, 'parseEnv' | 'defaultValue' | 'isBoolean'> & {
|
|
@@ -35,16 +35,6 @@ export async function poseidon2HashWithSeparator(input: Fieldable[], separator:
|
|
|
35
35
|
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export async function poseidon2HashAccumulate(input: Fieldable[]): Promise<Fr> {
|
|
39
|
-
const inputFields = serializeToFields(input);
|
|
40
|
-
await BarretenbergSync.initSingleton();
|
|
41
|
-
const api = BarretenbergSync.getSingleton();
|
|
42
|
-
const response = api.poseidon2HashAccumulate({
|
|
43
|
-
inputs: inputFields.map(i => i.toBuffer()),
|
|
44
|
-
});
|
|
45
|
-
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
38
|
/**
|
|
49
39
|
* Runs a Poseidon2 permutation.
|
|
50
40
|
* @param input the input state. Expected to be of size 4.
|
|
@@ -12,11 +12,9 @@ export class RandomnessSingleton {
|
|
|
12
12
|
private static instance: RandomnessSingleton;
|
|
13
13
|
|
|
14
14
|
private counter = 0;
|
|
15
|
+
private readonly log = createLogger('foundation:randomness_singleton');
|
|
15
16
|
|
|
16
|
-
private constructor(
|
|
17
|
-
private readonly seed?: number,
|
|
18
|
-
private readonly log = createLogger('foundation:randomness_singleton'),
|
|
19
|
-
) {
|
|
17
|
+
private constructor(private readonly seed?: number) {
|
|
20
18
|
if (seed !== undefined) {
|
|
21
19
|
this.log.debug(`Using pseudo-randomness with seed: ${seed}`);
|
|
22
20
|
this.counter = seed;
|
|
@@ -34,15 +34,6 @@ export function poseidon2HashWithSeparator(input: Fieldable[], separator: number
|
|
|
34
34
|
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
export function poseidon2HashAccumulate(input: Fieldable[]): Fr {
|
|
38
|
-
const inputFields = serializeToFields(input);
|
|
39
|
-
const api = BarretenbergSync.getSingleton();
|
|
40
|
-
const response = api.poseidon2HashAccumulate({
|
|
41
|
-
inputs: inputFields.map(i => i.toBuffer()),
|
|
42
|
-
});
|
|
43
|
-
return Fr.fromBuffer(Buffer.from(response.hash));
|
|
44
|
-
}
|
|
45
|
-
|
|
46
37
|
/**
|
|
47
38
|
* Runs a Poseidon2 permutation.
|
|
48
39
|
* @param input the input state. Expected to be of size 4.
|
|
@@ -122,6 +122,10 @@ abstract class BaseField {
|
|
|
122
122
|
return this.asBigInt === rhsBigInt ? 0 : this.asBigInt < rhsBigInt ? -1 : 1;
|
|
123
123
|
}
|
|
124
124
|
|
|
125
|
+
static cmp(lhs: BaseField, rhs: BaseField): -1 | 0 | 1 {
|
|
126
|
+
return lhs.cmp(rhs);
|
|
127
|
+
}
|
|
128
|
+
|
|
125
129
|
isZero(): boolean {
|
|
126
130
|
return this.asBigInt === 0n;
|
|
127
131
|
}
|
package/src/eth-address/index.ts
CHANGED
|
@@ -249,7 +249,7 @@ export class EthAddress {
|
|
|
249
249
|
/** Converts a number into an address. Useful for testing. */
|
|
250
250
|
static fromNumber(num: bigint | number): EthAddress {
|
|
251
251
|
const buffer = Buffer.alloc(EthAddress.SIZE_IN_BYTES);
|
|
252
|
-
buffer.writeBigUInt64BE(BigInt(num),
|
|
252
|
+
buffer.writeBigUInt64BE(BigInt(num), EthAddress.SIZE_IN_BYTES - 8);
|
|
253
253
|
return new EthAddress(buffer);
|
|
254
254
|
}
|
|
255
255
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { promisify } from 'node:util';
|
|
2
|
+
import { gunzip as gunzipCb, gzip as gzipCb } from 'node:zlib';
|
|
1
3
|
import { Agent, type Dispatcher } from 'undici';
|
|
2
4
|
|
|
3
5
|
import { createLogger } from '../../log/pino-logger.js';
|
|
@@ -5,8 +7,14 @@ import { NoRetryError } from '../../retry/index.js';
|
|
|
5
7
|
import { jsonStringify } from '../convert.js';
|
|
6
8
|
import type { JsonRpcFetch } from './fetch.js';
|
|
7
9
|
|
|
10
|
+
const gzip = promisify(gzipCb);
|
|
11
|
+
const gunzip = promisify(gunzipCb);
|
|
12
|
+
|
|
8
13
|
const log = createLogger('json-rpc:json_rpc_client:undici');
|
|
9
14
|
|
|
15
|
+
/** Minimum request size in bytes to trigger compression. */
|
|
16
|
+
const COMPRESSION_THRESHOLD = 1024;
|
|
17
|
+
|
|
10
18
|
export { Agent };
|
|
11
19
|
|
|
12
20
|
export function makeUndiciFetch(client = new Agent()): JsonRpcFetch {
|
|
@@ -14,14 +22,18 @@ export function makeUndiciFetch(client = new Agent()): JsonRpcFetch {
|
|
|
14
22
|
log.trace(`JsonRpcClient.fetch: ${host}`, { host, body });
|
|
15
23
|
let resp: Dispatcher.ResponseData;
|
|
16
24
|
try {
|
|
25
|
+
const jsonBody = Buffer.from(jsonStringify(body));
|
|
26
|
+
const shouldCompress = jsonBody.length >= COMPRESSION_THRESHOLD;
|
|
17
27
|
resp = await client.request({
|
|
18
28
|
method: 'POST',
|
|
19
29
|
origin: new URL(host),
|
|
20
30
|
path: '/',
|
|
21
|
-
body:
|
|
31
|
+
body: shouldCompress ? await gzip(jsonBody) : jsonBody,
|
|
22
32
|
headers: {
|
|
23
33
|
...extraHeaders,
|
|
24
34
|
'content-type': 'application/json',
|
|
35
|
+
...(shouldCompress && { 'content-encoding': 'gzip' }),
|
|
36
|
+
'accept-encoding': 'gzip',
|
|
25
37
|
},
|
|
26
38
|
});
|
|
27
39
|
} catch (err) {
|
|
@@ -31,13 +43,19 @@ export function makeUndiciFetch(client = new Agent()): JsonRpcFetch {
|
|
|
31
43
|
|
|
32
44
|
let responseJson: any;
|
|
33
45
|
const responseOk = resp.statusCode >= 200 && resp.statusCode <= 299;
|
|
46
|
+
const contentEncoding = resp.headers['content-encoding'];
|
|
34
47
|
try {
|
|
35
|
-
|
|
48
|
+
if (contentEncoding === 'gzip') {
|
|
49
|
+
const jsonBuffer = await gunzip(await resp.body.arrayBuffer());
|
|
50
|
+
responseJson = JSON.parse(jsonBuffer.toString('utf-8'));
|
|
51
|
+
} else {
|
|
52
|
+
responseJson = await resp.body.json();
|
|
53
|
+
}
|
|
36
54
|
} catch {
|
|
37
55
|
if (!responseOk) {
|
|
38
56
|
throw new Error('HTTP ' + resp.statusCode);
|
|
39
57
|
}
|
|
40
|
-
throw new Error(`Failed to parse body as JSON: ${await resp.body.text()}`);
|
|
58
|
+
throw new Error(`Failed to parse body as JSON. encoding: ${contentEncoding}, body: ${await resp.body.text()}`);
|
|
41
59
|
}
|
|
42
60
|
|
|
43
61
|
if (!responseOk) {
|
package/src/log/pino-logger.ts
CHANGED
|
@@ -5,7 +5,8 @@ import type { Writable } from 'stream';
|
|
|
5
5
|
import { inspect } from 'util';
|
|
6
6
|
|
|
7
7
|
import { compactArray } from '../collection/array.js';
|
|
8
|
-
import {
|
|
8
|
+
import type { EnvVar } from '../config/index.js';
|
|
9
|
+
import { parseBooleanEnv } from '../config/parse-env.js';
|
|
9
10
|
import { GoogleCloudLoggerConfig } from './gcloud-logger-config.js';
|
|
10
11
|
import { getLogLevelFromFilters, parseEnv } from './log-filters.js';
|
|
11
12
|
import type { LogLevel } from './log-levels.js';
|
package/src/retry/index.ts
CHANGED
|
@@ -103,3 +103,21 @@ export async function retryUntil<T>(
|
|
|
103
103
|
}
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Convenience wrapper around retryUntil with fast polling for tests.
|
|
109
|
+
* Uses 10s timeout and 100ms polling interval by default.
|
|
110
|
+
*
|
|
111
|
+
* @param fn - The function to retry until it returns a truthy value.
|
|
112
|
+
* @param name - Description of what we're waiting for (for error messages).
|
|
113
|
+
* @param timeout - Optional timeout in seconds. Defaults to 10s.
|
|
114
|
+
* @param interval - Optional interval in seconds. Defaults to 0.1s (100ms).
|
|
115
|
+
*/
|
|
116
|
+
export function retryFastUntil<T>(
|
|
117
|
+
fn: () => (T | undefined) | Promise<T | undefined>,
|
|
118
|
+
name = '',
|
|
119
|
+
timeout = 10,
|
|
120
|
+
interval = 0.1,
|
|
121
|
+
) {
|
|
122
|
+
return retryUntil(fn, name, timeout, interval);
|
|
123
|
+
}
|
|
@@ -224,15 +224,22 @@ export class BufferReader {
|
|
|
224
224
|
* deserializing each one using the 'fromBuffer' method of 'itemDeserializer'.
|
|
225
225
|
*
|
|
226
226
|
* @param itemDeserializer - Object with 'fromBuffer' method to deserialize vector elements.
|
|
227
|
+
* @param maxSize - Optional maximum allowed size for the vector. If the size exceeds this, an error is thrown.
|
|
227
228
|
* @returns An array of deserialized elements of type T.
|
|
228
229
|
*/
|
|
229
|
-
public readVector<T>(
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
230
|
+
public readVector<T>(
|
|
231
|
+
itemDeserializer: {
|
|
232
|
+
/**
|
|
233
|
+
* A method to deserialize data from a buffer.
|
|
234
|
+
*/
|
|
235
|
+
fromBuffer: (reader: BufferReader) => T;
|
|
236
|
+
},
|
|
237
|
+
maxSize?: number,
|
|
238
|
+
): T[] {
|
|
235
239
|
const size = this.readNumber();
|
|
240
|
+
if (maxSize !== undefined && size > maxSize) {
|
|
241
|
+
throw new Error(`Vector size ${size} exceeds maximum allowed ${maxSize}`);
|
|
242
|
+
}
|
|
236
243
|
const result = new Array<T>(size);
|
|
237
244
|
for (let i = 0; i < size; i++) {
|
|
238
245
|
result[i] = itemDeserializer.fromBuffer(this);
|
|
@@ -344,10 +351,11 @@ export class BufferReader {
|
|
|
344
351
|
* The method first reads the size of the string, then reads the corresponding
|
|
345
352
|
* number of bytes from the buffer and converts them to a string.
|
|
346
353
|
*
|
|
354
|
+
* @param maxSize - Optional maximum allowed size for the string buffer. If the size exceeds this, an error is thrown.
|
|
347
355
|
* @returns The read string from the buffer.
|
|
348
356
|
*/
|
|
349
|
-
public readString(): string {
|
|
350
|
-
return this.readBuffer().toString();
|
|
357
|
+
public readString(maxSize?: number): string {
|
|
358
|
+
return this.readBuffer(maxSize).toString();
|
|
351
359
|
}
|
|
352
360
|
|
|
353
361
|
/**
|
|
@@ -356,10 +364,14 @@ export class BufferReader {
|
|
|
356
364
|
* a Buffer with that size containing the bytes. Useful for reading variable-length
|
|
357
365
|
* binary data encoded as (size, data) format.
|
|
358
366
|
*
|
|
367
|
+
* @param maxSize - Optional maximum allowed size for the buffer. If the size exceeds this, an error is thrown.
|
|
359
368
|
* @returns A Buffer containing the read bytes.
|
|
360
369
|
*/
|
|
361
|
-
public readBuffer(): Buffer {
|
|
370
|
+
public readBuffer(maxSize?: number): Buffer {
|
|
362
371
|
const size = this.readNumber();
|
|
372
|
+
if (maxSize !== undefined && size > maxSize) {
|
|
373
|
+
throw new Error(`Buffer size ${size} exceeds maximum allowed ${maxSize}`);
|
|
374
|
+
}
|
|
363
375
|
this.#rangeCheck(size);
|
|
364
376
|
return this.readBytes(size);
|
|
365
377
|
}
|
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
3
|
-
import { sha256Trunc } from '@aztec/foundation/crypto/sha256';
|
|
4
|
-
|
|
5
|
-
import type { AsyncHasher, Hasher } from './hasher.js';
|
|
6
|
-
|
|
7
|
-
export const shaMerkleHash: Hasher['hash'] = (left: Buffer, right: Buffer) =>
|
|
8
|
-
sha256Trunc(Buffer.concat([left, right])) as Buffer<ArrayBuffer>;
|
|
9
|
-
|
|
10
|
-
export const pedersenMerkleHash: AsyncHasher['hash'] = async (left: Buffer, right: Buffer) =>
|
|
11
|
-
(await pedersenHashArray([left, right])).toBuffer() as Buffer<ArrayBuffer>;
|
|
12
|
-
|
|
13
|
-
export const poseidonMerkleHash: AsyncHasher['hash'] = async (left: Buffer, right: Buffer) =>
|
|
14
|
-
(await poseidon2Hash([left, right])).toBuffer() as Buffer<ArrayBuffer>;
|
|
1
|
+
import { poseidonMerkleHash, shaMerkleHash } from './hasher.js';
|
|
15
2
|
|
|
16
3
|
export const computeBalancedShaRoot = (leaves: Buffer[]) => computeBalancedMerkleTreeRoot(leaves);
|
|
17
4
|
|
|
18
|
-
export const computeBalancedPedersenRoot = async (leaves: Buffer[]) =>
|
|
19
|
-
await computeBalancedMerkleTreeRootAsync(leaves, pedersenMerkleHash);
|
|
20
|
-
|
|
21
5
|
export const computeBalancedPoseidonRoot = async (leaves: Buffer[]) =>
|
|
22
6
|
await computeBalancedMerkleTreeRootAsync(leaves, poseidonMerkleHash);
|
|
23
7
|
|
|
@@ -46,7 +30,7 @@ export function computeBalancedMerkleTreeRoot(leaves: Buffer[], hasher = shaMerk
|
|
|
46
30
|
|
|
47
31
|
/**
|
|
48
32
|
* Computes the Merkle root with the provided leaves **asynchronously**.
|
|
49
|
-
* This method uses an asynchronous hash function (defaults to `
|
|
33
|
+
* This method uses an asynchronous hash function (defaults to `poseidon2Hash`).
|
|
50
34
|
*
|
|
51
35
|
* @throws If the number of leaves is not a power of two.
|
|
52
36
|
*/
|
package/src/trees/hasher.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { poseidon2Hash } from '../crypto/poseidon/index.js';
|
|
2
|
+
import { sha256Trunc } from '../crypto/sha256/index.js';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Defines hasher interface used by Merkle trees.
|
|
3
6
|
*/
|
|
@@ -37,3 +40,9 @@ export interface AsyncHasher {
|
|
|
37
40
|
*/
|
|
38
41
|
hashInputs(inputs: Buffer[]): Promise<Buffer<ArrayBuffer>>;
|
|
39
42
|
}
|
|
43
|
+
|
|
44
|
+
export const shaMerkleHash: Hasher['hash'] = (left: Buffer, right: Buffer) =>
|
|
45
|
+
sha256Trunc(Buffer.concat([left, right])) as Buffer<ArrayBuffer>;
|
|
46
|
+
|
|
47
|
+
export const poseidonMerkleHash: AsyncHasher['hash'] = async (left: Buffer, right: Buffer) =>
|
|
48
|
+
(await poseidon2Hash([left, right])).toBuffer() as Buffer<ArrayBuffer>;
|
package/src/trees/index.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './unbalanced_merkle_tree.js';
|
|
3
|
-
export * from './unbalanced_tree_store.js';
|
|
1
|
+
export * from './balanced_merkle_tree_root.js';
|
|
4
2
|
export * from './merkle_tree_calculator.js';
|
|
5
3
|
export * from './merkle_tree.js';
|
|
6
4
|
export * from './indexed_merkle_tree_calculator.js';
|
|
@@ -10,3 +8,5 @@ export * from './membership_witness.js';
|
|
|
10
8
|
export * from './hasher.js';
|
|
11
9
|
export * from './indexed_tree_leaf.js';
|
|
12
10
|
export * from './unbalanced_merkle_tree_calculator.js';
|
|
11
|
+
export * from './unbalanced_merkle_tree_root.js';
|
|
12
|
+
export * from './unbalanced_tree_store.js';
|
|
@@ -38,6 +38,14 @@ export class MembershipWitness<N extends number> {
|
|
|
38
38
|
return [new Fr(this.leafIndex), ...this.siblingPath];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Returns a representation of the membership witness as expected by intrinsic Noir deserialization.
|
|
43
|
+
*/
|
|
44
|
+
public toNoirRepresentation(): (string | string[])[] {
|
|
45
|
+
// TODO(#12874): remove the stupid as string conversion by modifying ForeignCallOutput type in acvm.js
|
|
46
|
+
return [new Fr(this.leafIndex).toString() as string, this.siblingPath.map(fr => fr.toString()) as string[]];
|
|
47
|
+
}
|
|
48
|
+
|
|
41
49
|
static schemaFor<N extends number>(size: N) {
|
|
42
50
|
return schemas.Buffer.transform(b => MembershipWitness.fromBuffer(b, size));
|
|
43
51
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { poseidon2Hash } from '@aztec/foundation/crypto/poseidon';
|
|
2
2
|
|
|
3
3
|
import type { AsyncHasher } from './hasher.js';
|
|
4
4
|
import { MerkleTree } from './merkle_tree.js';
|
|
@@ -19,7 +19,7 @@ export class MerkleTreeCalculator {
|
|
|
19
19
|
height: number,
|
|
20
20
|
zeroLeaf: Buffer = Buffer.alloc(32),
|
|
21
21
|
hasher = async (left: Buffer, right: Buffer) =>
|
|
22
|
-
(await
|
|
22
|
+
(await poseidon2Hash([left, right])).toBuffer() as Buffer<ArrayBuffer>,
|
|
23
23
|
) {
|
|
24
24
|
const zeroHashes = [zeroLeaf];
|
|
25
25
|
for (let i = 0; i < height; i++) {
|