@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,74 +0,0 @@
|
|
|
1
|
-
import { Body } from '@aztec/circuit-types';
|
|
2
|
-
import { createDebugLogger } from '@aztec/foundation/log';
|
|
3
|
-
import { type AztecKVStore, type AztecMap, type AztecSingleton } from '@aztec/kv-store';
|
|
4
|
-
|
|
5
|
-
import { type DataRetrieval } from '../structs/data_retrieval.js';
|
|
6
|
-
|
|
7
|
-
export class BlockBodyStore {
|
|
8
|
-
/** Map block body hash to block body */
|
|
9
|
-
#blockBodies: AztecMap<string, Buffer>;
|
|
10
|
-
|
|
11
|
-
/** Stores L1 block number in which the last processed L2 block body was included */
|
|
12
|
-
#lastSynchedL1Block: AztecSingleton<bigint>;
|
|
13
|
-
|
|
14
|
-
constructor(private db: AztecKVStore, private log = createDebugLogger('aztec:archiver:block_body_store')) {
|
|
15
|
-
this.#blockBodies = db.openMap('archiver_block_bodies');
|
|
16
|
-
this.#lastSynchedL1Block = db.openSingleton('archiver_block_bodies_last_synched_l1_block');
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Append new block bodies to the store's map.
|
|
21
|
-
* @param blockBodies - The L2 block bodies to be added to the store.
|
|
22
|
-
* @returns True if the operation is successful.
|
|
23
|
-
*/
|
|
24
|
-
addBlockBodies(blockBodies: DataRetrieval<Body>): Promise<boolean> {
|
|
25
|
-
return this.db.transaction(() => {
|
|
26
|
-
for (const body of blockBodies.retrievedData) {
|
|
27
|
-
void this.#blockBodies.set(body.getTxsEffectsHash().toString('hex'), body.toBuffer());
|
|
28
|
-
}
|
|
29
|
-
void this.#lastSynchedL1Block.set(blockBodies.lastProcessedL1BlockNumber);
|
|
30
|
-
return true;
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Gets a list of L2 block bodies with its associated txsEffectsHashes
|
|
36
|
-
* @param txsEffectsHashes - The txsEffectsHashes list that corresponds to the blockBodies we want to retrieve
|
|
37
|
-
* @returns The requested L2 block bodies
|
|
38
|
-
*/
|
|
39
|
-
async getBlockBodies(txsEffectsHashes: Buffer[]): Promise<(Body | undefined)[]> {
|
|
40
|
-
const blockBodiesBuffer = await this.db.transaction(() =>
|
|
41
|
-
txsEffectsHashes.map(txsEffectsHash => this.#blockBodies.get(txsEffectsHash.toString('hex'))),
|
|
42
|
-
);
|
|
43
|
-
|
|
44
|
-
const blockBodies: (Body | undefined)[] = [];
|
|
45
|
-
for (let i = 0; i < blockBodiesBuffer.length; i++) {
|
|
46
|
-
const blockBodyBuffer = blockBodiesBuffer[i];
|
|
47
|
-
if (blockBodyBuffer === undefined) {
|
|
48
|
-
this.log.warn(`Block body buffer is undefined for txsEffectsHash: ${txsEffectsHashes[i].toString('hex')}`);
|
|
49
|
-
}
|
|
50
|
-
blockBodies.push(blockBodyBuffer ? Body.fromBuffer(blockBodyBuffer) : undefined);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return blockBodies;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Gets an L2 block body.
|
|
58
|
-
* @param txsEffectsHash - The txHash of the block body to return
|
|
59
|
-
* @returns The requested L2 block body
|
|
60
|
-
*/
|
|
61
|
-
getBlockBody(txsEffectsHash: Buffer): Body | undefined {
|
|
62
|
-
const blockBody = this.#blockBodies.get(txsEffectsHash.toString('hex'));
|
|
63
|
-
|
|
64
|
-
return blockBody && Body.fromBuffer(blockBody);
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
/**
|
|
68
|
-
* Gets the last L1 block number in which a L2 block body was included
|
|
69
|
-
* @returns The L1 block number
|
|
70
|
-
*/
|
|
71
|
-
getSynchedL1BlockNumber(): bigint | undefined {
|
|
72
|
-
return this.#lastSynchedL1Block.get();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import { type AztecKVStore, type AztecSingleton } from '@aztec/kv-store';
|
|
2
|
-
|
|
3
|
-
import { type SingletonDataRetrieval } from '../structs/data_retrieval.js';
|
|
4
|
-
|
|
5
|
-
export class ProvenStore {
|
|
6
|
-
/** Stores L1 block number in which the last processed L2 block was included */
|
|
7
|
-
#lastSynchedL1Block: AztecSingleton<bigint>;
|
|
8
|
-
|
|
9
|
-
/** Stores last proven L2 block number */
|
|
10
|
-
#lastProvenL2Block: AztecSingleton<number>;
|
|
11
|
-
|
|
12
|
-
constructor(private db: AztecKVStore) {
|
|
13
|
-
this.#lastSynchedL1Block = db.openSingleton('archiver_last_l1_block_proven_logs');
|
|
14
|
-
this.#lastProvenL2Block = db.openSingleton('archiver_last_proven_l2_block');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Gets the most recent L1 block processed.
|
|
19
|
-
*/
|
|
20
|
-
getSynchedL1BlockNumber(): bigint | undefined {
|
|
21
|
-
return this.#lastSynchedL1Block.get();
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
getProvenL2BlockNumber(): number {
|
|
25
|
-
return this.#lastProvenL2Block.get() ?? 0;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
async setProvenL2BlockNumber(blockNumber: SingletonDataRetrieval<number>) {
|
|
29
|
-
await this.db.transaction(() => {
|
|
30
|
-
void this.#lastProvenL2Block.set(blockNumber.retrievedData);
|
|
31
|
-
void this.#lastSynchedL1Block.set(blockNumber.lastProcessedL1BlockNumber);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
}
|