@aztec/archiver 0.28.0 → 0.29.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 -53
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +42 -180
- package/dest/archiver/archiver_store.d.ts +17 -63
- 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 +26 -168
- package/dest/archiver/data_retrieval.d.ts +5 -26
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +10 -64
- package/dest/archiver/eth_log_handlers.d.ts +5 -36
- package/dest/archiver/eth_log_handlers.d.ts.map +1 -1
- package/dest/archiver/eth_log_handlers.js +7 -75
- package/dest/archiver/kv_archiver_store/block_store.d.ts +2 -2
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +3 -3
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +11 -52
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +21 -84
- package/dest/archiver/kv_archiver_store/message_store.d.ts +10 -41
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/message_store.js +31 -136
- package/dest/archiver/memory_archiver_store/l1_to_l2_message_store.d.ts +8 -41
- 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 +22 -79
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +14 -76
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +22 -134
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +3 -15
- package/dest/rpc/archiver_client.d.ts.map +1 -1
- package/dest/rpc/archiver_client.js +2 -6
- package/dest/rpc/archiver_server.d.ts.map +1 -1
- package/dest/rpc/archiver_server.js +2 -6
- package/package.json +9 -9
- package/src/archiver/archiver.ts +47 -230
- package/src/archiver/archiver_store.ts +17 -72
- package/src/archiver/archiver_store_test_suite.ts +25 -208
- package/src/archiver/data_retrieval.ts +11 -93
- package/src/archiver/eth_log_handlers.ts +10 -104
- package/src/archiver/kv_archiver_store/block_store.ts +2 -2
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +19 -89
- package/src/archiver/kv_archiver_store/message_store.ts +36 -165
- package/src/archiver/memory_archiver_store/l1_to_l2_message_store.ts +21 -90
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +23 -150
- package/src/index.ts +1 -15
- package/src/rpc/archiver_client.ts +0 -8
- package/src/rpc/archiver_server.ts +0 -8
- package/dest/archiver/kv_archiver_store/contract_store.d.ts +0 -26
- package/dest/archiver/kv_archiver_store/contract_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_store.js +0 -49
- package/src/archiver/kv_archiver_store/contract_store.ts +0 -55
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
var _KVArchiverDataStore_blockStore, _KVArchiverDataStore_blockBodyStore, _KVArchiverDataStore_logStore,
|
|
1
|
+
var _KVArchiverDataStore_blockStore, _KVArchiverDataStore_blockBodyStore, _KVArchiverDataStore_logStore, _KVArchiverDataStore_messageStore, _KVArchiverDataStore_contractClassStore, _KVArchiverDataStore_contractInstanceStore, _KVArchiverDataStore_log;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
3
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
4
4
|
import { BlockBodyStore } from './block_body_store.js';
|
|
5
5
|
import { BlockStore } from './block_store.js';
|
|
6
6
|
import { ContractClassStore } from './contract_class_store.js';
|
|
7
7
|
import { ContractInstanceStore } from './contract_instance_store.js';
|
|
8
|
-
import { ContractStore } from './contract_store.js';
|
|
9
8
|
import { LogStore } from './log_store.js';
|
|
10
9
|
import { MessageStore } from './message_store.js';
|
|
11
10
|
/**
|
|
@@ -16,7 +15,6 @@ export class KVArchiverDataStore {
|
|
|
16
15
|
_KVArchiverDataStore_blockStore.set(this, void 0);
|
|
17
16
|
_KVArchiverDataStore_blockBodyStore.set(this, void 0);
|
|
18
17
|
_KVArchiverDataStore_logStore.set(this, void 0);
|
|
19
|
-
_KVArchiverDataStore_contractStore.set(this, void 0);
|
|
20
18
|
_KVArchiverDataStore_messageStore.set(this, void 0);
|
|
21
19
|
_KVArchiverDataStore_contractClassStore.set(this, void 0);
|
|
22
20
|
_KVArchiverDataStore_contractInstanceStore.set(this, void 0);
|
|
@@ -24,7 +22,6 @@ export class KVArchiverDataStore {
|
|
|
24
22
|
__classPrivateFieldSet(this, _KVArchiverDataStore_blockBodyStore, new BlockBodyStore(db), "f");
|
|
25
23
|
__classPrivateFieldSet(this, _KVArchiverDataStore_blockStore, new BlockStore(db, __classPrivateFieldGet(this, _KVArchiverDataStore_blockBodyStore, "f")), "f");
|
|
26
24
|
__classPrivateFieldSet(this, _KVArchiverDataStore_logStore, new LogStore(db, __classPrivateFieldGet(this, _KVArchiverDataStore_blockStore, "f"), logsMaxPageSize), "f");
|
|
27
|
-
__classPrivateFieldSet(this, _KVArchiverDataStore_contractStore, new ContractStore(db, __classPrivateFieldGet(this, _KVArchiverDataStore_blockStore, "f")), "f");
|
|
28
25
|
__classPrivateFieldSet(this, _KVArchiverDataStore_messageStore, new MessageStore(db), "f");
|
|
29
26
|
__classPrivateFieldSet(this, _KVArchiverDataStore_contractClassStore, new ContractClassStore(db), "f");
|
|
30
27
|
__classPrivateFieldSet(this, _KVArchiverDataStore_contractInstanceStore, new ContractInstanceStore(db), "f");
|
|
@@ -112,71 +109,30 @@ export class KVArchiverDataStore {
|
|
|
112
109
|
return __classPrivateFieldGet(this, _KVArchiverDataStore_logStore, "f").addLogs(encryptedLogs, unencryptedLogs, blockNumber);
|
|
113
110
|
}
|
|
114
111
|
/**
|
|
115
|
-
* Append
|
|
112
|
+
* Append L1 to L2 messages to the store.
|
|
116
113
|
* @param messages - The L1 to L2 messages to be added to the store.
|
|
117
114
|
* @param lastMessageL1BlockNumber - The L1 block number in which the last message was emitted.
|
|
118
115
|
* @returns True if the operation is successful.
|
|
119
116
|
*/
|
|
120
|
-
|
|
121
|
-
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").
|
|
117
|
+
addL1ToL2Messages(messages, lastMessageL1BlockNumber) {
|
|
118
|
+
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").addL1ToL2Messages(messages, lastMessageL1BlockNumber));
|
|
122
119
|
}
|
|
123
120
|
/**
|
|
124
|
-
*
|
|
125
|
-
* @param
|
|
126
|
-
* @
|
|
127
|
-
* @returns True if the operation is successful.
|
|
128
|
-
*/
|
|
129
|
-
addPendingL1ToL2Messages(messages, l1BlockNumber) {
|
|
130
|
-
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").addPendingMessages(messages, l1BlockNumber));
|
|
131
|
-
}
|
|
132
|
-
/**
|
|
133
|
-
* Remove pending L1 to L2 messages from the store (if they were cancelled).
|
|
134
|
-
* @param messages - The entry keys to be removed from the store.
|
|
135
|
-
* @param l1BlockNumber - The L1 block number for which to remove the messages.
|
|
136
|
-
* @returns True if the operation is successful.
|
|
137
|
-
*/
|
|
138
|
-
cancelPendingL1ToL2EntryKeys(messages, l1BlockNumber) {
|
|
139
|
-
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").cancelPendingMessages(messages, l1BlockNumber));
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Messages that have been published in an L2 block are confirmed.
|
|
143
|
-
* Add them to the confirmed store, also remove them from the pending store.
|
|
144
|
-
* @param entryKeys - The entry keys to be removed from the store.
|
|
145
|
-
* @param blockNumber - The block for which to add the messages.
|
|
146
|
-
* @returns True if the operation is successful.
|
|
147
|
-
*/
|
|
148
|
-
confirmL1ToL2EntryKeys(entryKeys) {
|
|
149
|
-
return __classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").confirmPendingMessages(entryKeys);
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Gets up to `limit` amount of pending L1 to L2 messages, sorted by fee
|
|
153
|
-
* @param limit - The number of messages to return (by default NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).
|
|
154
|
-
* @returns The requested L1 to L2 entry keys.
|
|
155
|
-
*/
|
|
156
|
-
getPendingL1ToL2EntryKeys(limit) {
|
|
157
|
-
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").getPendingEntryKeysByFee(limit));
|
|
158
|
-
}
|
|
159
|
-
/**
|
|
160
|
-
* Gets the confirmed L1 to L2 message corresponding to the given entry key.
|
|
161
|
-
* @param entryKey - The entry key to look up.
|
|
162
|
-
* @returns The requested L1 to L2 message or throws if not found.
|
|
121
|
+
* Gets the L1 to L2 message index in the L1 to L2 message tree.
|
|
122
|
+
* @param l1ToL2Message - The L1 to L2 message.
|
|
123
|
+
* @returns The index of the L1 to L2 message in the L1 to L2 message tree.
|
|
163
124
|
*/
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").getConfirmedMessage(entryKey));
|
|
167
|
-
}
|
|
168
|
-
catch (err) {
|
|
169
|
-
return Promise.reject(err);
|
|
170
|
-
}
|
|
125
|
+
getL1ToL2MessageIndex(l1ToL2Message) {
|
|
126
|
+
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").getL1ToL2MessageIndex(l1ToL2Message));
|
|
171
127
|
}
|
|
172
128
|
/**
|
|
173
|
-
* Gets
|
|
129
|
+
* Gets L1 to L2 message (to be) included in a given block.
|
|
174
130
|
* @param blockNumber - L2 block number to get messages for.
|
|
175
131
|
* @returns The L1 to L2 messages/leaves of the messages subtree (throws if not found).
|
|
176
132
|
*/
|
|
177
|
-
|
|
133
|
+
getL1ToL2Messages(blockNumber) {
|
|
178
134
|
try {
|
|
179
|
-
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").
|
|
135
|
+
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").getL1ToL2Messages(blockNumber));
|
|
180
136
|
}
|
|
181
137
|
catch (err) {
|
|
182
138
|
return Promise.reject(err);
|
|
@@ -210,43 +166,24 @@ export class KVArchiverDataStore {
|
|
|
210
166
|
return Promise.reject(err);
|
|
211
167
|
}
|
|
212
168
|
}
|
|
213
|
-
/**
|
|
214
|
-
* Add new extended contract data from an L2 block to the store's list.
|
|
215
|
-
* @param data - List of contracts' data to be added.
|
|
216
|
-
* @param blockNum - Number of the L2 block the contract data was deployed in.
|
|
217
|
-
* @returns True if the operation is successful.
|
|
218
|
-
*/
|
|
219
|
-
addExtendedContractData(data, blockNum) {
|
|
220
|
-
return __classPrivateFieldGet(this, _KVArchiverDataStore_contractStore, "f").addExtendedContractData(data, blockNum);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Get the extended contract data for this contract.
|
|
224
|
-
* @param contractAddress - The contract data address.
|
|
225
|
-
* @returns The extended contract data or undefined if not found.
|
|
226
|
-
*/
|
|
227
|
-
getExtendedContractData(contractAddress) {
|
|
228
|
-
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_contractStore, "f").getExtendedContractData(contractAddress));
|
|
229
|
-
}
|
|
230
169
|
/**
|
|
231
170
|
* Gets the number of the latest L2 block processed.
|
|
232
171
|
* @returns The number of the latest L2 block processed.
|
|
233
172
|
*/
|
|
234
|
-
|
|
235
|
-
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_blockStore, "f").
|
|
173
|
+
getSynchedL2BlockNumber() {
|
|
174
|
+
return Promise.resolve(__classPrivateFieldGet(this, _KVArchiverDataStore_blockStore, "f").getSynchedL2BlockNumber());
|
|
236
175
|
}
|
|
237
176
|
/**
|
|
238
177
|
* Gets the last L1 block number processed by the archiver
|
|
239
178
|
*/
|
|
240
|
-
|
|
241
|
-
const
|
|
242
|
-
const
|
|
179
|
+
getSynchedL1BlockNumbers() {
|
|
180
|
+
const blocks = __classPrivateFieldGet(this, _KVArchiverDataStore_blockStore, "f").getSynchedL1BlockNumber();
|
|
181
|
+
const messages = __classPrivateFieldGet(this, _KVArchiverDataStore_messageStore, "f").getSynchedL1BlockNumber();
|
|
243
182
|
return Promise.resolve({
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
newMessages,
|
|
247
|
-
cancelledMessages,
|
|
183
|
+
blocks,
|
|
184
|
+
messages,
|
|
248
185
|
});
|
|
249
186
|
}
|
|
250
187
|
}
|
|
251
|
-
_KVArchiverDataStore_blockStore = new WeakMap(), _KVArchiverDataStore_blockBodyStore = new WeakMap(), _KVArchiverDataStore_logStore = new WeakMap(),
|
|
252
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
188
|
+
_KVArchiverDataStore_blockStore = new WeakMap(), _KVArchiverDataStore_blockBodyStore = new WeakMap(), _KVArchiverDataStore_logStore = new WeakMap(), _KVArchiverDataStore_messageStore = new WeakMap(), _KVArchiverDataStore_contractClassStore = new WeakMap(), _KVArchiverDataStore_contractInstanceStore = new WeakMap(), _KVArchiverDataStore_log = new WeakMap();
|
|
189
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoia3ZfYXJjaGl2ZXJfc3RvcmUuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi9zcmMvYXJjaGl2ZXIva3ZfYXJjaGl2ZXJfc3RvcmUva3ZfYXJjaGl2ZXJfc3RvcmUudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFjQSxPQUFPLEVBQUUsaUJBQWlCL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QUVEOztPQUVHO0lBQ0gsd0JBQXdCO1FBQ3RCLE1BQU0sTUFBTSxHQUFHLHVCQUFBLElBQUksdUNBQVksQ0FBQyx1QkFBdUIsRUFBRSxDQUFDO1FBQzFELE1BQU0sUUFBUSxHQUFHLHVCQUFBLElBQUkseUNBQWMsQ0FBQyx1QkFBdUIsRUFBRSxDQUFDO1FBQzlELE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FBQztZQUNyQixNQUFNO1lBQ04sUUFBUTtTQUNULENBQUMsQ0FBQztJQUNMLENBQUM7Q0FDRiJ9
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InboxLeaf } from '@aztec/circuit-types';
|
|
2
2
|
import { Fr } from '@aztec/circuits.js';
|
|
3
3
|
import { AztecKVStore } from '@aztec/kv-store';
|
|
4
4
|
/**
|
|
@@ -9,54 +9,23 @@ export declare class MessageStore {
|
|
|
9
9
|
private db;
|
|
10
10
|
constructor(db: AztecKVStore);
|
|
11
11
|
/**
|
|
12
|
-
* Gets the last L1 block number that emitted new messages
|
|
12
|
+
* Gets the last L1 block number that emitted new messages.
|
|
13
13
|
* @returns The last L1 block number processed
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
newMessages: bigint;
|
|
17
|
-
addedMessages: bigint;
|
|
18
|
-
cancelledMessages: bigint;
|
|
19
|
-
};
|
|
15
|
+
getSynchedL1BlockNumber(): bigint;
|
|
20
16
|
/**
|
|
21
|
-
* Append
|
|
17
|
+
* Append L1 to L2 messages to the store.
|
|
22
18
|
* @param messages - The L1 to L2 messages to be added to the store.
|
|
23
19
|
* @param lastMessageL1BlockNumber - The L1 block number in which the last message was emitted.
|
|
24
20
|
* @returns True if the operation is successful.
|
|
25
21
|
*/
|
|
26
|
-
|
|
22
|
+
addL1ToL2Messages(messages: InboxLeaf[], lastMessageL1BlockNumber: bigint): Promise<boolean>;
|
|
27
23
|
/**
|
|
28
|
-
*
|
|
29
|
-
* @param
|
|
30
|
-
* @
|
|
31
|
-
* @returns True if the operation is successful.
|
|
32
|
-
*/
|
|
33
|
-
addPendingMessages(messages: L1ToL2Message[], l1BlockNumber: bigint): Promise<boolean>;
|
|
34
|
-
/**
|
|
35
|
-
* Remove pending L1 to L2 messages from the store (if they were cancelled).
|
|
36
|
-
* @param entryKeys - The entry keys to be removed from the store.
|
|
37
|
-
* @param l1BlockNumber - The L1 block number for which to remove the messages.
|
|
38
|
-
* @returns True if the operation is successful.
|
|
39
|
-
*/
|
|
40
|
-
cancelPendingMessages(entryKeys: Fr[], l1BlockNumber: bigint): Promise<boolean>;
|
|
41
|
-
/**
|
|
42
|
-
* Messages that have been published in an L2 block are confirmed.
|
|
43
|
-
* Add them to the confirmed store, also remove them from the pending store.
|
|
44
|
-
* @param entryKeys - The entry keys to be removed from the store.
|
|
45
|
-
* @returns True if the operation is successful.
|
|
46
|
-
*/
|
|
47
|
-
confirmPendingMessages(entryKeys: Fr[]): Promise<boolean>;
|
|
48
|
-
/**
|
|
49
|
-
* Gets the confirmed L1 to L2 message corresponding to the given entry key.
|
|
50
|
-
* @param entryKey - The entry key to look up.
|
|
51
|
-
* @returns The requested L1 to L2 message or throws if not found.
|
|
52
|
-
*/
|
|
53
|
-
getConfirmedMessage(entryKey: Fr): L1ToL2Message;
|
|
54
|
-
/**
|
|
55
|
-
* Gets up to `limit` amount of pending L1 to L2 messages, sorted by fee
|
|
56
|
-
* @param limit - The number of messages to return (by default NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).
|
|
57
|
-
* @returns The requested L1 to L2 entry keys.
|
|
24
|
+
* Gets the L1 to L2 message index in the L1 to L2 message tree.
|
|
25
|
+
* @param l1ToL2Message - The L1 to L2 message.
|
|
26
|
+
* @returns The index of the L1 to L2 message in the L1 to L2 message tree.
|
|
58
27
|
*/
|
|
59
|
-
|
|
60
|
-
|
|
28
|
+
getL1ToL2MessageIndex(l1ToL2Message: Fr): Promise<bigint>;
|
|
29
|
+
getL1ToL2Messages(blockNumber: bigint): Fr[];
|
|
61
30
|
}
|
|
62
31
|
//# sourceMappingURL=message_store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"message_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/message_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"message_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/message_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EACL,EAAE,EAIH,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,YAAY,EAA4B,MAAM,iBAAiB,CAAC;AAEzE;;GAEG;AACH,qBAAa,YAAY;;IASX,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,YAAY;IAMpC;;;OAGG;IACH,uBAAuB,IAAI,MAAM;IAIjC;;;;;OAKG;IACH,iBAAiB,CAAC,QAAQ,EAAE,SAAS,EAAE,EAAE,wBAAwB,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IA0B5F;;;;OAIG;IACI,qBAAqB,CAAC,aAAa,EAAE,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC;IAQhE,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,EAAE,EAAE;CAoB7C"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
var
|
|
1
|
+
var _MessageStore_l1ToL2Messages, _MessageStore_l1ToL2MessageIndices, _MessageStore_lastL1BlockMessages, _MessageStore_log, _MessageStore_l1ToL2MessagesSubtreeSize;
|
|
2
2
|
import { __classPrivateFieldGet, __classPrivateFieldSet } from "tslib";
|
|
3
|
-
import {
|
|
4
|
-
import { Fr, L1_TO_L2_MSG_SUBTREE_HEIGHT } from '@aztec/circuits.js';
|
|
3
|
+
import { Fr, INITIAL_L2_BLOCK_NUM, L1_TO_L2_MSG_SUBTREE_HEIGHT, NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP, } from '@aztec/circuits.js';
|
|
5
4
|
import { createDebugLogger } from '@aztec/foundation/log';
|
|
6
5
|
/**
|
|
7
6
|
* LMDB implementation of the ArchiverDataStore interface.
|
|
@@ -9,171 +8,67 @@ import { createDebugLogger } from '@aztec/foundation/log';
|
|
|
9
8
|
export class MessageStore {
|
|
10
9
|
constructor(db) {
|
|
11
10
|
this.db = db;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
_MessageStore_pendingMessagesByFee.set(this, void 0);
|
|
16
|
-
_MessageStore_messages.set(this, void 0);
|
|
17
|
-
_MessageStore_lastL1BlockAddingMessages.set(this, void 0);
|
|
18
|
-
_MessageStore_lastL1BlockCancellingMessages.set(this, void 0);
|
|
11
|
+
_MessageStore_l1ToL2Messages.set(this, void 0);
|
|
12
|
+
_MessageStore_l1ToL2MessageIndices.set(this, void 0);
|
|
13
|
+
_MessageStore_lastL1BlockMessages.set(this, void 0);
|
|
19
14
|
_MessageStore_log.set(this, createDebugLogger('aztec:archiver:message_store'));
|
|
20
15
|
_MessageStore_l1ToL2MessagesSubtreeSize.set(this, 2 ** L1_TO_L2_MSG_SUBTREE_HEIGHT);
|
|
21
|
-
__classPrivateFieldSet(this,
|
|
22
|
-
__classPrivateFieldSet(this,
|
|
23
|
-
__classPrivateFieldSet(this,
|
|
24
|
-
__classPrivateFieldSet(this, _MessageStore_lastL1BlockNewMessages, db.openSingleton('archiver_last_l1_block_new_messages'), "f");
|
|
25
|
-
__classPrivateFieldSet(this, _MessageStore_lastL1BlockAddingMessages, db.openSingleton('archiver_last_l1_block_adding_messages'), "f");
|
|
26
|
-
__classPrivateFieldSet(this, _MessageStore_lastL1BlockCancellingMessages, db.openSingleton('archiver_last_l1_block_cancelling_messages'), "f");
|
|
16
|
+
__classPrivateFieldSet(this, _MessageStore_l1ToL2Messages, db.openMap('archiver_l1_to_l2_messages'), "f");
|
|
17
|
+
__classPrivateFieldSet(this, _MessageStore_l1ToL2MessageIndices, db.openMap('archiver_l1_to_l2_message_indices'), "f");
|
|
18
|
+
__classPrivateFieldSet(this, _MessageStore_lastL1BlockMessages, db.openSingleton('archiver_last_l1_block_new_messages'), "f");
|
|
27
19
|
}
|
|
28
20
|
/**
|
|
29
|
-
* Gets the last L1 block number that emitted new messages
|
|
21
|
+
* Gets the last L1 block number that emitted new messages.
|
|
30
22
|
* @returns The last L1 block number processed
|
|
31
23
|
*/
|
|
32
|
-
|
|
33
|
-
return
|
|
34
|
-
newMessages: __classPrivateFieldGet(this, _MessageStore_lastL1BlockNewMessages, "f").get() ?? 0n,
|
|
35
|
-
// TODO(#4492): Nuke the following when purging the old inbox
|
|
36
|
-
addedMessages: __classPrivateFieldGet(this, _MessageStore_lastL1BlockAddingMessages, "f").get() ?? 0n,
|
|
37
|
-
cancelledMessages: __classPrivateFieldGet(this, _MessageStore_lastL1BlockCancellingMessages, "f").get() ?? 0n,
|
|
38
|
-
};
|
|
24
|
+
getSynchedL1BlockNumber() {
|
|
25
|
+
return __classPrivateFieldGet(this, _MessageStore_lastL1BlockMessages, "f").get() ?? 0n;
|
|
39
26
|
}
|
|
40
27
|
/**
|
|
41
|
-
* Append
|
|
28
|
+
* Append L1 to L2 messages to the store.
|
|
42
29
|
* @param messages - The L1 to L2 messages to be added to the store.
|
|
43
30
|
* @param lastMessageL1BlockNumber - The L1 block number in which the last message was emitted.
|
|
44
31
|
* @returns True if the operation is successful.
|
|
45
32
|
*/
|
|
46
|
-
|
|
33
|
+
addL1ToL2Messages(messages, lastMessageL1BlockNumber) {
|
|
47
34
|
return this.db.transaction(() => {
|
|
48
|
-
const lastL1BlockNumber = __classPrivateFieldGet(this,
|
|
35
|
+
const lastL1BlockNumber = __classPrivateFieldGet(this, _MessageStore_lastL1BlockMessages, "f").get() ?? 0n;
|
|
49
36
|
if (lastL1BlockNumber >= lastMessageL1BlockNumber) {
|
|
50
37
|
return false;
|
|
51
38
|
}
|
|
52
|
-
void __classPrivateFieldGet(this,
|
|
39
|
+
void __classPrivateFieldGet(this, _MessageStore_lastL1BlockMessages, "f").set(lastMessageL1BlockNumber);
|
|
53
40
|
for (const message of messages) {
|
|
54
41
|
if (message.index >= __classPrivateFieldGet(this, _MessageStore_l1ToL2MessagesSubtreeSize, "f")) {
|
|
55
42
|
throw new Error(`Message index ${message.index} out of subtree range`);
|
|
56
43
|
}
|
|
57
44
|
const key = `${message.blockNumber}-${message.index}`;
|
|
58
|
-
void __classPrivateFieldGet(this,
|
|
45
|
+
void __classPrivateFieldGet(this, _MessageStore_l1ToL2Messages, "f").setIfNotExists(key, message.leaf.toBuffer());
|
|
46
|
+
const indexInTheWholeTree = (message.blockNumber - BigInt(INITIAL_L2_BLOCK_NUM)) * BigInt(NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP) +
|
|
47
|
+
message.index;
|
|
48
|
+
void __classPrivateFieldGet(this, _MessageStore_l1ToL2MessageIndices, "f").setIfNotExists(message.leaf.toString(), indexInTheWholeTree);
|
|
59
49
|
}
|
|
60
50
|
return true;
|
|
61
51
|
});
|
|
62
52
|
}
|
|
63
53
|
/**
|
|
64
|
-
*
|
|
65
|
-
* @param
|
|
66
|
-
* @
|
|
67
|
-
* @returns True if the operation is successful.
|
|
68
|
-
*/
|
|
69
|
-
addPendingMessages(messages, l1BlockNumber) {
|
|
70
|
-
return this.db.transaction(() => {
|
|
71
|
-
const lastL1BlockNumber = __classPrivateFieldGet(this, _MessageStore_lastL1BlockAddingMessages, "f").get() ?? 0n;
|
|
72
|
-
if (lastL1BlockNumber >= l1BlockNumber) {
|
|
73
|
-
return false;
|
|
74
|
-
}
|
|
75
|
-
void __classPrivateFieldGet(this, _MessageStore_lastL1BlockAddingMessages, "f").set(l1BlockNumber);
|
|
76
|
-
for (const message of messages) {
|
|
77
|
-
const entryKey = message.entryKey?.toString();
|
|
78
|
-
if (!entryKey) {
|
|
79
|
-
throw new Error('Message does not have an entry key');
|
|
80
|
-
}
|
|
81
|
-
void __classPrivateFieldGet(this, _MessageStore_messages, "f").setIfNotExists(entryKey, {
|
|
82
|
-
message: message.toBuffer(),
|
|
83
|
-
fee: message.fee,
|
|
84
|
-
confirmed: false,
|
|
85
|
-
});
|
|
86
|
-
void __classPrivateFieldGet(this, _MessageStore_pendingMessagesByFee, "f").update([message.fee, entryKey], 1);
|
|
87
|
-
}
|
|
88
|
-
return true;
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
/**
|
|
92
|
-
* Remove pending L1 to L2 messages from the store (if they were cancelled).
|
|
93
|
-
* @param entryKeys - The entry keys to be removed from the store.
|
|
94
|
-
* @param l1BlockNumber - The L1 block number for which to remove the messages.
|
|
95
|
-
* @returns True if the operation is successful.
|
|
96
|
-
*/
|
|
97
|
-
cancelPendingMessages(entryKeys, l1BlockNumber) {
|
|
98
|
-
return this.db.transaction(() => {
|
|
99
|
-
const lastL1BlockNumber = __classPrivateFieldGet(this, _MessageStore_lastL1BlockCancellingMessages, "f").get() ?? 0n;
|
|
100
|
-
if (lastL1BlockNumber >= l1BlockNumber) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
void __classPrivateFieldGet(this, _MessageStore_lastL1BlockCancellingMessages, "f").set(l1BlockNumber);
|
|
104
|
-
for (const entryKey of entryKeys) {
|
|
105
|
-
const messageCtx = __classPrivateFieldGet(this, _MessageStore_messages, "f").get(entryKey.toString());
|
|
106
|
-
if (!messageCtx) {
|
|
107
|
-
throw new Error(`Message ${entryKey.toString()} not found`);
|
|
108
|
-
}
|
|
109
|
-
void __classPrivateFieldGet(this, _MessageStore_pendingMessagesByFee, "f").update([messageCtx.fee, entryKey.toString()], -1);
|
|
110
|
-
}
|
|
111
|
-
return true;
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
/**
|
|
115
|
-
* Messages that have been published in an L2 block are confirmed.
|
|
116
|
-
* Add them to the confirmed store, also remove them from the pending store.
|
|
117
|
-
* @param entryKeys - The entry keys to be removed from the store.
|
|
118
|
-
* @returns True if the operation is successful.
|
|
119
|
-
*/
|
|
120
|
-
confirmPendingMessages(entryKeys) {
|
|
121
|
-
return this.db.transaction(() => {
|
|
122
|
-
for (const entryKey of entryKeys) {
|
|
123
|
-
if (entryKey.equals(Fr.ZERO)) {
|
|
124
|
-
continue;
|
|
125
|
-
}
|
|
126
|
-
const messageCtx = __classPrivateFieldGet(this, _MessageStore_messages, "f").get(entryKey.toString());
|
|
127
|
-
if (!messageCtx) {
|
|
128
|
-
throw new Error(`Message ${entryKey.toString()} not found`);
|
|
129
|
-
}
|
|
130
|
-
messageCtx.confirmed = true;
|
|
131
|
-
void __classPrivateFieldGet(this, _MessageStore_messages, "f").set(entryKey.toString(), messageCtx);
|
|
132
|
-
void __classPrivateFieldGet(this, _MessageStore_pendingMessagesByFee, "f").update([messageCtx.fee, entryKey.toString()], -1);
|
|
133
|
-
}
|
|
134
|
-
return true;
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Gets the confirmed L1 to L2 message corresponding to the given entry key.
|
|
139
|
-
* @param entryKey - The entry key to look up.
|
|
140
|
-
* @returns The requested L1 to L2 message or throws if not found.
|
|
141
|
-
*/
|
|
142
|
-
getConfirmedMessage(entryKey) {
|
|
143
|
-
const messageCtx = __classPrivateFieldGet(this, _MessageStore_messages, "f").get(entryKey.toString());
|
|
144
|
-
if (!messageCtx) {
|
|
145
|
-
throw new Error(`Message ${entryKey.toString()} not found`);
|
|
146
|
-
}
|
|
147
|
-
if (!messageCtx.confirmed) {
|
|
148
|
-
throw new Error(`Message ${entryKey.toString()} not confirmed`);
|
|
149
|
-
}
|
|
150
|
-
return L1ToL2Message.fromBuffer(messageCtx.message);
|
|
151
|
-
}
|
|
152
|
-
/**
|
|
153
|
-
* Gets up to `limit` amount of pending L1 to L2 messages, sorted by fee
|
|
154
|
-
* @param limit - The number of messages to return (by default NUMBER_OF_L1_L2_MESSAGES_PER_ROLLUP).
|
|
155
|
-
* @returns The requested L1 to L2 entry keys.
|
|
54
|
+
* Gets the L1 to L2 message index in the L1 to L2 message tree.
|
|
55
|
+
* @param l1ToL2Message - The L1 to L2 message.
|
|
56
|
+
* @returns The index of the L1 to L2 message in the L1 to L2 message tree.
|
|
156
57
|
*/
|
|
157
|
-
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
})) {
|
|
162
|
-
// put `count` copies of this message in the result list
|
|
163
|
-
entryKeys.push(...Array(count).fill(Fr.fromString(entryKey)));
|
|
164
|
-
if (entryKeys.length >= limit) {
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
58
|
+
getL1ToL2MessageIndex(l1ToL2Message) {
|
|
59
|
+
const index = __classPrivateFieldGet(this, _MessageStore_l1ToL2MessageIndices, "f").get(l1ToL2Message.toString());
|
|
60
|
+
if (index === undefined) {
|
|
61
|
+
throw new Error(`L1 to L2 message index not found in the store for message ${l1ToL2Message.toString()}`);
|
|
167
62
|
}
|
|
168
|
-
return
|
|
63
|
+
return Promise.resolve(index);
|
|
169
64
|
}
|
|
170
|
-
|
|
65
|
+
getL1ToL2Messages(blockNumber) {
|
|
171
66
|
const messages = [];
|
|
172
67
|
let undefinedMessageFound = false;
|
|
173
68
|
for (let messageIndex = 0; messageIndex < __classPrivateFieldGet(this, _MessageStore_l1ToL2MessagesSubtreeSize, "f"); messageIndex++) {
|
|
174
69
|
// This is inefficient but probably fine for now.
|
|
175
70
|
const key = `${blockNumber}-${messageIndex}`;
|
|
176
|
-
const message = __classPrivateFieldGet(this,
|
|
71
|
+
const message = __classPrivateFieldGet(this, _MessageStore_l1ToL2Messages, "f").get(key);
|
|
177
72
|
if (message) {
|
|
178
73
|
if (undefinedMessageFound) {
|
|
179
74
|
throw new Error(`L1 to L2 message gap found in block ${blockNumber}`);
|
|
@@ -189,5 +84,5 @@ export class MessageStore {
|
|
|
189
84
|
return messages;
|
|
190
85
|
}
|
|
191
86
|
}
|
|
192
|
-
|
|
193
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
87
|
+
_MessageStore_l1ToL2Messages = new WeakMap(), _MessageStore_l1ToL2MessageIndices = new WeakMap(), _MessageStore_lastL1BlockMessages = new WeakMap(), _MessageStore_log = new WeakMap(), _MessageStore_l1ToL2MessagesSubtreeSize = new WeakMap();
|
|
88
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibWVzc2FnZV9zdG9yZS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy9hcmNoaXZlci9rdl9hcmNoaXZlcl9zdG9yZS9tZXNzYWdlX3N0b3JlLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7O0FBQ0EsT0FBTyxFQUNMLEVBQUUsRUFDRixvQkFBb0IsRUFDcEIsMkJBQTJCLEVBQzNCLG1DQUFtQyxHQUNwQyxNQUFNLG9CQUFvQixDQUFDO0FBQzVCLE9BQU8sRUFBRSxpQkFBaUIsRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBRzFEOztHQUVHO0FBQ0gsTUFBTSxPQUFPLFlBQVk7SUFTdkIsWUFBb0IsRUFBZ0I7UUFBaEIsT0FBRSxHQUFGLEVBQUUsQ0FBYztRQVJwQywrQ0FBMEM7UUFDMUMscURBQWdEO1FBQ2hELG9EQUE2QztRQUU3Qyw0QkFBTyxpQkFBaUIsQ0FBQyw4QkFBOEIsQ0FBQyxFQUFDO1FBRXpELGtEQUE2QixDQUFDLElBQUksMkJBQTJCLEVBQUM7UUFHNUQsdUJBQUEsSUFBSSxnQ0FBbUIsRUFBRSxDQUFDLE9BQU8sQ0FBQyw0QkFBNEIsQ0FBQyxNQUFBLENBQUM7UUFDaEUsdUJBQUEsSUFBSSxzQ0FBeUIsRUFBRSxDQUFDLE9BQU8sQ0FBQyxtQ0FBbUMsQ0FBQyxNQUFBLENBQUM7UUFDN0UsdUJBQUEsSUFBSSxxQ0FBd0IsRUFBRSxDQUFDLGFBQWEsQ0FBQyxxQ0FBcUMsQ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UFJLFlBQVksRUFBRSxDQUFDO1lBQzdDLE1BQU0sT0FBTyxHQUFHLHVCQUFBLElBQUksb0NBQWdCLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFDO1lBQzlDLElBQUksT0FBTyxFQUFFLENBQUM7Z0JBQ1osSUFBSSxxQkFBcUIsRUFBRSxDQUFDO29CQUMxQixNQUFNLElBQUksS0FBSyxDQUFDLHVDQUF1QyxXQUFXLEVBQUUsQ0FBQyxDQUFDO2dCQUN4RSxDQUFDO2dCQUNELFFBQVEsQ0FBQyxJQUFJLENBQUMsRUFBRSxDQUFDLFVBQVUsQ0FBQyxPQUFPLENBQUMsQ0FBQyxDQUFDO1lBQ3hDLENBQUM7aUJBQU0sQ0FBQztnQkFDTixxQkFBcUIsR0FBRyxJQUFJLENBQUM7Z0JBQzdCLDhHQUE4RztnQkFDOUcsbUZBQW1GO1lBQ3JGLENBQUM7UUFDSCxDQUFDO1FBQ0QsT0FBTyxRQUFRLENBQUM7SUFDbEIsQ0FBQztDQUNGIn0=
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { InboxLeaf } from '@aztec/circuit-types';
|
|
2
2
|
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
/**
|
|
4
|
-
* A simple in-memory implementation of an L1 to L2 message store
|
|
5
|
-
* that handles message duplication.
|
|
6
|
-
* TODO(#4492): Clean this up
|
|
4
|
+
* A simple in-memory implementation of an L1 to L2 message store.
|
|
7
5
|
*/
|
|
8
|
-
export declare class
|
|
6
|
+
export declare class L1ToL2MessageStore {
|
|
9
7
|
#private;
|
|
10
8
|
/**
|
|
11
9
|
* A map containing the entry key to the corresponding L1 to L2
|
|
@@ -13,44 +11,13 @@ export declare class NewL1ToL2MessageStore {
|
|
|
13
11
|
*/
|
|
14
12
|
protected store: Map<string, Fr>;
|
|
15
13
|
constructor();
|
|
16
|
-
addMessage(message:
|
|
14
|
+
addMessage(message: InboxLeaf): void;
|
|
17
15
|
getMessages(blockNumber: bigint): Fr[];
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* A simple in-memory implementation of an L1 to L2 message store
|
|
21
|
-
* that handles message duplication.
|
|
22
|
-
*/
|
|
23
|
-
export declare class L1ToL2MessageStore {
|
|
24
16
|
/**
|
|
25
|
-
*
|
|
26
|
-
*
|
|
17
|
+
* Gets the L1 to L2 message index in the L1 to L2 message tree.
|
|
18
|
+
* @param l1ToL2Message - The L1 to L2 message.
|
|
19
|
+
* @returns The index of the L1 to L2 message in the L1 to L2 message tree.
|
|
27
20
|
*/
|
|
28
|
-
|
|
29
|
-
constructor();
|
|
30
|
-
addMessage(entryKey: Fr, message: L1ToL2Message): void;
|
|
31
|
-
getMessage(entryKey: Fr): L1ToL2Message | undefined;
|
|
32
|
-
getMessageAndCount(entryKey: Fr): L1ToL2MessageAndCount | undefined;
|
|
21
|
+
getMessageIndex(l1ToL2Message: Fr): bigint;
|
|
33
22
|
}
|
|
34
|
-
/**
|
|
35
|
-
* Specifically for the store that will hold pending messages
|
|
36
|
-
* for removing messages or fetching multiple messages.
|
|
37
|
-
*/
|
|
38
|
-
export declare class PendingL1ToL2MessageStore extends L1ToL2MessageStore {
|
|
39
|
-
getEntryKeys(limit: number): Fr[];
|
|
40
|
-
removeMessage(entryKey: Fr): void;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Useful to keep track of the number of times a message has been seen.
|
|
44
|
-
*/
|
|
45
|
-
type L1ToL2MessageAndCount = {
|
|
46
|
-
/**
|
|
47
|
-
* The message.
|
|
48
|
-
*/
|
|
49
|
-
message: L1ToL2Message;
|
|
50
|
-
/**
|
|
51
|
-
* The number of times the message has been seen.
|
|
52
|
-
*/
|
|
53
|
-
count: number;
|
|
54
|
-
};
|
|
55
|
-
export {};
|
|
56
23
|
//# sourceMappingURL=l1_to_l2_message_store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"l1_to_l2_message_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/memory_archiver_store/l1_to_l2_message_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"l1_to_l2_message_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/memory_archiver_store/l1_to_l2_message_store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAMjD,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C;;GAEG;AACH,qBAAa,kBAAkB;;IAC7B;;;OAGG;IACH,SAAS,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,EAAE,CAAC,CAAa;;IAM7C,UAAU,CAAC,OAAO,EAAE,SAAS;IAQ7B,WAAW,CAAC,WAAW,EAAE,MAAM,GAAG,EAAE,EAAE;IAqBtC;;;;OAIG;IACH,eAAe,CAAC,aAAa,EAAE,EAAE,GAAG,MAAM;CAY3C"}
|