@aztec/archiver 0.24.0 → 0.26.1
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/archiver/archiver.d.ts +15 -11
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +67 -72
- package/dest/archiver/archiver_store.d.ts +37 -15
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +70 -54
- package/dest/archiver/data_retrieval.d.ts +18 -8
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +39 -14
- package/dest/archiver/eth_log_handlers.d.ts +25 -23
- package/dest/archiver/eth_log_handlers.d.ts.map +1 -1
- package/dest/archiver/eth_log_handlers.js +98 -57
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts +27 -0
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts.map +1 -0
- package/dest/archiver/kv_archiver_store/block_body_store.js +47 -0
- package/dest/archiver/kv_archiver_store/block_store.d.ts +19 -11
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +58 -30
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +1 -0
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +4 -1
- package/dest/archiver/kv_archiver_store/contract_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_store.js +6 -3
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +36 -16
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +52 -22
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +4 -3
- package/dest/archiver/kv_archiver_store/message_store.d.ts +9 -9
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +34 -31
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +6 -6
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.js +18 -18
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +41 -16
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +78 -29
- package/dest/index.js +2 -2
- package/dest/rpc/archiver_client.d.ts.map +1 -1
- package/dest/rpc/archiver_client.js +3 -3
- package/dest/rpc/archiver_server.d.ts.map +1 -1
- package/dest/rpc/archiver_server.js +4 -3
- package/package.json +10 -10
- package/src/archiver/archiver.ts +95 -92
- package/src/archiver/archiver_store.ts +42 -15
- package/src/archiver/archiver_store_test_suite.ts +73 -58
- package/src/archiver/data_retrieval.ts +61 -16
- package/src/archiver/eth_log_handlers.ts +142 -68
- package/src/archiver/kv_archiver_store/block_body_store.ts +54 -0
- package/src/archiver/kv_archiver_store/block_store.ts +71 -36
- package/src/archiver/kv_archiver_store/contract_class_store.ts +4 -0
- package/src/archiver/kv_archiver_store/contract_store.ts +7 -2
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +56 -20
- package/src/archiver/kv_archiver_store/log_store.ts +2 -2
- package/src/archiver/kv_archiver_store/message_store.ts +34 -30
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +17 -17
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +91 -29
- package/src/index.ts +1 -0
- package/src/rpc/archiver_client.ts +3 -1
- package/src/rpc/archiver_server.ts +5 -1
package/src/archiver/archiver.ts
CHANGED
|
@@ -10,23 +10,17 @@ import {
|
|
|
10
10
|
L2BlockL2Logs,
|
|
11
11
|
L2BlockSource,
|
|
12
12
|
L2LogsSource,
|
|
13
|
-
L2Tx,
|
|
14
13
|
LogFilter,
|
|
15
14
|
LogType,
|
|
15
|
+
TxEffect,
|
|
16
16
|
TxHash,
|
|
17
|
+
TxReceipt,
|
|
17
18
|
UnencryptedL2Log,
|
|
18
19
|
} from '@aztec/circuit-types';
|
|
19
|
-
import {
|
|
20
|
-
|
|
21
|
-
FunctionSelector,
|
|
22
|
-
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
23
|
-
REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE,
|
|
24
|
-
} from '@aztec/circuits.js';
|
|
25
|
-
import { ContractInstanceDeployedEvent, computeSaltedInitializationHash } from '@aztec/circuits.js/contract';
|
|
20
|
+
import { ContractClassRegisteredEvent, FunctionSelector } from '@aztec/circuits.js';
|
|
21
|
+
import { ContractInstanceDeployedEvent } from '@aztec/circuits.js/contract';
|
|
26
22
|
import { createEthereumChain } from '@aztec/ethereum';
|
|
27
23
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
28
|
-
import { toBigIntBE } from '@aztec/foundation/bigint-buffer';
|
|
29
|
-
import { padArrayEnd } from '@aztec/foundation/collection';
|
|
30
24
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
31
25
|
import { Fr } from '@aztec/foundation/fields';
|
|
32
26
|
import { DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
@@ -40,13 +34,13 @@ import {
|
|
|
40
34
|
ContractInstanceWithAddress,
|
|
41
35
|
} from '@aztec/types/contracts';
|
|
42
36
|
|
|
43
|
-
import omit from 'lodash.omit';
|
|
44
37
|
import { Chain, HttpTransport, PublicClient, createPublicClient, http } from 'viem';
|
|
45
38
|
|
|
46
39
|
import { ArchiverDataStore } from './archiver_store.js';
|
|
47
40
|
import { ArchiverConfig } from './config.js';
|
|
48
41
|
import {
|
|
49
|
-
|
|
42
|
+
retrieveBlockBodiesFromAvailabilityOracle,
|
|
43
|
+
retrieveBlockMetadataFromRollup,
|
|
50
44
|
retrieveNewCancelledL1ToL2Messages,
|
|
51
45
|
retrieveNewContractData,
|
|
52
46
|
retrieveNewPendingL1ToL2Messages,
|
|
@@ -73,12 +67,6 @@ export class Archiver implements ArchiveSource {
|
|
|
73
67
|
*/
|
|
74
68
|
private lastLoggedL1BlockNumber = 0n;
|
|
75
69
|
|
|
76
|
-
/** Address of the ClassRegisterer contract with a salt=1 */
|
|
77
|
-
private classRegistererAddress = ClassRegistererAddress;
|
|
78
|
-
|
|
79
|
-
/** Address of the InstanceDeployer contract with a salt=1 */
|
|
80
|
-
private instanceDeployerAddress = InstanceDeployerAddress;
|
|
81
|
-
|
|
82
70
|
/**
|
|
83
71
|
* Creates a new instance of the Archiver.
|
|
84
72
|
* @param publicClient - A client for interacting with the Ethereum node.
|
|
@@ -93,6 +81,7 @@ export class Archiver implements ArchiveSource {
|
|
|
93
81
|
constructor(
|
|
94
82
|
private readonly publicClient: PublicClient<HttpTransport, Chain>,
|
|
95
83
|
private readonly rollupAddress: EthAddress,
|
|
84
|
+
private readonly availabilityOracleAddress: EthAddress,
|
|
96
85
|
private readonly inboxAddress: EthAddress,
|
|
97
86
|
private readonly registryAddress: EthAddress,
|
|
98
87
|
private readonly contractDeploymentEmitterAddress: EthAddress,
|
|
@@ -123,6 +112,7 @@ export class Archiver implements ArchiveSource {
|
|
|
123
112
|
const archiver = new Archiver(
|
|
124
113
|
publicClient,
|
|
125
114
|
config.l1Contracts.rollupAddress,
|
|
115
|
+
config.l1Contracts.availabilityOracleAddress,
|
|
126
116
|
config.l1Contracts.inboxAddress,
|
|
127
117
|
config.l1Contracts.registryAddress,
|
|
128
118
|
config.l1Contracts.contractDeploymentEmitterAddress,
|
|
@@ -226,9 +216,9 @@ export class Archiver implements ArchiveSource {
|
|
|
226
216
|
messagesByBlock.set(blockNumber, messages);
|
|
227
217
|
}
|
|
228
218
|
|
|
229
|
-
for (const [
|
|
219
|
+
for (const [entryKey, blockNumber] of retrievedCancelledL1ToL2Messages.retrievedData) {
|
|
230
220
|
const messages = messagesByBlock.get(blockNumber) || [[], []];
|
|
231
|
-
messages[1].push(
|
|
221
|
+
messages[1].push(entryKey);
|
|
232
222
|
messagesByBlock.set(blockNumber, messages);
|
|
233
223
|
}
|
|
234
224
|
|
|
@@ -240,14 +230,27 @@ export class Archiver implements ArchiveSource {
|
|
|
240
230
|
`Adding ${newMessages.length} new messages and ${cancelledMessages.length} cancelled messages in L1 block ${l1Block}`,
|
|
241
231
|
);
|
|
242
232
|
await this.store.addPendingL1ToL2Messages(newMessages, l1Block);
|
|
243
|
-
await this.store.
|
|
233
|
+
await this.store.cancelPendingL1ToL2EntryKeys(cancelledMessages, l1Block);
|
|
244
234
|
}
|
|
245
235
|
|
|
246
236
|
// ********** Events that are processed per L2 block **********
|
|
247
237
|
|
|
248
238
|
// Read all data from chain and then write to our stores at the end
|
|
249
239
|
const nextExpectedL2BlockNum = BigInt((await this.store.getBlockNumber()) + 1);
|
|
250
|
-
|
|
240
|
+
|
|
241
|
+
const retrievedBlockBodies = await retrieveBlockBodiesFromAvailabilityOracle(
|
|
242
|
+
this.publicClient,
|
|
243
|
+
this.availabilityOracleAddress,
|
|
244
|
+
blockUntilSynced,
|
|
245
|
+
lastL1Blocks.addedBlock + 1n,
|
|
246
|
+
currentL1BlockNumber,
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
const blockBodies = retrievedBlockBodies.retrievedData.map(([blockBody]) => blockBody);
|
|
250
|
+
|
|
251
|
+
await this.store.addBlockBodies(blockBodies);
|
|
252
|
+
|
|
253
|
+
const retrievedBlockMetadata = await retrieveBlockMetadataFromRollup(
|
|
251
254
|
this.publicClient,
|
|
252
255
|
this.rollupAddress,
|
|
253
256
|
blockUntilSynced,
|
|
@@ -256,6 +259,23 @@ export class Archiver implements ArchiveSource {
|
|
|
256
259
|
nextExpectedL2BlockNum,
|
|
257
260
|
);
|
|
258
261
|
|
|
262
|
+
const retrievedBodyHashes = retrievedBlockMetadata.retrievedData.map(
|
|
263
|
+
([header]) => header.contentCommitment.txsHash,
|
|
264
|
+
);
|
|
265
|
+
|
|
266
|
+
const blockBodiesFromStore = await this.store.getBlockBodies(retrievedBodyHashes);
|
|
267
|
+
|
|
268
|
+
if (retrievedBlockMetadata.retrievedData.length !== blockBodiesFromStore.length) {
|
|
269
|
+
throw new Error('Block headers length does not equal block bodies length');
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const retrievedBlocks = {
|
|
273
|
+
retrievedData: retrievedBlockMetadata.retrievedData.map(
|
|
274
|
+
(blockMetadata, i) =>
|
|
275
|
+
new L2Block(blockMetadata[1], blockMetadata[0], blockBodiesFromStore[i], blockMetadata[2]),
|
|
276
|
+
),
|
|
277
|
+
};
|
|
278
|
+
|
|
259
279
|
if (retrievedBlocks.retrievedData.length === 0) {
|
|
260
280
|
return;
|
|
261
281
|
} else {
|
|
@@ -267,9 +287,9 @@ export class Archiver implements ArchiveSource {
|
|
|
267
287
|
}
|
|
268
288
|
|
|
269
289
|
// create the block number -> block hash mapping to ensure we retrieve the appropriate events
|
|
270
|
-
const
|
|
290
|
+
const blockNumberToBodyHash: { [key: number]: Buffer | undefined } = {};
|
|
271
291
|
retrievedBlocks.retrievedData.forEach((block: L2Block) => {
|
|
272
|
-
|
|
292
|
+
blockNumberToBodyHash[block.number] = block.header.contentCommitment.txsHash;
|
|
273
293
|
});
|
|
274
294
|
const retrievedContracts = await retrieveNewContractData(
|
|
275
295
|
this.publicClient,
|
|
@@ -277,21 +297,25 @@ export class Archiver implements ArchiveSource {
|
|
|
277
297
|
blockUntilSynced,
|
|
278
298
|
lastL1Blocks.addedBlock + 1n,
|
|
279
299
|
currentL1BlockNumber,
|
|
280
|
-
|
|
300
|
+
blockNumberToBodyHash,
|
|
281
301
|
);
|
|
282
302
|
|
|
283
303
|
this.log(`Retrieved ${retrievedBlocks.retrievedData.length} block(s) from chain`);
|
|
284
304
|
|
|
285
305
|
await Promise.all(
|
|
286
|
-
retrievedBlocks.retrievedData.map(block =>
|
|
287
|
-
|
|
288
|
-
|
|
306
|
+
retrievedBlocks.retrievedData.map(block => {
|
|
307
|
+
const encryptedLogs = block.body.encryptedLogs;
|
|
308
|
+
const unencryptedLogs = block.body.unencryptedLogs;
|
|
309
|
+
|
|
310
|
+
return this.store.addLogs(encryptedLogs, unencryptedLogs, block.number);
|
|
311
|
+
}),
|
|
289
312
|
);
|
|
290
313
|
|
|
291
314
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
292
315
|
await Promise.all(
|
|
293
316
|
retrievedBlocks.retrievedData.map(async block => {
|
|
294
|
-
const blockLogs =
|
|
317
|
+
const blockLogs = block.body.txEffects
|
|
318
|
+
.flatMap(txEffect => (txEffect ? [txEffect.unencryptedLogs] : []))
|
|
295
319
|
.flatMap(txLog => txLog.unrollLogs())
|
|
296
320
|
.map(log => UnencryptedL2Log.fromBuffer(log));
|
|
297
321
|
await this.storeRegisteredContractClasses(blockLogs, block.number);
|
|
@@ -312,21 +336,13 @@ export class Archiver implements ArchiveSource {
|
|
|
312
336
|
);
|
|
313
337
|
|
|
314
338
|
// from retrieved L2Blocks, confirm L1 to L2 messages that have been published
|
|
315
|
-
// from each l2block fetch all
|
|
339
|
+
// from each l2block fetch all entryKeys in a flattened array:
|
|
316
340
|
this.log(`Confirming l1 to l2 messages in store`);
|
|
317
341
|
for (const block of retrievedBlocks.retrievedData) {
|
|
318
|
-
await this.store.
|
|
342
|
+
await this.store.confirmL1ToL2EntryKeys(block.body.l1ToL2Messages);
|
|
319
343
|
}
|
|
320
344
|
|
|
321
|
-
|
|
322
|
-
// remove logs to serve "lightweight" block information. Logs can be fetched separately if needed.
|
|
323
|
-
await this.store.addBlocks(
|
|
324
|
-
retrievedBlocks.retrievedData.map(block => {
|
|
325
|
-
// Ensure we pad the L1 to L2 message array to the full size before storing.
|
|
326
|
-
block.newL1ToL2Messages = padArrayEnd(block.newL1ToL2Messages, Fr.ZERO, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP);
|
|
327
|
-
return L2Block.fromFields(omit(block, ['newEncryptedLogs', 'newUnencryptedLogs']), block.getL1BlockNumber());
|
|
328
|
-
}),
|
|
329
|
-
);
|
|
345
|
+
await this.store.addBlocks(retrievedBlocks.retrievedData);
|
|
330
346
|
}
|
|
331
347
|
|
|
332
348
|
/**
|
|
@@ -334,22 +350,9 @@ export class Archiver implements ArchiveSource {
|
|
|
334
350
|
* @param allLogs - All logs emitted in a bunch of blocks.
|
|
335
351
|
*/
|
|
336
352
|
private async storeRegisteredContractClasses(allLogs: UnencryptedL2Log[], blockNum: number) {
|
|
337
|
-
const contractClasses
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
if (
|
|
341
|
-
!log.contractAddress.equals(this.classRegistererAddress) ||
|
|
342
|
-
toBigIntBE(log.data.subarray(0, 32)) !== REGISTERER_CONTRACT_CLASS_REGISTERED_MAGIC_VALUE
|
|
343
|
-
) {
|
|
344
|
-
continue;
|
|
345
|
-
}
|
|
346
|
-
const event = ContractClassRegisteredEvent.fromLogData(log.data);
|
|
347
|
-
contractClasses.push(event.toContractClassPublic());
|
|
348
|
-
} catch (err) {
|
|
349
|
-
this.log.warn(`Error processing log ${log.toHumanReadable()}: ${err}`);
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
+
const contractClasses = ContractClassRegisteredEvent.fromLogs(allLogs, ClassRegistererAddress).map(e =>
|
|
354
|
+
e.toContractClassPublic(),
|
|
355
|
+
);
|
|
353
356
|
if (contractClasses.length > 0) {
|
|
354
357
|
contractClasses.forEach(c => this.log(`Registering contract class ${c.id.toString()}`));
|
|
355
358
|
await this.store.addContractClasses(contractClasses, blockNum);
|
|
@@ -361,22 +364,9 @@ export class Archiver implements ArchiveSource {
|
|
|
361
364
|
* @param allLogs - All logs emitted in a bunch of blocks.
|
|
362
365
|
*/
|
|
363
366
|
private async storeDeployedContractInstances(allLogs: UnencryptedL2Log[], blockNum: number) {
|
|
364
|
-
const contractInstances
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
if (
|
|
368
|
-
!log.contractAddress.equals(this.instanceDeployerAddress) ||
|
|
369
|
-
!ContractInstanceDeployedEvent.isContractInstanceDeployedEvent(log.data)
|
|
370
|
-
) {
|
|
371
|
-
continue;
|
|
372
|
-
}
|
|
373
|
-
const event = ContractInstanceDeployedEvent.fromLogData(log.data);
|
|
374
|
-
contractInstances.push(event.toContractInstance());
|
|
375
|
-
} catch (err) {
|
|
376
|
-
this.log.warn(`Error processing log ${log.toHumanReadable()}: ${err}`);
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
|
|
367
|
+
const contractInstances = ContractInstanceDeployedEvent.fromLogs(allLogs, InstanceDeployerAddress).map(e =>
|
|
368
|
+
e.toContractInstance(),
|
|
369
|
+
);
|
|
380
370
|
if (contractInstances.length > 0) {
|
|
381
371
|
contractInstances.forEach(c => this.log(`Storing contract instance at ${c.address.toString()}`));
|
|
382
372
|
await this.store.addContractInstances(contractInstances, blockNum);
|
|
@@ -445,8 +435,12 @@ export class Archiver implements ArchiveSource {
|
|
|
445
435
|
return blocks.length === 0 ? undefined : blocks[0];
|
|
446
436
|
}
|
|
447
437
|
|
|
448
|
-
public
|
|
449
|
-
return this.store.
|
|
438
|
+
public getTxEffect(txHash: TxHash): Promise<TxEffect | undefined> {
|
|
439
|
+
return this.store.getTxEffect(txHash);
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
public getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined> {
|
|
443
|
+
return this.store.getSettledTxReceipt(txHash);
|
|
450
444
|
}
|
|
451
445
|
|
|
452
446
|
/**
|
|
@@ -472,19 +466,11 @@ export class Archiver implements ArchiveSource {
|
|
|
472
466
|
|
|
473
467
|
const contractClass = await this.store.getContractClass(instance.contractClassId);
|
|
474
468
|
if (!contractClass) {
|
|
475
|
-
this.log.warn(
|
|
476
|
-
`Contract class ${instance.contractClassId.toString()} for address ${address.toString()} not found`,
|
|
477
|
-
);
|
|
469
|
+
this.log.warn(`Class ${instance.contractClassId.toString()} for address ${address.toString()} not found`);
|
|
478
470
|
return undefined;
|
|
479
471
|
}
|
|
480
472
|
|
|
481
|
-
return
|
|
482
|
-
new ContractData(address, instance.portalContractAddress),
|
|
483
|
-
contractClass.publicFunctions.map(f => new EncodedContractFunction(f.selector, f.isInternal, f.bytecode)),
|
|
484
|
-
contractClass.id,
|
|
485
|
-
computeSaltedInitializationHash(instance),
|
|
486
|
-
instance.publicKeysHash,
|
|
487
|
-
);
|
|
473
|
+
return ExtendedContractData.fromClassAndInstance(contractClass, instance);
|
|
488
474
|
}
|
|
489
475
|
|
|
490
476
|
/**
|
|
@@ -502,8 +488,21 @@ export class Archiver implements ArchiveSource {
|
|
|
502
488
|
* @param contractAddress - The contract data address.
|
|
503
489
|
* @returns ContractData with the portal address (if we didn't throw an error).
|
|
504
490
|
*/
|
|
505
|
-
public getContractData(contractAddress: AztecAddress): Promise<ContractData | undefined> {
|
|
506
|
-
return this.store.getContractData(contractAddress);
|
|
491
|
+
public async getContractData(contractAddress: AztecAddress): Promise<ContractData | undefined> {
|
|
492
|
+
return (await this.store.getContractData(contractAddress)) ?? this.makeContractDataFor(contractAddress);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/**
|
|
496
|
+
* Temporary method for creating a fake contract data out of classes and instances registered in the node.
|
|
497
|
+
* Used as a fallback if the extended contract data is not found.
|
|
498
|
+
*/
|
|
499
|
+
private async makeContractDataFor(address: AztecAddress): Promise<ContractData | undefined> {
|
|
500
|
+
const instance = await this.store.getContractInstance(address);
|
|
501
|
+
if (!instance) {
|
|
502
|
+
return undefined;
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
return new ContractData(address, instance.portalContractAddress);
|
|
507
506
|
}
|
|
508
507
|
|
|
509
508
|
/**
|
|
@@ -571,17 +570,21 @@ export class Archiver implements ArchiveSource {
|
|
|
571
570
|
* @param limit - The number of messages to return.
|
|
572
571
|
* @returns The requested L1 to L2 messages' keys.
|
|
573
572
|
*/
|
|
574
|
-
|
|
575
|
-
return this.store.
|
|
573
|
+
getPendingL1ToL2EntryKeys(limit: number): Promise<Fr[]> {
|
|
574
|
+
return this.store.getPendingL1ToL2EntryKeys(limit);
|
|
576
575
|
}
|
|
577
576
|
|
|
578
577
|
/**
|
|
579
|
-
* Gets the confirmed/consumed L1 to L2 message associated with the given
|
|
580
|
-
* @param
|
|
578
|
+
* Gets the confirmed/consumed L1 to L2 message associated with the given entry key
|
|
579
|
+
* @param entryKey - The entry key.
|
|
581
580
|
* @returns The L1 to L2 message (throws if not found).
|
|
582
581
|
*/
|
|
583
|
-
getConfirmedL1ToL2Message(
|
|
584
|
-
return this.store.getConfirmedL1ToL2Message(
|
|
582
|
+
getConfirmedL1ToL2Message(entryKey: Fr): Promise<L1ToL2Message> {
|
|
583
|
+
return this.store.getConfirmedL1ToL2Message(entryKey);
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
getContractClassIds(): Promise<Fr[]> {
|
|
587
|
+
return this.store.getContractClassIds();
|
|
585
588
|
}
|
|
586
589
|
}
|
|
587
590
|
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
Body,
|
|
2
3
|
ContractData,
|
|
3
4
|
ExtendedContractData,
|
|
4
5
|
GetUnencryptedLogsResponse,
|
|
5
6
|
L1ToL2Message,
|
|
6
7
|
L2Block,
|
|
7
8
|
L2BlockL2Logs,
|
|
8
|
-
L2Tx,
|
|
9
9
|
LogFilter,
|
|
10
10
|
LogType,
|
|
11
|
+
TxEffect,
|
|
11
12
|
TxHash,
|
|
13
|
+
TxReceipt,
|
|
12
14
|
} from '@aztec/circuit-types';
|
|
13
15
|
import { Fr } from '@aztec/circuits.js';
|
|
14
16
|
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
@@ -38,6 +40,21 @@ export interface ArchiverDataStore {
|
|
|
38
40
|
*/
|
|
39
41
|
addBlocks(blocks: L2Block[]): Promise<boolean>;
|
|
40
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Append new block bodies to the store's list.
|
|
45
|
+
* @param blockBodies - The L2 block bodies to be added to the store.
|
|
46
|
+
* @returns True if the operation is successful.
|
|
47
|
+
*/
|
|
48
|
+
addBlockBodies(blockBodies: Body[]): Promise<boolean>;
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Gets block bodies that have the same txsHashes as we supply.
|
|
52
|
+
*
|
|
53
|
+
* @param txsHashes - A list of txsHashes (body hashes).
|
|
54
|
+
* @returns The requested L2 block bodies
|
|
55
|
+
*/
|
|
56
|
+
getBlockBodies(txsHashes: Buffer[]): Promise<Body[]>;
|
|
57
|
+
|
|
41
58
|
/**
|
|
42
59
|
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
43
60
|
* @param from - Number of the first block to return (inclusive).
|
|
@@ -47,11 +64,18 @@ export interface ArchiverDataStore {
|
|
|
47
64
|
getBlocks(from: number, limit: number): Promise<L2Block[]>;
|
|
48
65
|
|
|
49
66
|
/**
|
|
50
|
-
* Gets
|
|
51
|
-
* @param txHash - The txHash of the
|
|
52
|
-
* @returns The requested
|
|
67
|
+
* Gets a tx effect.
|
|
68
|
+
* @param txHash - The txHash of the tx corresponding to the tx effect.
|
|
69
|
+
* @returns The requested tx effect (or undefined if not found).
|
|
53
70
|
*/
|
|
54
|
-
|
|
71
|
+
getTxEffect(txHash: TxHash): Promise<TxEffect | undefined>;
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Gets a receipt of a settled tx.
|
|
75
|
+
* @param txHash - The hash of a tx we try to get the receipt for.
|
|
76
|
+
* @returns The requested tx receipt (or undefined if not found).
|
|
77
|
+
*/
|
|
78
|
+
getSettledTxReceipt(txHash: TxHash): Promise<TxReceipt | undefined>;
|
|
55
79
|
|
|
56
80
|
/**
|
|
57
81
|
* Append new logs to the store's list.
|
|
@@ -76,33 +100,33 @@ export interface ArchiverDataStore {
|
|
|
76
100
|
|
|
77
101
|
/**
|
|
78
102
|
* Remove pending L1 to L2 messages from the store (if they were cancelled).
|
|
79
|
-
* @param
|
|
103
|
+
* @param entryKeys - The entry keys to be removed from the store.
|
|
80
104
|
* @param l1BlockNumber - The block number of the L1 block that cancelled the messages.
|
|
81
105
|
* @returns True if the operation is successful.
|
|
82
106
|
*/
|
|
83
|
-
|
|
107
|
+
cancelPendingL1ToL2EntryKeys(entryKeys: Fr[], l1BlockNumber: bigint): Promise<boolean>;
|
|
84
108
|
|
|
85
109
|
/**
|
|
86
110
|
* Messages that have been published in an L2 block are confirmed.
|
|
87
111
|
* Add them to the confirmed store, also remove them from the pending store.
|
|
88
|
-
* @param
|
|
112
|
+
* @param entryKeys - The entry keys to be removed from the store.
|
|
89
113
|
* @returns True if the operation is successful.
|
|
90
114
|
*/
|
|
91
|
-
|
|
115
|
+
confirmL1ToL2EntryKeys(entryKeys: Fr[]): Promise<boolean>;
|
|
92
116
|
|
|
93
117
|
/**
|
|
94
118
|
* Gets up to `limit` amount of pending L1 to L2 messages, sorted by fee
|
|
95
|
-
* @param limit - The number of
|
|
96
|
-
* @returns The requested L1 to L2
|
|
119
|
+
* @param limit - The number of entries to return (by default NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).
|
|
120
|
+
* @returns The requested L1 to L2 entry keys.
|
|
97
121
|
*/
|
|
98
|
-
|
|
122
|
+
getPendingL1ToL2EntryKeys(limit: number): Promise<Fr[]>;
|
|
99
123
|
|
|
100
124
|
/**
|
|
101
|
-
* Gets the confirmed L1 to L2 message corresponding to the given
|
|
102
|
-
* @param
|
|
125
|
+
* Gets the confirmed L1 to L2 message corresponding to the given entry key.
|
|
126
|
+
* @param entryKey - The entry key to look up.
|
|
103
127
|
* @returns The requested L1 to L2 message or throws if not found.
|
|
104
128
|
*/
|
|
105
|
-
getConfirmedL1ToL2Message(
|
|
129
|
+
getConfirmedL1ToL2Message(entryKey: Fr): Promise<L1ToL2Message>;
|
|
106
130
|
|
|
107
131
|
/**
|
|
108
132
|
* Gets up to `limit` amount of logs starting from `from`.
|
|
@@ -196,4 +220,7 @@ export interface ArchiverDataStore {
|
|
|
196
220
|
* @param address - Address of the contract.
|
|
197
221
|
*/
|
|
198
222
|
getContractInstance(address: AztecAddress): Promise<ContractInstanceWithAddress | undefined>;
|
|
223
|
+
|
|
224
|
+
/** Returns the list of all class ids known by the archiver. */
|
|
225
|
+
getContractClassIds(): Promise<Fr[]>;
|
|
199
226
|
}
|