@aztec/stdlib 0.82.3 → 0.83.0
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/avm/avm.d.ts +3889 -382
- package/dest/avm/avm.d.ts.map +1 -1
- package/dest/avm/avm.js +64 -18
- package/dest/avm/avm_proving_request.d.ts +1610 -66
- package/dest/avm/avm_proving_request.d.ts.map +1 -1
- package/dest/block/l2_block_downloader/l2_block_stream.d.ts +9 -12
- package/dest/block/l2_block_downloader/l2_block_stream.d.ts.map +1 -1
- package/dest/block/l2_block_downloader/l2_block_stream.js +39 -11
- package/dest/config/config.d.ts +2 -2
- package/dest/config/config.d.ts.map +1 -1
- package/dest/config/config.js +4 -5
- package/dest/contract/interfaces/node-info.d.ts +2 -2
- package/dest/contract/interfaces/node-info.d.ts.map +1 -1
- package/dest/contract/interfaces/node-info.js +1 -1
- package/dest/interfaces/prover-client.d.ts +3 -3
- package/dest/interfaces/prover-client.d.ts.map +1 -1
- package/dest/interfaces/prover-client.js +6 -4
- package/dest/interfaces/proving-job.d.ts +1610 -66
- package/dest/interfaces/proving-job.d.ts.map +1 -1
- package/dest/interfaces/pxe.d.ts +7 -6
- package/dest/interfaces/pxe.d.ts.map +1 -1
- package/dest/interfaces/pxe.js +1 -1
- package/dest/keys/derivation.d.ts +1 -1
- package/dest/keys/derivation.d.ts.map +1 -1
- package/dest/keys/derivation.js +10 -2
- package/dest/logs/index.d.ts +2 -1
- package/dest/logs/index.d.ts.map +1 -1
- package/dest/logs/index.js +2 -1
- package/dest/logs/pending_tagged_log.d.ts +17 -0
- package/dest/logs/pending_tagged_log.d.ts.map +1 -0
- package/dest/logs/pending_tagged_log.js +45 -0
- package/dest/logs/{l1_payload/shared_secret_derivation.d.ts → shared_secret_derivation.d.ts} +4 -3
- package/dest/logs/shared_secret_derivation.d.ts.map +1 -0
- package/dest/logs/{l1_payload/shared_secret_derivation.js → shared_secret_derivation.js} +3 -5
- package/dest/logs/tx_scoped_l2_log.d.ts +6 -1
- package/dest/logs/tx_scoped_l2_log.d.ts.map +1 -1
- package/dest/logs/tx_scoped_l2_log.js +12 -4
- package/dest/note/note.d.ts +45 -4
- package/dest/note/note.d.ts.map +1 -1
- package/dest/note/note.js +51 -4
- package/dest/proofs/proof.d.ts.map +1 -1
- package/dest/proofs/proof.js +33 -7
- package/dest/snapshots/download.js +1 -1
- package/dest/snapshots/types.d.ts +4 -4
- package/dest/snapshots/types.d.ts.map +1 -1
- package/dest/snapshots/types.js +1 -1
- package/dest/snapshots/upload.d.ts +1 -1
- package/dest/snapshots/upload.d.ts.map +1 -1
- package/dest/snapshots/upload.js +1 -1
- package/dest/tests/factories.d.ts +10 -2
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +42 -6
- package/dest/tests/mocks.d.ts +2 -1
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +5 -1
- package/dest/trees/nullifier_leaf.d.ts +46 -21
- package/dest/trees/nullifier_leaf.d.ts.map +1 -1
- package/dest/trees/nullifier_leaf.js +48 -30
- package/dest/trees/nullifier_membership_witness.d.ts +28 -12
- package/dest/trees/nullifier_membership_witness.d.ts.map +1 -1
- package/dest/trees/protocol_contract_leaf.d.ts +0 -1
- package/dest/trees/protocol_contract_leaf.d.ts.map +1 -1
- package/dest/trees/protocol_contract_leaf.js +0 -3
- package/dest/trees/public_data_leaf.d.ts +46 -25
- package/dest/trees/public_data_leaf.d.ts.map +1 -1
- package/dest/trees/public_data_leaf.js +35 -30
- package/dest/trees/public_data_witness.d.ts +36 -18
- package/dest/trees/public_data_witness.d.ts.map +1 -1
- package/dest/trees/public_data_witness.js +6 -6
- package/dest/versioning/versioning.d.ts +1 -1
- package/dest/versioning/versioning.d.ts.map +1 -1
- package/dest/versioning/versioning.js +6 -6
- package/package.json +6 -7
- package/src/avm/avm.ts +74 -20
- package/src/block/l2_block_downloader/l2_block_stream.ts +58 -29
- package/src/config/config.ts +6 -6
- package/src/contract/interfaces/node-info.ts +3 -3
- package/src/interfaces/prover-client.ts +9 -7
- package/src/interfaces/pxe.ts +14 -7
- package/src/keys/derivation.ts +12 -6
- package/src/logs/index.ts +2 -1
- package/src/logs/pending_tagged_log.ts +43 -0
- package/src/logs/{l1_payload/shared_secret_derivation.ts → shared_secret_derivation.ts} +4 -11
- package/src/logs/tx_scoped_l2_log.ts +13 -4
- package/src/note/note.ts +61 -5
- package/src/proofs/proof.ts +39 -5
- package/src/snapshots/download.ts +1 -1
- package/src/snapshots/types.ts +2 -2
- package/src/snapshots/upload.ts +5 -3
- package/src/tests/factories.ts +72 -8
- package/src/tests/mocks.ts +7 -0
- package/src/trees/nullifier_leaf.ts +49 -26
- package/src/trees/protocol_contract_leaf.ts +0 -4
- package/src/trees/public_data_leaf.ts +31 -29
- package/src/trees/public_data_witness.ts +6 -6
- package/src/versioning/versioning.ts +8 -14
- package/dest/event/event.d.ts +0 -24
- package/dest/event/event.d.ts.map +0 -1
- package/dest/event/event.js +0 -13
- package/dest/event/event_metadata.d.ts +0 -38
- package/dest/event/event_metadata.d.ts.map +0 -1
- package/dest/event/event_metadata.js +0 -45
- package/dest/event/index.d.ts +0 -4
- package/dest/event/index.d.ts.map +0 -1
- package/dest/event/index.js +0 -3
- package/dest/event/l1_event_payload.d.ts +0 -52
- package/dest/event/l1_event_payload.d.ts.map +0 -1
- package/dest/event/l1_event_payload.js +0 -64
- package/dest/logs/l1_payload/encrypted_log_payload.d.ts +0 -50
- package/dest/logs/l1_payload/encrypted_log_payload.d.ts.map +0 -1
- package/dest/logs/l1_payload/encrypted_log_payload.js +0 -140
- package/dest/logs/l1_payload/encryption_util.d.ts +0 -24
- package/dest/logs/l1_payload/encryption_util.d.ts.map +0 -1
- package/dest/logs/l1_payload/encryption_util.js +0 -46
- package/dest/logs/l1_payload/index.d.ts +0 -3
- package/dest/logs/l1_payload/index.d.ts.map +0 -1
- package/dest/logs/l1_payload/index.js +0 -2
- package/dest/logs/l1_payload/payload.d.ts +0 -60
- package/dest/logs/l1_payload/payload.d.ts.map +0 -1
- package/dest/logs/l1_payload/payload.js +0 -61
- package/dest/logs/l1_payload/shared_secret_derivation.d.ts.map +0 -1
- package/src/event/event.ts +0 -16
- package/src/event/event_metadata.ts +0 -56
- package/src/event/index.ts +0 -3
- package/src/event/l1_event_payload.ts +0 -87
- package/src/logs/l1_payload/encrypted_log_payload.ts +0 -202
- package/src/logs/l1_payload/encryption_util.ts +0 -54
- package/src/logs/l1_payload/index.ts +0 -2
- package/src/logs/l1_payload/payload.ts +0 -73
|
@@ -3,7 +3,7 @@ import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
|
3
3
|
return {
|
|
4
4
|
l1ChainId: config.l1ChainId,
|
|
5
5
|
l1RollupAddress: config.l1Contracts?.rollupAddress,
|
|
6
|
-
|
|
6
|
+
rollupVersion: config.rollupVersion,
|
|
7
7
|
l2ProtocolContractsTreeRoot: l2ProtocolContractsTreeRoot.toString(),
|
|
8
8
|
l2CircuitsVkTreeRoot: l2CircuitsVkTreeRoot.toString()
|
|
9
9
|
};
|
|
@@ -16,7 +16,7 @@ import { jsonStringify } from '@aztec/foundation/json-rpc';
|
|
|
16
16
|
'00',
|
|
17
17
|
versions.l1ChainId,
|
|
18
18
|
versions.l1RollupAddress.toString().slice(2, 10),
|
|
19
|
-
versions.
|
|
19
|
+
versions.rollupVersion,
|
|
20
20
|
versions.l2ProtocolContractsTreeRoot.toString().slice(2, 10),
|
|
21
21
|
versions.l2CircuitsVkTreeRoot.toString().slice(2, 10)
|
|
22
22
|
].join('-');
|
|
@@ -28,7 +28,7 @@ export class ComponentsVersionsError extends Error {
|
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
/** Checks if the compressed string matches against the expected versions. Throws on mismatch. */ export function checkCompressedComponentVersion(compressed, expected) {
|
|
31
|
-
const [versionVersion, l1ChainId, l1RollupAddress,
|
|
31
|
+
const [versionVersion, l1ChainId, l1RollupAddress, rollupVersion, l2ProtocolContractsTreeRoot, l2CircuitsVkTreeRoot] = compressed.split('-');
|
|
32
32
|
if (versionVersion !== '00') {
|
|
33
33
|
throw new ComponentsVersionsError('version', '00', versionVersion);
|
|
34
34
|
}
|
|
@@ -38,8 +38,8 @@ export class ComponentsVersionsError extends Error {
|
|
|
38
38
|
if (l1RollupAddress !== expected.l1RollupAddress.toString().slice(2, 10)) {
|
|
39
39
|
throw new ComponentsVersionsError(`L1 address`, expected.l1RollupAddress.toString(), l1RollupAddress);
|
|
40
40
|
}
|
|
41
|
-
if (
|
|
42
|
-
throw new ComponentsVersionsError('L2 chain version', expected.
|
|
41
|
+
if (rollupVersion !== expected.rollupVersion.toString()) {
|
|
42
|
+
throw new ComponentsVersionsError('L2 chain version', expected.rollupVersion.toString(), rollupVersion);
|
|
43
43
|
}
|
|
44
44
|
if (l2ProtocolContractsTreeRoot !== expected.l2ProtocolContractsTreeRoot.toString().slice(2, 10)) {
|
|
45
45
|
throw new ComponentsVersionsError(`L2 protocol contracts vk tree root`, expected.l2ProtocolContractsTreeRoot.toString(), l2ProtocolContractsTreeRoot);
|
|
@@ -54,7 +54,7 @@ export class ComponentsVersionsError extends Error {
|
|
|
54
54
|
'l2ProtocolContractsTreeRoot',
|
|
55
55
|
'l2CircuitsVkTreeRoot',
|
|
56
56
|
'l1ChainId',
|
|
57
|
-
'
|
|
57
|
+
'rollupVersion'
|
|
58
58
|
]){
|
|
59
59
|
const actualValue = actual[key];
|
|
60
60
|
const expectedValue = expected[key];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/stdlib",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.83.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"inherits": [
|
|
6
6
|
"../package.common.json",
|
|
@@ -34,7 +34,6 @@
|
|
|
34
34
|
"./tx": "./dest/tx/index.js",
|
|
35
35
|
"./fees": "./dest/fees/index.js",
|
|
36
36
|
"./note": "./dest/note/index.js",
|
|
37
|
-
"./event": "./dest/event/index.js",
|
|
38
37
|
"./p2p": "./dest/p2p/index.js",
|
|
39
38
|
"./errors": "./dest/errors/index.js",
|
|
40
39
|
"./stats": "./dest/stats/index.js",
|
|
@@ -68,11 +67,11 @@
|
|
|
68
67
|
"test": "NODE_NO_WARNINGS=1 node --experimental-vm-modules ../node_modules/.bin/jest --passWithNoTests --maxWorkers=${JEST_MAX_WORKERS:-8}"
|
|
69
68
|
},
|
|
70
69
|
"dependencies": {
|
|
71
|
-
"@aztec/bb.js": "0.
|
|
72
|
-
"@aztec/blob-lib": "0.
|
|
73
|
-
"@aztec/constants": "0.
|
|
74
|
-
"@aztec/ethereum": "0.
|
|
75
|
-
"@aztec/foundation": "0.
|
|
70
|
+
"@aztec/bb.js": "0.83.0",
|
|
71
|
+
"@aztec/blob-lib": "0.83.0",
|
|
72
|
+
"@aztec/constants": "0.83.0",
|
|
73
|
+
"@aztec/ethereum": "0.83.0",
|
|
74
|
+
"@aztec/foundation": "0.83.0",
|
|
76
75
|
"@google-cloud/storage": "^7.15.0",
|
|
77
76
|
"lodash.chunk": "^4.2.0",
|
|
78
77
|
"lodash.isequal": "^4.5.0",
|
package/src/avm/avm.ts
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import { jsonParseWithSchema, jsonStringify } from '@aztec/foundation/json-rpc';
|
|
3
3
|
import { schemas } from '@aztec/foundation/schemas';
|
|
4
|
-
import type { IndexedTreeLeaf } from '@aztec/foundation/trees';
|
|
5
4
|
|
|
6
5
|
import { z } from 'zod';
|
|
7
6
|
|
|
8
7
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
9
8
|
import { PublicKeys } from '../keys/public_keys.js';
|
|
10
9
|
import { AppendOnlyTreeSnapshot } from '../trees/append_only_tree_snapshot.js';
|
|
11
|
-
import
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
10
|
+
import { MerkleTreeId } from '../trees/merkle_tree_id.js';
|
|
11
|
+
import { NullifierLeafPreimage } from '../trees/nullifier_leaf.js';
|
|
12
|
+
import { PublicDataTreeLeafPreimage } from '../trees/public_data_leaf.js';
|
|
14
13
|
import { AvmCircuitPublicInputs } from './avm_circuit_public_inputs.js';
|
|
15
14
|
import { serializeWithMessagePack } from './message_pack.js';
|
|
16
15
|
|
|
@@ -152,22 +151,20 @@ export class AvmGetPreviousValueIndexHint {
|
|
|
152
151
|
}
|
|
153
152
|
}
|
|
154
153
|
|
|
154
|
+
type IndexedTreeLeafPreimages = NullifierLeafPreimage | PublicDataTreeLeafPreimage;
|
|
155
|
+
type IndexedTreeLeafPreimagesClasses = typeof NullifierLeafPreimage | typeof PublicDataTreeLeafPreimage;
|
|
156
|
+
|
|
155
157
|
// Hint for MerkleTreeDB.getLeafPreimage.
|
|
156
158
|
// NOTE: I need this factory because in order to get hold of the schema, I need an actual instance of the class,
|
|
157
159
|
// having the type doesn't suffice since TS does type erasure in the end.
|
|
158
|
-
function AvmGetLeafPreimageHintFactory
|
|
159
|
-
schema: z.ZodSchema;
|
|
160
|
-
new (...args: any[]): T;
|
|
161
|
-
}) {
|
|
160
|
+
function AvmGetLeafPreimageHintFactory(klass: IndexedTreeLeafPreimagesClasses) {
|
|
162
161
|
return class AvmGetLeafPreimageHint {
|
|
163
162
|
constructor(
|
|
164
163
|
public readonly hintKey: AppendOnlyTreeSnapshot,
|
|
165
164
|
// params (tree id will be implicit)
|
|
166
165
|
public readonly index: bigint,
|
|
167
166
|
// return
|
|
168
|
-
public readonly
|
|
169
|
-
public readonly nextIndex: bigint,
|
|
170
|
-
public readonly nextValue: Fr,
|
|
167
|
+
public readonly leafPreimage: IndexedTreeLeafPreimages,
|
|
171
168
|
) {}
|
|
172
169
|
|
|
173
170
|
static get schema() {
|
|
@@ -175,21 +172,16 @@ function AvmGetLeafPreimageHintFactory<T extends IndexedTreeLeaf>(klass: {
|
|
|
175
172
|
.object({
|
|
176
173
|
hintKey: AppendOnlyTreeSnapshot.schema,
|
|
177
174
|
index: schemas.BigInt,
|
|
178
|
-
|
|
179
|
-
nextIndex: schemas.BigInt,
|
|
180
|
-
nextValue: schemas.Fr,
|
|
175
|
+
leafPreimage: klass.schema,
|
|
181
176
|
})
|
|
182
|
-
.transform(
|
|
183
|
-
({ hintKey, index, leaf, nextIndex, nextValue }) =>
|
|
184
|
-
new AvmGetLeafPreimageHint(hintKey, index, leaf, nextIndex, nextValue),
|
|
185
|
-
);
|
|
177
|
+
.transform(({ hintKey, index, leafPreimage }) => new AvmGetLeafPreimageHint(hintKey, index, leafPreimage));
|
|
186
178
|
}
|
|
187
179
|
};
|
|
188
180
|
}
|
|
189
181
|
|
|
190
182
|
// Note: only supported for PUBLIC_DATA_TREE and NULLIFIER_TREE.
|
|
191
|
-
export class AvmGetLeafPreimageHintPublicDataTree extends AvmGetLeafPreimageHintFactory(
|
|
192
|
-
export class AvmGetLeafPreimageHintNullifierTree extends AvmGetLeafPreimageHintFactory(
|
|
183
|
+
export class AvmGetLeafPreimageHintPublicDataTree extends AvmGetLeafPreimageHintFactory(PublicDataTreeLeafPreimage) {}
|
|
184
|
+
export class AvmGetLeafPreimageHintNullifierTree extends AvmGetLeafPreimageHintFactory(NullifierLeafPreimage) {}
|
|
193
185
|
|
|
194
186
|
// Hint for MerkleTreeDB.getLeafValue.
|
|
195
187
|
// Note: only supported for NOTE_HASH_TREE and L1_TO_L2_MESSAGE_TREE.
|
|
@@ -215,6 +207,60 @@ export class AvmGetLeafValueHint {
|
|
|
215
207
|
}
|
|
216
208
|
}
|
|
217
209
|
|
|
210
|
+
// Hint for MerkleTreeDB.sequentialInsert.
|
|
211
|
+
// NOTE: I need this factory because in order to get hold of the schema, I need an actual instance of the class,
|
|
212
|
+
// having the type doesn't suffice since TS does type erasure in the end.
|
|
213
|
+
function AvmSequentialInsertHintFactory(klass: IndexedTreeLeafPreimagesClasses) {
|
|
214
|
+
return class AvmSequentialInsertHint {
|
|
215
|
+
constructor(
|
|
216
|
+
public readonly hintKey: AppendOnlyTreeSnapshot,
|
|
217
|
+
public readonly stateAfter: AppendOnlyTreeSnapshot,
|
|
218
|
+
// params
|
|
219
|
+
public readonly treeId: MerkleTreeId,
|
|
220
|
+
public readonly leaf: InstanceType<IndexedTreeLeafPreimagesClasses>['leaf'],
|
|
221
|
+
// return
|
|
222
|
+
public readonly lowLeavesWitnessData: {
|
|
223
|
+
leaf: IndexedTreeLeafPreimages;
|
|
224
|
+
index: bigint;
|
|
225
|
+
path: Fr[];
|
|
226
|
+
},
|
|
227
|
+
public readonly insertionWitnessData: {
|
|
228
|
+
leaf: IndexedTreeLeafPreimages;
|
|
229
|
+
index: bigint;
|
|
230
|
+
path: Fr[];
|
|
231
|
+
},
|
|
232
|
+
) {}
|
|
233
|
+
|
|
234
|
+
static get schema() {
|
|
235
|
+
return z
|
|
236
|
+
.object({
|
|
237
|
+
hintKey: AppendOnlyTreeSnapshot.schema,
|
|
238
|
+
stateAfter: AppendOnlyTreeSnapshot.schema,
|
|
239
|
+
treeId: z.number().int().nonnegative(),
|
|
240
|
+
leaf: klass.leafSchema,
|
|
241
|
+
lowLeavesWitnessData: z.object({
|
|
242
|
+
leaf: klass.schema,
|
|
243
|
+
index: schemas.BigInt,
|
|
244
|
+
path: schemas.Fr.array(),
|
|
245
|
+
}),
|
|
246
|
+
insertionWitnessData: z.object({
|
|
247
|
+
leaf: klass.schema,
|
|
248
|
+
index: schemas.BigInt,
|
|
249
|
+
path: schemas.Fr.array(),
|
|
250
|
+
}),
|
|
251
|
+
})
|
|
252
|
+
.transform(
|
|
253
|
+
({ hintKey, stateAfter, treeId, leaf, lowLeavesWitnessData, insertionWitnessData }) =>
|
|
254
|
+
new AvmSequentialInsertHint(hintKey, stateAfter, treeId, leaf, lowLeavesWitnessData, insertionWitnessData),
|
|
255
|
+
);
|
|
256
|
+
}
|
|
257
|
+
};
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Note: only supported for PUBLIC_DATA_TREE and NULLIFIER_TREE.
|
|
261
|
+
export class AvmSequentialInsertHintPublicDataTree extends AvmSequentialInsertHintFactory(PublicDataTreeLeafPreimage) {}
|
|
262
|
+
export class AvmSequentialInsertHintNullifierTree extends AvmSequentialInsertHintFactory(NullifierLeafPreimage) {}
|
|
263
|
+
|
|
218
264
|
////////////////////////////////////////////////////////////////////////////
|
|
219
265
|
// Hints (other)
|
|
220
266
|
////////////////////////////////////////////////////////////////////////////
|
|
@@ -254,6 +300,8 @@ export class AvmExecutionHints {
|
|
|
254
300
|
public readonly getLeafPreimageHintsPublicDataTree: AvmGetLeafPreimageHintPublicDataTree[] = [],
|
|
255
301
|
public readonly getLeafPreimageHintsNullifierTree: AvmGetLeafPreimageHintNullifierTree[] = [],
|
|
256
302
|
public readonly getLeafValueHints: AvmGetLeafValueHint[] = [],
|
|
303
|
+
public readonly sequentialInsertHintsPublicDataTree: AvmSequentialInsertHintPublicDataTree[] = [],
|
|
304
|
+
public readonly sequentialInsertHintsNullifierTree: AvmSequentialInsertHintNullifierTree[] = [],
|
|
257
305
|
) {}
|
|
258
306
|
|
|
259
307
|
static empty() {
|
|
@@ -272,6 +320,8 @@ export class AvmExecutionHints {
|
|
|
272
320
|
getLeafPreimageHintsPublicDataTree: AvmGetLeafPreimageHintPublicDataTree.schema.array(),
|
|
273
321
|
getLeafPreimageHintsNullifierTree: AvmGetLeafPreimageHintNullifierTree.schema.array(),
|
|
274
322
|
getLeafValueHints: AvmGetLeafValueHint.schema.array(),
|
|
323
|
+
sequentialInsertHintsPublicDataTree: AvmSequentialInsertHintPublicDataTree.schema.array(),
|
|
324
|
+
sequentialInsertHintsNullifierTree: AvmSequentialInsertHintNullifierTree.schema.array(),
|
|
275
325
|
})
|
|
276
326
|
.transform(
|
|
277
327
|
({
|
|
@@ -284,6 +334,8 @@ export class AvmExecutionHints {
|
|
|
284
334
|
getLeafPreimageHintsPublicDataTree,
|
|
285
335
|
getLeafPreimageHintsNullifierTree,
|
|
286
336
|
getLeafValueHints,
|
|
337
|
+
sequentialInsertHintsPublicDataTree,
|
|
338
|
+
sequentialInsertHintsNullifierTree,
|
|
287
339
|
}) =>
|
|
288
340
|
new AvmExecutionHints(
|
|
289
341
|
enqueuedCalls,
|
|
@@ -295,6 +347,8 @@ export class AvmExecutionHints {
|
|
|
295
347
|
getLeafPreimageHintsPublicDataTree,
|
|
296
348
|
getLeafPreimageHintsNullifierTree,
|
|
297
349
|
getLeafValueHints,
|
|
350
|
+
sequentialInsertHintsPublicDataTree,
|
|
351
|
+
sequentialInsertHintsNullifierTree,
|
|
298
352
|
),
|
|
299
353
|
);
|
|
300
354
|
}
|
|
@@ -66,12 +66,20 @@ export class L2BlockStream {
|
|
|
66
66
|
|
|
67
67
|
// Check if there was a reorg and emit a chain-pruned event if so.
|
|
68
68
|
let latestBlockNumber = localTips.latest.number;
|
|
69
|
-
|
|
69
|
+
const sourceCache = new BlockHashCache([sourceTips.latest]);
|
|
70
|
+
while (!(await this.areBlockHashesEqualAt(latestBlockNumber, { sourceCache }))) {
|
|
70
71
|
latestBlockNumber--;
|
|
71
72
|
}
|
|
73
|
+
|
|
72
74
|
if (latestBlockNumber < localTips.latest.number) {
|
|
73
75
|
this.log.verbose(`Reorg detected. Pruning blocks from ${latestBlockNumber + 1} to ${localTips.latest.number}.`);
|
|
74
|
-
await this.emitEvent({
|
|
76
|
+
await this.emitEvent({
|
|
77
|
+
type: 'chain-pruned',
|
|
78
|
+
block: {
|
|
79
|
+
number: latestBlockNumber,
|
|
80
|
+
hash: sourceCache.get(latestBlockNumber) ?? (await this.getBlockHashFromSource(latestBlockNumber))!,
|
|
81
|
+
},
|
|
82
|
+
});
|
|
75
83
|
}
|
|
76
84
|
|
|
77
85
|
// If we are just starting, use the starting block number from the options.
|
|
@@ -100,10 +108,13 @@ export class L2BlockStream {
|
|
|
100
108
|
|
|
101
109
|
// Update the proven and finalized tips.
|
|
102
110
|
if (localTips.proven !== undefined && sourceTips.proven.number !== localTips.proven.number) {
|
|
103
|
-
await this.emitEvent({
|
|
111
|
+
await this.emitEvent({
|
|
112
|
+
type: 'chain-proven',
|
|
113
|
+
block: sourceTips.proven,
|
|
114
|
+
});
|
|
104
115
|
}
|
|
105
116
|
if (localTips.finalized !== undefined && sourceTips.finalized.number !== localTips.finalized.number) {
|
|
106
|
-
await this.emitEvent({ type: 'chain-finalized',
|
|
117
|
+
await this.emitEvent({ type: 'chain-finalized', block: sourceTips.finalized });
|
|
107
118
|
}
|
|
108
119
|
} catch (err: any) {
|
|
109
120
|
if (err.name === 'AbortError') {
|
|
@@ -118,29 +129,31 @@ export class L2BlockStream {
|
|
|
118
129
|
* @param blockNumber - The block number to test.
|
|
119
130
|
* @param args - A cache of data already requested from source, to avoid re-requesting it.
|
|
120
131
|
*/
|
|
121
|
-
private async areBlockHashesEqualAt(blockNumber: number, args: { sourceCache:
|
|
132
|
+
private async areBlockHashesEqualAt(blockNumber: number, args: { sourceCache: BlockHashCache }) {
|
|
122
133
|
if (blockNumber === 0) {
|
|
123
134
|
return true;
|
|
124
135
|
}
|
|
125
136
|
const localBlockHash = await this.localData.getL2BlockHash(blockNumber);
|
|
126
|
-
const
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
this.log.trace(`Comparing block hashes for block ${blockNumber}`, {
|
|
133
|
-
localBlockHash,
|
|
134
|
-
sourceBlockHash,
|
|
135
|
-
sourceCacheNumber: args.sourceCache[0]?.number,
|
|
136
|
-
sourceCacheHash: args.sourceCache[0]?.hash,
|
|
137
|
-
});
|
|
137
|
+
const sourceBlockHashFromCache = args.sourceCache.get(blockNumber);
|
|
138
|
+
const sourceBlockHash = args.sourceCache.get(blockNumber) ?? (await this.getBlockHashFromSource(blockNumber));
|
|
139
|
+
if (!sourceBlockHashFromCache && sourceBlockHash) {
|
|
140
|
+
args.sourceCache.add({ number: blockNumber, hash: sourceBlockHash });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
this.log.trace(`Comparing block hashes for block ${blockNumber}`, { localBlockHash, sourceBlockHash });
|
|
138
144
|
return localBlockHash === sourceBlockHash;
|
|
139
145
|
}
|
|
140
146
|
|
|
147
|
+
private getBlockHashFromSource(blockNumber: number) {
|
|
148
|
+
return this.l2BlockSource
|
|
149
|
+
.getBlockHeader(blockNumber)
|
|
150
|
+
.then(h => h?.hash())
|
|
151
|
+
.then(hash => hash?.toString());
|
|
152
|
+
}
|
|
153
|
+
|
|
141
154
|
private async emitEvent(event: L2BlockStreamEvent) {
|
|
142
155
|
this.log.debug(
|
|
143
|
-
`Emitting ${event.type} (${event.type === 'blocks-added' ? event.blocks.length : event.
|
|
156
|
+
`Emitting ${event.type} (${event.type === 'blocks-added' ? event.blocks.length : event.block.number})`,
|
|
144
157
|
);
|
|
145
158
|
await this.handler.handleBlockStreamEvent(event);
|
|
146
159
|
if (!this.isRunning() && !this.isSyncing) {
|
|
@@ -149,6 +162,26 @@ export class L2BlockStream {
|
|
|
149
162
|
}
|
|
150
163
|
}
|
|
151
164
|
|
|
165
|
+
class BlockHashCache {
|
|
166
|
+
private readonly cache: Map<number, string> = new Map();
|
|
167
|
+
|
|
168
|
+
constructor(initial: L2BlockId[] = []) {
|
|
169
|
+
for (const block of initial) {
|
|
170
|
+
this.add(block);
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
public add(block: L2BlockId) {
|
|
175
|
+
if (block.hash) {
|
|
176
|
+
this.cache.set(block.number, block.hash);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
public get(blockNumber: number) {
|
|
181
|
+
return this.cache.get(blockNumber);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
|
|
152
185
|
/** Interface to the local view of the chain. Implemented by world-state and l2-tips-store. */
|
|
153
186
|
export interface L2BlockStreamLocalDataProvider {
|
|
154
187
|
getL2BlockHash(number: number): Promise<string | undefined>;
|
|
@@ -161,23 +194,19 @@ export interface L2BlockStreamEventHandler {
|
|
|
161
194
|
}
|
|
162
195
|
|
|
163
196
|
export type L2BlockStreamEvent =
|
|
164
|
-
| {
|
|
197
|
+
| /** Emits blocks added to the chain. */ {
|
|
165
198
|
type: 'blocks-added';
|
|
166
|
-
/** New blocks added to the chain. */
|
|
167
199
|
blocks: PublishedL2Block[];
|
|
168
200
|
}
|
|
169
|
-
| {
|
|
201
|
+
| /** Reports last correct block (new tip of the unproven chain). */ {
|
|
170
202
|
type: 'chain-pruned';
|
|
171
|
-
|
|
172
|
-
blockNumber: number;
|
|
203
|
+
block: L2BlockId;
|
|
173
204
|
}
|
|
174
|
-
| {
|
|
205
|
+
| /** Reports new proven block. */ {
|
|
175
206
|
type: 'chain-proven';
|
|
176
|
-
|
|
177
|
-
blockNumber: number;
|
|
207
|
+
block: L2BlockId;
|
|
178
208
|
}
|
|
179
|
-
| {
|
|
209
|
+
| /** Reports new finalized block (proven and finalized on L1). */ {
|
|
180
210
|
type: 'chain-finalized';
|
|
181
|
-
|
|
182
|
-
blockNumber: number;
|
|
211
|
+
block: L2BlockId;
|
|
183
212
|
};
|
package/src/config/config.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { l1ContractAddressesMapping } from '@aztec/ethereum/l1-contract-addresses';
|
|
2
|
-
import {
|
|
2
|
+
import type { ConfigMappingsType } from '@aztec/foundation/config';
|
|
3
3
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
|
|
5
5
|
export { type AllowedElement, type SequencerConfig, SequencerConfigSchema } from '../interfaces/configs.js';
|
|
@@ -7,7 +7,7 @@ export { type AllowedElement, type SequencerConfig, SequencerConfigSchema } from
|
|
|
7
7
|
export const emptyChainConfig: ChainConfig = {
|
|
8
8
|
l1ChainId: 0,
|
|
9
9
|
l1Contracts: { rollupAddress: EthAddress.ZERO },
|
|
10
|
-
|
|
10
|
+
rollupVersion: 0,
|
|
11
11
|
};
|
|
12
12
|
|
|
13
13
|
export const chainConfigMappings: ConfigMappingsType<ChainConfig> = {
|
|
@@ -17,10 +17,10 @@ export const chainConfigMappings: ConfigMappingsType<ChainConfig> = {
|
|
|
17
17
|
defaultValue: 31337,
|
|
18
18
|
description: 'The chain ID of the ethereum host.',
|
|
19
19
|
},
|
|
20
|
-
|
|
21
|
-
env: '
|
|
20
|
+
rollupVersion: {
|
|
21
|
+
env: 'ROLLUP_VERSION',
|
|
22
22
|
description: 'The version of the rollup.',
|
|
23
|
-
|
|
23
|
+
parseEnv: (val: string) => (Number.isSafeInteger(parseInt(val, 10)) ? parseInt(val, 10) : undefined),
|
|
24
24
|
},
|
|
25
25
|
l1Contracts: {
|
|
26
26
|
description: 'The deployed L1 contract addresses',
|
|
@@ -33,7 +33,7 @@ export type ChainConfig = {
|
|
|
33
33
|
/** The chain id of the ethereum host. */
|
|
34
34
|
l1ChainId: number;
|
|
35
35
|
/** The version of the rollup. */
|
|
36
|
-
|
|
36
|
+
rollupVersion: number;
|
|
37
37
|
/** The address to the L1 contracts. */
|
|
38
38
|
l1Contracts: {
|
|
39
39
|
/** The address to rollup */
|
|
@@ -11,8 +11,8 @@ export interface NodeInfo {
|
|
|
11
11
|
nodeVersion: string;
|
|
12
12
|
/** L1 chain id. */
|
|
13
13
|
l1ChainId: number;
|
|
14
|
-
/**
|
|
15
|
-
|
|
14
|
+
/** Rollup version. */
|
|
15
|
+
rollupVersion: number;
|
|
16
16
|
/** The node's ENR. */
|
|
17
17
|
enr: string | undefined;
|
|
18
18
|
/** The deployed l1 contract addresses */
|
|
@@ -25,7 +25,7 @@ export const NodeInfoSchema: ZodFor<NodeInfo> = z
|
|
|
25
25
|
.object({
|
|
26
26
|
nodeVersion: z.string(),
|
|
27
27
|
l1ChainId: z.number().int().nonnegative(),
|
|
28
|
-
|
|
28
|
+
rollupVersion: z.number().int().nonnegative(),
|
|
29
29
|
enr: z.string().optional(),
|
|
30
30
|
l1ContractAddresses: L1ContractAddressesSchema,
|
|
31
31
|
protocolContractAddresses: ProtocolContractAddressesSchema,
|
|
@@ -26,7 +26,7 @@ export type ProverConfig = ActualProverConfig & {
|
|
|
26
26
|
/** The URL to the Aztec node to take proving jobs from */
|
|
27
27
|
nodeUrl?: string;
|
|
28
28
|
/** Identifier of the prover */
|
|
29
|
-
proverId
|
|
29
|
+
proverId?: Fr;
|
|
30
30
|
/** Number of proving agents to start within the prover. */
|
|
31
31
|
proverAgentCount: number;
|
|
32
32
|
/** Store for failed proof inputs. */
|
|
@@ -36,7 +36,7 @@ export type ProverConfig = ActualProverConfig & {
|
|
|
36
36
|
export const ProverConfigSchema = z.object({
|
|
37
37
|
nodeUrl: z.string().optional(),
|
|
38
38
|
realProofs: z.boolean(),
|
|
39
|
-
proverId: schemas.Fr,
|
|
39
|
+
proverId: schemas.Fr.optional(),
|
|
40
40
|
proverTestDelayType: z.enum(['fixed', 'realistic']),
|
|
41
41
|
proverTestDelayMs: z.number(),
|
|
42
42
|
proverTestDelayFactor: z.number(),
|
|
@@ -55,9 +55,8 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
|
|
|
55
55
|
},
|
|
56
56
|
proverId: {
|
|
57
57
|
env: 'PROVER_ID',
|
|
58
|
-
parseEnv: (val
|
|
59
|
-
description: '
|
|
60
|
-
defaultValue: Fr.ZERO,
|
|
58
|
+
parseEnv: (val?: string) => parseProverId(val),
|
|
59
|
+
description: 'Hex value that identifies the prover. Defaults to the address used for submitting proofs if not set.',
|
|
61
60
|
},
|
|
62
61
|
proverTestDelayType: {
|
|
63
62
|
env: 'PROVER_TEST_DELAY_TYPE',
|
|
@@ -85,8 +84,11 @@ export const proverConfigMappings: ConfigMappingsType<ProverConfig> = {
|
|
|
85
84
|
},
|
|
86
85
|
};
|
|
87
86
|
|
|
88
|
-
function parseProverId(str
|
|
89
|
-
|
|
87
|
+
function parseProverId(str?: string) {
|
|
88
|
+
if (!str) {
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
return Fr.fromHexString(str);
|
|
90
92
|
}
|
|
91
93
|
|
|
92
94
|
/**
|
package/src/interfaces/pxe.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { L1_TO_L2_MSG_TREE_HEIGHT } from '@aztec/constants';
|
|
2
|
-
import type { Fr
|
|
2
|
+
import type { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import type { ApiSchemaFor, ZodFor } from '@aztec/foundation/schemas';
|
|
4
4
|
import { SiblingPath } from '@aztec/foundation/trees';
|
|
5
5
|
|
|
@@ -129,7 +129,7 @@ export interface PXE {
|
|
|
129
129
|
|
|
130
130
|
/**
|
|
131
131
|
* Proves the private portion of a simulated transaction, ready to send to the network
|
|
132
|
-
* (where
|
|
132
|
+
* (where validators prove the public portion).
|
|
133
133
|
*
|
|
134
134
|
* @param txRequest - An authenticated tx request ready for proving
|
|
135
135
|
* @param privateExecutionResult - The result of the private execution of the transaction
|
|
@@ -313,7 +313,7 @@ export interface PXE {
|
|
|
313
313
|
|
|
314
314
|
/**
|
|
315
315
|
* Returns the information about the server's node. Includes current Node version, compatible Noir version,
|
|
316
|
-
* L1 chain identifier,
|
|
316
|
+
* L1 chain identifier, rollup version, and L1 address of the rollup contract.
|
|
317
317
|
* @returns - The node information.
|
|
318
318
|
*/
|
|
319
319
|
getNodeInfo(): Promise<NodeInfo>;
|
|
@@ -354,13 +354,20 @@ export interface PXE {
|
|
|
354
354
|
|
|
355
355
|
/**
|
|
356
356
|
* Returns the private events given search parameters.
|
|
357
|
+
* @param contractAddress - The address of the contract to get events from.
|
|
357
358
|
* @param eventMetadata - Metadata of the event. This should be the class generated from the contract. e.g. Contract.events.Event
|
|
358
359
|
* @param from - The block number to search from.
|
|
359
|
-
* @param
|
|
360
|
-
* @param
|
|
360
|
+
* @param numBlocks - The amount of blocks to search.
|
|
361
|
+
* @param recipients - The addresses that decrypted the logs.
|
|
361
362
|
* @returns - The deserialized events.
|
|
362
363
|
*/
|
|
363
|
-
getPrivateEvents<T>(
|
|
364
|
+
getPrivateEvents<T>(
|
|
365
|
+
contractAddress: AztecAddress,
|
|
366
|
+
eventMetadata: EventMetadataDefinition,
|
|
367
|
+
from: number,
|
|
368
|
+
numBlocks: number,
|
|
369
|
+
recipients: AztecAddress[],
|
|
370
|
+
): Promise<T[]>;
|
|
364
371
|
|
|
365
372
|
/**
|
|
366
373
|
* Returns the public events given search parameters.
|
|
@@ -505,7 +512,7 @@ export const PXESchema: ApiSchemaFor<PXE> = {
|
|
|
505
512
|
getContractClassMetadata: z.function().args(schemas.Fr, optional(z.boolean())).returns(ContractClassMetadataSchema),
|
|
506
513
|
getPrivateEvents: z
|
|
507
514
|
.function()
|
|
508
|
-
.args(EventMetadataDefinitionSchema, z.number(), z.number(), z.array(schemas.
|
|
515
|
+
.args(schemas.AztecAddress, EventMetadataDefinitionSchema, z.number(), z.number(), z.array(schemas.AztecAddress))
|
|
509
516
|
.returns(z.array(AbiDecodedSchema)),
|
|
510
517
|
getPublicEvents: z
|
|
511
518
|
.function()
|
package/src/keys/derivation.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { GeneratorIndex } from '@aztec/constants';
|
|
2
|
-
import { Grumpkin, poseidon2HashWithSeparator, sha512ToGrumpkinScalar } from '@aztec/foundation/crypto';
|
|
2
|
+
import { Grumpkin, poseidon2Hash, poseidon2HashWithSeparator, sha512ToGrumpkinScalar } from '@aztec/foundation/crypto';
|
|
3
3
|
import { Fq, Fr, GrumpkinScalar } from '@aztec/foundation/fields';
|
|
4
4
|
|
|
5
5
|
import { AztecAddress } from '../aztec-address/index.js';
|
|
@@ -123,11 +123,7 @@ export async function deriveKeys(secretKey: Fr) {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
// Returns shared tagging secret computed with Diffie-Hellman key exchange.
|
|
126
|
-
|
|
127
|
-
knownAddress: CompleteAddress,
|
|
128
|
-
ivsk: Fq,
|
|
129
|
-
externalAddress: AztecAddress,
|
|
130
|
-
) {
|
|
126
|
+
async function computeTaggingSecretPoint(knownAddress: CompleteAddress, ivsk: Fq, externalAddress: AztecAddress) {
|
|
131
127
|
const knownPreaddress = await computePreaddress(await knownAddress.publicKeys.hash(), knownAddress.partialAddress);
|
|
132
128
|
// TODO: #8970 - Computation of address point from x coordinate might fail
|
|
133
129
|
const externalAddressPoint = await externalAddress.toAddressPoint();
|
|
@@ -139,3 +135,13 @@ export async function computeTaggingSecretPoint(
|
|
|
139
135
|
// computeAddressSecret takes care of selecting the one that leads to a positive y-coordinate, which is the only valid address point
|
|
140
136
|
return curve.mul(externalAddressPoint, await computeAddressSecret(knownPreaddress, ivsk));
|
|
141
137
|
}
|
|
138
|
+
|
|
139
|
+
export async function computeAppTaggingSecret(
|
|
140
|
+
knownAddress: CompleteAddress,
|
|
141
|
+
ivsk: Fq,
|
|
142
|
+
externalAddress: AztecAddress,
|
|
143
|
+
app: AztecAddress,
|
|
144
|
+
) {
|
|
145
|
+
const taggingSecretPoint = await computeTaggingSecretPoint(knownAddress, ivsk, externalAddress);
|
|
146
|
+
return poseidon2Hash([taggingSecretPoint.x, taggingSecretPoint.y, app]);
|
|
147
|
+
}
|
package/src/logs/index.ts
CHANGED
|
@@ -3,9 +3,10 @@ export * from './indexed_tagging_secret.js';
|
|
|
3
3
|
export * from './contract_class_log.js';
|
|
4
4
|
export * from './public_log.js';
|
|
5
5
|
export * from './private_log.js';
|
|
6
|
+
export * from './pending_tagged_log.js';
|
|
6
7
|
export * from './log_id.js';
|
|
7
8
|
export * from './log_filter.js';
|
|
8
9
|
export * from './extended_public_log.js';
|
|
9
10
|
export * from './extended_contract_class_log.js';
|
|
10
|
-
export * from './
|
|
11
|
+
export * from './shared_secret_derivation.js';
|
|
11
12
|
export * from './tx_scoped_l2_log.js';
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { MAX_NOTE_HASHES_PER_TX, PRIVATE_LOG_SIZE_IN_FIELDS } from '@aztec/constants';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
|
+
|
|
4
|
+
import type { AztecAddress } from '../aztec-address/index.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents a pending tagged log as it is stored in the pending tagged log array to which the syncNotes oracle
|
|
8
|
+
* inserts found private logs. A TS version of `pending_tagged_log.nr`.
|
|
9
|
+
*/
|
|
10
|
+
export class PendingTaggedLog {
|
|
11
|
+
constructor(
|
|
12
|
+
public log: Fr[],
|
|
13
|
+
public txHash: Fr,
|
|
14
|
+
public uniqueNoteHashesInTx: Fr[],
|
|
15
|
+
public firstNullifierInTx: Fr,
|
|
16
|
+
public recipient: AztecAddress,
|
|
17
|
+
public logIndexInTx: number,
|
|
18
|
+
) {}
|
|
19
|
+
|
|
20
|
+
toFields(): Fr[] {
|
|
21
|
+
return [
|
|
22
|
+
...serializeBoundedVec(this.log, PRIVATE_LOG_SIZE_IN_FIELDS),
|
|
23
|
+
this.txHash,
|
|
24
|
+
...serializeBoundedVec(this.uniqueNoteHashesInTx, MAX_NOTE_HASHES_PER_TX),
|
|
25
|
+
this.firstNullifierInTx,
|
|
26
|
+
this.recipient.toField(),
|
|
27
|
+
new Fr(this.logIndexInTx),
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Helper function to serialize a bounded vector according to Noir's BoundedVec format
|
|
34
|
+
* @param values - The values to serialize
|
|
35
|
+
* @param maxLength - The maximum length of the bounded vector
|
|
36
|
+
* @returns The serialized bounded vector as Fr[]
|
|
37
|
+
*/
|
|
38
|
+
function serializeBoundedVec(values: Fr[], maxLength: number): Fr[] {
|
|
39
|
+
const lengthDiff = maxLength - values.length;
|
|
40
|
+
const zeroPaddingArray = Array(lengthDiff).fill(Fr.ZERO);
|
|
41
|
+
const storage = values.concat(zeroPaddingArray);
|
|
42
|
+
return [...storage, new Fr(values.length)];
|
|
43
|
+
}
|