@aztec/archiver 0.61.0 → 0.63.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/archiver/archiver.d.ts +13 -5
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +49 -26
- package/dest/archiver/archiver_store.d.ts +10 -5
- 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 +64 -36
- package/dest/archiver/config.d.ts +2 -6
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +3 -6
- package/dest/archiver/epoch_helpers.d.ts +10 -10
- package/dest/archiver/epoch_helpers.d.ts.map +1 -1
- package/dest/archiver/epoch_helpers.js +9 -10
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +10 -5
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +17 -5
- package/dest/archiver/kv_archiver_store/log_store.d.ts +8 -2
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +144 -57
- package/dest/archiver/kv_archiver_store/message_store.d.ts +2 -3
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +7 -12
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +2 -3
- 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 +4 -9
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +15 -7
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +139 -35
- package/dest/factory.d.ts +5 -2
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +2 -2
- package/dest/rpc/index.d.ts +3 -2
- package/dest/rpc/index.d.ts.map +1 -1
- package/dest/rpc/index.js +10 -3
- package/dest/test/mock_archiver.d.ts +1 -1
- package/dest/test/mock_archiver.d.ts.map +1 -1
- package/dest/test/mock_archiver.js +3 -3
- package/dest/test/mock_l1_to_l2_message_source.d.ts +1 -1
- package/dest/test/mock_l1_to_l2_message_source.d.ts.map +1 -1
- package/dest/test/mock_l1_to_l2_message_source.js +2 -2
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +6 -4
- package/package.json +10 -10
- package/src/archiver/archiver.ts +60 -31
- package/src/archiver/archiver_store.ts +11 -5
- package/src/archiver/archiver_store_test_suite.ts +85 -40
- package/src/archiver/config.ts +11 -12
- package/src/archiver/epoch_helpers.ts +16 -12
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +18 -6
- package/src/archiver/kv_archiver_store/log_store.ts +176 -58
- package/src/archiver/kv_archiver_store/message_store.ts +6 -12
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +3 -8
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +155 -31
- package/src/factory.ts +6 -3
- package/src/rpc/index.ts +11 -2
- package/src/test/mock_archiver.ts +2 -2
- package/src/test/mock_l1_to_l2_message_source.ts +1 -1
- package/src/test/mock_l2_block_source.ts +5 -3
- package/dest/rpc/archiver_client.d.ts +0 -3
- package/dest/rpc/archiver_client.d.ts.map +0 -1
- package/dest/rpc/archiver_client.js +0 -12
- package/dest/rpc/archiver_server.d.ts +0 -9
- package/dest/rpc/archiver_server.d.ts.map +0 -1
- package/dest/rpc/archiver_server.js +0 -20
- package/src/rpc/archiver_client.ts +0 -29
- package/src/rpc/archiver_server.ts +0 -35
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { L2Block, TxReceipt, TxStatus } from '@aztec/circuit-types';
|
|
2
2
|
import { EthAddress } from '@aztec/circuits.js';
|
|
3
|
+
import { DefaultL1ContractsConfig } from '@aztec/ethereum';
|
|
3
4
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
5
|
import { getSlotRangeForEpoch } from '../archiver/epoch_helpers.js';
|
|
5
6
|
/**
|
|
@@ -55,8 +56,8 @@ export class MockL2BlockSource {
|
|
|
55
56
|
getBlockNumber() {
|
|
56
57
|
return Promise.resolve(this.l2Blocks.length);
|
|
57
58
|
}
|
|
58
|
-
|
|
59
|
-
return
|
|
59
|
+
getProvenBlockNumber() {
|
|
60
|
+
return Promise.resolve(this.provenBlockNumber);
|
|
60
61
|
}
|
|
61
62
|
getProvenL2EpochNumber() {
|
|
62
63
|
return Promise.resolve(this.provenEpochNumber);
|
|
@@ -84,7 +85,8 @@ export class MockL2BlockSource {
|
|
|
84
85
|
return Promise.resolve(this.l2Blocks.at(typeof number === 'number' ? number - 1 : -1)?.header);
|
|
85
86
|
}
|
|
86
87
|
getBlocksForEpoch(epochNumber) {
|
|
87
|
-
const
|
|
88
|
+
const epochDuration = DefaultL1ContractsConfig.aztecEpochDuration;
|
|
89
|
+
const [start, end] = getSlotRangeForEpoch(epochNumber, { epochDuration });
|
|
88
90
|
const blocks = this.l2Blocks.filter(b => {
|
|
89
91
|
const slot = b.header.globalVariables.slotNumber.toBigInt();
|
|
90
92
|
return slot >= start && slot <= end;
|
|
@@ -151,4 +153,4 @@ export class MockL2BlockSource {
|
|
|
151
153
|
return Promise.resolve();
|
|
152
154
|
}
|
|
153
155
|
}
|
|
154
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
156
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibW9ja19sMl9ibG9ja19zb3VyY2UuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvdGVzdC9tb2NrX2wyX2Jsb2NrX3NvdXJjZS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsT0FBTyxFQUFnRCxTQUFTLEV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QUMsRUFBRSxJQUFJLEVBQUUsQ0FBQyxRQUFRLEVBQUUsRUFBRTtZQUM5RSxTQUFTLEVBQUUsRUFBRSxNQUFNLEVBQUUsU0FBUyxFQUFFLElBQUksRUFBRSxJQUFJLENBQUMsUUFBUSxDQUFDLFNBQVMsR0FBRyxDQUFDLENBQUMsRUFBRSxJQUFJLEVBQUUsQ0FBQyxRQUFRLEVBQUUsRUFBRTtTQUN4RixDQUFDO0lBQ0osQ0FBQztJQUVELGdCQUFnQjtRQUNkLE1BQU0sSUFBSSxLQUFLLENBQUMseUJBQXlCLENBQUMsQ0FBQztJQUM3QyxDQUFDO0lBRUQsZUFBZTtRQUNiLE1BQU0sSUFBSSxLQUFLLENBQUMseUJBQXlCLENBQUMsQ0FBQztJQUM3QyxDQUFDO0lBRUQsZUFBZSxDQUFDLFlBQW9CO1FBQ2xDLE1BQU0sSUFBSSxLQUFLLENBQUMseUJBQXlCLENBQUMsQ0FBQztJQUM3QyxDQUFDO0lBRUQ7OztPQUdHO0lBQ0ksS0FBSztRQUNWLE9BQU8sT0FBTyxDQUFDLE9BQU8sRUFBRSxDQUFDO0lBQzNCLENBQUM7SUFFRDs7O09BR0c7SUFDSSxJQUFJO1FBQ1QsT0FBTyxPQUFPLENBQUMsT0FBTyxFQUFFLENBQUM7SUFDM0IsQ0FBQztDQUNGIn0=
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.63.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -65,15 +65,15 @@
|
|
|
65
65
|
]
|
|
66
66
|
},
|
|
67
67
|
"dependencies": {
|
|
68
|
-
"@aztec/circuit-types": "0.
|
|
69
|
-
"@aztec/circuits.js": "0.
|
|
70
|
-
"@aztec/ethereum": "0.
|
|
71
|
-
"@aztec/foundation": "0.
|
|
72
|
-
"@aztec/kv-store": "0.
|
|
73
|
-
"@aztec/l1-artifacts": "0.
|
|
74
|
-
"@aztec/protocol-contracts": "0.
|
|
75
|
-
"@aztec/telemetry-client": "0.
|
|
76
|
-
"@aztec/types": "0.
|
|
68
|
+
"@aztec/circuit-types": "0.63.0",
|
|
69
|
+
"@aztec/circuits.js": "0.63.0",
|
|
70
|
+
"@aztec/ethereum": "0.63.0",
|
|
71
|
+
"@aztec/foundation": "0.63.0",
|
|
72
|
+
"@aztec/kv-store": "0.63.0",
|
|
73
|
+
"@aztec/l1-artifacts": "0.63.0",
|
|
74
|
+
"@aztec/protocol-contracts": "0.63.0",
|
|
75
|
+
"@aztec/telemetry-client": "0.63.0",
|
|
76
|
+
"@aztec/types": "0.63.0",
|
|
77
77
|
"debug": "^4.3.4",
|
|
78
78
|
"lodash.groupby": "^4.6.0",
|
|
79
79
|
"lodash.omit": "^4.5.0",
|
package/src/archiver/archiver.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type
|
|
2
|
+
type EncryptedL2Log,
|
|
3
3
|
type FromLogType,
|
|
4
4
|
type GetUnencryptedLogsResponse,
|
|
5
5
|
type InboxLeaf,
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
type TxEffect,
|
|
16
16
|
type TxHash,
|
|
17
17
|
type TxReceipt,
|
|
18
|
+
type TxScopedL2Log,
|
|
18
19
|
type UnencryptedL2Log,
|
|
19
20
|
} from '@aztec/circuit-types';
|
|
20
21
|
import {
|
|
@@ -160,6 +161,8 @@ export class Archiver implements ArchiveSource {
|
|
|
160
161
|
rollup.read.GENESIS_TIME(),
|
|
161
162
|
] as const);
|
|
162
163
|
|
|
164
|
+
const { aztecEpochDuration: epochDuration, aztecSlotDuration: slotDuration, ethereumSlotDuration } = config;
|
|
165
|
+
|
|
163
166
|
const archiver = new Archiver(
|
|
164
167
|
publicClient,
|
|
165
168
|
config.l1Contracts.rollupAddress,
|
|
@@ -168,7 +171,7 @@ export class Archiver implements ArchiveSource {
|
|
|
168
171
|
archiverStore,
|
|
169
172
|
config.archiverPollingIntervalMS ?? 10_000,
|
|
170
173
|
new ArchiverInstrumentation(telemetry),
|
|
171
|
-
{ l1StartBlock, l1GenesisTime },
|
|
174
|
+
{ l1StartBlock, l1GenesisTime, epochDuration, slotDuration, ethereumSlotDuration },
|
|
172
175
|
);
|
|
173
176
|
await archiver.start(blockUntilSynced);
|
|
174
177
|
return archiver;
|
|
@@ -246,6 +249,12 @@ export class Archiver implements ArchiveSource {
|
|
|
246
249
|
// ********** Events that are processed per L1 block **********
|
|
247
250
|
await this.handleL1ToL2Messages(blockUntilSynced, messagesSynchedTo, currentL1BlockNumber);
|
|
248
251
|
|
|
252
|
+
// Store latest l1 block number and timestamp seen. Used for epoch and slots calculations.
|
|
253
|
+
if (!this.l1BlockNumber || this.l1BlockNumber < currentL1BlockNumber) {
|
|
254
|
+
this.l1Timestamp = (await this.publicClient.getBlock({ blockNumber: currentL1BlockNumber })).timestamp;
|
|
255
|
+
this.l1BlockNumber = currentL1BlockNumber;
|
|
256
|
+
}
|
|
257
|
+
|
|
249
258
|
// ********** Events that are processed per L2 block **********
|
|
250
259
|
if (currentL1BlockNumber > blocksSynchedTo) {
|
|
251
260
|
// First we retrieve new L2 blocks
|
|
@@ -257,21 +266,17 @@ export class Archiver implements ArchiveSource {
|
|
|
257
266
|
// up to which point we're pruning, and then requesting L2 blocks up to that point only.
|
|
258
267
|
await this.handleEpochPrune(provenBlockNumber, currentL1BlockNumber);
|
|
259
268
|
}
|
|
260
|
-
|
|
261
|
-
// Store latest l1 block number and timestamp seen. Used for epoch and slots calculations.
|
|
262
|
-
if (!this.l1BlockNumber || this.l1BlockNumber < currentL1BlockNumber) {
|
|
263
|
-
this.l1Timestamp = await this.publicClient.getBlock({ blockNumber: currentL1BlockNumber }).then(b => b.timestamp);
|
|
264
|
-
this.l1BlockNumber = currentL1BlockNumber;
|
|
265
|
-
}
|
|
266
269
|
}
|
|
267
270
|
|
|
268
271
|
/** Checks if there'd be a reorg for the next block submission and start pruning now. */
|
|
269
272
|
private async handleEpochPrune(provenBlockNumber: bigint, currentL1BlockNumber: bigint) {
|
|
270
273
|
const localPendingBlockNumber = BigInt(await this.getBlockNumber());
|
|
271
274
|
|
|
275
|
+
const time = (this.l1Timestamp ?? 0n) + BigInt(this.l1constants.ethereumSlotDuration);
|
|
276
|
+
|
|
272
277
|
const canPrune =
|
|
273
278
|
localPendingBlockNumber > provenBlockNumber &&
|
|
274
|
-
(await this.rollup.read.
|
|
279
|
+
(await this.rollup.read.canPruneAtTime([time], { blockNumber: currentL1BlockNumber }));
|
|
275
280
|
|
|
276
281
|
if (canPrune) {
|
|
277
282
|
this.log.verbose(`L2 prune will occur on next submission. Rolling back to last proven block.`);
|
|
@@ -343,7 +348,7 @@ export class Archiver implements ArchiveSource {
|
|
|
343
348
|
localBlockForDestinationProvenBlockNumber &&
|
|
344
349
|
provenArchive === localBlockForDestinationProvenBlockNumber.archive.root.toString()
|
|
345
350
|
) {
|
|
346
|
-
this.log.
|
|
351
|
+
this.log.verbose(`Updating the proven block number to ${provenBlockNumber} and epoch to ${provenEpochNumber}`);
|
|
347
352
|
await this.store.setProvenL2BlockNumber(Number(provenBlockNumber));
|
|
348
353
|
// if we are here then we must have a valid proven epoch number
|
|
349
354
|
await this.store.setProvenL2EpochNumber(Number(provenEpochNumber));
|
|
@@ -499,7 +504,7 @@ export class Archiver implements ArchiveSource {
|
|
|
499
504
|
}
|
|
500
505
|
|
|
501
506
|
public async getBlocksForEpoch(epochNumber: bigint): Promise<L2Block[]> {
|
|
502
|
-
const [start, end] = getSlotRangeForEpoch(epochNumber);
|
|
507
|
+
const [start, end] = getSlotRangeForEpoch(epochNumber, this.l1constants);
|
|
503
508
|
const blocks: L2Block[] = [];
|
|
504
509
|
|
|
505
510
|
// Walk the list of blocks backwards and filter by slots matching the requested epoch.
|
|
@@ -520,7 +525,7 @@ export class Archiver implements ArchiveSource {
|
|
|
520
525
|
// The epoch is complete if the current L2 block is the last one in the epoch (or later)
|
|
521
526
|
const header = await this.getBlockHeader('latest');
|
|
522
527
|
const slot = header?.globalVariables.slotNumber.toBigInt();
|
|
523
|
-
const [_startSlot, endSlot] = getSlotRangeForEpoch(epochNumber);
|
|
528
|
+
const [_startSlot, endSlot] = getSlotRangeForEpoch(epochNumber, this.l1constants);
|
|
524
529
|
if (slot && slot >= endSlot) {
|
|
525
530
|
return true;
|
|
526
531
|
}
|
|
@@ -634,7 +639,7 @@ export class Archiver implements ArchiveSource {
|
|
|
634
639
|
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
|
|
635
640
|
* that tag.
|
|
636
641
|
*/
|
|
637
|
-
getLogsByTags(tags: Fr[]): Promise<
|
|
642
|
+
getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
|
|
638
643
|
return this.store.getLogsByTags(tags);
|
|
639
644
|
}
|
|
640
645
|
|
|
@@ -647,6 +652,15 @@ export class Archiver implements ArchiveSource {
|
|
|
647
652
|
return this.store.getUnencryptedLogs(filter);
|
|
648
653
|
}
|
|
649
654
|
|
|
655
|
+
/**
|
|
656
|
+
* Gets contract class logs based on the provided filter.
|
|
657
|
+
* @param filter - The filter to apply to the logs.
|
|
658
|
+
* @returns The requested logs.
|
|
659
|
+
*/
|
|
660
|
+
getContractClassLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
|
|
661
|
+
return this.store.getContractClassLogs(filter);
|
|
662
|
+
}
|
|
663
|
+
|
|
650
664
|
/**
|
|
651
665
|
* Gets the number of the latest L2 block processed by the block source implementation.
|
|
652
666
|
* @returns The number of the latest L2 block processed by the block source implementation.
|
|
@@ -686,13 +700,12 @@ export class Archiver implements ArchiveSource {
|
|
|
686
700
|
}
|
|
687
701
|
|
|
688
702
|
/**
|
|
689
|
-
* Gets the
|
|
703
|
+
* Gets the L1 to L2 message index in the L1 to L2 message tree.
|
|
690
704
|
* @param l1ToL2Message - The L1 to L2 message.
|
|
691
|
-
* @param startIndex - The index to start searching from.
|
|
692
705
|
* @returns The index of the L1 to L2 message in the L1 to L2 message tree (undefined if not found).
|
|
693
706
|
*/
|
|
694
|
-
getL1ToL2MessageIndex(l1ToL2Message: Fr
|
|
695
|
-
return this.store.getL1ToL2MessageIndex(l1ToL2Message
|
|
707
|
+
getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint | undefined> {
|
|
708
|
+
return this.store.getL1ToL2MessageIndex(l1ToL2Message);
|
|
696
709
|
}
|
|
697
710
|
|
|
698
711
|
getContractClassIds(): Promise<Fr[]> {
|
|
@@ -786,7 +799,7 @@ class ArchiverStoreHelper
|
|
|
786
799
|
* Extracts and stores contract instances out of ContractInstanceDeployed events emitted by the canonical deployer contract.
|
|
787
800
|
* @param allLogs - All logs emitted in a bunch of blocks.
|
|
788
801
|
*/
|
|
789
|
-
async #updateDeployedContractInstances(allLogs:
|
|
802
|
+
async #updateDeployedContractInstances(allLogs: EncryptedL2Log[], blockNum: number, operation: Operation) {
|
|
790
803
|
const contractInstances = ContractInstanceDeployedEvent.fromLogs(allLogs).map(e => e.toContractInstance());
|
|
791
804
|
if (contractInstances.length > 0) {
|
|
792
805
|
contractInstances.forEach(c =>
|
|
@@ -865,15 +878,18 @@ class ArchiverStoreHelper
|
|
|
865
878
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
866
879
|
...(await Promise.all(
|
|
867
880
|
blocks.map(async block => {
|
|
868
|
-
const
|
|
869
|
-
.flatMap(txEffect => (txEffect ? [txEffect.
|
|
881
|
+
const contractClassLogs = block.data.body.txEffects
|
|
882
|
+
.flatMap(txEffect => (txEffect ? [txEffect.contractClassLogs] : []))
|
|
883
|
+
.flatMap(txLog => txLog.unrollLogs());
|
|
884
|
+
// ContractInstanceDeployed event logs are now broadcast in .encryptedLogs
|
|
885
|
+
const allEncryptedLogs = block.data.body.txEffects
|
|
886
|
+
.flatMap(txEffect => (txEffect ? [txEffect.encryptedLogs] : []))
|
|
870
887
|
.flatMap(txLog => txLog.unrollLogs());
|
|
871
|
-
|
|
872
888
|
return (
|
|
873
889
|
await Promise.all([
|
|
874
|
-
this.#updateRegisteredContractClasses(
|
|
875
|
-
this.#updateDeployedContractInstances(
|
|
876
|
-
this.#storeBroadcastedIndividualFunctions(
|
|
890
|
+
this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Store),
|
|
891
|
+
this.#updateDeployedContractInstances(allEncryptedLogs, block.data.number, Operation.Store),
|
|
892
|
+
this.#storeBroadcastedIndividualFunctions(contractClassLogs, block.data.number),
|
|
877
893
|
])
|
|
878
894
|
).every(Boolean);
|
|
879
895
|
}),
|
|
@@ -895,11 +911,15 @@ class ArchiverStoreHelper
|
|
|
895
911
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
896
912
|
...(await Promise.all(
|
|
897
913
|
blocks.map(async block => {
|
|
898
|
-
const
|
|
899
|
-
.flatMap(txEffect => (txEffect ? [txEffect.
|
|
914
|
+
const contractClassLogs = block.data.body.txEffects
|
|
915
|
+
.flatMap(txEffect => (txEffect ? [txEffect.contractClassLogs] : []))
|
|
900
916
|
.flatMap(txLog => txLog.unrollLogs());
|
|
901
|
-
|
|
902
|
-
|
|
917
|
+
// ContractInstanceDeployed event logs are now broadcast in .encryptedLogs
|
|
918
|
+
const allEncryptedLogs = block.data.body.txEffects
|
|
919
|
+
.flatMap(txEffect => (txEffect ? [txEffect.encryptedLogs] : []))
|
|
920
|
+
.flatMap(txLog => txLog.unrollLogs());
|
|
921
|
+
await this.#updateRegisteredContractClasses(contractClassLogs, block.data.number, Operation.Delete);
|
|
922
|
+
await this.#updateDeployedContractInstances(allEncryptedLogs, block.data.number, Operation.Delete);
|
|
903
923
|
}),
|
|
904
924
|
)),
|
|
905
925
|
this.store.deleteLogs(blocks.map(b => b.data)),
|
|
@@ -925,8 +945,8 @@ class ArchiverStoreHelper
|
|
|
925
945
|
getL1ToL2Messages(blockNumber: bigint): Promise<Fr[]> {
|
|
926
946
|
return this.store.getL1ToL2Messages(blockNumber);
|
|
927
947
|
}
|
|
928
|
-
getL1ToL2MessageIndex(l1ToL2Message: Fr
|
|
929
|
-
return this.store.getL1ToL2MessageIndex(l1ToL2Message
|
|
948
|
+
getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint | undefined> {
|
|
949
|
+
return this.store.getL1ToL2MessageIndex(l1ToL2Message);
|
|
930
950
|
}
|
|
931
951
|
getLogs<TLogType extends LogType>(
|
|
932
952
|
from: number,
|
|
@@ -935,12 +955,15 @@ class ArchiverStoreHelper
|
|
|
935
955
|
): Promise<L2BlockL2Logs<FromLogType<TLogType>>[]> {
|
|
936
956
|
return this.store.getLogs(from, limit, logType);
|
|
937
957
|
}
|
|
938
|
-
getLogsByTags(tags: Fr[]): Promise<
|
|
958
|
+
getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]> {
|
|
939
959
|
return this.store.getLogsByTags(tags);
|
|
940
960
|
}
|
|
941
961
|
getUnencryptedLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
|
|
942
962
|
return this.store.getUnencryptedLogs(filter);
|
|
943
963
|
}
|
|
964
|
+
getContractClassLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse> {
|
|
965
|
+
return this.store.getContractClassLogs(filter);
|
|
966
|
+
}
|
|
944
967
|
getSynchedL2BlockNumber(): Promise<number> {
|
|
945
968
|
return this.store.getSynchedL2BlockNumber();
|
|
946
969
|
}
|
|
@@ -988,9 +1011,15 @@ class ArchiverStoreHelper
|
|
|
988
1011
|
type L1RollupConstants = {
|
|
989
1012
|
l1StartBlock: bigint;
|
|
990
1013
|
l1GenesisTime: bigint;
|
|
1014
|
+
slotDuration: number;
|
|
1015
|
+
epochDuration: number;
|
|
1016
|
+
ethereumSlotDuration: number;
|
|
991
1017
|
};
|
|
992
1018
|
|
|
993
1019
|
const EmptyL1RollupConstants: L1RollupConstants = {
|
|
994
1020
|
l1StartBlock: 0n,
|
|
995
1021
|
l1GenesisTime: 0n,
|
|
1022
|
+
epochDuration: 0,
|
|
1023
|
+
slotDuration: 0,
|
|
1024
|
+
ethereumSlotDuration: 0,
|
|
996
1025
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type EncryptedL2NoteLog,
|
|
3
2
|
type FromLogType,
|
|
4
3
|
type GetUnencryptedLogsResponse,
|
|
5
4
|
type InboxLeaf,
|
|
@@ -10,6 +9,7 @@ import {
|
|
|
10
9
|
type TxEffect,
|
|
11
10
|
type TxHash,
|
|
12
11
|
type TxReceipt,
|
|
12
|
+
type TxScopedL2Log,
|
|
13
13
|
} from '@aztec/circuit-types';
|
|
14
14
|
import {
|
|
15
15
|
type ContractClassPublic,
|
|
@@ -111,12 +111,11 @@ export interface ArchiverDataStore {
|
|
|
111
111
|
getL1ToL2Messages(blockNumber: bigint): Promise<Fr[]>;
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
* Gets the
|
|
114
|
+
* Gets the L1 to L2 message index in the L1 to L2 message tree.
|
|
115
115
|
* @param l1ToL2Message - The L1 to L2 message.
|
|
116
|
-
* @param startIndex - The index to start searching from.
|
|
117
116
|
* @returns The index of the L1 to L2 message in the L1 to L2 message tree (undefined if not found).
|
|
118
117
|
*/
|
|
119
|
-
getL1ToL2MessageIndex(l1ToL2Message: Fr
|
|
118
|
+
getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint | undefined>;
|
|
120
119
|
|
|
121
120
|
/**
|
|
122
121
|
* Get the total number of L1 to L2 messages
|
|
@@ -143,7 +142,7 @@ export interface ArchiverDataStore {
|
|
|
143
142
|
* @returns For each received tag, an array of matching logs is returned. An empty array implies no logs match
|
|
144
143
|
* that tag.
|
|
145
144
|
*/
|
|
146
|
-
getLogsByTags(tags: Fr[]): Promise<
|
|
145
|
+
getLogsByTags(tags: Fr[]): Promise<TxScopedL2Log[][]>;
|
|
147
146
|
|
|
148
147
|
/**
|
|
149
148
|
* Gets unencrypted logs based on the provided filter.
|
|
@@ -152,6 +151,13 @@ export interface ArchiverDataStore {
|
|
|
152
151
|
*/
|
|
153
152
|
getUnencryptedLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse>;
|
|
154
153
|
|
|
154
|
+
/**
|
|
155
|
+
* Gets contract class logs based on the provided filter.
|
|
156
|
+
* @param filter - The filter to apply to the logs.
|
|
157
|
+
* @returns The requested logs.
|
|
158
|
+
*/
|
|
159
|
+
getContractClassLogs(filter: LogFilter): Promise<GetUnencryptedLogsResponse>;
|
|
160
|
+
|
|
155
161
|
/**
|
|
156
162
|
* Gets the number of the latest L2 block processed.
|
|
157
163
|
* @returns The number of the latest L2 block processed.
|
|
@@ -257,20 +257,6 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
|
|
|
257
257
|
await store.getL1ToL2Messages(l2BlockNumber);
|
|
258
258
|
}).rejects.toThrow(`L1 to L2 message gap found in block ${l2BlockNumber}`);
|
|
259
259
|
});
|
|
260
|
-
|
|
261
|
-
it('correctly handles duplicate messages', async () => {
|
|
262
|
-
const messageHash = Fr.random();
|
|
263
|
-
const msgs = [new InboxLeaf(0n, messageHash), new InboxLeaf(16n, messageHash)];
|
|
264
|
-
|
|
265
|
-
await store.addL1ToL2Messages({ lastProcessedL1BlockNumber: 100n, retrievedData: msgs });
|
|
266
|
-
|
|
267
|
-
const index1 = (await store.getL1ToL2MessageIndex(messageHash, 0n))!;
|
|
268
|
-
expect(index1).toBe(0n);
|
|
269
|
-
const index2 = await store.getL1ToL2MessageIndex(messageHash, index1 + 1n);
|
|
270
|
-
expect(index2).toBeDefined();
|
|
271
|
-
expect(index2).toBeGreaterThan(index1);
|
|
272
|
-
expect(index2).toBe(16n);
|
|
273
|
-
});
|
|
274
260
|
});
|
|
275
261
|
|
|
276
262
|
describe('contractInstances', () => {
|
|
@@ -358,14 +344,24 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
|
|
|
358
344
|
describe('getLogsByTags', () => {
|
|
359
345
|
const txsPerBlock = 4;
|
|
360
346
|
const numPrivateFunctionCalls = 3;
|
|
361
|
-
const
|
|
347
|
+
const numPublicFunctionCalls = 1;
|
|
348
|
+
const numEncryptedLogsPerFn = 2;
|
|
349
|
+
const numUnencryptedLogsPerFn = 1;
|
|
362
350
|
const numBlocks = 10;
|
|
363
351
|
let blocks: L1Published<L2Block>[];
|
|
364
|
-
let
|
|
352
|
+
let encryptedLogTags: { [i: number]: { [j: number]: Buffer[] } } = {};
|
|
353
|
+
let unencryptedLogTags: { [i: number]: { [j: number]: Buffer[] } } = {};
|
|
365
354
|
|
|
366
355
|
beforeEach(async () => {
|
|
367
356
|
blocks = times(numBlocks, (index: number) => ({
|
|
368
|
-
data: L2Block.random(
|
|
357
|
+
data: L2Block.random(
|
|
358
|
+
index + 1,
|
|
359
|
+
txsPerBlock,
|
|
360
|
+
numPrivateFunctionCalls,
|
|
361
|
+
numPublicFunctionCalls,
|
|
362
|
+
numEncryptedLogsPerFn,
|
|
363
|
+
numUnencryptedLogsPerFn,
|
|
364
|
+
),
|
|
369
365
|
l1: { blockNumber: BigInt(index), blockHash: `0x${index}`, timestamp: BigInt(index) },
|
|
370
366
|
}));
|
|
371
367
|
// Last block has the note encrypted log tags of the first tx copied from the previous block
|
|
@@ -387,46 +383,94 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
|
|
|
387
383
|
await store.addBlocks(blocks);
|
|
388
384
|
await store.addLogs(blocks.map(b => b.data));
|
|
389
385
|
|
|
390
|
-
|
|
386
|
+
encryptedLogTags = {};
|
|
387
|
+
unencryptedLogTags = {};
|
|
391
388
|
blocks.forEach((b, blockIndex) => {
|
|
392
|
-
if (!
|
|
393
|
-
|
|
389
|
+
if (!encryptedLogTags[blockIndex]) {
|
|
390
|
+
encryptedLogTags[blockIndex] = {};
|
|
391
|
+
}
|
|
392
|
+
if (!unencryptedLogTags[blockIndex]) {
|
|
393
|
+
unencryptedLogTags[blockIndex] = {};
|
|
394
394
|
}
|
|
395
395
|
b.data.body.noteEncryptedLogs.txLogs.forEach((txLogs, txIndex) => {
|
|
396
|
-
if (!
|
|
397
|
-
|
|
396
|
+
if (!encryptedLogTags[blockIndex][txIndex]) {
|
|
397
|
+
encryptedLogTags[blockIndex][txIndex] = [];
|
|
398
|
+
}
|
|
399
|
+
encryptedLogTags[blockIndex][txIndex].push(...txLogs.unrollLogs().map(log => log.data.subarray(0, 32)));
|
|
400
|
+
});
|
|
401
|
+
b.data.body.unencryptedLogs.txLogs.forEach((txLogs, txIndex) => {
|
|
402
|
+
if (!unencryptedLogTags[blockIndex][txIndex]) {
|
|
403
|
+
unencryptedLogTags[blockIndex][txIndex] = [];
|
|
398
404
|
}
|
|
399
|
-
|
|
405
|
+
unencryptedLogTags[blockIndex][txIndex].push(...txLogs.unrollLogs().map(log => log.data.subarray(0, 32)));
|
|
400
406
|
});
|
|
401
407
|
});
|
|
402
408
|
});
|
|
403
409
|
|
|
404
|
-
it('is possible to batch request
|
|
410
|
+
it('is possible to batch request encrypted logs of a tx via tags', async () => {
|
|
405
411
|
// get random tx from any block that's not the last one
|
|
406
412
|
const targetBlockIndex = randomInt(numBlocks - 2);
|
|
407
413
|
const targetTxIndex = randomInt(txsPerBlock);
|
|
408
414
|
|
|
409
415
|
const logsByTags = await store.getLogsByTags(
|
|
410
|
-
|
|
416
|
+
encryptedLogTags[targetBlockIndex][targetTxIndex].map(buffer => new Fr(buffer)),
|
|
411
417
|
);
|
|
412
418
|
|
|
413
|
-
const expectedResponseSize = numPrivateFunctionCalls *
|
|
419
|
+
const expectedResponseSize = numPrivateFunctionCalls * numEncryptedLogsPerFn;
|
|
414
420
|
expect(logsByTags.length).toEqual(expectedResponseSize);
|
|
415
421
|
|
|
416
422
|
logsByTags.forEach((logsByTag, logIndex) => {
|
|
417
423
|
expect(logsByTag).toHaveLength(1);
|
|
418
|
-
const [
|
|
419
|
-
expect(
|
|
420
|
-
|
|
424
|
+
const [scopedLog] = logsByTag;
|
|
425
|
+
expect(scopedLog.txHash).toEqual(blocks[targetBlockIndex].data.body.txEffects[targetTxIndex].txHash);
|
|
426
|
+
expect(scopedLog.logData).toEqual(
|
|
427
|
+
blocks[targetBlockIndex].data.body.noteEncryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex].data,
|
|
421
428
|
);
|
|
422
429
|
});
|
|
423
430
|
});
|
|
424
431
|
|
|
425
|
-
|
|
432
|
+
// TODO: Allow this test when #9835 is fixed and tags can be correctly decoded
|
|
433
|
+
it.skip('is possible to batch request all logs (encrypted and unencrypted) of a tx via tags', async () => {
|
|
434
|
+
// get random tx from any block that's not the last one
|
|
435
|
+
const targetBlockIndex = randomInt(numBlocks - 2);
|
|
436
|
+
const targetTxIndex = randomInt(txsPerBlock);
|
|
437
|
+
|
|
438
|
+
const logsByTags = await store.getLogsByTags(
|
|
439
|
+
encryptedLogTags[targetBlockIndex][targetTxIndex]
|
|
440
|
+
.concat(unencryptedLogTags[targetBlockIndex][targetTxIndex])
|
|
441
|
+
.map(buffer => new Fr(buffer)),
|
|
442
|
+
);
|
|
443
|
+
|
|
444
|
+
const expectedResponseSize =
|
|
445
|
+
numPrivateFunctionCalls * numEncryptedLogsPerFn + numPublicFunctionCalls * numUnencryptedLogsPerFn;
|
|
446
|
+
expect(logsByTags.length).toEqual(expectedResponseSize);
|
|
447
|
+
|
|
448
|
+
const encryptedLogsByTags = logsByTags.slice(0, numPrivateFunctionCalls * numEncryptedLogsPerFn);
|
|
449
|
+
const unencryptedLogsByTags = logsByTags.slice(numPrivateFunctionCalls * numEncryptedLogsPerFn);
|
|
450
|
+
encryptedLogsByTags.forEach((logsByTag, logIndex) => {
|
|
451
|
+
expect(logsByTag).toHaveLength(1);
|
|
452
|
+
const [scopedLog] = logsByTag;
|
|
453
|
+
expect(scopedLog.txHash).toEqual(blocks[targetBlockIndex].data.body.txEffects[targetTxIndex].txHash);
|
|
454
|
+
expect(scopedLog.logData).toEqual(
|
|
455
|
+
blocks[targetBlockIndex].data.body.noteEncryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex].data,
|
|
456
|
+
);
|
|
457
|
+
});
|
|
458
|
+
unencryptedLogsByTags.forEach((logsByTag, logIndex) => {
|
|
459
|
+
expect(logsByTag).toHaveLength(1);
|
|
460
|
+
const [scopedLog] = logsByTag;
|
|
461
|
+
expect(scopedLog.logData).toEqual(
|
|
462
|
+
blocks[targetBlockIndex].data.body.unencryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex].data,
|
|
463
|
+
);
|
|
464
|
+
});
|
|
465
|
+
});
|
|
466
|
+
|
|
467
|
+
it('is possible to batch request logs of different blocks via tags', async () => {
|
|
426
468
|
// get first tx of first block and second tx of second block
|
|
427
|
-
const logsByTags = await store.getLogsByTags(
|
|
469
|
+
const logsByTags = await store.getLogsByTags(
|
|
470
|
+
[...encryptedLogTags[0][0], ...encryptedLogTags[1][1]].map(buffer => new Fr(buffer)),
|
|
471
|
+
);
|
|
428
472
|
|
|
429
|
-
const expectedResponseSize = 2 * numPrivateFunctionCalls *
|
|
473
|
+
const expectedResponseSize = 2 * numPrivateFunctionCalls * numEncryptedLogsPerFn;
|
|
430
474
|
expect(logsByTags.length).toEqual(expectedResponseSize);
|
|
431
475
|
|
|
432
476
|
logsByTags.forEach(logsByTag => expect(logsByTag).toHaveLength(1));
|
|
@@ -434,14 +478,14 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
|
|
|
434
478
|
|
|
435
479
|
it('is possible to batch request logs that have the same tag but different content', async () => {
|
|
436
480
|
// get first tx of last block
|
|
437
|
-
const logsByTags = await store.getLogsByTags(
|
|
481
|
+
const logsByTags = await store.getLogsByTags(encryptedLogTags[numBlocks - 1][0].map(buffer => new Fr(buffer)));
|
|
438
482
|
|
|
439
|
-
const expectedResponseSize = numPrivateFunctionCalls *
|
|
483
|
+
const expectedResponseSize = numPrivateFunctionCalls * numEncryptedLogsPerFn;
|
|
440
484
|
expect(logsByTags.length).toEqual(expectedResponseSize);
|
|
441
485
|
|
|
442
486
|
logsByTags.forEach(logsByTag => {
|
|
443
487
|
expect(logsByTag).toHaveLength(2);
|
|
444
|
-
const [tag0, tag1] = logsByTag.map(
|
|
488
|
+
const [tag0, tag1] = logsByTag.map(scopedLog => new Fr(scopedLog.logData.subarray(0, 32)));
|
|
445
489
|
expect(tag0).toEqual(tag1);
|
|
446
490
|
});
|
|
447
491
|
});
|
|
@@ -453,10 +497,10 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
|
|
|
453
497
|
|
|
454
498
|
const logsByTags = await store.getLogsByTags([
|
|
455
499
|
Fr.random(),
|
|
456
|
-
...
|
|
500
|
+
...encryptedLogTags[targetBlockIndex][targetTxIndex].slice(1).map(buffer => new Fr(buffer)),
|
|
457
501
|
]);
|
|
458
502
|
|
|
459
|
-
const expectedResponseSize = numPrivateFunctionCalls *
|
|
503
|
+
const expectedResponseSize = numPrivateFunctionCalls * numEncryptedLogsPerFn;
|
|
460
504
|
expect(logsByTags.length).toEqual(expectedResponseSize);
|
|
461
505
|
|
|
462
506
|
const [emptyLogsByTag, ...populatedLogsByTags] = logsByTags;
|
|
@@ -464,9 +508,10 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
|
|
|
464
508
|
|
|
465
509
|
populatedLogsByTags.forEach((logsByTag, logIndex) => {
|
|
466
510
|
expect(logsByTag).toHaveLength(1);
|
|
467
|
-
const [
|
|
468
|
-
expect(
|
|
469
|
-
|
|
511
|
+
const [scopedLog] = logsByTag;
|
|
512
|
+
expect(scopedLog.txHash).toEqual(blocks[targetBlockIndex].data.body.txEffects[targetTxIndex].txHash);
|
|
513
|
+
expect(scopedLog.logData).toEqual(
|
|
514
|
+
blocks[targetBlockIndex].data.body.noteEncryptedLogs.txLogs[targetTxIndex].unrollLogs()[logIndex + 1].data,
|
|
470
515
|
);
|
|
471
516
|
});
|
|
472
517
|
});
|
package/src/archiver/config.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type L1ContractAddresses,
|
|
3
|
+
type L1ContractsConfig,
|
|
4
|
+
type L1ReaderConfig,
|
|
5
|
+
l1ContractsConfigMappings,
|
|
6
|
+
l1ReaderConfigMappings,
|
|
7
|
+
} from '@aztec/ethereum';
|
|
2
8
|
import { type ConfigMappingsType, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
3
9
|
|
|
4
10
|
/**
|
|
@@ -32,14 +38,10 @@ export type ArchiverConfig = {
|
|
|
32
38
|
*/
|
|
33
39
|
l1Contracts: L1ContractAddresses;
|
|
34
40
|
|
|
35
|
-
/**
|
|
36
|
-
* Optional dir to store data. If omitted will store in memory.
|
|
37
|
-
*/
|
|
38
|
-
dataDirectory: string | undefined;
|
|
39
|
-
|
|
40
41
|
/** The max number of logs that can be obtained in 1 "getUnencryptedLogs" call. */
|
|
41
42
|
maxLogs?: number;
|
|
42
|
-
} & L1ReaderConfig
|
|
43
|
+
} & L1ReaderConfig &
|
|
44
|
+
L1ContractsConfig;
|
|
43
45
|
|
|
44
46
|
export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
45
47
|
archiverUrl: {
|
|
@@ -50,11 +52,7 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
50
52
|
archiverPollingIntervalMS: {
|
|
51
53
|
env: 'ARCHIVER_POLLING_INTERVAL_MS',
|
|
52
54
|
description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
|
|
53
|
-
...numberConfigHelper(
|
|
54
|
-
},
|
|
55
|
-
dataDirectory: {
|
|
56
|
-
env: 'DATA_DIRECTORY',
|
|
57
|
-
description: 'Optional dir to store data. If omitted will store in memory.',
|
|
55
|
+
...numberConfigHelper(1_000),
|
|
58
56
|
},
|
|
59
57
|
maxLogs: {
|
|
60
58
|
env: 'ARCHIVER_MAX_LOGS',
|
|
@@ -67,6 +65,7 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
67
65
|
description: 'The polling interval viem uses in ms',
|
|
68
66
|
...numberConfigHelper(1000),
|
|
69
67
|
},
|
|
68
|
+
...l1ContractsConfigMappings,
|
|
70
69
|
};
|
|
71
70
|
|
|
72
71
|
/**
|