@aztec/archiver 0.0.1-commit.88e6f9396 → 0.0.1-commit.8c0b8ff
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.d.ts +2 -1
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +22 -10
- package/dest/config.d.ts +3 -3
- package/dest/config.d.ts.map +1 -1
- package/dest/config.js +1 -2
- package/dest/errors.d.ts +1 -15
- package/dest/errors.d.ts.map +1 -1
- package/dest/errors.js +0 -18
- package/dest/factory.d.ts +3 -3
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +7 -4
- package/dest/l1/data_retrieval.d.ts +3 -6
- package/dest/l1/data_retrieval.d.ts.map +1 -1
- package/dest/l1/data_retrieval.js +6 -12
- package/dest/modules/data_source_base.d.ts +3 -3
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/data_source_base.js +4 -4
- package/dest/modules/data_store_updater.d.ts +1 -1
- package/dest/modules/data_store_updater.d.ts.map +1 -1
- package/dest/modules/data_store_updater.js +43 -10
- package/dest/modules/instrumentation.d.ts +1 -12
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +0 -10
- package/dest/modules/l1_synchronizer.d.ts +1 -1
- package/dest/modules/l1_synchronizer.d.ts.map +1 -1
- package/dest/modules/l1_synchronizer.js +13 -18
- package/dest/store/block_store.d.ts +2 -1
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +50 -5
- package/dest/store/contract_class_store.d.ts +1 -1
- package/dest/store/contract_class_store.d.ts.map +1 -1
- package/dest/store/contract_class_store.js +6 -2
- package/dest/store/contract_instance_store.d.ts +1 -1
- package/dest/store/contract_instance_store.d.ts.map +1 -1
- package/dest/store/contract_instance_store.js +6 -2
- package/dest/store/kv_archiver_store.d.ts +6 -11
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +7 -13
- package/dest/store/log_store.d.ts +3 -6
- package/dest/store/log_store.d.ts.map +1 -1
- package/dest/store/log_store.js +6 -45
- package/dest/store/message_store.d.ts +1 -5
- package/dest/store/message_store.d.ts.map +1 -1
- package/dest/store/message_store.js +0 -13
- package/dest/test/fake_l1_state.d.ts +8 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -1
- package/dest/test/fake_l1_state.js +16 -11
- package/package.json +13 -13
- package/src/archiver.ts +25 -10
- package/src/config.ts +1 -8
- package/src/errors.ts +0 -30
- package/src/factory.ts +13 -6
- package/src/l1/data_retrieval.ts +9 -17
- package/src/modules/data_source_base.ts +3 -8
- package/src/modules/data_store_updater.ts +51 -12
- package/src/modules/instrumentation.ts +0 -20
- package/src/modules/l1_synchronizer.ts +25 -29
- package/src/store/block_store.ts +62 -5
- package/src/store/contract_class_store.ts +7 -3
- package/src/store/contract_instance_store.ts +8 -5
- package/src/store/kv_archiver_store.ts +7 -19
- package/src/store/log_store.ts +15 -60
- package/src/store/message_store.ts +0 -19
- package/src/test/fake_l1_state.ts +20 -15
|
@@ -14,7 +14,6 @@ import {
|
|
|
14
14
|
} from '@aztec/kv-store';
|
|
15
15
|
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
16
16
|
|
|
17
|
-
import { L1ToL2MessagesNotReadyError } from '../errors.js';
|
|
18
17
|
import {
|
|
19
18
|
type InboxMessage,
|
|
20
19
|
deserializeInboxMessage,
|
|
@@ -41,8 +40,6 @@ export class MessageStore {
|
|
|
41
40
|
#lastSynchedL1Block: AztecAsyncSingleton<Buffer>;
|
|
42
41
|
/** Stores total messages stored */
|
|
43
42
|
#totalMessageCount: AztecAsyncSingleton<bigint>;
|
|
44
|
-
/** Stores the checkpoint number whose message tree is currently being filled on L1. */
|
|
45
|
-
#inboxTreeInProgress: AztecAsyncSingleton<bigint>;
|
|
46
43
|
|
|
47
44
|
#log = createLogger('archiver:message_store');
|
|
48
45
|
|
|
@@ -51,7 +48,6 @@ export class MessageStore {
|
|
|
51
48
|
this.#l1ToL2MessageIndices = db.openMap('archiver_l1_to_l2_message_indices');
|
|
52
49
|
this.#lastSynchedL1Block = db.openSingleton('archiver_last_l1_block_id');
|
|
53
50
|
this.#totalMessageCount = db.openSingleton('archiver_l1_to_l2_message_count');
|
|
54
|
-
this.#inboxTreeInProgress = db.openSingleton('archiver_inbox_tree_in_progress');
|
|
55
51
|
}
|
|
56
52
|
|
|
57
53
|
public async getTotalL1ToL2MessageCount(): Promise<bigint> {
|
|
@@ -189,22 +185,7 @@ export class MessageStore {
|
|
|
189
185
|
return msg ? deserializeInboxMessage(msg) : undefined;
|
|
190
186
|
}
|
|
191
187
|
|
|
192
|
-
/** Returns the inbox tree-in-progress checkpoint number from L1, or undefined if not yet set. */
|
|
193
|
-
public getInboxTreeInProgress(): Promise<bigint | undefined> {
|
|
194
|
-
return this.#inboxTreeInProgress.getAsync();
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
/** Persists the inbox tree-in-progress checkpoint number from L1 state. */
|
|
198
|
-
public async setInboxTreeInProgress(value: bigint): Promise<void> {
|
|
199
|
-
await this.#inboxTreeInProgress.set(value);
|
|
200
|
-
}
|
|
201
|
-
|
|
202
188
|
public async getL1ToL2Messages(checkpointNumber: CheckpointNumber): Promise<Fr[]> {
|
|
203
|
-
const treeInProgress = await this.#inboxTreeInProgress.getAsync();
|
|
204
|
-
if (treeInProgress !== undefined && BigInt(checkpointNumber) >= treeInProgress) {
|
|
205
|
-
throw new L1ToL2MessagesNotReadyError(checkpointNumber, treeInProgress);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
189
|
const messages: Fr[] = [];
|
|
209
190
|
|
|
210
191
|
const [startIndex, endIndex] = InboxLeaf.indexRangeForCheckpoint(checkpointNumber);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
2
|
import { type Blob, getBlobsPerL1Block, getPrefixedEthBlobCommitments } from '@aztec/blob-lib';
|
|
3
|
-
import { INITIAL_CHECKPOINT_NUMBER } from '@aztec/constants';
|
|
4
3
|
import type { CheckpointProposedLog, InboxContract, MessageSentLog, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
4
|
import { MULTI_CALL_3_ADDRESS } from '@aztec/ethereum/contracts';
|
|
6
5
|
import type { ViemPublicClient } from '@aztec/ethereum/types';
|
|
@@ -332,6 +331,21 @@ export class FakeL1State {
|
|
|
332
331
|
this.updatePendingCheckpointNumber();
|
|
333
332
|
}
|
|
334
333
|
|
|
334
|
+
/**
|
|
335
|
+
* Moves a checkpoint to a different L1 block number (simulates L1 reorg that
|
|
336
|
+
* re-includes the same checkpoint transaction in a different block).
|
|
337
|
+
* The checkpoint content stays the same — only the L1 metadata changes.
|
|
338
|
+
* Auto-updates pending status.
|
|
339
|
+
*/
|
|
340
|
+
moveCheckpointToL1Block(checkpointNumber: CheckpointNumber, newL1BlockNumber: bigint): void {
|
|
341
|
+
for (const cpData of this.checkpoints) {
|
|
342
|
+
if (cpData.checkpointNumber === checkpointNumber) {
|
|
343
|
+
cpData.l1BlockNumber = newL1BlockNumber;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
this.updatePendingCheckpointNumber();
|
|
347
|
+
}
|
|
348
|
+
|
|
335
349
|
/**
|
|
336
350
|
* Removes messages after a given total index (simulates L1 reorg).
|
|
337
351
|
* Auto-updates rolling hash.
|
|
@@ -451,22 +465,13 @@ export class FakeL1State {
|
|
|
451
465
|
createMockInboxContract(_publicClient: MockProxy<ViemPublicClient>): MockProxy<InboxContract> {
|
|
452
466
|
const mockInbox = mock<InboxContract>();
|
|
453
467
|
|
|
454
|
-
mockInbox.getState.mockImplementation(() =>
|
|
455
|
-
|
|
456
|
-
// after its messages are sealed, so treeInProgress > checkpointNumber for all published checkpoints.
|
|
457
|
-
const maxFromMessages =
|
|
458
|
-
this.messages.length > 0 ? Math.max(...this.messages.map(m => Number(m.checkpointNumber))) + 1 : 0;
|
|
459
|
-
const maxFromCheckpoints =
|
|
460
|
-
this.checkpoints.length > 0
|
|
461
|
-
? Math.max(...this.checkpoints.filter(cp => !cp.pruned).map(cp => Number(cp.checkpointNumber))) + 1
|
|
462
|
-
: 0;
|
|
463
|
-
const treeInProgress = Math.max(maxFromMessages, maxFromCheckpoints, INITIAL_CHECKPOINT_NUMBER);
|
|
464
|
-
return Promise.resolve({
|
|
468
|
+
mockInbox.getState.mockImplementation(() =>
|
|
469
|
+
Promise.resolve({
|
|
465
470
|
messagesRollingHash: this.messagesRollingHash,
|
|
466
471
|
totalMessagesInserted: BigInt(this.messages.length),
|
|
467
|
-
treeInProgress:
|
|
468
|
-
})
|
|
469
|
-
|
|
472
|
+
treeInProgress: 0n,
|
|
473
|
+
}),
|
|
474
|
+
);
|
|
470
475
|
|
|
471
476
|
// Mock the wrapper methods for fetching message events
|
|
472
477
|
mockInbox.getMessageSentEvents.mockImplementation((fromBlock: bigint, toBlock: bigint) =>
|