@aztec/archiver 0.47.1 → 0.49.2
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 +4 -0
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +53 -22
- package/dest/archiver/archiver_store.d.ts +5 -3
- 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 +21 -5
- package/dest/archiver/config.d.ts +5 -15
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +30 -13
- package/dest/archiver/data_retrieval.d.ts +11 -5
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +26 -5
- package/dest/archiver/eth_log_handlers.d.ts.map +1 -1
- package/dest/archiver/eth_log_handlers.js +35 -13
- package/dest/archiver/instrumentation.d.ts +3 -1
- package/dest/archiver/instrumentation.d.ts.map +1 -1
- package/dest/archiver/instrumentation.js +15 -6
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts +11 -4
- package/dest/archiver/kv_archiver_store/block_body_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_body_store.js +27 -9
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +2 -2
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +2 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts +4 -3
- package/dest/archiver/memory_archiver_store/memory_archiver_store.d.ts.map +1 -1
- package/dest/archiver/memory_archiver_store/memory_archiver_store.js +7 -8
- package/dest/index.d.ts +1 -0
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +4 -2
- package/package.json +10 -10
- package/src/archiver/archiver.ts +61 -22
- package/src/archiver/archiver_store.ts +5 -3
- package/src/archiver/archiver_store_test_suite.ts +26 -9
- package/src/archiver/config.ts +33 -37
- package/src/archiver/data_retrieval.ts +39 -8
- package/src/archiver/eth_log_handlers.ts +43 -13
- package/src/archiver/instrumentation.ts +26 -6
- package/src/archiver/kv_archiver_store/block_body_store.ts +30 -10
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +3 -2
- package/src/archiver/memory_archiver_store/memory_archiver_store.ts +10 -12
- package/src/index.ts +4 -1
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type Body, type InboxLeaf } from '@aztec/circuit-types';
|
|
2
|
-
import { type AppendOnlyTreeSnapshot, type Header } from '@aztec/circuits.js';
|
|
2
|
+
import { type AppendOnlyTreeSnapshot, Fr, type Header } from '@aztec/circuits.js';
|
|
3
3
|
import { type EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
+
import { type DebugLogger, createDebugLogger } from '@aztec/foundation/log';
|
|
5
|
+
import { RollupAbi } from '@aztec/l1-artifacts';
|
|
4
6
|
|
|
5
|
-
import { type PublicClient } from 'viem';
|
|
7
|
+
import { type PublicClient, getAbiItem } from 'viem';
|
|
6
8
|
|
|
7
9
|
import {
|
|
8
10
|
getL2BlockProcessedLogs,
|
|
@@ -44,6 +46,7 @@ export async function retrieveBlockMetadataFromRollup(
|
|
|
44
46
|
searchStartBlock: bigint,
|
|
45
47
|
searchEndBlock: bigint,
|
|
46
48
|
expectedNextL2BlockNum: bigint,
|
|
49
|
+
logger: DebugLogger = createDebugLogger('aztec:archiver'),
|
|
47
50
|
): Promise<DataRetrieval<[Header, AppendOnlyTreeSnapshot]>> {
|
|
48
51
|
const retrievedBlockMetadata: [Header, AppendOnlyTreeSnapshot][] = [];
|
|
49
52
|
do {
|
|
@@ -60,13 +63,18 @@ export async function retrieveBlockMetadataFromRollup(
|
|
|
60
63
|
break;
|
|
61
64
|
}
|
|
62
65
|
|
|
66
|
+
const lastLog = l2BlockProcessedLogs[l2BlockProcessedLogs.length - 1];
|
|
67
|
+
logger.debug(
|
|
68
|
+
`Got L2 block processed logs for ${l2BlockProcessedLogs[0].blockNumber}-${lastLog.blockNumber} between ${searchStartBlock}-${searchEndBlock} L1 blocks`,
|
|
69
|
+
);
|
|
70
|
+
|
|
63
71
|
const newBlockMetadata = await processL2BlockProcessedLogs(
|
|
64
72
|
publicClient,
|
|
65
73
|
expectedNextL2BlockNum,
|
|
66
74
|
l2BlockProcessedLogs,
|
|
67
75
|
);
|
|
68
76
|
retrievedBlockMetadata.push(...newBlockMetadata);
|
|
69
|
-
searchStartBlock =
|
|
77
|
+
searchStartBlock = lastLog.blockNumber! + 1n;
|
|
70
78
|
expectedNextL2BlockNum += BigInt(newBlockMetadata.length);
|
|
71
79
|
} while (blockUntilSynced && searchStartBlock <= searchEndBlock);
|
|
72
80
|
return { lastProcessedL1BlockNumber: searchStartBlock - 1n, retrievedData: retrievedBlockMetadata };
|
|
@@ -79,7 +87,7 @@ export async function retrieveBlockMetadataFromRollup(
|
|
|
79
87
|
* @param blockUntilSynced - If true, blocks until the archiver has fully synced.
|
|
80
88
|
* @param searchStartBlock - The block number to use for starting the search.
|
|
81
89
|
* @param searchEndBlock - The highest block number that we should search up to.
|
|
82
|
-
* @returns A array of
|
|
90
|
+
* @returns A array of L2 block bodies as well as the next eth block to search from
|
|
83
91
|
*/
|
|
84
92
|
export async function retrieveBlockBodiesFromAvailabilityOracle(
|
|
85
93
|
publicClient: PublicClient,
|
|
@@ -87,8 +95,8 @@ export async function retrieveBlockBodiesFromAvailabilityOracle(
|
|
|
87
95
|
blockUntilSynced: boolean,
|
|
88
96
|
searchStartBlock: bigint,
|
|
89
97
|
searchEndBlock: bigint,
|
|
90
|
-
): Promise<DataRetrieval<
|
|
91
|
-
const retrievedBlockBodies:
|
|
98
|
+
): Promise<DataRetrieval<Body>> {
|
|
99
|
+
const retrievedBlockBodies: Body[] = [];
|
|
92
100
|
|
|
93
101
|
do {
|
|
94
102
|
if (searchStartBlock > searchEndBlock) {
|
|
@@ -105,9 +113,10 @@ export async function retrieveBlockBodiesFromAvailabilityOracle(
|
|
|
105
113
|
}
|
|
106
114
|
|
|
107
115
|
const newBlockBodies = await processTxsPublishedLogs(publicClient, l2TxsPublishedLogs);
|
|
108
|
-
retrievedBlockBodies.push(...newBlockBodies);
|
|
109
|
-
searchStartBlock = l2TxsPublishedLogs[l2TxsPublishedLogs.length - 1].blockNumber
|
|
116
|
+
retrievedBlockBodies.push(...newBlockBodies.map(([body]) => body));
|
|
117
|
+
searchStartBlock = l2TxsPublishedLogs[l2TxsPublishedLogs.length - 1].blockNumber + 1n;
|
|
110
118
|
} while (blockUntilSynced && searchStartBlock <= searchEndBlock);
|
|
119
|
+
|
|
111
120
|
return { lastProcessedL1BlockNumber: searchStartBlock - 1n, retrievedData: retrievedBlockBodies };
|
|
112
121
|
}
|
|
113
122
|
|
|
@@ -143,3 +152,25 @@ export async function retrieveL1ToL2Messages(
|
|
|
143
152
|
} while (blockUntilSynced && searchStartBlock <= searchEndBlock);
|
|
144
153
|
return { lastProcessedL1BlockNumber: searchStartBlock - 1n, retrievedData: retrievedL1ToL2Messages };
|
|
145
154
|
}
|
|
155
|
+
|
|
156
|
+
/** Retrieves L2ProofVerified events from the rollup contract. */
|
|
157
|
+
export async function retrieveL2ProofVerifiedEvents(
|
|
158
|
+
publicClient: PublicClient,
|
|
159
|
+
rollupAddress: EthAddress,
|
|
160
|
+
searchStartBlock: bigint,
|
|
161
|
+
searchEndBlock?: bigint,
|
|
162
|
+
): Promise<{ l1BlockNumber: bigint; l2BlockNumber: bigint; proverId: Fr }[]> {
|
|
163
|
+
const logs = await publicClient.getLogs({
|
|
164
|
+
address: rollupAddress.toString(),
|
|
165
|
+
fromBlock: searchStartBlock,
|
|
166
|
+
toBlock: searchEndBlock ? searchEndBlock + 1n : undefined,
|
|
167
|
+
strict: true,
|
|
168
|
+
event: getAbiItem({ abi: RollupAbi, name: 'L2ProofVerified' }),
|
|
169
|
+
});
|
|
170
|
+
|
|
171
|
+
return logs.map(log => ({
|
|
172
|
+
l1BlockNumber: log.blockNumber,
|
|
173
|
+
l2BlockNumber: log.args.blockNumber,
|
|
174
|
+
proverId: Fr.fromString(log.args.proverId),
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
@@ -5,7 +5,16 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
5
5
|
import { numToUInt32BE } from '@aztec/foundation/serialize';
|
|
6
6
|
import { AvailabilityOracleAbi, InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
7
7
|
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
type Hex,
|
|
10
|
+
type Log,
|
|
11
|
+
type PublicClient,
|
|
12
|
+
decodeFunctionData,
|
|
13
|
+
getAbiItem,
|
|
14
|
+
getAddress,
|
|
15
|
+
hexToBytes,
|
|
16
|
+
slice,
|
|
17
|
+
} from 'viem';
|
|
9
18
|
|
|
10
19
|
/**
|
|
11
20
|
* Processes newly received MessageSent (L1 to L2) logs.
|
|
@@ -88,7 +97,7 @@ async function getBlockMetadataFromRollupTx(
|
|
|
88
97
|
data,
|
|
89
98
|
});
|
|
90
99
|
|
|
91
|
-
if (functionName
|
|
100
|
+
if (!(functionName === 'process' || functionName === 'publishAndProcess')) {
|
|
92
101
|
throw new Error(`Unexpected method called ${functionName}`);
|
|
93
102
|
}
|
|
94
103
|
const [headerHex, archiveRootHex] = args! as readonly [Hex, Hex];
|
|
@@ -113,7 +122,7 @@ async function getBlockMetadataFromRollupTx(
|
|
|
113
122
|
|
|
114
123
|
/**
|
|
115
124
|
* Gets block bodies from calldata of an L1 transaction, and deserializes them into Body objects.
|
|
116
|
-
* Assumes that the block was published
|
|
125
|
+
* @note Assumes that the block was published using `publishAndProcess` or `publish`.
|
|
117
126
|
* TODO: Add retries and error management.
|
|
118
127
|
* @param publicClient - The viem public client to use for transaction retrieval.
|
|
119
128
|
* @param txHash - Hash of the tx that published it.
|
|
@@ -124,20 +133,41 @@ async function getBlockBodiesFromAvailabilityOracleTx(
|
|
|
124
133
|
txHash: `0x${string}`,
|
|
125
134
|
): Promise<Body> {
|
|
126
135
|
const { input: data } = await publicClient.getTransaction({ hash: txHash });
|
|
127
|
-
const
|
|
128
|
-
abi: AvailabilityOracleAbi,
|
|
129
|
-
data,
|
|
130
|
-
});
|
|
136
|
+
const DATA_INDEX = [3, 2, 0];
|
|
131
137
|
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
138
|
+
// @note Use `forge inspect Rollup methodIdentifiers to get this,
|
|
139
|
+
// If using `forge sig` you will get an INVALID value for the case with a struct.
|
|
140
|
+
// [
|
|
141
|
+
// "publishAndProcess(bytes calldata _header,bytes32 _archive,SignatureLib.Signature[] memory _signatures,bytes calldata _body)",
|
|
142
|
+
// "publishAndProcess(bytes calldata _header,bytes32 _archive,bytes calldata _body)",
|
|
143
|
+
// "publish(bytes calldata _body)"
|
|
144
|
+
// ]
|
|
145
|
+
const SUPPORTED_SIGS = ['0xe4e90c26', '0xe86e3595', '0x7fd28346'];
|
|
135
146
|
|
|
136
|
-
const
|
|
147
|
+
const signature = slice(data, 0, 4);
|
|
137
148
|
|
|
138
|
-
|
|
149
|
+
if (!SUPPORTED_SIGS.includes(signature)) {
|
|
150
|
+
throw new Error(`Unexpected method called ${signature}`);
|
|
151
|
+
}
|
|
139
152
|
|
|
140
|
-
|
|
153
|
+
if (signature === SUPPORTED_SIGS[2]) {
|
|
154
|
+
const { args } = decodeFunctionData({
|
|
155
|
+
abi: AvailabilityOracleAbi,
|
|
156
|
+
data,
|
|
157
|
+
});
|
|
158
|
+
const [bodyHex] = args! as [Hex];
|
|
159
|
+
const blockBody = Body.fromBuffer(Buffer.from(hexToBytes(bodyHex)));
|
|
160
|
+
return blockBody;
|
|
161
|
+
} else {
|
|
162
|
+
const { args } = decodeFunctionData({
|
|
163
|
+
abi: RollupAbi,
|
|
164
|
+
data,
|
|
165
|
+
});
|
|
166
|
+
const index = SUPPORTED_SIGS.indexOf(signature);
|
|
167
|
+
const bodyHex = args![DATA_INDEX[index]] as Hex;
|
|
168
|
+
const blockBody = Body.fromBuffer(Buffer.from(hexToBytes(bodyHex)));
|
|
169
|
+
return blockBody;
|
|
170
|
+
}
|
|
141
171
|
}
|
|
142
172
|
|
|
143
173
|
/**
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import { type L2Block } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
Attributes,
|
|
4
|
+
type Gauge,
|
|
5
|
+
type Histogram,
|
|
6
|
+
Metrics,
|
|
7
|
+
type TelemetryClient,
|
|
8
|
+
ValueType,
|
|
9
|
+
exponentialBuckets,
|
|
10
|
+
} from '@aztec/telemetry-client';
|
|
3
11
|
|
|
4
12
|
export class ArchiverInstrumentation {
|
|
5
13
|
private blockHeight: Gauge;
|
|
6
|
-
private blockSize:
|
|
14
|
+
private blockSize: Gauge;
|
|
15
|
+
private syncDuration: Histogram;
|
|
7
16
|
|
|
8
17
|
constructor(telemetry: TelemetryClient) {
|
|
9
18
|
const meter = telemetry.getMeter('Archiver');
|
|
@@ -12,19 +21,30 @@ export class ArchiverInstrumentation {
|
|
|
12
21
|
valueType: ValueType.INT,
|
|
13
22
|
});
|
|
14
23
|
|
|
15
|
-
this.blockSize = meter.
|
|
16
|
-
description: 'The number of transactions
|
|
24
|
+
this.blockSize = meter.createGauge(Metrics.ARCHIVER_BLOCK_SIZE, {
|
|
25
|
+
description: 'The number of transactions in a block',
|
|
26
|
+
valueType: ValueType.INT,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
this.syncDuration = meter.createHistogram(Metrics.ARCHIVER_SYNC_DURATION, {
|
|
30
|
+
unit: 'ms',
|
|
31
|
+
description: 'Duration to sync a block',
|
|
17
32
|
valueType: ValueType.INT,
|
|
18
33
|
advice: {
|
|
19
|
-
explicitBucketBoundaries:
|
|
34
|
+
explicitBucketBoundaries: exponentialBuckets(1, 16),
|
|
20
35
|
},
|
|
21
36
|
});
|
|
22
37
|
}
|
|
23
38
|
|
|
24
|
-
public processNewBlocks(blocks: L2Block[]) {
|
|
39
|
+
public processNewBlocks(syncTimePerBlock: number, blocks: L2Block[]) {
|
|
40
|
+
this.syncDuration.record(syncTimePerBlock);
|
|
25
41
|
this.blockHeight.record(Math.max(...blocks.map(b => b.number)));
|
|
26
42
|
for (const block of blocks) {
|
|
27
43
|
this.blockSize.record(block.body.txEffects.length);
|
|
28
44
|
}
|
|
29
45
|
}
|
|
46
|
+
|
|
47
|
+
public updateLastProvenBlock(blockNumber: number) {
|
|
48
|
+
this.blockHeight.record(blockNumber, { [Attributes.STATUS]: 'proven' });
|
|
49
|
+
}
|
|
30
50
|
}
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import { Body } from '@aztec/circuit-types';
|
|
2
|
-
import {
|
|
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 '../data_retrieval.js';
|
|
3
6
|
|
|
4
7
|
export class BlockBodyStore {
|
|
5
8
|
/** Map block body hash to block body */
|
|
6
9
|
#blockBodies: AztecMap<string, Buffer>;
|
|
7
10
|
|
|
8
|
-
|
|
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')) {
|
|
9
15
|
this.#blockBodies = db.openMap('archiver_block_bodies');
|
|
16
|
+
this.#lastSynchedL1Block = db.openSingleton('archiver_block_bodies_last_synched_l1_block');
|
|
10
17
|
}
|
|
11
18
|
|
|
12
19
|
/**
|
|
@@ -14,12 +21,12 @@ export class BlockBodyStore {
|
|
|
14
21
|
* @param blockBodies - The L2 block bodies to be added to the store.
|
|
15
22
|
* @returns True if the operation is successful.
|
|
16
23
|
*/
|
|
17
|
-
addBlockBodies(blockBodies: Body
|
|
24
|
+
addBlockBodies(blockBodies: DataRetrieval<Body>): Promise<boolean> {
|
|
18
25
|
return this.db.transaction(() => {
|
|
19
|
-
for (const body of blockBodies) {
|
|
26
|
+
for (const body of blockBodies.retrievedData) {
|
|
20
27
|
void this.#blockBodies.set(body.getTxsEffectsHash().toString('hex'), body.toBuffer());
|
|
21
28
|
}
|
|
22
|
-
|
|
29
|
+
void this.#lastSynchedL1Block.set(blockBodies.lastProcessedL1BlockNumber);
|
|
23
30
|
return true;
|
|
24
31
|
});
|
|
25
32
|
}
|
|
@@ -29,21 +36,26 @@ export class BlockBodyStore {
|
|
|
29
36
|
* @param txsEffectsHashes - The txsEffectsHashes list that corresponds to the blockBodies we want to retrieve
|
|
30
37
|
* @returns The requested L2 block bodies
|
|
31
38
|
*/
|
|
32
|
-
async getBlockBodies(txsEffectsHashes: Buffer[]): Promise<Body[]> {
|
|
39
|
+
async getBlockBodies(txsEffectsHashes: Buffer[]): Promise<(Body | undefined)[]> {
|
|
33
40
|
const blockBodiesBuffer = await this.db.transaction(() =>
|
|
34
41
|
txsEffectsHashes.map(txsEffectsHash => this.#blockBodies.get(txsEffectsHash.toString('hex'))),
|
|
35
42
|
);
|
|
36
43
|
|
|
37
|
-
|
|
38
|
-
|
|
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);
|
|
39
51
|
}
|
|
40
52
|
|
|
41
|
-
return
|
|
53
|
+
return blockBodies;
|
|
42
54
|
}
|
|
43
55
|
|
|
44
56
|
/**
|
|
45
57
|
* Gets an L2 block body.
|
|
46
|
-
* @param txsEffectsHash - The txHash of the
|
|
58
|
+
* @param txsEffectsHash - The txHash of the block body to return
|
|
47
59
|
* @returns The requested L2 block body
|
|
48
60
|
*/
|
|
49
61
|
getBlockBody(txsEffectsHash: Buffer): Body | undefined {
|
|
@@ -51,4 +63,12 @@ export class BlockBodyStore {
|
|
|
51
63
|
|
|
52
64
|
return blockBody && Body.fromBuffer(blockBody);
|
|
53
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 {
|
|
72
|
+
return this.#lastSynchedL1Block.get() ?? 0n;
|
|
73
|
+
}
|
|
54
74
|
}
|
|
@@ -101,7 +101,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
101
101
|
* @param blockBodies - The L2 block bodies to be added to the store.
|
|
102
102
|
* @returns True if the operation is successful.
|
|
103
103
|
*/
|
|
104
|
-
addBlockBodies(blockBodies: Body
|
|
104
|
+
addBlockBodies(blockBodies: DataRetrieval<Body>): Promise<boolean> {
|
|
105
105
|
return this.#blockBodyStore.addBlockBodies(blockBodies);
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -111,7 +111,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
111
111
|
* @param txsEffectsHashes - A list of txsEffectsHashes (body hashes).
|
|
112
112
|
* @returns The requested L2 block bodies
|
|
113
113
|
*/
|
|
114
|
-
getBlockBodies(txsEffectsHashes: Buffer[]): Promise<Body[]> {
|
|
114
|
+
getBlockBodies(txsEffectsHashes: Buffer[]): Promise<(Body | undefined)[]> {
|
|
115
115
|
return this.#blockBodyStore.getBlockBodies(txsEffectsHashes);
|
|
116
116
|
}
|
|
117
117
|
|
|
@@ -260,6 +260,7 @@ export class KVArchiverDataStore implements ArchiverDataStore {
|
|
|
260
260
|
getSynchPoint(): Promise<ArchiverL1SynchPoint> {
|
|
261
261
|
return Promise.resolve({
|
|
262
262
|
blocksSynchedTo: this.#blockStore.getSynchedL1BlockNumber(),
|
|
263
|
+
blockBodiesSynchedTo: this.#blockBodyStore.getSynchedL1BlockNumber(),
|
|
263
264
|
messagesSynchedTo: this.#messageStore.getSynchedL1BlockNumber(),
|
|
264
265
|
});
|
|
265
266
|
}
|
|
@@ -45,7 +45,7 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
45
45
|
private l2BlockBodies: Map<string, Body> = new Map();
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* An array containing all the
|
|
48
|
+
* An array containing all the tx effects in the L2 blocks that have been fetched so far.
|
|
49
49
|
*/
|
|
50
50
|
private txEffects: TxEffect[] = [];
|
|
51
51
|
|
|
@@ -83,6 +83,7 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
83
83
|
private contractInstances: Map<string, ContractInstanceWithAddress> = new Map();
|
|
84
84
|
|
|
85
85
|
private lastL1BlockNewBlocks: bigint = 0n;
|
|
86
|
+
private lastL1BlockNewBlockBodies: bigint = 0n;
|
|
86
87
|
private lastL1BlockNewMessages: bigint = 0n;
|
|
87
88
|
private lastProvenL2BlockNumber: number = 0;
|
|
88
89
|
|
|
@@ -163,11 +164,11 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
163
164
|
* @param blockBodies - The L2 block bodies to be added to the store.
|
|
164
165
|
* @returns True if the operation is successful.
|
|
165
166
|
*/
|
|
166
|
-
addBlockBodies(blockBodies: Body
|
|
167
|
-
for (const body of blockBodies) {
|
|
167
|
+
addBlockBodies(blockBodies: DataRetrieval<Body>): Promise<boolean> {
|
|
168
|
+
for (const body of blockBodies.retrievedData) {
|
|
168
169
|
void this.l2BlockBodies.set(body.getTxsEffectsHash().toString('hex'), body);
|
|
169
170
|
}
|
|
170
|
-
|
|
171
|
+
this.lastL1BlockNewBlockBodies = blockBodies.lastProcessedL1BlockNumber;
|
|
171
172
|
return Promise.resolve(true);
|
|
172
173
|
}
|
|
173
174
|
|
|
@@ -177,14 +178,10 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
177
178
|
* @param txsEffectsHashes - A list of txsEffectsHashes (body hashes).
|
|
178
179
|
* @returns The requested L2 block bodies
|
|
179
180
|
*/
|
|
180
|
-
getBlockBodies(txsEffectsHashes: Buffer[]): Promise<Body[]> {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
throw new Error('Block body is undefined');
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return Promise.resolve(blockBodies as Body[]);
|
|
181
|
+
getBlockBodies(txsEffectsHashes: Buffer[]): Promise<(Body | undefined)[]> {
|
|
182
|
+
return Promise.resolve(
|
|
183
|
+
txsEffectsHashes.map(txsEffectsHash => this.l2BlockBodies.get(txsEffectsHash.toString('hex'))),
|
|
184
|
+
);
|
|
188
185
|
}
|
|
189
186
|
|
|
190
187
|
/**
|
|
@@ -447,6 +444,7 @@ export class MemoryArchiverStore implements ArchiverDataStore {
|
|
|
447
444
|
return Promise.resolve({
|
|
448
445
|
blocksSynchedTo: this.lastL1BlockNewBlocks,
|
|
449
446
|
messagesSynchedTo: this.lastL1BlockNewMessages,
|
|
447
|
+
blockBodiesSynchedTo: this.lastL1BlockNewBlockBodies,
|
|
450
448
|
});
|
|
451
449
|
}
|
|
452
450
|
|
package/src/index.ts
CHANGED
|
@@ -12,6 +12,9 @@ export * from './archiver/index.js';
|
|
|
12
12
|
export * from './rpc/index.js';
|
|
13
13
|
export * from './factory.js';
|
|
14
14
|
|
|
15
|
+
// We are not storing the info from these events in the archiver for now (and we don't really need to), so we expose this query directly
|
|
16
|
+
export { retrieveL2ProofVerifiedEvents } from './archiver/data_retrieval.js';
|
|
17
|
+
|
|
15
18
|
const log = createDebugLogger('aztec:archiver');
|
|
16
19
|
|
|
17
20
|
/**
|
|
@@ -20,7 +23,7 @@ const log = createDebugLogger('aztec:archiver');
|
|
|
20
23
|
// eslint-disable-next-line require-await
|
|
21
24
|
async function main() {
|
|
22
25
|
const config = getArchiverConfigFromEnv();
|
|
23
|
-
const { rpcUrl, l1Contracts } = config;
|
|
26
|
+
const { l1RpcUrl: rpcUrl, l1Contracts } = config;
|
|
24
27
|
|
|
25
28
|
const publicClient = createPublicClient({
|
|
26
29
|
chain: localhost,
|