@aztec/archiver 0.55.1 → 0.57.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/README.md +1 -1
- package/dest/archiver/archiver.d.ts +27 -25
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +391 -169
- package/dest/archiver/archiver_store.d.ts +47 -23
- 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 +75 -42
- package/dest/archiver/config.js +6 -6
- package/dest/archiver/data_retrieval.d.ts +32 -5
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +126 -16
- package/dest/archiver/epoch_helpers.d.ts +15 -0
- package/dest/archiver/epoch_helpers.d.ts.map +1 -0
- package/dest/archiver/epoch_helpers.js +23 -0
- package/dest/archiver/kv_archiver_store/block_store.d.ts +22 -3
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +75 -12
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +2 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.js +11 -4
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +1 -0
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.js +4 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +31 -23
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +65 -38
- package/dest/archiver/kv_archiver_store/log_store.d.ts +4 -5
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/log_store.js +18 -14
- package/dest/archiver/kv_archiver_store/message_store.d.ts +2 -0
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +18 -8
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +1 -0
- 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 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +23 -39
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +132 -91
- package/dest/index.d.ts +0 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +2 -2
- package/dest/test/index.d.ts +2 -0
- package/dest/test/index.d.ts.map +1 -0
- package/dest/test/index.js +2 -0
- package/dest/test/mock_l2_block_source.d.ts +73 -0
- package/dest/test/mock_l2_block_source.d.ts.map +1 -0
- package/dest/test/mock_l2_block_source.js +134 -0
- package/package.json +15 -11
- package/src/archiver/archiver.ts +531 -248
- package/src/archiver/archiver_store.ts +53 -31
- package/src/archiver/archiver_store_test_suite.ts +93 -81
- package/src/archiver/config.ts +5 -5
- package/src/archiver/data_retrieval.ts +189 -30
- package/src/archiver/epoch_helpers.ts +26 -0
- package/src/archiver/kv_archiver_store/block_store.ts +87 -12
- package/src/archiver/kv_archiver_store/contract_class_store.ts +18 -5
- package/src/archiver/kv_archiver_store/contract_instance_store.ts +4 -0
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +74 -47
- package/src/archiver/kv_archiver_store/log_store.ts +18 -18
- package/src/archiver/kv_archiver_store/message_store.ts +18 -5
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +4 -0
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +155 -108
- package/src/index.ts +1 -2
- package/src/test/index.ts +1 -0
- package/src/test/mock_l2_block_source.ts +165 -0
- package/dest/archiver/eth_log_handlers.d.ts +0 -59
- package/dest/archiver/eth_log_handlers.d.ts.map +0 -1
- package/dest/archiver/eth_log_handlers.js +0 -155
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts +0 -34
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_body_store.js +0 -65
- package/dest/archiver/kv_archiver_store/proven_store.d.ts +0 -14
- package/dest/archiver/kv_archiver_store/proven_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/proven_store.js +0 -30
- package/src/archiver/eth_log_handlers.ts +0 -213
- package/src/archiver/kv_archiver_store/block_body_store.ts +0 -74
- package/src/archiver/kv_archiver_store/proven_store.ts +0 -34
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import {
|
|
2
|
-
type Body,
|
|
3
|
-
type EncryptedL2BlockL2Logs,
|
|
4
|
-
type EncryptedNoteL2BlockL2Logs,
|
|
5
2
|
type FromLogType,
|
|
6
3
|
type GetUnencryptedLogsResponse,
|
|
7
4
|
type InboxLeaf,
|
|
@@ -12,9 +9,8 @@ import {
|
|
|
12
9
|
type TxEffect,
|
|
13
10
|
type TxHash,
|
|
14
11
|
type TxReceipt,
|
|
15
|
-
type UnencryptedL2BlockL2Logs,
|
|
16
12
|
} from '@aztec/circuit-types';
|
|
17
|
-
import { type Fr } from '@aztec/circuits.js';
|
|
13
|
+
import { type Fr, type Header } from '@aztec/circuits.js';
|
|
18
14
|
import { type ContractArtifact } from '@aztec/foundation/abi';
|
|
19
15
|
import { type AztecAddress } from '@aztec/foundation/aztec-address';
|
|
20
16
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
@@ -27,24 +23,20 @@ import {
|
|
|
27
23
|
} from '@aztec/types/contracts';
|
|
28
24
|
|
|
29
25
|
import { type ArchiverDataStore, type ArchiverL1SynchPoint } from '../archiver_store.js';
|
|
30
|
-
import { type DataRetrieval
|
|
26
|
+
import { type DataRetrieval } from '../structs/data_retrieval.js';
|
|
31
27
|
import { type L1Published } from '../structs/published.js';
|
|
32
|
-
import { BlockBodyStore } from './block_body_store.js';
|
|
33
28
|
import { BlockStore } from './block_store.js';
|
|
34
29
|
import { ContractArtifactsStore } from './contract_artifacts_store.js';
|
|
35
30
|
import { ContractClassStore } from './contract_class_store.js';
|
|
36
31
|
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
37
32
|
import { LogStore } from './log_store.js';
|
|
38
33
|
import { MessageStore } from './message_store.js';
|
|
39
|
-
import { ProvenStore } from './proven_store.js';
|
|
40
34
|
|
|
41
35
|
/**
|
|
42
36
|
* LMDB implementation of the ArchiverDataStore interface.
|
|
43
37
|
*/
|
|
44
38
|
export class KVArchiverDataStore implements ArchiverDataStore {
|
|
45
|
-
#blockBodyStore: BlockBodyStore;
|
|
46
39
|
#blockStore: BlockStore;
|
|
47
|
-
#provenStore: ProvenStore;
|
|
48
40
|
#logStore: LogStore;
|
|
49
41
|
#messageStore: MessageStore;
|
|
50
42
|
#contractClassStore: ContractClassStore;
|
|
@@ -54,9 +46,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
54
46
|
#log = createDebugLogger('aztec:archiver:data-store');
|
|
55
47
|
|
|
56
48
|
constructor(db: AztecKVStore, logsMaxPageSize: number = 1000) {
|
|
57
|
-
this.#
|
|
58
|
-
this.#blockStore = new BlockStore(db, this.#blockBodyStore);
|
|
59
|
-
this.#provenStore = new ProvenStore(db);
|
|
49
|
+
this.#blockStore = new BlockStore(db);
|
|
60
50
|
this.#logStore = new LogStore(db, this.#blockStore, logsMaxPageSize);
|
|
61
51
|
this.#messageStore = new MessageStore(db);
|
|
62
52
|
this.#contractClassStore = new ContractClassStore(db);
|
|
@@ -84,8 +74,14 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
84
74
|
return Promise.resolve(this.#contractInstanceStore.getContractInstance(address));
|
|
85
75
|
}
|
|
86
76
|
|
|
87
|
-
async addContractClasses(data: ContractClassPublic[],
|
|
88
|
-
return (await Promise.all(data.map(c => this.#contractClassStore.addContractClass(c)))).every(Boolean);
|
|
77
|
+
async addContractClasses(data: ContractClassPublic[], blockNumber: number): Promise<boolean> {
|
|
78
|
+
return (await Promise.all(data.map(c => this.#contractClassStore.addContractClass(c, blockNumber)))).every(Boolean);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
async deleteContractClasses(data: ContractClassPublic[], blockNumber: number): Promise<boolean> {
|
|
82
|
+
return (await Promise.all(data.map(c => this.#contractClassStore.deleteContractClasses(c, blockNumber)))).every(
|
|
83
|
+
Boolean,
|
|
84
|
+
);
|
|
89
85
|
}
|
|
90
86
|
|
|
91
87
|
addFunctions(
|
|
@@ -100,23 +96,8 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
100
96
|
return (await Promise.all(data.map(c => this.#contractInstanceStore.addContractInstance(c)))).every(Boolean);
|
|
101
97
|
}
|
|
102
98
|
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
* @param blockBodies - The L2 block bodies to be added to the store.
|
|
106
|
-
* @returns True if the operation is successful.
|
|
107
|
-
*/
|
|
108
|
-
addBlockBodies(blockBodies: DataRetrieval<Body>): Promise<boolean> {
|
|
109
|
-
return this.#blockBodyStore.addBlockBodies(blockBodies);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Gets block bodies that have the same txHashes as we supply.
|
|
114
|
-
*
|
|
115
|
-
* @param txsEffectsHashes - A list of txsEffectsHashes (body hashes).
|
|
116
|
-
* @returns The requested L2 block bodies
|
|
117
|
-
*/
|
|
118
|
-
getBlockBodies(txsEffectsHashes: Buffer[]): Promise<(Body | undefined)[]> {
|
|
119
|
-
return this.#blockBodyStore.getBlockBodies(txsEffectsHashes);
|
|
99
|
+
async deleteContractInstances(data: ContractInstanceWithAddress[], _blockNumber: number): Promise<boolean> {
|
|
100
|
+
return (await Promise.all(data.map(c => this.#contractInstanceStore.deleteContractInstance(c)))).every(Boolean);
|
|
120
101
|
}
|
|
121
102
|
|
|
122
103
|
/**
|
|
@@ -128,6 +109,17 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
128
109
|
return this.#blockStore.addBlocks(blocks);
|
|
129
110
|
}
|
|
130
111
|
|
|
112
|
+
/**
|
|
113
|
+
* Unwinds blocks from the database
|
|
114
|
+
* @param from - The tip of the chain, passed for verification purposes,
|
|
115
|
+
* ensuring that we don't end up deleting something we did not intend
|
|
116
|
+
* @param blocksToUnwind - The number of blocks we are to unwind
|
|
117
|
+
* @returns True if the operation is successful
|
|
118
|
+
*/
|
|
119
|
+
unwindBlocks(from: number, blocksToUnwind: number): Promise<boolean> {
|
|
120
|
+
return this.#blockStore.unwindBlocks(from, blocksToUnwind);
|
|
121
|
+
}
|
|
122
|
+
|
|
131
123
|
/**
|
|
132
124
|
* Gets up to `limit` amount of L2 blocks starting from `from`.
|
|
133
125
|
*
|
|
@@ -144,6 +136,22 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
144
136
|
}
|
|
145
137
|
}
|
|
146
138
|
|
|
139
|
+
/**
|
|
140
|
+
* Gets up to `limit` amount of L2 blocks headers starting from `from`.
|
|
141
|
+
*
|
|
142
|
+
* @param start - Number of the first block to return (inclusive).
|
|
143
|
+
* @param limit - The number of blocks to return.
|
|
144
|
+
* @returns The requested L2 blocks
|
|
145
|
+
*/
|
|
146
|
+
getBlockHeaders(start: number, limit: number): Promise<Header[]> {
|
|
147
|
+
try {
|
|
148
|
+
return Promise.resolve(Array.from(this.#blockStore.getBlockHeaders(start, limit)));
|
|
149
|
+
} catch (err) {
|
|
150
|
+
// this function is sync so if any errors are thrown we need to make sure they're passed on as rejected Promises
|
|
151
|
+
return Promise.reject(err);
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
147
155
|
/**
|
|
148
156
|
* Gets a tx effect.
|
|
149
157
|
* @param txHash - The txHash of the tx corresponding to the tx effect.
|
|
@@ -164,18 +172,19 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
164
172
|
|
|
165
173
|
/**
|
|
166
174
|
* Append new logs to the store's list.
|
|
167
|
-
* @param
|
|
168
|
-
* @param unencryptedLogs - The type of the logs to be added to the store.
|
|
169
|
-
* @param blockNumber - The block for which to add the logs.
|
|
175
|
+
* @param blocks - The blocks for which to add the logs.
|
|
170
176
|
* @returns True if the operation is successful.
|
|
171
177
|
*/
|
|
172
|
-
addLogs(
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
addLogs(blocks: L2Block[]): Promise<boolean> {
|
|
179
|
+
return this.#logStore.addLogs(blocks);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
deleteLogs(blocks: L2Block[]): Promise<boolean> {
|
|
183
|
+
return this.#logStore.deleteLogs(blocks);
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
getTotalL1ToL2MessageCount(): Promise<bigint> {
|
|
187
|
+
return Promise.resolve(this.#messageStore.getTotalL1ToL2MessageCount());
|
|
179
188
|
}
|
|
180
189
|
|
|
181
190
|
/**
|
|
@@ -251,11 +260,31 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
251
260
|
}
|
|
252
261
|
|
|
253
262
|
getProvenL2BlockNumber(): Promise<number> {
|
|
254
|
-
return Promise.resolve(this.#
|
|
263
|
+
return Promise.resolve(this.#blockStore.getProvenL2BlockNumber());
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
getProvenL2EpochNumber(): Promise<number | undefined> {
|
|
267
|
+
return Promise.resolve(this.#blockStore.getProvenL2EpochNumber());
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
setProvenL2BlockNumber(blockNumber: number) {
|
|
271
|
+
this.#blockStore.setProvenL2BlockNumber(blockNumber);
|
|
272
|
+
return Promise.resolve();
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
setProvenL2EpochNumber(epochNumber: number) {
|
|
276
|
+
this.#blockStore.setProvenL2EpochNumber(epochNumber);
|
|
277
|
+
return Promise.resolve();
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
setBlockSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
281
|
+
this.#blockStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
282
|
+
return Promise.resolve();
|
|
255
283
|
}
|
|
256
284
|
|
|
257
|
-
|
|
258
|
-
|
|
285
|
+
setMessageSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
286
|
+
this.#messageStore.setSynchedL1BlockNumber(l1BlockNumber);
|
|
287
|
+
return Promise.resolve();
|
|
259
288
|
}
|
|
260
289
|
|
|
261
290
|
/**
|
|
@@ -264,9 +293,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
264
293
|
getSynchPoint(): Promise<ArchiverL1SynchPoint> {
|
|
265
294
|
return Promise.resolve({
|
|
266
295
|
blocksSynchedTo: this.#blockStore.getSynchedL1BlockNumber(),
|
|
267
|
-
blockBodiesSynchedTo: this.#blockBodyStore.getSynchedL1BlockNumber(),
|
|
268
296
|
messagesSynchedTo: this.#messageStore.getSynchedL1BlockNumber(),
|
|
269
|
-
provenLogsSynchedTo: this.#provenStore.getSynchedL1BlockNumber(),
|
|
270
297
|
});
|
|
271
298
|
}
|
|
272
299
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
ExtendedUnencryptedL2Log,
|
|
5
5
|
type FromLogType,
|
|
6
6
|
type GetUnencryptedLogsResponse,
|
|
7
|
+
type L2Block,
|
|
7
8
|
type L2BlockL2Logs,
|
|
8
9
|
type LogFilter,
|
|
9
10
|
LogId,
|
|
@@ -37,29 +38,28 @@ export class LogStore {
|
|
|
37
38
|
|
|
38
39
|
/**
|
|
39
40
|
* Append new logs to the store's list.
|
|
40
|
-
* @param
|
|
41
|
-
* @param unencryptedLogs - The type of the logs to be added to the store.
|
|
42
|
-
* @param blockNumber - The block for which to add the logs.
|
|
41
|
+
* @param blocks - The blocks for which to add the logs.
|
|
43
42
|
* @returns True if the operation is successful.
|
|
44
43
|
*/
|
|
45
|
-
addLogs(
|
|
46
|
-
noteEncryptedLogs: EncryptedNoteL2BlockL2Logs | undefined,
|
|
47
|
-
encryptedLogs: EncryptedL2BlockL2Logs | undefined,
|
|
48
|
-
unencryptedLogs: UnencryptedL2BlockL2Logs | undefined,
|
|
49
|
-
blockNumber: number,
|
|
50
|
-
): Promise<boolean> {
|
|
44
|
+
addLogs(blocks: L2Block[]): Promise<boolean> {
|
|
51
45
|
return this.db.transaction(() => {
|
|
52
|
-
|
|
53
|
-
void this.#noteEncryptedLogs.set(
|
|
54
|
-
|
|
46
|
+
blocks.forEach(block => {
|
|
47
|
+
void this.#noteEncryptedLogs.set(block.number, block.body.noteEncryptedLogs.toBuffer());
|
|
48
|
+
void this.#encryptedLogs.set(block.number, block.body.encryptedLogs.toBuffer());
|
|
49
|
+
void this.#unencryptedLogs.set(block.number, block.body.unencryptedLogs.toBuffer());
|
|
50
|
+
});
|
|
55
51
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
52
|
+
return true;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
59
55
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
56
|
+
deleteLogs(blocks: L2Block[]): Promise<boolean> {
|
|
57
|
+
return this.db.transaction(() => {
|
|
58
|
+
blocks.forEach(block => {
|
|
59
|
+
void this.#noteEncryptedLogs.delete(block.number);
|
|
60
|
+
void this.#encryptedLogs.delete(block.number);
|
|
61
|
+
void this.#unencryptedLogs.delete(block.number);
|
|
62
|
+
});
|
|
63
63
|
|
|
64
64
|
return true;
|
|
65
65
|
});
|
|
@@ -16,7 +16,8 @@ import { type DataRetrieval } from '../structs/data_retrieval.js';
|
|
|
16
16
|
export class MessageStore {
|
|
17
17
|
#l1ToL2Messages: AztecMap<string, Buffer>;
|
|
18
18
|
#l1ToL2MessageIndices: AztecMap<string, bigint[]>; // We store array of bigints here because there can be duplicate messages
|
|
19
|
-
#
|
|
19
|
+
#lastSynchedL1Block: AztecSingleton<bigint>;
|
|
20
|
+
#totalMessageCount: AztecSingleton<bigint>;
|
|
20
21
|
|
|
21
22
|
#log = createDebugLogger('aztec:archiver:message_store');
|
|
22
23
|
|
|
@@ -25,7 +26,12 @@ export class MessageStore {
|
|
|
25
26
|
constructor(private db: AztecKVStore) {
|
|
26
27
|
this.#l1ToL2Messages = db.openMap('archiver_l1_to_l2_messages');
|
|
27
28
|
this.#l1ToL2MessageIndices = db.openMap('archiver_l1_to_l2_message_indices');
|
|
28
|
-
this.#
|
|
29
|
+
this.#lastSynchedL1Block = db.openSingleton('archiver_last_l1_block_new_messages');
|
|
30
|
+
this.#totalMessageCount = db.openSingleton('archiver_l1_to_l2_message_count');
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
getTotalL1ToL2MessageCount(): bigint {
|
|
34
|
+
return this.#totalMessageCount.get() ?? 0n;
|
|
29
35
|
}
|
|
30
36
|
|
|
31
37
|
/**
|
|
@@ -33,7 +39,11 @@ export class MessageStore {
|
|
|
33
39
|
* @returns The last L1 block number processed
|
|
34
40
|
*/
|
|
35
41
|
getSynchedL1BlockNumber(): bigint | undefined {
|
|
36
|
-
return this.#
|
|
42
|
+
return this.#lastSynchedL1Block.get();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
setSynchedL1BlockNumber(l1BlockNumber: bigint) {
|
|
46
|
+
void this.#lastSynchedL1Block.set(l1BlockNumber);
|
|
37
47
|
}
|
|
38
48
|
|
|
39
49
|
/**
|
|
@@ -43,12 +53,12 @@ export class MessageStore {
|
|
|
43
53
|
*/
|
|
44
54
|
addL1ToL2Messages(messages: DataRetrieval<InboxLeaf>): Promise<boolean> {
|
|
45
55
|
return this.db.transaction(() => {
|
|
46
|
-
const lastL1BlockNumber = this.#
|
|
56
|
+
const lastL1BlockNumber = this.#lastSynchedL1Block.get() ?? 0n;
|
|
47
57
|
if (lastL1BlockNumber >= messages.lastProcessedL1BlockNumber) {
|
|
48
58
|
return false;
|
|
49
59
|
}
|
|
50
60
|
|
|
51
|
-
void this.#
|
|
61
|
+
void this.#lastSynchedL1Block.set(messages.lastProcessedL1BlockNumber);
|
|
52
62
|
|
|
53
63
|
for (const message of messages.retrievedData) {
|
|
54
64
|
if (message.index >= this.#l1ToL2MessagesSubtreeSize) {
|
|
@@ -66,6 +76,9 @@ export class MessageStore {
|
|
|
66
76
|
void this.#l1ToL2MessageIndices.set(message.leaf.toString(), indices);
|
|
67
77
|
}
|
|
68
78
|
|
|
79
|
+
const lastTotalMessageCount = this.getTotalL1ToL2MessageCount();
|
|
80
|
+
void this.#totalMessageCount.set(lastTotalMessageCount + BigInt(messages.retrievedData.length));
|
|
81
|
+
|
|
69
82
|
return true;
|
|
70
83
|
});
|
|
71
84
|
}
|
|
@@ -19,6 +19,10 @@ export class L1ToL2MessageStore {
|
|
|
19
19
|
|
|
20
20
|
constructor() {}
|
|
21
21
|
|
|
22
|
+
getTotalL1ToL2MessageCount(): bigint {
|
|
23
|
+
return BigInt(this.store.size);
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
addMessage(message: InboxLeaf) {
|
|
23
27
|
if (message.index >= this.#l1ToL2MessagesSubtreeSize) {
|
|
24
28
|
throw new Error(`Message index ${message.index} out of subtree range`);
|