@aztec/stdlib 4.0.0-nightly.20260119 → 4.0.0-nightly.20260120
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 +300 -300
- package/dest/block/block_parameter.d.ts +4 -3
- package/dest/block/block_parameter.d.ts.map +1 -1
- package/dest/block/block_parameter.js +2 -0
- package/dest/block/checkpointed_l2_block.d.ts +10 -127
- package/dest/block/checkpointed_l2_block.d.ts.map +1 -1
- package/dest/block/checkpointed_l2_block.js +2 -41
- package/dest/block/in_block.d.ts +3 -3
- package/dest/block/in_block.d.ts.map +1 -1
- package/dest/block/index.d.ts +1 -3
- package/dest/block/index.d.ts.map +1 -1
- package/dest/block/index.js +0 -2
- package/dest/block/l2_block_new.d.ts +11 -9
- package/dest/block/l2_block_new.d.ts.map +1 -1
- package/dest/block/l2_block_new.js +5 -5
- package/dest/block/l2_block_source.d.ts +20 -11
- package/dest/block/l2_block_source.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.d.ts +10 -8
- package/dest/checkpoint/checkpoint.d.ts.map +1 -1
- package/dest/checkpoint/checkpoint.js +2 -2
- package/dest/checkpoint/published_checkpoint.d.ts +11 -9
- package/dest/checkpoint/published_checkpoint.d.ts.map +1 -1
- package/dest/interfaces/archiver.d.ts +1 -1
- package/dest/interfaces/archiver.d.ts.map +1 -1
- package/dest/interfaces/archiver.js +9 -8
- package/dest/interfaces/aztec-node.d.ts +35 -40
- package/dest/interfaces/aztec-node.d.ts.map +1 -1
- package/dest/interfaces/aztec-node.js +6 -8
- package/dest/interfaces/block-builder.d.ts +18 -17
- package/dest/interfaces/block-builder.d.ts.map +1 -1
- package/dest/interfaces/proving-job.d.ts +166 -166
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_note_hash_read_request_hints.js +16 -6
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.d.ts.map +1 -1
- package/dest/kernel/hints/build_nullifier_read_request_hints.js +14 -4
- package/dest/p2p/block_proposal.d.ts +9 -9
- package/dest/p2p/block_proposal.d.ts.map +1 -1
- package/dest/p2p/block_proposal.js +6 -5
- package/dest/p2p/checkpoint_proposal.d.ts +4 -4
- package/dest/p2p/checkpoint_proposal.d.ts.map +1 -1
- package/dest/p2p/checkpoint_proposal.js +3 -3
- package/dest/p2p/consensus_payload.d.ts +1 -3
- package/dest/p2p/consensus_payload.d.ts.map +1 -1
- package/dest/p2p/consensus_payload.js +0 -3
- package/dest/tests/factories.d.ts +2 -4
- package/dest/tests/factories.d.ts.map +1 -1
- package/dest/tests/factories.js +3 -13
- package/dest/tests/jest.d.ts +4 -4
- package/dest/tests/jest.js +9 -9
- package/dest/tests/mocks.d.ts +12 -12
- package/dest/tests/mocks.d.ts.map +1 -1
- package/dest/tests/mocks.js +33 -21
- package/package.json +9 -9
- package/src/block/block_parameter.ts +4 -2
- package/src/block/checkpointed_l2_block.ts +2 -53
- package/src/block/in_block.ts +2 -2
- package/src/block/index.ts +0 -2
- package/src/block/l2_block_new.ts +14 -7
- package/src/block/l2_block_source.ts +21 -11
- package/src/checkpoint/checkpoint.ts +8 -2
- package/src/interfaces/archiver.ts +9 -8
- package/src/interfaces/aztec-node.ts +39 -57
- package/src/interfaces/block-builder.ts +33 -28
- package/src/kernel/hints/build_note_hash_read_request_hints.ts +17 -6
- package/src/kernel/hints/build_nullifier_read_request_hints.ts +22 -10
- package/src/p2p/block_proposal.ts +10 -10
- package/src/p2p/checkpoint_proposal.ts +4 -4
- package/src/p2p/consensus_payload.ts +0 -5
- package/src/tests/factories.ts +2 -25
- package/src/tests/jest.ts +9 -9
- package/src/tests/mocks.ts +35 -28
- package/dest/block/l2_block.d.ts +0 -150
- package/dest/block/l2_block.d.ts.map +0 -1
- package/dest/block/l2_block.js +0 -201
- package/dest/block/l2_block_code_to_purge.d.ts +0 -11
- package/dest/block/l2_block_code_to_purge.d.ts.map +0 -1
- package/dest/block/l2_block_code_to_purge.js +0 -55
- package/dest/block/l2_block_header.d.ts +0 -106
- package/dest/block/l2_block_header.d.ts.map +0 -1
- package/dest/block/l2_block_header.js +0 -167
- package/src/block/l2_block.ts +0 -274
- package/src/block/l2_block_code_to_purge.ts +0 -81
- package/src/block/l2_block_header.ts +0 -268
|
@@ -4,8 +4,7 @@ import type { ApiSchemaFor } from '@aztec/foundation/schemas';
|
|
|
4
4
|
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
|
|
7
|
-
import { CheckpointedL2Block
|
|
8
|
-
import { L2Block } from '../block/l2_block.js';
|
|
7
|
+
import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
|
|
9
8
|
import { L2BlockNew } from '../block/l2_block_new.js';
|
|
10
9
|
import { type L2BlockSource, L2TipsSchema } from '../block/l2_block_source.js';
|
|
11
10
|
import { ValidateCheckpointResultSchema } from '../block/validate_block_result.js';
|
|
@@ -83,7 +82,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
83
82
|
getRegistryAddress: z.function().args().returns(schemas.EthAddress),
|
|
84
83
|
getBlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
85
84
|
getProvenBlockNumber: z.function().args().returns(BlockNumberSchema),
|
|
86
|
-
getBlock: z.function().args(BlockNumberSchema).returns(
|
|
85
|
+
getBlock: z.function().args(BlockNumberSchema).returns(L2BlockNew.schema.optional()),
|
|
87
86
|
getBlockHeader: z
|
|
88
87
|
.function()
|
|
89
88
|
.args(z.union([BlockNumberSchema, z.literal('latest')]))
|
|
@@ -96,7 +95,7 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
96
95
|
getBlocks: z
|
|
97
96
|
.function()
|
|
98
97
|
.args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
|
|
99
|
-
.returns(z.array(
|
|
98
|
+
.returns(z.array(L2BlockNew.schema)),
|
|
100
99
|
getPublishedCheckpoints: z
|
|
101
100
|
.function()
|
|
102
101
|
.args(CheckpointNumberSchema, schemas.Integer)
|
|
@@ -104,22 +103,24 @@ export const ArchiverApiSchema: ApiSchemaFor<ArchiverApi> = {
|
|
|
104
103
|
getPublishedBlocks: z
|
|
105
104
|
.function()
|
|
106
105
|
.args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
|
|
107
|
-
.returns(z.array(
|
|
106
|
+
.returns(z.array(CheckpointedL2Block.schema)),
|
|
108
107
|
getL2BlocksNew: z
|
|
109
108
|
.function()
|
|
110
109
|
.args(BlockNumberSchema, schemas.Integer, optional(z.boolean()))
|
|
111
110
|
.returns(z.array(L2BlockNew.schema)),
|
|
112
|
-
getPublishedBlockByHash: z.function().args(schemas.Fr).returns(
|
|
113
|
-
getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(
|
|
111
|
+
getPublishedBlockByHash: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
|
|
112
|
+
getPublishedBlockByArchive: z.function().args(schemas.Fr).returns(CheckpointedL2Block.schema.optional()),
|
|
114
113
|
getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
|
|
115
114
|
getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
|
|
116
115
|
getL2BlockNew: z.function().args(BlockNumberSchema).returns(L2BlockNew.schema.optional()),
|
|
116
|
+
getL2BlockNewByHash: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
|
|
117
|
+
getL2BlockNewByArchive: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
|
|
117
118
|
getTxEffect: z.function().args(TxHash.schema).returns(indexedTxSchema().optional()),
|
|
118
119
|
getSettledTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema.optional()),
|
|
119
120
|
getL2SlotNumber: z.function().args().returns(schemas.SlotNumber.optional()),
|
|
120
121
|
getL2EpochNumber: z.function().args().returns(EpochNumberSchema.optional()),
|
|
121
122
|
getCheckpointsForEpoch: z.function().args(EpochNumberSchema).returns(z.array(Checkpoint.schema)),
|
|
122
|
-
getBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(
|
|
123
|
+
getBlocksForEpoch: z.function().args(EpochNumberSchema).returns(z.array(L2BlockNew.schema)),
|
|
123
124
|
getBlocksForSlot: z.function().args(schemas.SlotNumber).returns(z.array(L2BlockNew.schema)),
|
|
124
125
|
getBlockHeadersForEpoch: z.function().args(EpochNumberSchema).returns(z.array(BlockHeader.schema)),
|
|
125
126
|
isEpochComplete: z.function().args(EpochNumberSchema).returns(z.boolean()),
|
|
@@ -24,9 +24,8 @@ import { z } from 'zod';
|
|
|
24
24
|
|
|
25
25
|
import type { AztecAddress } from '../aztec-address/index.js';
|
|
26
26
|
import { type BlockParameter, BlockParameterSchema } from '../block/block_parameter.js';
|
|
27
|
-
import { CheckpointedL2Block
|
|
27
|
+
import { CheckpointedL2Block } from '../block/checkpointed_l2_block.js';
|
|
28
28
|
import { type DataInBlock, dataInBlockSchemaFor } from '../block/in_block.js';
|
|
29
|
-
import { L2Block } from '../block/l2_block.js';
|
|
30
29
|
import { L2BlockNew } from '../block/l2_block_new.js';
|
|
31
30
|
import { type L2BlockSource, type L2Tips, L2TipsSchema } from '../block/l2_block_source.js';
|
|
32
31
|
import { PublishedCheckpoint } from '../checkpoint/published_checkpoint.js';
|
|
@@ -99,72 +98,63 @@ export interface AztecNode
|
|
|
99
98
|
/**
|
|
100
99
|
* Find the indexes of the given leaves in the given tree along with a block metadata pointing to the block in which
|
|
101
100
|
* the leaves were inserted.
|
|
102
|
-
* @param
|
|
101
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
103
102
|
* @param treeId - The tree to search in.
|
|
104
103
|
* @param leafValues - The values to search for.
|
|
105
104
|
* @returns The indices of leaves and the block metadata of a block in which the leaves were inserted.
|
|
106
105
|
*/
|
|
107
106
|
findLeavesIndexes(
|
|
108
|
-
|
|
107
|
+
block: BlockParameter,
|
|
109
108
|
treeId: MerkleTreeId,
|
|
110
109
|
leafValues: Fr[],
|
|
111
110
|
): Promise<(DataInBlock<bigint> | undefined)[]>;
|
|
112
111
|
|
|
113
112
|
/**
|
|
114
113
|
* Returns a sibling path for the given index in the nullifier tree.
|
|
115
|
-
* @param
|
|
114
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
116
115
|
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
117
116
|
* @returns The sibling path for the leaf index.
|
|
118
117
|
*/
|
|
119
|
-
getNullifierSiblingPath(
|
|
120
|
-
blockNumber: BlockParameter,
|
|
121
|
-
leafIndex: bigint,
|
|
122
|
-
): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>>;
|
|
118
|
+
getNullifierSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof NULLIFIER_TREE_HEIGHT>>;
|
|
123
119
|
|
|
124
120
|
/**
|
|
125
121
|
* Returns a sibling path for the given index in the note hash tree.
|
|
126
|
-
* @param
|
|
122
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
127
123
|
* @param leafIndex - The index of the leaf for which the sibling path is required.
|
|
128
124
|
* @returns The sibling path for the leaf index.
|
|
129
125
|
*/
|
|
130
|
-
getNoteHashSiblingPath(
|
|
131
|
-
blockNumber: BlockParameter,
|
|
132
|
-
leafIndex: bigint,
|
|
133
|
-
): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
126
|
+
getNoteHashSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof NOTE_HASH_TREE_HEIGHT>>;
|
|
134
127
|
|
|
135
128
|
/**
|
|
136
129
|
* Returns a sibling path for a leaf in the committed historic blocks tree.
|
|
137
|
-
* @param
|
|
130
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
138
131
|
* @param leafIndex - Index of the leaf in the tree.
|
|
139
132
|
* @returns The sibling path.
|
|
140
133
|
*/
|
|
141
|
-
getArchiveSiblingPath(
|
|
134
|
+
getArchiveSiblingPath(block: BlockParameter, leafIndex: bigint): Promise<SiblingPath<typeof ARCHIVE_HEIGHT>>;
|
|
142
135
|
|
|
143
136
|
/**
|
|
144
137
|
* Returns a sibling path for a leaf in the committed public data tree.
|
|
145
|
-
* @param
|
|
138
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
146
139
|
* @param leafIndex - Index of the leaf in the tree.
|
|
147
140
|
* @returns The sibling path.
|
|
148
141
|
*/
|
|
149
142
|
getPublicDataSiblingPath(
|
|
150
|
-
|
|
143
|
+
block: BlockParameter,
|
|
151
144
|
leafIndex: bigint,
|
|
152
145
|
): Promise<SiblingPath<typeof PUBLIC_DATA_TREE_HEIGHT>>;
|
|
153
146
|
|
|
154
147
|
/**
|
|
155
148
|
* Returns a nullifier membership witness for a given nullifier at a given block.
|
|
156
|
-
* @param
|
|
149
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
157
150
|
* @param nullifier - Nullifier we try to find witness for.
|
|
158
151
|
* @returns The nullifier membership witness (if found).
|
|
159
152
|
*/
|
|
160
|
-
getNullifierMembershipWitness(
|
|
161
|
-
blockNumber: BlockParameter,
|
|
162
|
-
nullifier: Fr,
|
|
163
|
-
): Promise<NullifierMembershipWitness | undefined>;
|
|
153
|
+
getNullifierMembershipWitness(block: BlockParameter, nullifier: Fr): Promise<NullifierMembershipWitness | undefined>;
|
|
164
154
|
|
|
165
155
|
/**
|
|
166
156
|
* Returns a low nullifier membership witness for a given nullifier at a given block.
|
|
167
|
-
* @param
|
|
157
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
168
158
|
* @param nullifier - Nullifier we try to find the low nullifier witness for.
|
|
169
159
|
* @returns The low nullifier membership witness (if found).
|
|
170
160
|
* @remarks Low nullifier witness can be used to perform a nullifier non-inclusion proof by leveraging the "linked
|
|
@@ -172,49 +162,49 @@ export interface AztecNode
|
|
|
172
162
|
* we are trying to prove non-inclusion for.
|
|
173
163
|
*/
|
|
174
164
|
getLowNullifierMembershipWitness(
|
|
175
|
-
|
|
165
|
+
block: BlockParameter,
|
|
176
166
|
nullifier: Fr,
|
|
177
167
|
): Promise<NullifierMembershipWitness | undefined>;
|
|
178
168
|
|
|
179
169
|
/**
|
|
180
170
|
* Returns a public data tree witness for a given leaf slot at a given block.
|
|
181
|
-
* @param
|
|
171
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
182
172
|
* @param leafSlot - The leaf slot we try to find the witness for.
|
|
183
173
|
* @returns The public data witness (if found).
|
|
184
174
|
* @remarks The witness can be used to compute the current value of the public data tree leaf. If the low leaf preimage corresponds to an
|
|
185
175
|
* "in range" slot, means that the slot doesn't exist and the value is 0. If the low leaf preimage corresponds to the exact slot, the current value
|
|
186
176
|
* is contained in the leaf preimage.
|
|
187
177
|
*/
|
|
188
|
-
getPublicDataWitness(
|
|
178
|
+
getPublicDataWitness(block: BlockParameter, leafSlot: Fr): Promise<PublicDataWitness | undefined>;
|
|
189
179
|
|
|
190
180
|
/**
|
|
191
181
|
* Returns a membership witness for a given archive leaf at a given block.
|
|
192
|
-
* @param
|
|
182
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
193
183
|
* @param archive - The archive leaf we try to find the witness for.
|
|
194
184
|
*/
|
|
195
185
|
getArchiveMembershipWitness(
|
|
196
|
-
|
|
186
|
+
block: BlockParameter,
|
|
197
187
|
archive: Fr,
|
|
198
188
|
): Promise<MembershipWitness<typeof ARCHIVE_HEIGHT> | undefined>;
|
|
199
189
|
|
|
200
190
|
/**
|
|
201
191
|
* Returns a membership witness for a given note hash at a given block.
|
|
202
|
-
* @param
|
|
192
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
203
193
|
* @param noteHash - The note hash we try to find the witness for.
|
|
204
194
|
*/
|
|
205
195
|
getNoteHashMembershipWitness(
|
|
206
|
-
|
|
196
|
+
block: BlockParameter,
|
|
207
197
|
noteHash: Fr,
|
|
208
198
|
): Promise<MembershipWitness<typeof NOTE_HASH_TREE_HEIGHT> | undefined>;
|
|
209
199
|
|
|
210
200
|
/**
|
|
211
201
|
* Returns the index and a sibling path for a leaf in the committed l1 to l2 data tree.
|
|
212
|
-
* @param
|
|
202
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
213
203
|
* @param l1ToL2Message - The l1ToL2Message to get the index / sibling path for.
|
|
214
204
|
* @returns A tuple of the index and the sibling path of the L1ToL2Message (undefined if not found).
|
|
215
205
|
*/
|
|
216
206
|
getL1ToL2MessageMembershipWitness(
|
|
217
|
-
|
|
207
|
+
block: BlockParameter,
|
|
218
208
|
l1ToL2Message: Fr,
|
|
219
209
|
): Promise<[bigint, SiblingPath<typeof L1_TO_L2_MSG_TREE_HEIGHT>] | undefined>;
|
|
220
210
|
|
|
@@ -238,25 +228,25 @@ export interface AztecNode
|
|
|
238
228
|
getL2ToL1Messages(epoch: EpochNumber): Promise<Fr[][][][]>;
|
|
239
229
|
|
|
240
230
|
/**
|
|
241
|
-
* Get a block specified by its number.
|
|
242
|
-
* @param number - The block number
|
|
231
|
+
* Get a block specified by its block number or 'latest'.
|
|
232
|
+
* @param number - The block number or 'latest'.
|
|
243
233
|
* @returns The requested block.
|
|
244
234
|
*/
|
|
245
|
-
getBlock(number: BlockParameter): Promise<
|
|
235
|
+
getBlock(number: BlockParameter): Promise<L2BlockNew | undefined>;
|
|
246
236
|
|
|
247
237
|
/**
|
|
248
238
|
* Get a block specified by its hash.
|
|
249
239
|
* @param blockHash - The block hash being requested.
|
|
250
240
|
* @returns The requested block.
|
|
251
241
|
*/
|
|
252
|
-
getBlockByHash(blockHash: Fr): Promise<
|
|
242
|
+
getBlockByHash(blockHash: Fr): Promise<L2BlockNew | undefined>;
|
|
253
243
|
|
|
254
244
|
/**
|
|
255
245
|
* Get a block specified by its archive root.
|
|
256
246
|
* @param archive - The archive root being requested.
|
|
257
247
|
* @returns The requested block.
|
|
258
248
|
*/
|
|
259
|
-
getBlockByArchive(archive: Fr): Promise<
|
|
249
|
+
getBlockByArchive(archive: Fr): Promise<L2BlockNew | undefined>;
|
|
260
250
|
|
|
261
251
|
/**
|
|
262
252
|
* Method to fetch the latest block number synchronized by the node.
|
|
@@ -289,7 +279,7 @@ export interface AztecNode
|
|
|
289
279
|
* @param limit - The maximum number of blocks to return.
|
|
290
280
|
* @returns The blocks requested.
|
|
291
281
|
*/
|
|
292
|
-
getBlocks(from: BlockNumber, limit: number): Promise<
|
|
282
|
+
getBlocks(from: BlockNumber, limit: number): Promise<L2BlockNew[]>;
|
|
293
283
|
|
|
294
284
|
/**
|
|
295
285
|
* Method to fetch the current min fees.
|
|
@@ -420,25 +410,19 @@ export interface AztecNode
|
|
|
420
410
|
* @remarks The storage slot here refers to the slot as it is defined in Noir not the index in the merkle tree.
|
|
421
411
|
* Aztec's version of `eth_getStorageAt`.
|
|
422
412
|
*
|
|
413
|
+
* @param block - The block parameter (block number, block hash, or 'latest') at which to get the data.
|
|
423
414
|
* @param contract - Address of the contract to query.
|
|
424
415
|
* @param slot - Slot to query.
|
|
425
|
-
* @param blockNumber - The block number at which to get the data or 'latest'.
|
|
426
416
|
* @returns Storage value at the given contract slot.
|
|
427
417
|
*/
|
|
428
|
-
getPublicStorageAt(
|
|
418
|
+
getPublicStorageAt(block: BlockParameter, contract: AztecAddress, slot: Fr): Promise<Fr>;
|
|
429
419
|
|
|
430
420
|
/**
|
|
431
|
-
* Returns the
|
|
432
|
-
* @
|
|
433
|
-
*/
|
|
434
|
-
getBlockHeader(blockNumber?: BlockParameter): Promise<BlockHeader | undefined>;
|
|
435
|
-
|
|
436
|
-
/**
|
|
437
|
-
* Get a block header specified by its hash.
|
|
438
|
-
* @param blockHash - The block hash being requested.
|
|
421
|
+
* Returns the block header for a given block number, block hash, or 'latest'.
|
|
422
|
+
* @param block - The block parameter (block number, block hash, or 'latest'). Defaults to 'latest'.
|
|
439
423
|
* @returns The requested block header.
|
|
440
424
|
*/
|
|
441
|
-
|
|
425
|
+
getBlockHeader(block?: BlockParameter): Promise<BlockHeader | undefined>;
|
|
442
426
|
|
|
443
427
|
/**
|
|
444
428
|
* Get a block header specified by its archive root.
|
|
@@ -570,11 +554,11 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
570
554
|
.args(EpochNumberSchema)
|
|
571
555
|
.returns(z.array(z.array(z.array(z.array(schemas.Fr))))),
|
|
572
556
|
|
|
573
|
-
getBlock: z.function().args(BlockParameterSchema).returns(
|
|
557
|
+
getBlock: z.function().args(BlockParameterSchema).returns(L2BlockNew.schema.optional()),
|
|
574
558
|
|
|
575
|
-
getBlockByHash: z.function().args(schemas.Fr).returns(
|
|
559
|
+
getBlockByHash: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
|
|
576
560
|
|
|
577
|
-
getBlockByArchive: z.function().args(schemas.Fr).returns(
|
|
561
|
+
getBlockByArchive: z.function().args(schemas.Fr).returns(L2BlockNew.schema.optional()),
|
|
578
562
|
|
|
579
563
|
getBlockNumber: z.function().returns(BlockNumberSchema),
|
|
580
564
|
|
|
@@ -587,12 +571,12 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
587
571
|
getBlocks: z
|
|
588
572
|
.function()
|
|
589
573
|
.args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
|
|
590
|
-
.returns(z.array(
|
|
574
|
+
.returns(z.array(L2BlockNew.schema)),
|
|
591
575
|
|
|
592
576
|
getPublishedBlocks: z
|
|
593
577
|
.function()
|
|
594
578
|
.args(BlockNumberPositiveSchema, z.number().gt(0).lte(MAX_RPC_BLOCKS_LEN))
|
|
595
|
-
.returns(z.array(
|
|
579
|
+
.returns(z.array(CheckpointedL2Block.schema)),
|
|
596
580
|
|
|
597
581
|
getPublishedCheckpoints: z
|
|
598
582
|
.function()
|
|
@@ -663,8 +647,6 @@ export const AztecNodeApiSchema: ApiSchemaFor<AztecNode> = {
|
|
|
663
647
|
|
|
664
648
|
getBlockHeader: z.function().args(optional(BlockParameterSchema)).returns(BlockHeader.schema.optional()),
|
|
665
649
|
|
|
666
|
-
getBlockHeaderByHash: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
|
|
667
|
-
|
|
668
650
|
getBlockHeaderByArchive: z.function().args(schemas.Fr).returns(BlockHeader.schema.optional()),
|
|
669
651
|
|
|
670
652
|
getValidatorsStats: z.function().returns(ValidatorsStatsSchema),
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import type { BlockNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import type { BlockNumber, CheckpointNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { Timer } from '@aztec/foundation/timer';
|
|
4
3
|
|
|
5
|
-
import type {
|
|
4
|
+
import type { L2BlockNew } from '../block/l2_block_new.js';
|
|
6
5
|
import type { ChainConfig, SequencerConfig } from '../config/chain-config.js';
|
|
7
6
|
import type { L1RollupConstants } from '../epoch-helpers/index.js';
|
|
8
7
|
import type { Gas } from '../gas/gas.js';
|
|
9
|
-
import type { MerkleTreeWriteOperations } from '../trees/index.js';
|
|
10
8
|
import type { BlockHeader } from '../tx/block_header.js';
|
|
11
|
-
import type { GlobalVariables } from '../tx/global_variables.js';
|
|
9
|
+
import type { CheckpointGlobalVariables, GlobalVariables } from '../tx/global_variables.js';
|
|
12
10
|
import type { FailedTx, ProcessedTx } from '../tx/processed_tx.js';
|
|
13
11
|
import { Tx } from '../tx/tx.js';
|
|
14
12
|
import type { TxValidator } from '../tx/validator/tx_validator.js';
|
|
13
|
+
import type { MerkleTreeWriteOperations } from './merkle_tree_operations.js';
|
|
15
14
|
import type { ProcessedTxHandler } from './processed-tx-handler.js';
|
|
16
15
|
|
|
17
16
|
/** The interface to a block builder. Generates an L2 block out of a set of processed txs. */
|
|
@@ -32,7 +31,7 @@ export interface IBlockFactory extends ProcessedTxHandler {
|
|
|
32
31
|
/**
|
|
33
32
|
* Assembles the block and updates the archive tree.
|
|
34
33
|
*/
|
|
35
|
-
setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<
|
|
34
|
+
setBlockCompleted(expectedBlockHeader?: BlockHeader): Promise<L2BlockNew>;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
37
|
export interface PublicProcessorLimits {
|
|
@@ -47,17 +46,6 @@ export interface PublicProcessorValidator {
|
|
|
47
46
|
preprocessValidator?: TxValidator<Tx>;
|
|
48
47
|
nullifierCache?: { addNullifiers: (nullifiers: Buffer[]) => void };
|
|
49
48
|
}
|
|
50
|
-
export interface BuildBlockResult {
|
|
51
|
-
block: L2Block;
|
|
52
|
-
publicGas: Gas;
|
|
53
|
-
publicProcessorDuration: number;
|
|
54
|
-
numMsgs: number;
|
|
55
|
-
numTxs: number;
|
|
56
|
-
failedTxs: FailedTx[];
|
|
57
|
-
blockBuildingTimer: Timer;
|
|
58
|
-
usedTxs: Tx[];
|
|
59
|
-
usedTxBlobFields: number;
|
|
60
|
-
}
|
|
61
49
|
|
|
62
50
|
export type FullNodeBlockBuilderConfig = Pick<L1RollupConstants, 'l1GenesisTime' | 'slotDuration'> &
|
|
63
51
|
Pick<ChainConfig, 'l1ChainId' | 'rollupVersion'> &
|
|
@@ -73,19 +61,36 @@ export const FullNodeBlockBuilderConfigKeys: (keyof FullNodeBlockBuilderConfig)[
|
|
|
73
61
|
'fakeThrowAfterProcessingTxCount',
|
|
74
62
|
] as const;
|
|
75
63
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
64
|
+
/** Result of building a block within a checkpoint. */
|
|
65
|
+
export interface BuildBlockInCheckpointResult {
|
|
66
|
+
block: L2BlockNew;
|
|
67
|
+
publicGas: Gas;
|
|
68
|
+
publicProcessorDuration: number;
|
|
69
|
+
numTxs: number;
|
|
70
|
+
failedTxs: FailedTx[];
|
|
71
|
+
usedTxs: Tx[];
|
|
72
|
+
usedTxBlobFields: number;
|
|
73
|
+
}
|
|
80
74
|
|
|
75
|
+
/** Interface for building blocks within a checkpoint context. */
|
|
76
|
+
export interface ICheckpointBlockBuilder {
|
|
81
77
|
buildBlock(
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
): Promise<BuildBlockResult>;
|
|
78
|
+
pendingTxs: Iterable<Tx> | AsyncIterable<Tx>,
|
|
79
|
+
blockNumber: BlockNumber,
|
|
80
|
+
timestamp: bigint,
|
|
81
|
+
opts: PublicProcessorLimits,
|
|
82
|
+
): Promise<BuildBlockInCheckpointResult>;
|
|
83
|
+
}
|
|
89
84
|
|
|
85
|
+
/** Interface for creating checkpoint builders. */
|
|
86
|
+
export interface ICheckpointsBuilder {
|
|
90
87
|
getFork(blockNumber: BlockNumber): Promise<MerkleTreeWriteOperations>;
|
|
88
|
+
|
|
89
|
+
startCheckpoint(
|
|
90
|
+
checkpointNumber: CheckpointNumber,
|
|
91
|
+
constants: CheckpointGlobalVariables,
|
|
92
|
+
l1ToL2Messages: Fr[],
|
|
93
|
+
previousCheckpointOutHashes: Fr[],
|
|
94
|
+
fork: MerkleTreeWriteOperations,
|
|
95
|
+
): Promise<ICheckpointBlockBuilder>;
|
|
91
96
|
}
|
|
@@ -76,17 +76,28 @@ export async function buildNoteHashReadRequestHintsFromResetActions<PENDING exte
|
|
|
76
76
|
builder.addPendingReadRequest(hint.readRequestIndex, hint.pendingValueIndex);
|
|
77
77
|
});
|
|
78
78
|
|
|
79
|
+
// Collect all settled read requests
|
|
80
|
+
const settledRequests: { index: number; readRequest: ScopedReadRequest }[] = [];
|
|
79
81
|
for (let i = 0; i < resetActions.actions.length; i++) {
|
|
80
82
|
if (resetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
|
|
81
|
-
|
|
82
|
-
const membershipWitness = await oracle.getNoteHashMembershipWitness(readRequest.value);
|
|
83
|
-
if (!membershipWitness) {
|
|
84
|
-
throw new Error('Read request is reading an unknown note hash.');
|
|
85
|
-
}
|
|
86
|
-
builder.addSettledReadRequest(i, membershipWitness, readRequest.value);
|
|
83
|
+
settledRequests.push({ index: i, readRequest: noteHashReadRequests.array[i] });
|
|
87
84
|
}
|
|
88
85
|
}
|
|
89
86
|
|
|
87
|
+
// Fetch all membership witnesses in parallel
|
|
88
|
+
const membershipWitnesses = await Promise.all(
|
|
89
|
+
settledRequests.map(({ readRequest }) => oracle.getNoteHashMembershipWitness(readRequest.value)),
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
// Add settled read requests to builder
|
|
93
|
+
for (let i = 0; i < settledRequests.length; i++) {
|
|
94
|
+
const membershipWitness = membershipWitnesses[i];
|
|
95
|
+
if (!membershipWitness) {
|
|
96
|
+
throw new Error('Read request is reading an unknown note hash.');
|
|
97
|
+
}
|
|
98
|
+
builder.addSettledReadRequest(settledRequests[i].index, membershipWitness, settledRequests[i].readRequest.value);
|
|
99
|
+
}
|
|
100
|
+
|
|
90
101
|
const noteHashMap: Map<bigint, { noteHash: ScopedNoteHash; index: number }[]> = new Map();
|
|
91
102
|
noteHashes.getActiveItems().forEach((noteHash, index) => {
|
|
92
103
|
const value = noteHash.value.toBigInt();
|
|
@@ -82,21 +82,33 @@ export async function buildNullifierReadRequestHintsFromResetActions<PENDING ext
|
|
|
82
82
|
builder.addPendingReadRequest(hint.readRequestIndex, hint.pendingValueIndex);
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
+
// Collect all settled read requests
|
|
86
|
+
const settledRequests: { index: number; readRequest: ScopedReadRequest }[] = [];
|
|
85
87
|
for (let i = 0; i < resetActions.actions.length; i++) {
|
|
86
88
|
if (resetActions.actions[i] === ReadRequestActionEnum.READ_AS_SETTLED) {
|
|
87
|
-
|
|
88
|
-
const siloedValue = siloed
|
|
89
|
-
? readRequest.value
|
|
90
|
-
: await siloNullifier(readRequest.contractAddress, readRequest.value);
|
|
91
|
-
const membershipWitnessWithPreimage = await oracle.getNullifierMembershipWitness(siloedValue);
|
|
92
|
-
builder.addSettledReadRequest(
|
|
93
|
-
i,
|
|
94
|
-
membershipWitnessWithPreimage.membershipWitness,
|
|
95
|
-
membershipWitnessWithPreimage.leafPreimage,
|
|
96
|
-
);
|
|
89
|
+
settledRequests.push({ index: i, readRequest: nullifierReadRequests.array[i] });
|
|
97
90
|
}
|
|
98
91
|
}
|
|
99
92
|
|
|
93
|
+
// Compute siloed values in parallel (if not already siloed)
|
|
94
|
+
const siloedValues = siloed
|
|
95
|
+
? settledRequests.map(({ readRequest }) => readRequest.value)
|
|
96
|
+
: await Promise.all(
|
|
97
|
+
settledRequests.map(({ readRequest }) => siloNullifier(readRequest.contractAddress, readRequest.value)),
|
|
98
|
+
);
|
|
99
|
+
|
|
100
|
+
// Fetch all membership witnesses in parallel
|
|
101
|
+
const membershipWitnesses = await Promise.all(siloedValues.map(value => oracle.getNullifierMembershipWitness(value)));
|
|
102
|
+
|
|
103
|
+
// Add settled read requests to builder
|
|
104
|
+
for (let i = 0; i < settledRequests.length; i++) {
|
|
105
|
+
builder.addSettledReadRequest(
|
|
106
|
+
settledRequests[i].index,
|
|
107
|
+
membershipWitnesses[i].membershipWitness,
|
|
108
|
+
membershipWitnesses[i].leafPreimage,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
100
112
|
return builder.toHints();
|
|
101
113
|
}
|
|
102
114
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { BlockNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
3
|
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
4
4
|
import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
@@ -8,8 +8,8 @@ import { Signature } from '@aztec/foundation/eth-signature';
|
|
|
8
8
|
import { BufferReader, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
9
9
|
import { DutyType, type SigningContext } from '@aztec/validator-ha-signer/types';
|
|
10
10
|
|
|
11
|
-
import type { L2Block } from '../block/l2_block.js';
|
|
12
11
|
import type { L2BlockInfo } from '../block/l2_block_info.js';
|
|
12
|
+
import type { L2BlockNew } from '../block/l2_block_new.js';
|
|
13
13
|
import { MAX_TXS_PER_BLOCK } from '../deserialization/index.js';
|
|
14
14
|
import { BlockHeader } from '../tx/block_header.js';
|
|
15
15
|
import { TxHash } from '../tx/index.js';
|
|
@@ -52,7 +52,7 @@ export class BlockProposal extends Gossipable {
|
|
|
52
52
|
// TODO(palla/mbps): Is this really needed? Can we just derive it from the indexWithinCheckpoint of the parent block and the slot number?
|
|
53
53
|
// See the block-proposal-handler, we have a lot of extra validations to check this is correct, so maybe we can avoid storing it here.
|
|
54
54
|
/** Index of this block within the checkpoint (0-indexed) */
|
|
55
|
-
public readonly indexWithinCheckpoint:
|
|
55
|
+
public readonly indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
56
56
|
|
|
57
57
|
/** Hash of L1 to L2 messages for this checkpoint (constant across all blocks in checkpoint) */
|
|
58
58
|
public readonly inHash: Fr,
|
|
@@ -121,7 +121,7 @@ export class BlockProposal extends Gossipable {
|
|
|
121
121
|
|
|
122
122
|
static async createProposalFromSigner(
|
|
123
123
|
blockHeader: BlockHeader,
|
|
124
|
-
indexWithinCheckpoint:
|
|
124
|
+
indexWithinCheckpoint: IndexWithinCheckpoint,
|
|
125
125
|
inHash: Fr,
|
|
126
126
|
archiveRoot: Fr,
|
|
127
127
|
txHashes: TxHash[],
|
|
@@ -212,7 +212,7 @@ export class BlockProposal extends Gossipable {
|
|
|
212
212
|
const reader = BufferReader.asReader(buf);
|
|
213
213
|
|
|
214
214
|
const blockHeader = reader.readObject(BlockHeader);
|
|
215
|
-
const indexWithinCheckpoint = reader.readNumber();
|
|
215
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(reader.readNumber());
|
|
216
216
|
const inHash = reader.readObject(Fr);
|
|
217
217
|
const archiveRoot = reader.readObject(Fr);
|
|
218
218
|
const signature = reader.readObject(Signature);
|
|
@@ -256,13 +256,13 @@ export class BlockProposal extends Gossipable {
|
|
|
256
256
|
}
|
|
257
257
|
|
|
258
258
|
static empty(): BlockProposal {
|
|
259
|
-
return new BlockProposal(BlockHeader.empty(), 0, Fr.ZERO, Fr.ZERO, [], Signature.empty());
|
|
259
|
+
return new BlockProposal(BlockHeader.empty(), IndexWithinCheckpoint(0), Fr.ZERO, Fr.ZERO, [], Signature.empty());
|
|
260
260
|
}
|
|
261
261
|
|
|
262
262
|
static random(): BlockProposal {
|
|
263
263
|
return new BlockProposal(
|
|
264
264
|
BlockHeader.random(),
|
|
265
|
-
Math.floor(Math.random() * 5),
|
|
265
|
+
IndexWithinCheckpoint(Math.floor(Math.random() * 5)),
|
|
266
266
|
Fr.random(),
|
|
267
267
|
Fr.random(),
|
|
268
268
|
[TxHash.random(), TxHash.random()],
|
|
@@ -284,11 +284,11 @@ export class BlockProposal extends Gossipable {
|
|
|
284
284
|
/**
|
|
285
285
|
* Check if this proposal matches the given block.
|
|
286
286
|
* Compares the archive root and block header.
|
|
287
|
-
* @param block - The
|
|
287
|
+
* @param block - The L2BlockNew to compare against
|
|
288
288
|
* @returns True if the proposal matches the block
|
|
289
289
|
*/
|
|
290
|
-
matchesBlock(block:
|
|
291
|
-
return this.archiveRoot.equals(block.archive.root) && this.blockHeader.equals(block.
|
|
290
|
+
matchesBlock(block: L2BlockNew): boolean {
|
|
291
|
+
return this.archiveRoot.equals(block.archive.root) && this.blockHeader.equals(block.header);
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
/**
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BlockNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
1
|
+
import { BlockNumber, IndexWithinCheckpoint, SlotNumber } from '@aztec/foundation/branded-types';
|
|
2
2
|
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
3
3
|
import { keccak256 } from '@aztec/foundation/crypto/keccak';
|
|
4
4
|
import { tryRecoverAddress } from '@aztec/foundation/crypto/secp256k1-signer';
|
|
@@ -42,7 +42,7 @@ export type CheckpointLastBlockData = {
|
|
|
42
42
|
/** The per-block header for the last block in the checkpoint */
|
|
43
43
|
blockHeader: BlockHeader;
|
|
44
44
|
/** Index of this block within the checkpoint (should be the last index, e.g., numBlocks - 1) */
|
|
45
|
-
indexWithinCheckpoint:
|
|
45
|
+
indexWithinCheckpoint: IndexWithinCheckpoint;
|
|
46
46
|
/** The sequence of transactions in the last block */
|
|
47
47
|
txHashes: TxHash[];
|
|
48
48
|
/** The tx in the last block (optional, for DA guarantees) */
|
|
@@ -253,7 +253,7 @@ export class CheckpointProposal extends Gossipable {
|
|
|
253
253
|
|
|
254
254
|
if (hasLastBlock) {
|
|
255
255
|
const blockHeader = reader.readObject(BlockHeader);
|
|
256
|
-
const indexWithinCheckpoint = reader.readNumber();
|
|
256
|
+
const indexWithinCheckpoint = IndexWithinCheckpoint(reader.readNumber());
|
|
257
257
|
const blockSignature = reader.readObject(Signature);
|
|
258
258
|
const txHashCount = reader.readNumber();
|
|
259
259
|
if (txHashCount > MAX_TXS_PER_BLOCK) {
|
|
@@ -309,7 +309,7 @@ export class CheckpointProposal extends Gossipable {
|
|
|
309
309
|
static random(): CheckpointProposal {
|
|
310
310
|
return new CheckpointProposal(CheckpointHeader.random(), Fr.random(), Signature.random(), {
|
|
311
311
|
blockHeader: BlockHeader.random(),
|
|
312
|
-
indexWithinCheckpoint: Math.floor(Math.random() * 5),
|
|
312
|
+
indexWithinCheckpoint: IndexWithinCheckpoint(Math.floor(Math.random() * 5)),
|
|
313
313
|
txHashes: [TxHash.random(), TxHash.random()],
|
|
314
314
|
signature: Signature.random(),
|
|
315
315
|
});
|
|
@@ -7,7 +7,6 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
7
7
|
import { encodeAbiParameters, parseAbiParameters } from 'viem';
|
|
8
8
|
import { z } from 'zod';
|
|
9
9
|
|
|
10
|
-
import type { L2Block } from '../block/l2_block.js';
|
|
11
10
|
import type { Checkpoint } from '../checkpoint/checkpoint.js';
|
|
12
11
|
import { CheckpointHeader } from '../rollup/checkpoint_header.js';
|
|
13
12
|
import type { CheckpointProposal, CheckpointProposalCore } from './checkpoint_proposal.js';
|
|
@@ -76,10 +75,6 @@ export class ConsensusPayload implements Signable {
|
|
|
76
75
|
return new ConsensusPayload(fields.header, fields.archive);
|
|
77
76
|
}
|
|
78
77
|
|
|
79
|
-
static fromBlock(block: L2Block): ConsensusPayload {
|
|
80
|
-
return new ConsensusPayload(block.header.toCheckpointHeader(), block.archive.root);
|
|
81
|
-
}
|
|
82
|
-
|
|
83
78
|
static fromCheckpoint(checkpoint: Checkpoint): ConsensusPayload {
|
|
84
79
|
return new ConsensusPayload(checkpoint.header, checkpoint.archive.root);
|
|
85
80
|
}
|