@aztec/archiver 0.0.1-commit.59e663cd → 0.0.1-commit.5cf06de3
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 +1 -1
- package/dest/archiver.d.ts.map +1 -1
- package/dest/archiver.js +15 -2
- package/dest/factory.d.ts +1 -1
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +1 -2
- package/dest/l1/data_retrieval.js +1 -1
- package/dest/l1/validate_trace.d.ts +6 -3
- package/dest/l1/validate_trace.d.ts.map +1 -1
- package/dest/l1/validate_trace.js +13 -9
- package/dest/modules/data_source_base.d.ts +5 -5
- package/dest/modules/data_source_base.d.ts.map +1 -1
- package/dest/modules/instrumentation.d.ts +1 -1
- package/dest/modules/instrumentation.d.ts.map +1 -1
- package/dest/modules/instrumentation.js +17 -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 +2 -3
- package/dest/store/block_store.d.ts +2 -2
- package/dest/store/block_store.d.ts.map +1 -1
- package/dest/store/block_store.js +2 -2
- 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 +11 -7
- package/dest/store/kv_archiver_store.d.ts +5 -5
- package/dest/store/kv_archiver_store.d.ts.map +1 -1
- package/dest/store/kv_archiver_store.js +2 -3
- package/dest/store/log_store.js +1 -1
- package/dest/test/index.d.ts +1 -2
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +3 -2
- package/dest/test/mock_l2_block_source.d.ts +4 -4
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +3 -3
- package/package.json +14 -13
- package/src/archiver.ts +21 -1
- package/src/factory.ts +1 -2
- package/src/l1/data_retrieval.ts +1 -1
- package/src/l1/validate_trace.ts +24 -6
- package/src/modules/data_source_base.ts +4 -4
- package/src/modules/instrumentation.ts +15 -10
- package/src/modules/l1_synchronizer.ts +2 -3
- package/src/store/block_store.ts +2 -2
- package/src/store/contract_class_store.ts +11 -7
- package/src/store/kv_archiver_store.ts +5 -5
- package/src/store/log_store.ts +2 -2
- package/src/test/index.ts +3 -1
- package/src/test/mock_l2_block_source.ts +5 -5
|
@@ -16,7 +16,7 @@ import { DateProvider, Timer, elapsed } from '@aztec/foundation/timer';
|
|
|
16
16
|
import { isDefined } from '@aztec/foundation/types';
|
|
17
17
|
import { type ArchiverEmitter, L2BlockSourceEvents, type ValidateCheckpointResult } from '@aztec/stdlib/block';
|
|
18
18
|
import { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
19
|
-
import { type L1RollupConstants, getEpochAtSlot,
|
|
19
|
+
import { type L1RollupConstants, getEpochAtSlot, getSlotAtNextL1Block } from '@aztec/stdlib/epoch-helpers';
|
|
20
20
|
import { computeInHashFromL1ToL2Messages } from '@aztec/stdlib/messaging';
|
|
21
21
|
import { type Traceable, type Tracer, execInSpan, trackSpan } from '@aztec/telemetry-client';
|
|
22
22
|
|
|
@@ -249,8 +249,7 @@ export class ArchiverL1Synchronizer implements Traceable {
|
|
|
249
249
|
const firstUncheckpointedBlockSlot = firstUncheckpointedBlockHeader?.getSlot();
|
|
250
250
|
|
|
251
251
|
// What's the slot at the next L1 block? All blocks for slots strictly before this one should've been checkpointed by now.
|
|
252
|
-
const
|
|
253
|
-
const slotAtNextL1Block = getSlotAtTimestamp(nextL1BlockTimestamp, this.l1Constants);
|
|
252
|
+
const slotAtNextL1Block = getSlotAtNextL1Block(currentL1Timestamp, this.l1Constants);
|
|
254
253
|
|
|
255
254
|
// Prune provisional blocks from slots that have ended without being checkpointed
|
|
256
255
|
if (firstUncheckpointedBlockSlot !== undefined && firstUncheckpointedBlockSlot < slotAtNextL1Block) {
|
package/src/store/block_store.ts
CHANGED
|
@@ -351,7 +351,7 @@ export class BlockStore {
|
|
|
351
351
|
}
|
|
352
352
|
|
|
353
353
|
private async addBlockToDatabase(block: L2Block, checkpointNumber: number, indexWithinCheckpoint: number) {
|
|
354
|
-
const blockHash =
|
|
354
|
+
const blockHash = await block.hash();
|
|
355
355
|
|
|
356
356
|
await this.#blocks.set(block.number, {
|
|
357
357
|
header: block.header.toBuffer(),
|
|
@@ -624,7 +624,7 @@ export class BlockStore {
|
|
|
624
624
|
}
|
|
625
625
|
}
|
|
626
626
|
|
|
627
|
-
async getCheckpointedBlockByHash(blockHash:
|
|
627
|
+
async getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined> {
|
|
628
628
|
const blockNumber = await this.#blockHashIndex.getAsync(blockHash.toString());
|
|
629
629
|
if (blockNumber === undefined) {
|
|
630
630
|
return undefined;
|
|
@@ -28,18 +28,22 @@ export class ContractClassStore {
|
|
|
28
28
|
bytecodeCommitment: Fr,
|
|
29
29
|
blockNumber: number,
|
|
30
30
|
): Promise<void> {
|
|
31
|
-
await this
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
await this.db.transactionAsync(async () => {
|
|
32
|
+
await this.#contractClasses.setIfNotExists(
|
|
33
|
+
contractClass.id.toString(),
|
|
34
|
+
serializeContractClassPublic({ ...contractClass, l2BlockNumber: blockNumber }),
|
|
35
|
+
);
|
|
36
|
+
await this.#bytecodeCommitments.setIfNotExists(contractClass.id.toString(), bytecodeCommitment.toBuffer());
|
|
37
|
+
});
|
|
36
38
|
}
|
|
37
39
|
|
|
38
40
|
async deleteContractClasses(contractClass: ContractClassPublic, blockNumber: number): Promise<void> {
|
|
39
41
|
const restoredContractClass = await this.#contractClasses.getAsync(contractClass.id.toString());
|
|
40
42
|
if (restoredContractClass && deserializeContractClassPublic(restoredContractClass).l2BlockNumber >= blockNumber) {
|
|
41
|
-
await this
|
|
42
|
-
|
|
43
|
+
await this.db.transactionAsync(async () => {
|
|
44
|
+
await this.#contractClasses.delete(contractClass.id.toString());
|
|
45
|
+
await this.#bytecodeCommitments.delete(contractClass.id.toString());
|
|
46
|
+
});
|
|
43
47
|
}
|
|
44
48
|
}
|
|
45
49
|
|
|
@@ -291,7 +291,7 @@ export class KVArchiverDataStore implements ContractDataSource {
|
|
|
291
291
|
* Returns the block for the given hash, or undefined if not exists.
|
|
292
292
|
* @param blockHash - The block hash to return.
|
|
293
293
|
*/
|
|
294
|
-
getCheckpointedBlockByHash(blockHash:
|
|
294
|
+
getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined> {
|
|
295
295
|
return this.#blockStore.getCheckpointedBlockByHash(blockHash);
|
|
296
296
|
}
|
|
297
297
|
/**
|
|
@@ -312,8 +312,8 @@ export class KVArchiverDataStore implements ContractDataSource {
|
|
|
312
312
|
* Returns the block for the given hash, or undefined if not exists.
|
|
313
313
|
* @param blockHash - The block hash to return.
|
|
314
314
|
*/
|
|
315
|
-
getBlockByHash(blockHash:
|
|
316
|
-
return this.#blockStore.getBlockByHash(
|
|
315
|
+
getBlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
|
|
316
|
+
return this.#blockStore.getBlockByHash(blockHash);
|
|
317
317
|
}
|
|
318
318
|
/**
|
|
319
319
|
* Returns the block for the given archive root, or undefined if not exists.
|
|
@@ -357,8 +357,8 @@ export class KVArchiverDataStore implements ContractDataSource {
|
|
|
357
357
|
* Returns the block header for the given hash, or undefined if not exists.
|
|
358
358
|
* @param blockHash - The block hash to return.
|
|
359
359
|
*/
|
|
360
|
-
getBlockHeaderByHash(blockHash:
|
|
361
|
-
return this.#blockStore.getBlockHeaderByHash(
|
|
360
|
+
getBlockHeaderByHash(blockHash: BlockHash): Promise<BlockHeader | undefined> {
|
|
361
|
+
return this.#blockStore.getBlockHeaderByHash(blockHash);
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
/**
|
package/src/store/log_store.ts
CHANGED
|
@@ -271,7 +271,7 @@ export class LogStore {
|
|
|
271
271
|
});
|
|
272
272
|
}
|
|
273
273
|
|
|
274
|
-
#packWithBlockHash(blockHash:
|
|
274
|
+
#packWithBlockHash(blockHash: BlockHash, data: Buffer<ArrayBufferLike>[]): Buffer<ArrayBufferLike> {
|
|
275
275
|
return Buffer.concat([blockHash.toBuffer(), ...data]);
|
|
276
276
|
}
|
|
277
277
|
|
|
@@ -282,7 +282,7 @@ export class LogStore {
|
|
|
282
282
|
throw new Error('Failed to read block hash from log entry buffer');
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
-
return BlockHash
|
|
285
|
+
return new BlockHash(blockHash);
|
|
286
286
|
}
|
|
287
287
|
|
|
288
288
|
deleteLogs(blocks: L2Block[]): Promise<boolean> {
|
package/src/test/index.ts
CHANGED
|
@@ -2,4 +2,6 @@ export * from './mock_structs.js';
|
|
|
2
2
|
export * from './mock_l2_block_source.js';
|
|
3
3
|
export * from './mock_l1_to_l2_message_source.js';
|
|
4
4
|
export * from './mock_archiver.js';
|
|
5
|
-
|
|
5
|
+
// NOTE: noop_l1_archiver.js is intentionally NOT exported here because it imports
|
|
6
|
+
// jest-mock-extended, which depends on @jest/globals and can only run inside Jest.
|
|
7
|
+
// Import it directly: import { NoopL1Archiver } from '@aztec/archiver/test/noop-l1';
|
|
@@ -195,7 +195,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
195
195
|
return checkpoint;
|
|
196
196
|
}
|
|
197
197
|
|
|
198
|
-
public async getCheckpointedBlockByHash(blockHash:
|
|
198
|
+
public async getCheckpointedBlockByHash(blockHash: BlockHash): Promise<CheckpointedL2Block | undefined> {
|
|
199
199
|
for (const block of this.l2Blocks) {
|
|
200
200
|
const hash = await block.hash();
|
|
201
201
|
if (hash.equals(blockHash)) {
|
|
@@ -225,7 +225,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
225
225
|
);
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
-
public async getL2BlockByHash(blockHash:
|
|
228
|
+
public async getL2BlockByHash(blockHash: BlockHash): Promise<L2Block | undefined> {
|
|
229
229
|
for (const block of this.l2Blocks) {
|
|
230
230
|
const hash = await block.hash();
|
|
231
231
|
if (hash.equals(blockHash)) {
|
|
@@ -240,7 +240,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
240
240
|
return Promise.resolve(block);
|
|
241
241
|
}
|
|
242
242
|
|
|
243
|
-
public async getBlockHeaderByHash(blockHash:
|
|
243
|
+
public async getBlockHeaderByHash(blockHash: BlockHash): Promise<BlockHeader | undefined> {
|
|
244
244
|
for (const block of this.l2Blocks) {
|
|
245
245
|
const hash = await block.hash();
|
|
246
246
|
if (hash.equals(blockHash)) {
|
|
@@ -322,7 +322,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
322
322
|
return {
|
|
323
323
|
data: txEffect,
|
|
324
324
|
l2BlockNumber: block.number,
|
|
325
|
-
l2BlockHash:
|
|
325
|
+
l2BlockHash: await block.hash(),
|
|
326
326
|
txIndexInBlock: block.body.txEffects.indexOf(txEffect),
|
|
327
327
|
};
|
|
328
328
|
}
|
|
@@ -343,7 +343,7 @@ export class MockL2BlockSource implements L2BlockSource, ContractDataSource {
|
|
|
343
343
|
TxExecutionResult.SUCCESS,
|
|
344
344
|
undefined,
|
|
345
345
|
txEffect.transactionFee.toBigInt(),
|
|
346
|
-
|
|
346
|
+
await block.hash(),
|
|
347
347
|
block.number,
|
|
348
348
|
);
|
|
349
349
|
}
|