@aztec/archiver 0.31.0 → 0.32.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 +11 -11
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +4 -5
- package/dest/archiver/archiver_store.d.ts +7 -7
- package/dest/archiver/archiver_store.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts +1 -1
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +5 -5
- package/dest/archiver/config.d.ts +1 -1
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.d.ts +4 -4
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/eth_log_handlers.d.ts +2 -2
- package/dest/archiver/eth_log_handlers.d.ts.map +1 -1
- package/dest/archiver/eth_log_handlers.js +1 -1
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts +1 -1
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts +5 -5
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +2 -2
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +3 -3
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +9 -9
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +1 -1
- package/dest/archiver/kv_archiver_store/log_store.d.ts +5 -5
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +7 -5
- package/dest/archiver/kv_archiver_store/message_store.d.ts +3 -3
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +2 -2
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +7 -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 +4 -4
- package/dest/rpc/archiver_client.d.ts +1 -1
- package/dest/rpc/archiver_client.d.ts.map +1 -1
- package/dest/rpc/archiver_client.js +4 -3
- package/dest/rpc/archiver_server.d.ts +1 -1
- package/dest/rpc/archiver_server.d.ts.map +1 -1
- package/dest/rpc/archiver_server.js +4 -3
- package/package.json +9 -9
- package/src/archiver/archiver.ts +33 -29
- package/src/archiver/archiver_store.ts +27 -20
- package/src/archiver/archiver_store_test_suite.ts +12 -10
- package/src/archiver/config.ts +1 -1
- package/src/archiver/data_retrieval.ts +4 -4
- package/src/archiver/eth_log_handlers.ts +2 -2
- package/src/archiver/kv_archiver_store/block_body_store.ts +1 -1
- package/src/archiver/kv_archiver_store/block_store.ts +5 -5
- package/src/archiver/kv_archiver_store/contract_class_store.ts +4 -4
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +3 -3
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +29 -22
- package/src/archiver/kv_archiver_store/log_store.ts +29 -16
- package/src/archiver/kv_archiver_store/message_store.ts +3 -3
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +2 -2
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +34 -22
- package/src/rpc/archiver_client.ts +6 -4
- package/src/rpc/archiver_server.ts +5 -3
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Body,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
type Body,
|
|
3
|
+
type EncryptedL2BlockL2Logs,
|
|
4
|
+
type FromLogType,
|
|
5
|
+
type GetUnencryptedLogsResponse,
|
|
6
|
+
type InboxLeaf,
|
|
7
|
+
type L2Block,
|
|
8
|
+
type L2BlockL2Logs,
|
|
9
|
+
type LogFilter,
|
|
10
|
+
type LogType,
|
|
11
|
+
type TxEffect,
|
|
12
|
+
type TxHash,
|
|
13
|
+
type TxReceipt,
|
|
14
|
+
type UnencryptedL2BlockL2Logs,
|
|
12
15
|
} from '@aztec/circuit-types';
|
|
13
|
-
import { Fr } from '@aztec/circuits.js';
|
|
14
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
16
|
+
import { type Fr } from '@aztec/circuits.js';
|
|
17
|
+
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
15
18
|
import {
|
|
16
|
-
ContractClassPublic,
|
|
17
|
-
ContractInstanceWithAddress,
|
|
18
|
-
ExecutablePrivateFunctionWithMembershipProof,
|
|
19
|
-
UnconstrainedFunctionWithMembershipProof,
|
|
19
|
+
type ContractClassPublic,
|
|
20
|
+
type ContractInstanceWithAddress,
|
|
21
|
+
type ExecutablePrivateFunctionWithMembershipProof,
|
|
22
|
+
type UnconstrainedFunctionWithMembershipProof,
|
|
20
23
|
} from '@aztec/types/contracts';
|
|
21
24
|
|
|
22
|
-
import { DataRetrieval } from './data_retrieval.js';
|
|
25
|
+
import { type DataRetrieval } from './data_retrieval.js';
|
|
23
26
|
|
|
24
27
|
/**
|
|
25
28
|
* Represents the latest L1 block processed by the archiver for various objects in L2.
|
|
@@ -88,8 +91,8 @@ export interface ArchiverDataStore {
|
|
|
88
91
|
* @returns True if the operation is successful.
|
|
89
92
|
*/
|
|
90
93
|
addLogs(
|
|
91
|
-
encryptedLogs:
|
|
92
|
-
unencryptedLogs:
|
|
94
|
+
encryptedLogs: EncryptedL2BlockL2Logs | undefined,
|
|
95
|
+
unencryptedLogs: UnencryptedL2BlockL2Logs | undefined,
|
|
93
96
|
blockNumber: number,
|
|
94
97
|
): Promise<boolean>;
|
|
95
98
|
|
|
@@ -122,7 +125,11 @@ export interface ArchiverDataStore {
|
|
|
122
125
|
* @param logType - Specifies whether to return encrypted or unencrypted logs.
|
|
123
126
|
* @returns The requested logs.
|
|
124
127
|
*/
|
|
125
|
-
getLogs
|
|
128
|
+
getLogs<TLogType extends LogType>(
|
|
129
|
+
from: number,
|
|
130
|
+
limit: number,
|
|
131
|
+
logType: TLogType,
|
|
132
|
+
): Promise<L2BlockL2Logs<FromLogType<TLogType>>[]>;
|
|
126
133
|
|
|
127
134
|
/**
|
|
128
135
|
* Gets unencrypted logs based on the provided filter.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InboxLeaf, L2Block, L2BlockContext, LogId, LogType, TxHash
|
|
1
|
+
import { InboxLeaf, L2Block, L2BlockContext, LogId, LogType, TxHash } from '@aztec/circuit-types';
|
|
2
2
|
import '@aztec/circuit-types/jest';
|
|
3
3
|
import { AztecAddress, Fr, INITIAL_L2_BLOCK_NUM, L1_TO_L2_MSG_SUBTREE_HEIGHT } from '@aztec/circuits.js';
|
|
4
4
|
import {
|
|
@@ -8,10 +8,14 @@ import {
|
|
|
8
8
|
} from '@aztec/circuits.js/testing';
|
|
9
9
|
import { times } from '@aztec/foundation/collection';
|
|
10
10
|
import { randomBytes, randomInt } from '@aztec/foundation/crypto';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
type ContractClassPublic,
|
|
13
|
+
type ContractInstanceWithAddress,
|
|
14
|
+
SerializableContractInstance,
|
|
15
|
+
} from '@aztec/types/contracts';
|
|
12
16
|
|
|
13
|
-
import { ArchiverDataStore } from './archiver_store.js';
|
|
14
|
-
import { DataRetrieval } from './data_retrieval.js';
|
|
17
|
+
import { type ArchiverDataStore } from './archiver_store.js';
|
|
18
|
+
import { type DataRetrieval } from './data_retrieval.js';
|
|
15
19
|
|
|
16
20
|
/**
|
|
17
21
|
* @param testName - The name of the test suite.
|
|
@@ -367,11 +371,10 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
|
|
|
367
371
|
const targetTxIndex = randomInt(txsPerBlock);
|
|
368
372
|
const targetFunctionLogIndex = randomInt(numPublicFunctionCalls);
|
|
369
373
|
const targetLogIndex = randomInt(numUnencryptedLogs);
|
|
370
|
-
const targetContractAddress =
|
|
374
|
+
const targetContractAddress =
|
|
371
375
|
blocks.retrievedData[targetBlockIndex].body.txEffects[targetTxIndex].unencryptedLogs.functionLogs[
|
|
372
376
|
targetFunctionLogIndex
|
|
373
|
-
].logs[targetLogIndex]
|
|
374
|
-
).contractAddress;
|
|
377
|
+
].logs[targetLogIndex].contractAddress;
|
|
375
378
|
|
|
376
379
|
const response = await store.getUnencryptedLogs({ contractAddress: targetContractAddress });
|
|
377
380
|
|
|
@@ -388,11 +391,10 @@ export function describeArchiverDataStore(testName: string, getStore: () => Arch
|
|
|
388
391
|
const targetTxIndex = randomInt(txsPerBlock);
|
|
389
392
|
const targetFunctionLogIndex = randomInt(numPublicFunctionCalls);
|
|
390
393
|
const targetLogIndex = randomInt(numUnencryptedLogs);
|
|
391
|
-
const targetSelector =
|
|
394
|
+
const targetSelector =
|
|
392
395
|
blocks.retrievedData[targetBlockIndex].body.txEffects[targetTxIndex].unencryptedLogs.functionLogs[
|
|
393
396
|
targetFunctionLogIndex
|
|
394
|
-
].logs[targetLogIndex]
|
|
395
|
-
).selector;
|
|
397
|
+
].logs[targetLogIndex].selector;
|
|
396
398
|
|
|
397
399
|
const response = await store.getUnencryptedLogs({ selector: targetSelector });
|
|
398
400
|
|
package/src/archiver/config.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Body, InboxLeaf } from '@aztec/circuit-types';
|
|
2
|
-
import { AppendOnlyTreeSnapshot, Header } from '@aztec/circuits.js';
|
|
3
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
1
|
+
import { type Body, type InboxLeaf } from '@aztec/circuit-types';
|
|
2
|
+
import { type AppendOnlyTreeSnapshot, type Header } from '@aztec/circuits.js';
|
|
3
|
+
import { type EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
|
|
5
|
-
import { PublicClient } from 'viem';
|
|
5
|
+
import { type PublicClient } from 'viem';
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
getL2BlockProcessedLogs,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Body, InboxLeaf } from '@aztec/circuit-types';
|
|
2
2
|
import { AppendOnlyTreeSnapshot, Header } from '@aztec/circuits.js';
|
|
3
|
-
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
3
|
+
import { type EthAddress } from '@aztec/foundation/eth-address';
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { numToUInt32BE } from '@aztec/foundation/serialize';
|
|
6
6
|
import { AvailabilityOracleAbi, InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
7
7
|
|
|
8
|
-
import { Hex, Log, PublicClient, decodeFunctionData, getAbiItem, getAddress, hexToBytes } from 'viem';
|
|
8
|
+
import { type Hex, type Log, type PublicClient, decodeFunctionData, getAbiItem, getAddress, hexToBytes } from 'viem';
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Processes newly received MessageSent (L1 to L2) logs.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { L2Block, TxEffect, TxHash, TxReceipt, TxStatus } from '@aztec/circuit-types';
|
|
2
|
-
import { AppendOnlyTreeSnapshot, AztecAddress, Header, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
|
|
1
|
+
import { L2Block, type TxEffect, type TxHash, TxReceipt, TxStatus } from '@aztec/circuit-types';
|
|
2
|
+
import { AppendOnlyTreeSnapshot, type AztecAddress, Header, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
|
|
3
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
|
-
import { AztecKVStore, AztecMap, AztecSingleton, Range } from '@aztec/kv-store';
|
|
4
|
+
import { type AztecKVStore, type AztecMap, type AztecSingleton, type Range } from '@aztec/kv-store';
|
|
5
5
|
|
|
6
|
-
import { DataRetrieval } from '../data_retrieval.js';
|
|
7
|
-
import { BlockBodyStore } from './block_body_store.js';
|
|
6
|
+
import { type DataRetrieval } from '../data_retrieval.js';
|
|
7
|
+
import { type BlockBodyStore } from './block_body_store.js';
|
|
8
8
|
|
|
9
9
|
type BlockIndexValue = [blockNumber: number, index: number];
|
|
10
10
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { Fr, FunctionSelector, Vector } from '@aztec/circuits.js';
|
|
2
2
|
import { BufferReader, numToUInt8, serializeToBuffer } from '@aztec/foundation/serialize';
|
|
3
|
-
import { AztecKVStore, AztecMap } from '@aztec/kv-store';
|
|
3
|
+
import { type AztecKVStore, type AztecMap } from '@aztec/kv-store';
|
|
4
4
|
import {
|
|
5
|
-
ContractClassPublic,
|
|
6
|
-
ExecutablePrivateFunctionWithMembershipProof,
|
|
7
|
-
UnconstrainedFunctionWithMembershipProof,
|
|
5
|
+
type ContractClassPublic,
|
|
6
|
+
type ExecutablePrivateFunctionWithMembershipProof,
|
|
7
|
+
type UnconstrainedFunctionWithMembershipProof,
|
|
8
8
|
} from '@aztec/types/contracts';
|
|
9
9
|
|
|
10
10
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AztecAddress } from '@aztec/circuits.js';
|
|
2
|
-
import { AztecKVStore, AztecMap } from '@aztec/kv-store';
|
|
3
|
-
import { ContractInstanceWithAddress, SerializableContractInstance } from '@aztec/types/contracts';
|
|
1
|
+
import { type AztecAddress } from '@aztec/circuits.js';
|
|
2
|
+
import { type AztecKVStore, type AztecMap } from '@aztec/kv-store';
|
|
3
|
+
import { type ContractInstanceWithAddress, SerializableContractInstance } from '@aztec/types/contracts';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* LMDB implementation of the ArchiverDataStore interface.
|
|
@@ -1,28 +1,31 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Body,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
2
|
+
type Body,
|
|
3
|
+
type EncryptedL2BlockL2Logs,
|
|
4
|
+
type FromLogType,
|
|
5
|
+
type GetUnencryptedLogsResponse,
|
|
6
|
+
type InboxLeaf,
|
|
7
|
+
type L2Block,
|
|
8
|
+
type L2BlockL2Logs,
|
|
9
|
+
type LogFilter,
|
|
10
|
+
type LogType,
|
|
11
|
+
type TxEffect,
|
|
12
|
+
type TxHash,
|
|
13
|
+
type TxReceipt,
|
|
14
|
+
type UnencryptedL2BlockL2Logs,
|
|
12
15
|
} from '@aztec/circuit-types';
|
|
13
|
-
import { Fr } from '@aztec/circuits.js';
|
|
14
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
16
|
+
import { type Fr } from '@aztec/circuits.js';
|
|
17
|
+
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
15
18
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
16
|
-
import { AztecKVStore } from '@aztec/kv-store';
|
|
19
|
+
import { type AztecKVStore } from '@aztec/kv-store';
|
|
17
20
|
import {
|
|
18
|
-
ContractClassPublic,
|
|
19
|
-
ContractInstanceWithAddress,
|
|
20
|
-
ExecutablePrivateFunctionWithMembershipProof,
|
|
21
|
-
UnconstrainedFunctionWithMembershipProof,
|
|
21
|
+
type ContractClassPublic,
|
|
22
|
+
type ContractInstanceWithAddress,
|
|
23
|
+
type ExecutablePrivateFunctionWithMembershipProof,
|
|
24
|
+
type UnconstrainedFunctionWithMembershipProof,
|
|
22
25
|
} from '@aztec/types/contracts';
|
|
23
26
|
|
|
24
|
-
import { ArchiverDataStore, ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
25
|
-
import { DataRetrieval } from '../data_retrieval.js';
|
|
27
|
+
import { type ArchiverDataStore, type ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
28
|
+
import { type DataRetrieval } from '../data_retrieval.js';
|
|
26
29
|
import { BlockBodyStore } from './block_body_store.js';
|
|
27
30
|
import { BlockStore } from './block_store.js';
|
|
28
31
|
import { ContractClassStore } from './contract_class_store.js';
|
|
@@ -150,8 +153,8 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
150
153
|
* @returns True if the operation is successful.
|
|
151
154
|
*/
|
|
152
155
|
addLogs(
|
|
153
|
-
encryptedLogs:
|
|
154
|
-
unencryptedLogs:
|
|
156
|
+
encryptedLogs: EncryptedL2BlockL2Logs | undefined,
|
|
157
|
+
unencryptedLogs: UnencryptedL2BlockL2Logs | undefined,
|
|
155
158
|
blockNumber: number,
|
|
156
159
|
): Promise<boolean> {
|
|
157
160
|
return this.#logStore.addLogs(encryptedLogs, unencryptedLogs, blockNumber);
|
|
@@ -196,7 +199,11 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
196
199
|
* @param logType - Specifies whether to return encrypted or unencrypted logs.
|
|
197
200
|
* @returns The requested logs.
|
|
198
201
|
*/
|
|
199
|
-
getLogs
|
|
202
|
+
getLogs<TLogType extends LogType>(
|
|
203
|
+
start: number,
|
|
204
|
+
limit: number,
|
|
205
|
+
logType: TLogType,
|
|
206
|
+
): Promise<L2BlockL2Logs<FromLogType<TLogType>>[]> {
|
|
200
207
|
try {
|
|
201
208
|
return Promise.resolve(Array.from(this.#logStore.getLogs(start, limit, logType)));
|
|
202
209
|
} catch (err) {
|
|
@@ -1,17 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EncryptedL2BlockL2Logs,
|
|
2
3
|
ExtendedUnencryptedL2Log,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type FromLogType,
|
|
5
|
+
type GetUnencryptedLogsResponse,
|
|
6
|
+
type L2BlockL2Logs,
|
|
7
|
+
type LogFilter,
|
|
6
8
|
LogId,
|
|
7
9
|
LogType,
|
|
8
|
-
|
|
10
|
+
UnencryptedL2BlockL2Logs,
|
|
11
|
+
type UnencryptedL2Log,
|
|
9
12
|
} from '@aztec/circuit-types';
|
|
10
13
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js/constants';
|
|
11
14
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
12
|
-
import { AztecKVStore, AztecMap } from '@aztec/kv-store';
|
|
15
|
+
import { type AztecKVStore, type AztecMap } from '@aztec/kv-store';
|
|
13
16
|
|
|
14
|
-
import { BlockStore } from './block_store.js';
|
|
17
|
+
import { type BlockStore } from './block_store.js';
|
|
15
18
|
|
|
16
19
|
/**
|
|
17
20
|
* A store for logs
|
|
@@ -37,8 +40,8 @@ export class LogStore {
|
|
|
37
40
|
* @returns True if the operation is successful.
|
|
38
41
|
*/
|
|
39
42
|
addLogs(
|
|
40
|
-
encryptedLogs:
|
|
41
|
-
unencryptedLogs:
|
|
43
|
+
encryptedLogs: EncryptedL2BlockL2Logs | undefined,
|
|
44
|
+
unencryptedLogs: UnencryptedL2BlockL2Logs | undefined,
|
|
42
45
|
blockNumber: number,
|
|
43
46
|
): Promise<boolean> {
|
|
44
47
|
return this.db.transaction(() => {
|
|
@@ -61,10 +64,15 @@ export class LogStore {
|
|
|
61
64
|
* @param logType - Specifies whether to return encrypted or unencrypted logs.
|
|
62
65
|
* @returns The requested logs.
|
|
63
66
|
*/
|
|
64
|
-
*getLogs
|
|
67
|
+
*getLogs<TLogType extends LogType>(
|
|
68
|
+
start: number,
|
|
69
|
+
limit: number,
|
|
70
|
+
logType: TLogType,
|
|
71
|
+
): IterableIterator<L2BlockL2Logs<FromLogType<TLogType>>> {
|
|
65
72
|
const logMap = logType === LogType.ENCRYPTED ? this.#encryptedLogs : this.#unencryptedLogs;
|
|
73
|
+
const L2BlockL2Logs = logType === LogType.ENCRYPTED ? EncryptedL2BlockL2Logs : UnencryptedL2BlockL2Logs;
|
|
66
74
|
for (const buffer of logMap.values({ start, limit })) {
|
|
67
|
-
yield L2BlockL2Logs.fromBuffer(buffer)
|
|
75
|
+
yield L2BlockL2Logs.fromBuffer(buffer) as L2BlockL2Logs<FromLogType<TLogType>>;
|
|
68
76
|
}
|
|
69
77
|
}
|
|
70
78
|
|
|
@@ -94,7 +102,7 @@ export class LogStore {
|
|
|
94
102
|
}
|
|
95
103
|
|
|
96
104
|
const unencryptedLogsInBlock = this.#getBlockLogs(blockNumber, LogType.UNENCRYPTED);
|
|
97
|
-
const txLogs = unencryptedLogsInBlock.txLogs[txIndex].unrollLogs()
|
|
105
|
+
const txLogs = unencryptedLogsInBlock.txLogs[txIndex].unrollLogs();
|
|
98
106
|
|
|
99
107
|
const logs: ExtendedUnencryptedL2Log[] = [];
|
|
100
108
|
const maxLogsHit = this.#accumulateLogs(logs, blockNumber, txIndex, txLogs, filter);
|
|
@@ -118,9 +126,9 @@ export class LogStore {
|
|
|
118
126
|
|
|
119
127
|
let maxLogsHit = false;
|
|
120
128
|
loopOverBlocks: for (const [blockNumber, logBuffer] of this.#unencryptedLogs.entries({ start, end })) {
|
|
121
|
-
const unencryptedLogsInBlock =
|
|
129
|
+
const unencryptedLogsInBlock = UnencryptedL2BlockL2Logs.fromBuffer(logBuffer);
|
|
122
130
|
for (let txIndex = filter.afterLog?.txIndex ?? 0; txIndex < unencryptedLogsInBlock.txLogs.length; txIndex++) {
|
|
123
|
-
const txLogs = unencryptedLogsInBlock.txLogs[txIndex].unrollLogs()
|
|
131
|
+
const txLogs = unencryptedLogsInBlock.txLogs[txIndex].unrollLogs();
|
|
124
132
|
maxLogsHit = this.#accumulateLogs(logs, blockNumber, txIndex, txLogs, filter);
|
|
125
133
|
if (maxLogsHit) {
|
|
126
134
|
this.#log(`Max logs hit at block ${blockNumber}`);
|
|
@@ -161,14 +169,19 @@ export class LogStore {
|
|
|
161
169
|
return maxLogsHit;
|
|
162
170
|
}
|
|
163
171
|
|
|
164
|
-
#getBlockLogs
|
|
172
|
+
#getBlockLogs<TLogType extends LogType>(
|
|
173
|
+
blockNumber: number,
|
|
174
|
+
logType: TLogType,
|
|
175
|
+
): L2BlockL2Logs<FromLogType<TLogType>> {
|
|
165
176
|
const logMap = logType === LogType.ENCRYPTED ? this.#encryptedLogs : this.#unencryptedLogs;
|
|
177
|
+
const L2BlockL2Logs: typeof EncryptedL2BlockL2Logs | typeof UnencryptedL2BlockL2Logs =
|
|
178
|
+
logType === LogType.ENCRYPTED ? EncryptedL2BlockL2Logs : UnencryptedL2BlockL2Logs;
|
|
166
179
|
const buffer = logMap.get(blockNumber);
|
|
167
180
|
|
|
168
181
|
if (!buffer) {
|
|
169
|
-
return new L2BlockL2Logs([])
|
|
182
|
+
return new L2BlockL2Logs([]) as L2BlockL2Logs<FromLogType<TLogType>>;
|
|
170
183
|
}
|
|
171
184
|
|
|
172
|
-
return L2BlockL2Logs.fromBuffer(buffer)
|
|
185
|
+
return L2BlockL2Logs.fromBuffer(buffer) as L2BlockL2Logs<FromLogType<TLogType>>;
|
|
173
186
|
}
|
|
174
187
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { InboxLeaf } from '@aztec/circuit-types';
|
|
1
|
+
import { type InboxLeaf } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
3
|
Fr,
|
|
4
4
|
INITIAL_L2_BLOCK_NUM,
|
|
@@ -6,9 +6,9 @@ import {
|
|
|
6
6
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
7
7
|
} from '@aztec/circuits.js';
|
|
8
8
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
9
|
-
import { AztecKVStore, AztecMap, AztecSingleton } from '@aztec/kv-store';
|
|
9
|
+
import { type AztecKVStore, type AztecMap, type AztecSingleton } from '@aztec/kv-store';
|
|
10
10
|
|
|
11
|
-
import { DataRetrieval } from '../data_retrieval.js';
|
|
11
|
+
import { type DataRetrieval } from '../data_retrieval.js';
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* LMDB implementation of the ArchiverDataStore interface.
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { InboxLeaf } from '@aztec/circuit-types';
|
|
1
|
+
import { type InboxLeaf } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
3
|
INITIAL_L2_BLOCK_NUM,
|
|
4
4
|
L1_TO_L2_MSG_SUBTREE_HEIGHT,
|
|
5
5
|
NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP,
|
|
6
6
|
} from '@aztec/circuits.js/constants';
|
|
7
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
7
|
+
import { type Fr } from '@aztec/foundation/fields';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* A simple in-memory implementation of an L1 to L2 message store.
|
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import {
|
|
2
|
-
Body,
|
|
2
|
+
type Body,
|
|
3
|
+
type EncryptedL2BlockL2Logs,
|
|
3
4
|
ExtendedUnencryptedL2Log,
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
type FromLogType,
|
|
6
|
+
type GetUnencryptedLogsResponse,
|
|
7
|
+
type InboxLeaf,
|
|
8
|
+
type L2Block,
|
|
7
9
|
L2BlockContext,
|
|
8
|
-
L2BlockL2Logs,
|
|
9
|
-
LogFilter,
|
|
10
|
+
type L2BlockL2Logs,
|
|
11
|
+
type LogFilter,
|
|
10
12
|
LogId,
|
|
11
13
|
LogType,
|
|
12
|
-
TxEffect,
|
|
13
|
-
TxHash,
|
|
14
|
+
type TxEffect,
|
|
15
|
+
type TxHash,
|
|
14
16
|
TxReceipt,
|
|
15
17
|
TxStatus,
|
|
16
|
-
|
|
18
|
+
type UnencryptedL2BlockL2Logs,
|
|
17
19
|
} from '@aztec/circuit-types';
|
|
18
20
|
import { Fr, INITIAL_L2_BLOCK_NUM } from '@aztec/circuits.js';
|
|
19
|
-
import { AztecAddress } from '@aztec/foundation/aztec-address';
|
|
21
|
+
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
20
22
|
import {
|
|
21
|
-
ContractClassPublic,
|
|
22
|
-
ContractInstanceWithAddress,
|
|
23
|
-
ExecutablePrivateFunctionWithMembershipProof,
|
|
24
|
-
UnconstrainedFunctionWithMembershipProof,
|
|
23
|
+
type ContractClassPublic,
|
|
24
|
+
type ContractInstanceWithAddress,
|
|
25
|
+
type ExecutablePrivateFunctionWithMembershipProof,
|
|
26
|
+
type UnconstrainedFunctionWithMembershipProof,
|
|
25
27
|
} from '@aztec/types/contracts';
|
|
26
28
|
|
|
27
|
-
import { ArchiverDataStore, ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
28
|
-
import { DataRetrieval } from '../data_retrieval.js';
|
|
29
|
+
import { type ArchiverDataStore, type ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
30
|
+
import { type DataRetrieval } from '../data_retrieval.js';
|
|
29
31
|
import { L1ToL2MessageStore } from './l1_to_l2_message_store.js';
|
|
30
32
|
|
|
31
33
|
/**
|
|
@@ -51,13 +53,13 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
51
53
|
* An array containing all the encrypted logs that have been fetched so far.
|
|
52
54
|
* Note: Index in the "outer" array equals to (corresponding L2 block's number - INITIAL_L2_BLOCK_NUM).
|
|
53
55
|
*/
|
|
54
|
-
private encryptedLogsPerBlock:
|
|
56
|
+
private encryptedLogsPerBlock: EncryptedL2BlockL2Logs[] = [];
|
|
55
57
|
|
|
56
58
|
/**
|
|
57
59
|
* An array containing all the unencrypted logs that have been fetched so far.
|
|
58
60
|
* Note: Index in the "outer" array equals to (corresponding L2 block's number - INITIAL_L2_BLOCK_NUM).
|
|
59
61
|
*/
|
|
60
|
-
private unencryptedLogsPerBlock:
|
|
62
|
+
private unencryptedLogsPerBlock: UnencryptedL2BlockL2Logs[] = [];
|
|
61
63
|
|
|
62
64
|
/**
|
|
63
65
|
* Contains all L1 to L2 messages.
|
|
@@ -183,7 +185,11 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
183
185
|
* @param blockNumber - The block for which to add the logs.
|
|
184
186
|
* @returns True if the operation is successful.
|
|
185
187
|
*/
|
|
186
|
-
addLogs(
|
|
188
|
+
addLogs(
|
|
189
|
+
encryptedLogs: EncryptedL2BlockL2Logs,
|
|
190
|
+
unencryptedLogs: UnencryptedL2BlockL2Logs,
|
|
191
|
+
blockNumber: number,
|
|
192
|
+
): Promise<boolean> {
|
|
187
193
|
if (encryptedLogs) {
|
|
188
194
|
this.encryptedLogsPerBlock[blockNumber - INITIAL_L2_BLOCK_NUM] = encryptedLogs;
|
|
189
195
|
}
|
|
@@ -288,11 +294,17 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
288
294
|
* @param logType - Specifies whether to return encrypted or unencrypted logs.
|
|
289
295
|
* @returns The requested logs.
|
|
290
296
|
*/
|
|
291
|
-
getLogs
|
|
297
|
+
getLogs<TLogType extends LogType>(
|
|
298
|
+
from: number,
|
|
299
|
+
limit: number,
|
|
300
|
+
logType: TLogType,
|
|
301
|
+
): Promise<L2BlockL2Logs<FromLogType<TLogType>>[]> {
|
|
292
302
|
if (from < INITIAL_L2_BLOCK_NUM || limit < 1) {
|
|
293
303
|
throw new Error(`Invalid limit: ${limit}`);
|
|
294
304
|
}
|
|
295
|
-
const logs =
|
|
305
|
+
const logs = (
|
|
306
|
+
logType === LogType.ENCRYPTED ? this.encryptedLogsPerBlock : this.unencryptedLogsPerBlock
|
|
307
|
+
) as L2BlockL2Logs<FromLogType<TLogType>>[];
|
|
296
308
|
if (from > logs.length) {
|
|
297
309
|
return Promise.resolve([]);
|
|
298
310
|
}
|
|
@@ -355,7 +367,7 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
355
367
|
const blockContext = this.l2BlockContexts[fromBlockIndex];
|
|
356
368
|
const blockLogs = this.unencryptedLogsPerBlock[fromBlockIndex];
|
|
357
369
|
for (; txIndexInBlock < blockLogs.txLogs.length; txIndexInBlock++) {
|
|
358
|
-
const txLogs = blockLogs.txLogs[txIndexInBlock].unrollLogs()
|
|
370
|
+
const txLogs = blockLogs.txLogs[txIndexInBlock].unrollLogs();
|
|
359
371
|
for (; logIndexInTx < txLogs.length; logIndexInTx++) {
|
|
360
372
|
const log = txLogs[logIndexInTx];
|
|
361
373
|
if (
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EncryptedL2BlockL2Logs,
|
|
2
3
|
ExtendedUnencryptedL2Log,
|
|
3
4
|
L2Block,
|
|
4
|
-
L2BlockL2Logs,
|
|
5
5
|
NullifierMembershipWitness,
|
|
6
6
|
TxReceipt,
|
|
7
|
+
UnencryptedL2BlockL2Logs,
|
|
7
8
|
} from '@aztec/circuit-types';
|
|
8
9
|
import { EthAddress, Fr } from '@aztec/circuits.js';
|
|
9
10
|
import { createJsonRpcClient, makeFetch } from '@aztec/foundation/json-rpc/client';
|
|
10
11
|
|
|
11
|
-
import { ArchiveSource } from '../archiver/archiver.js';
|
|
12
|
+
import { type ArchiveSource } from '../archiver/archiver.js';
|
|
12
13
|
|
|
13
14
|
export const createArchiverClient = (url: string, fetch = makeFetch([1, 2, 3], true)): ArchiveSource =>
|
|
14
15
|
createJsonRpcClient<ArchiveSource>(
|
|
@@ -18,10 +19,11 @@ export const createArchiverClient = (url: string, fetch = makeFetch([1, 2, 3], t
|
|
|
18
19
|
ExtendedUnencryptedL2Log,
|
|
19
20
|
Fr,
|
|
20
21
|
L2Block,
|
|
21
|
-
|
|
22
|
+
EncryptedL2BlockL2Logs,
|
|
23
|
+
UnencryptedL2BlockL2Logs,
|
|
22
24
|
},
|
|
23
25
|
{ TxReceipt, NullifierMembershipWitness },
|
|
24
26
|
false,
|
|
25
27
|
'archiver',
|
|
26
28
|
fetch,
|
|
27
|
-
);
|
|
29
|
+
) as ArchiveSource;
|
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EncryptedL2BlockL2Logs,
|
|
2
3
|
ExtendedUnencryptedL2Log,
|
|
3
4
|
L2Block,
|
|
4
|
-
L2BlockL2Logs,
|
|
5
5
|
NullifierMembershipWitness,
|
|
6
6
|
TxEffect,
|
|
7
7
|
TxReceipt,
|
|
8
|
+
UnencryptedL2BlockL2Logs,
|
|
8
9
|
} from '@aztec/circuit-types';
|
|
9
10
|
import { EthAddress, Fr } from '@aztec/circuits.js';
|
|
10
11
|
import { JsonRpcServer } from '@aztec/foundation/json-rpc/server';
|
|
11
12
|
|
|
12
|
-
import { Archiver } from '../archiver/archiver.js';
|
|
13
|
+
import { type Archiver } from '../archiver/archiver.js';
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Wrap an Archiver instance with a JSON RPC HTTP server.
|
|
@@ -24,7 +25,8 @@ export function createArchiverRpcServer(archiverService: Archiver): JsonRpcServe
|
|
|
24
25
|
ExtendedUnencryptedL2Log,
|
|
25
26
|
Fr,
|
|
26
27
|
L2Block,
|
|
27
|
-
|
|
28
|
+
EncryptedL2BlockL2Logs,
|
|
29
|
+
UnencryptedL2BlockL2Logs,
|
|
28
30
|
TxEffect,
|
|
29
31
|
},
|
|
30
32
|
{ TxReceipt, NullifierMembershipWitness },
|