@aztec/archiver 0.87.2 → 0.87.3-nightly.20250529
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 -3
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +20 -2
- package/dest/archiver/archiver_store_test_suite.d.ts.map +1 -1
- package/dest/archiver/archiver_store_test_suite.js +5 -6
- package/dest/archiver/data_retrieval.d.ts +4 -5
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +11 -10
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +13 -10
- package/dest/test/mock_l2_block_source.d.ts +1 -1
- package/dest/test/mock_l2_block_source.js +1 -1
- package/package.json +12 -14
- package/src/archiver/archiver.ts +27 -3
- package/src/archiver/archiver_store_test_suite.ts +5 -6
- package/src/archiver/data_retrieval.ts +20 -13
- package/src/archiver/kv_archiver_store/block_store.ts +15 -11
- package/src/test/mock_l2_block_source.ts +1 -1
|
@@ -7,7 +7,7 @@ import { type Logger } from '@aztec/foundation/log';
|
|
|
7
7
|
import type { CustomRange } from '@aztec/kv-store';
|
|
8
8
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
9
9
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
-
import { type L2Block, type L2BlockSource, type L2Tips } from '@aztec/stdlib/block';
|
|
10
|
+
import { type ArchiverEmitter, type L2Block, type L2BlockSource, type L2Tips } from '@aztec/stdlib/block';
|
|
11
11
|
import { type ContractClassPublic, type ContractDataSource, type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
12
12
|
import { type L1RollupConstants } from '@aztec/stdlib/epoch-helpers';
|
|
13
13
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
@@ -16,7 +16,6 @@ import { type LogFilter, type PrivateLog, TxScopedL2Log } from '@aztec/stdlib/lo
|
|
|
16
16
|
import type { L1ToL2MessageSource } from '@aztec/stdlib/messaging';
|
|
17
17
|
import { type BlockHeader, type IndexedTxEffect, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
18
18
|
import { type TelemetryClient, type Traceable, type Tracer } from '@aztec/telemetry-client';
|
|
19
|
-
import { EventEmitter } from 'events';
|
|
20
19
|
import type { ArchiverDataStore, ArchiverL1SynchPoint } from './archiver_store.js';
|
|
21
20
|
import type { ArchiverConfig } from './config.js';
|
|
22
21
|
import { ArchiverInstrumentation } from './instrumentation.js';
|
|
@@ -26,12 +25,13 @@ import type { PublishedL2Block } from './structs/published.js';
|
|
|
26
25
|
* Helper interface to combine all sources this archiver implementation provides.
|
|
27
26
|
*/
|
|
28
27
|
export type ArchiveSource = L2BlockSource & L2LogsSource & ContractDataSource & L1ToL2MessageSource;
|
|
28
|
+
declare const Archiver_base: new () => ArchiverEmitter;
|
|
29
29
|
/**
|
|
30
30
|
* Pulls L2 blocks in a non-blocking manner and provides interface for their retrieval.
|
|
31
31
|
* Responsible for handling robust L1 polling so that other components do not need to
|
|
32
32
|
* concern themselves with it.
|
|
33
33
|
*/
|
|
34
|
-
export declare class Archiver extends
|
|
34
|
+
export declare class Archiver extends Archiver_base implements ArchiveSource, Traceable {
|
|
35
35
|
private readonly publicClient;
|
|
36
36
|
private readonly l1Addresses;
|
|
37
37
|
readonly dataStore: ArchiverDataStore;
|
|
@@ -246,4 +246,5 @@ export declare class ArchiverStoreHelper implements Omit<ArchiverDataStore, 'add
|
|
|
246
246
|
removeL1ToL2Messages(startIndex: bigint): Promise<void>;
|
|
247
247
|
getLastL1ToL2Message(): Promise<InboxMessage | undefined>;
|
|
248
248
|
}
|
|
249
|
+
export {};
|
|
249
250
|
//# sourceMappingURL=archiver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver.ts"],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MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC;IAGhH,+BAA+B,CAAC,iBAAiB,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGlF,qBAAqB,CAAC,KAAK,GAAE,WAAW,CAAC,MAAM,CAAM,GAAG,qBAAqB,CAAC,YAAY,CAAC;IAG3F,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGvD,oBAAoB,IAAI,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC;CAG1D"}
|
|
@@ -370,8 +370,18 @@ import { ArchiverInstrumentation } from './instrumentation.js';
|
|
|
370
370
|
});
|
|
371
371
|
}
|
|
372
372
|
}
|
|
373
|
-
retrieveL1ToL2Message(leaf) {
|
|
374
|
-
|
|
373
|
+
async retrieveL1ToL2Message(leaf) {
|
|
374
|
+
const currentL1BlockNumber = await this.publicClient.getBlockNumber();
|
|
375
|
+
let searchStartBlock = 0n;
|
|
376
|
+
let searchEndBlock = this.l1constants.l1StartBlock - 1n;
|
|
377
|
+
do {
|
|
378
|
+
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, currentL1BlockNumber);
|
|
379
|
+
const message = await retrieveL1ToL2Message(this.inbox.getContract(), leaf, searchStartBlock, searchEndBlock);
|
|
380
|
+
if (message) {
|
|
381
|
+
return message;
|
|
382
|
+
}
|
|
383
|
+
}while (searchEndBlock < currentL1BlockNumber)
|
|
384
|
+
return undefined;
|
|
375
385
|
}
|
|
376
386
|
async rollbackL1ToL2Messages(localLastMessage, messagesSyncPoint) {
|
|
377
387
|
// Slowly go back through our messages until we find the last common message.
|
|
@@ -470,6 +480,14 @@ import { ArchiverInstrumentation } from './instrumentation.js';
|
|
|
470
480
|
this.log.info(`Updated proven chain to block ${provenBlockNumber}`, {
|
|
471
481
|
provenBlockNumber
|
|
472
482
|
});
|
|
483
|
+
const provenSlotNumber = localBlockForDestinationProvenBlockNumber.header.globalVariables.slotNumber.toBigInt();
|
|
484
|
+
const provenEpochNumber = getEpochAtSlot(provenSlotNumber, this.l1constants);
|
|
485
|
+
this.emit(L2BlockSourceEvents.L2BlockProven, {
|
|
486
|
+
type: L2BlockSourceEvents.L2BlockProven,
|
|
487
|
+
blockNumber: provenBlockNumber,
|
|
488
|
+
slotNumber: provenSlotNumber,
|
|
489
|
+
epochNumber: provenEpochNumber
|
|
490
|
+
});
|
|
473
491
|
} else {
|
|
474
492
|
this.log.trace(`Proven block ${provenBlockNumber} already stored.`);
|
|
475
493
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver_store_test_suite.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver_store_test_suite.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"archiver_store_test_suite.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver_store_test_suite.ts"],"names":[],"mappings":"AA4BA,OAAO,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,qBAAqB,CAAC;AAMnF;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,QAi/B/D"}
|
|
@@ -3,12 +3,11 @@ import { makeTuple } from '@aztec/foundation/array';
|
|
|
3
3
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
4
4
|
import { times, timesParallel } from '@aztec/foundation/collection';
|
|
5
5
|
import { randomInt } from '@aztec/foundation/crypto';
|
|
6
|
-
import { Signature } from '@aztec/foundation/eth-signature';
|
|
7
6
|
import { Fr } from '@aztec/foundation/fields';
|
|
8
7
|
import { toArray } from '@aztec/foundation/iterable';
|
|
9
8
|
import { sleep } from '@aztec/foundation/sleep';
|
|
10
9
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
11
|
-
import { L2Block, wrapInBlock } from '@aztec/stdlib/block';
|
|
10
|
+
import { CommitteeAttestation, L2Block, wrapInBlock } from '@aztec/stdlib/block';
|
|
12
11
|
import { SerializableContractInstance, computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
13
12
|
import { LogId, PrivateLog, PublicLog } from '@aztec/stdlib/logs';
|
|
14
13
|
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
@@ -59,7 +58,7 @@ import { MessageStoreError } from './kv_archiver_store/message_store.js';
|
|
|
59
58
|
blockHash: `0x${l1BlockNumber}`,
|
|
60
59
|
timestamp: BigInt(l1BlockNumber * 1000)
|
|
61
60
|
},
|
|
62
|
-
|
|
61
|
+
attestations: times(3, CommitteeAttestation.random)
|
|
63
62
|
});
|
|
64
63
|
const expectBlocksEqual = (actual, expected)=>{
|
|
65
64
|
expect(actual.length).toEqual(expected.length);
|
|
@@ -68,7 +67,7 @@ import { MessageStoreError } from './kv_archiver_store/message_store.js';
|
|
|
68
67
|
const actualBlock = actual[i];
|
|
69
68
|
expect(actualBlock.l1).toEqual(expectedBlock.l1);
|
|
70
69
|
expect(actualBlock.block.equals(expectedBlock.block)).toBe(true);
|
|
71
|
-
expect(actualBlock.
|
|
70
|
+
expect(actualBlock.attestations.every((a, i)=>a.equals(expectedBlock.attestations[i]))).toBe(true);
|
|
72
71
|
}
|
|
73
72
|
};
|
|
74
73
|
beforeEach(async ()=>{
|
|
@@ -789,7 +788,7 @@ import { MessageStoreError } from './kv_archiver_store/message_store.js';
|
|
|
789
788
|
});
|
|
790
789
|
return {
|
|
791
790
|
block: block,
|
|
792
|
-
|
|
791
|
+
attestations: times(3, CommitteeAttestation.random),
|
|
793
792
|
l1: {
|
|
794
793
|
blockNumber: BigInt(blockNumber),
|
|
795
794
|
blockHash: `0x${blockNumber}`,
|
|
@@ -910,7 +909,7 @@ import { MessageStoreError } from './kv_archiver_store/message_store.js';
|
|
|
910
909
|
blockHash: `0x${index}`,
|
|
911
910
|
timestamp: BigInt(index)
|
|
912
911
|
},
|
|
913
|
-
|
|
912
|
+
attestations: times(3, CommitteeAttestation.random)
|
|
914
913
|
}));
|
|
915
914
|
await store.addBlocks(blocks);
|
|
916
915
|
await store.addLogs(blocks.map((b)=>b.block));
|
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
|
|
2
2
|
import type { ViemClient, ViemPublicClient } from '@aztec/ethereum';
|
|
3
3
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
4
|
-
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
5
|
import { type Logger } from '@aztec/foundation/log';
|
|
7
6
|
import { type InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
8
|
-
import { Body } from '@aztec/stdlib/block';
|
|
7
|
+
import { Body, CommitteeAttestation } from '@aztec/stdlib/block';
|
|
9
8
|
import { Proof } from '@aztec/stdlib/proofs';
|
|
10
9
|
import { ProposedBlockHeader, StateReference } from '@aztec/stdlib/tx';
|
|
11
10
|
import { type GetContractReturnType, type Hex } from 'viem';
|
|
@@ -21,7 +20,7 @@ export type RetrievedL2Block = {
|
|
|
21
20
|
l1: L1PublishedData;
|
|
22
21
|
chainId: Fr;
|
|
23
22
|
version: Fr;
|
|
24
|
-
|
|
23
|
+
attestations: CommitteeAttestation[];
|
|
25
24
|
};
|
|
26
25
|
export declare function retrievedBlockToPublishedL2Block(retrievedBlock: RetrievedL2Block): PublishedL2Block;
|
|
27
26
|
/**
|
|
@@ -35,8 +34,8 @@ export declare function retrievedBlockToPublishedL2Block(retrievedBlock: Retriev
|
|
|
35
34
|
*/
|
|
36
35
|
export declare function retrieveBlocksFromRollup(rollup: GetContractReturnType<typeof RollupAbi, ViemPublicClient>, publicClient: ViemPublicClient, blobSinkClient: BlobSinkClientInterface, searchStartBlock: bigint, searchEndBlock: bigint, logger?: Logger): Promise<RetrievedL2Block[]>;
|
|
37
36
|
export declare function getL1BlockTime(publicClient: ViemPublicClient, blockNumber: bigint): Promise<bigint>;
|
|
38
|
-
/** Given an L1 to L2 message, retrieves its corresponding event from the Inbox. */
|
|
39
|
-
export declare function retrieveL1ToL2Message(inbox: GetContractReturnType<typeof InboxAbi, ViemClient>, leaf: Fr, fromBlock: bigint): Promise<InboxMessage | undefined>;
|
|
37
|
+
/** Given an L1 to L2 message, retrieves its corresponding event from the Inbox within a specific block range. */
|
|
38
|
+
export declare function retrieveL1ToL2Message(inbox: GetContractReturnType<typeof InboxAbi, ViemClient>, leaf: Fr, fromBlock: bigint, toBlock: bigint): Promise<InboxMessage | undefined>;
|
|
40
39
|
/**
|
|
41
40
|
* Fetch L1 to L2 messages.
|
|
42
41
|
* @param publicClient - The viem public client to use for transaction retrieval.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"data_retrieval.d.ts","sourceRoot":"","sources":["../../src/archiver/data_retrieval.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"data_retrieval.d.ts","sourceRoot":"","sources":["../../src/archiver/data_retrieval.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AACvE,OAAO,KAAK,EAEV,UAAU,EAEV,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,MAAM,EAAgB,MAAM,uBAAuB,CAAC;AAClE,OAAO,EAAgB,KAAK,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,IAAI,EAAE,oBAAoB,EAAW,MAAM,qBAAqB,CAA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,KAAK,MAAM,EAAE,EACrB,gBAAgB,EAAE,EAAE,GACnB,OAAO,CAAC,gBAAgB,CAAC,CAmC3B"}
|
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
import { Blob, BlobDeserializationError } from '@aztec/blob-lib';
|
|
2
2
|
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
3
3
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
4
|
-
import { Signature } from '@aztec/foundation/eth-signature';
|
|
5
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
6
5
|
import { createLogger } from '@aztec/foundation/log';
|
|
7
6
|
import { ForwarderAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
8
|
-
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
7
|
+
import { Body, CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
|
|
9
8
|
import { Proof } from '@aztec/stdlib/proofs';
|
|
10
9
|
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
11
10
|
import { BlockHeader, GlobalVariables, ProposedBlockHeader, StateReference } from '@aztec/stdlib/tx';
|
|
12
11
|
import { decodeFunctionData, getAbiItem, hexToBytes } from 'viem';
|
|
13
12
|
import { NoBlobBodiesFoundError } from './errors.js';
|
|
14
13
|
export function retrievedBlockToPublishedL2Block(retrievedBlock) {
|
|
15
|
-
const { l2BlockNumber, archiveRoot, stateReference, header: proposedHeader, body, l1, chainId, version,
|
|
14
|
+
const { l2BlockNumber, archiveRoot, stateReference, header: proposedHeader, body, l1, chainId, version, attestations } = retrievedBlock;
|
|
16
15
|
const archive = new AppendOnlyTreeSnapshot(archiveRoot, Number(l2BlockNumber + 1n));
|
|
17
16
|
const globalVariables = GlobalVariables.from({
|
|
18
17
|
chainId,
|
|
@@ -36,7 +35,7 @@ export function retrievedBlockToPublishedL2Block(retrievedBlock) {
|
|
|
36
35
|
return {
|
|
37
36
|
block,
|
|
38
37
|
l1,
|
|
39
|
-
|
|
38
|
+
attestations
|
|
40
39
|
};
|
|
41
40
|
}
|
|
42
41
|
/**
|
|
@@ -113,7 +112,7 @@ export function retrievedBlockToPublishedL2Block(retrievedBlock) {
|
|
|
113
112
|
l1BlockNumber: log.blockNumber,
|
|
114
113
|
l2BlockNumber,
|
|
115
114
|
archive: archive.toString(),
|
|
116
|
-
|
|
115
|
+
attestations: block.attestations
|
|
117
116
|
});
|
|
118
117
|
} else {
|
|
119
118
|
logger.warn(`Ignoring L2 block ${l2BlockNumber} due to archive root mismatch`, {
|
|
@@ -191,7 +190,7 @@ export async function getL1BlockTime(publicClient, blockNumber) {
|
|
|
191
190
|
if (rollupFunctionName !== 'propose') {
|
|
192
191
|
throw new Error(`Unexpected rollup method called ${rollupFunctionName}`);
|
|
193
192
|
}
|
|
194
|
-
const [decodedArgs,
|
|
193
|
+
const [decodedArgs, attestations, _blobInput] = rollupArgs;
|
|
195
194
|
const header = ProposedBlockHeader.fromBuffer(Buffer.from(hexToBytes(decodedArgs.header)));
|
|
196
195
|
const blobBodies = await blobSinkClient.getBlobSidecar(blockHash, blobHashes);
|
|
197
196
|
if (blobBodies.length === 0) {
|
|
@@ -218,16 +217,18 @@ export async function getL1BlockTime(publicClient, blockNumber) {
|
|
|
218
217
|
stateReference,
|
|
219
218
|
header,
|
|
220
219
|
body,
|
|
221
|
-
|
|
220
|
+
attestations: attestations.map(CommitteeAttestation.fromViem)
|
|
222
221
|
};
|
|
223
222
|
}
|
|
224
|
-
/** Given an L1 to L2 message, retrieves its corresponding event from the Inbox. */ export async function retrieveL1ToL2Message(inbox, leaf, fromBlock) {
|
|
223
|
+
/** Given an L1 to L2 message, retrieves its corresponding event from the Inbox within a specific block range. */ export async function retrieveL1ToL2Message(inbox, leaf, fromBlock, toBlock) {
|
|
225
224
|
const logs = await inbox.getEvents.MessageSent({
|
|
226
225
|
hash: leaf.toString()
|
|
227
226
|
}, {
|
|
228
|
-
fromBlock
|
|
227
|
+
fromBlock,
|
|
228
|
+
toBlock
|
|
229
229
|
});
|
|
230
|
-
|
|
230
|
+
const messages = mapLogsInboxMessage(logs);
|
|
231
|
+
return messages.length > 0 ? messages[0] : undefined;
|
|
231
232
|
}
|
|
232
233
|
/**
|
|
233
234
|
* Fetch L1 to L2 messages.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"block_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/block_store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAA6C,MAAM,iBAAiB,CAAC;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGxF,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"block_store.d.ts","sourceRoot":"","sources":["../../../src/archiver/kv_archiver_store/block_store.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAA6C,MAAM,iBAAiB,CAAC;AACpG,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAGhE,OAAO,EAAE,WAAW,EAAE,KAAK,eAAe,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGxF,OAAO,KAAK,EAAmB,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEjF,OAAO,EAAE,SAAS,EAAE,KAAK,QAAQ,EAAE,KAAK,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAYzE;;GAEG;AACH,qBAAa,UAAU;;IAqBT,OAAO,CAAC,EAAE;gBAAF,EAAE,EAAE,iBAAiB;IASzC;;;;OAIG;IACG,SAAS,CAAC,MAAM,EAAE,gBAAgB,EAAE,EAAE,IAAI,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AAE,MAAM;CAe3C"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
-
import {
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
|
-
import { Body, L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
5
|
+
import { Body, CommitteeAttestation, L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
6
6
|
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
7
7
|
import { BlockHeader, TxReceipt } from '@aztec/stdlib/tx';
|
|
8
8
|
import { BlockNumberNotSequentialError, InitialBlockNumberNotSequentialError } from '../errors.js';
|
|
@@ -55,11 +55,13 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
55
55
|
throw new BlockNumberNotSequentialError(block.block.number, previousBlock.block.number);
|
|
56
56
|
}
|
|
57
57
|
previousBlock = block;
|
|
58
|
+
const blockHash = (await block.block.hash()).toBuffer();
|
|
58
59
|
await this.#blocks.set(block.block.number, {
|
|
59
60
|
header: block.block.header.toBuffer(),
|
|
61
|
+
blockHash: blockHash,
|
|
60
62
|
archive: block.block.archive.toBuffer(),
|
|
61
63
|
l1: block.l1,
|
|
62
|
-
|
|
64
|
+
attestations: block.attestations.map((attestation)=>attestation.toBuffer())
|
|
63
65
|
});
|
|
64
66
|
for(let i = 0; i < block.block.body.txEffects.length; i++){
|
|
65
67
|
const txEffect = block.block.body.txEffects[i];
|
|
@@ -68,7 +70,7 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
68
70
|
i
|
|
69
71
|
]);
|
|
70
72
|
}
|
|
71
|
-
await this.#blockBodies.set(
|
|
73
|
+
await this.#blockBodies.set(blockHash.toString(), block.block.body.toBuffer());
|
|
72
74
|
}
|
|
73
75
|
await this.#lastSynchedL1Block.set(blocks[blocks.length - 1].l1.blockNumber);
|
|
74
76
|
return true;
|
|
@@ -160,22 +162,23 @@ export { TxReceipt } from '@aztec/stdlib/tx';
|
|
|
160
162
|
async getBlockFromBlockStorage(blockNumber, blockStorage) {
|
|
161
163
|
const header = BlockHeader.fromBuffer(blockStorage.header);
|
|
162
164
|
const archive = AppendOnlyTreeSnapshot.fromBuffer(blockStorage.archive);
|
|
163
|
-
const blockHash =
|
|
164
|
-
const
|
|
165
|
+
const blockHash = blockStorage.blockHash;
|
|
166
|
+
const blockHashString = blockHash.toString();
|
|
167
|
+
const blockBodyBuffer = await this.#blockBodies.getAsync(blockHashString);
|
|
165
168
|
if (blockBodyBuffer === undefined) {
|
|
166
169
|
this.#log.warn(`Could not find body for block ${header.globalVariables.blockNumber.toNumber()} ${blockHash}`);
|
|
167
170
|
return undefined;
|
|
168
171
|
}
|
|
169
172
|
const body = Body.fromBuffer(blockBodyBuffer);
|
|
170
|
-
const block = new L2Block(archive, header, body);
|
|
173
|
+
const block = new L2Block(archive, header, body, Fr.fromBuffer(blockHash));
|
|
171
174
|
if (block.number !== blockNumber) {
|
|
172
|
-
throw new Error(`Block number mismatch when retrieving block from archive (expected ${blockNumber} but got ${block.number} with hash ${
|
|
175
|
+
throw new Error(`Block number mismatch when retrieving block from archive (expected ${blockNumber} but got ${block.number} with hash ${blockHashString})`);
|
|
173
176
|
}
|
|
174
|
-
const
|
|
177
|
+
const attestations = blockStorage.attestations.map(CommitteeAttestation.fromBuffer);
|
|
175
178
|
return {
|
|
176
179
|
block,
|
|
177
180
|
l1: blockStorage.l1,
|
|
178
|
-
|
|
181
|
+
attestations
|
|
179
182
|
};
|
|
180
183
|
}
|
|
181
184
|
/**
|
|
@@ -55,7 +55,7 @@ export declare class MockL2BlockSource implements L2BlockSource, ContractDataSou
|
|
|
55
55
|
blockHash: `0x${string}`;
|
|
56
56
|
timestamp: bigint;
|
|
57
57
|
};
|
|
58
|
-
|
|
58
|
+
attestations: never[];
|
|
59
59
|
}[]>;
|
|
60
60
|
getBlockHeader(number: number | 'latest'): Promise<BlockHeader | undefined>;
|
|
61
61
|
getBlocksForEpoch(epochNumber: bigint): Promise<L2Block[]>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "0.87.
|
|
3
|
+
"version": "0.87.3-nightly.20250529",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
@@ -62,18 +62,17 @@
|
|
|
62
62
|
]
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
|
-
"@aztec/blob-lib": "0.87.
|
|
66
|
-
"@aztec/blob-sink": "0.87.
|
|
67
|
-
"@aztec/constants": "0.87.
|
|
68
|
-
"@aztec/ethereum": "0.87.
|
|
69
|
-
"@aztec/foundation": "0.87.
|
|
70
|
-
"@aztec/kv-store": "0.87.
|
|
71
|
-
"@aztec/l1-artifacts": "0.87.
|
|
72
|
-
"@aztec/noir-protocol-circuits-types": "0.87.
|
|
73
|
-
"@aztec/protocol-contracts": "0.87.
|
|
74
|
-
"@aztec/stdlib": "0.87.
|
|
75
|
-
"@aztec/telemetry-client": "0.87.
|
|
76
|
-
"debug": "^4.3.4",
|
|
65
|
+
"@aztec/blob-lib": "0.87.3-nightly.20250529",
|
|
66
|
+
"@aztec/blob-sink": "0.87.3-nightly.20250529",
|
|
67
|
+
"@aztec/constants": "0.87.3-nightly.20250529",
|
|
68
|
+
"@aztec/ethereum": "0.87.3-nightly.20250529",
|
|
69
|
+
"@aztec/foundation": "0.87.3-nightly.20250529",
|
|
70
|
+
"@aztec/kv-store": "0.87.3-nightly.20250529",
|
|
71
|
+
"@aztec/l1-artifacts": "0.87.3-nightly.20250529",
|
|
72
|
+
"@aztec/noir-protocol-circuits-types": "0.87.3-nightly.20250529",
|
|
73
|
+
"@aztec/protocol-contracts": "0.87.3-nightly.20250529",
|
|
74
|
+
"@aztec/stdlib": "0.87.3-nightly.20250529",
|
|
75
|
+
"@aztec/telemetry-client": "0.87.3-nightly.20250529",
|
|
77
76
|
"lodash.groupby": "^4.6.0",
|
|
78
77
|
"lodash.omit": "^4.5.0",
|
|
79
78
|
"tsc-watch": "^6.0.0",
|
|
@@ -82,7 +81,6 @@
|
|
|
82
81
|
},
|
|
83
82
|
"devDependencies": {
|
|
84
83
|
"@jest/globals": "^29.5.0",
|
|
85
|
-
"@types/debug": "^4.1.7",
|
|
86
84
|
"@types/jest": "^29.5.0",
|
|
87
85
|
"@types/lodash.groupby": "^4.6.9",
|
|
88
86
|
"@types/lodash.omit": "^4.5.7",
|
package/src/archiver/archiver.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
31
31
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
32
32
|
import {
|
|
33
|
+
type ArchiverEmitter,
|
|
33
34
|
type L2Block,
|
|
34
35
|
type L2BlockId,
|
|
35
36
|
type L2BlockSource,
|
|
@@ -88,7 +89,7 @@ export type ArchiveSource = L2BlockSource & L2LogsSource & ContractDataSource &
|
|
|
88
89
|
* Responsible for handling robust L1 polling so that other components do not need to
|
|
89
90
|
* concern themselves with it.
|
|
90
91
|
*/
|
|
91
|
-
export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
|
|
92
|
+
export class Archiver extends (EventEmitter as new () => ArchiverEmitter) implements ArchiveSource, Traceable {
|
|
92
93
|
/**
|
|
93
94
|
* A promise in which we will be continually fetching new L2 blocks.
|
|
94
95
|
*/
|
|
@@ -522,8 +523,22 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
|
|
|
522
523
|
}
|
|
523
524
|
}
|
|
524
525
|
|
|
525
|
-
private retrieveL1ToL2Message(leaf: Fr): Promise<InboxMessage | undefined> {
|
|
526
|
-
|
|
526
|
+
private async retrieveL1ToL2Message(leaf: Fr): Promise<InboxMessage | undefined> {
|
|
527
|
+
const currentL1BlockNumber = await this.publicClient.getBlockNumber();
|
|
528
|
+
let searchStartBlock: bigint = 0n;
|
|
529
|
+
let searchEndBlock: bigint = this.l1constants.l1StartBlock - 1n;
|
|
530
|
+
|
|
531
|
+
do {
|
|
532
|
+
[searchStartBlock, searchEndBlock] = this.nextRange(searchEndBlock, currentL1BlockNumber);
|
|
533
|
+
|
|
534
|
+
const message = await retrieveL1ToL2Message(this.inbox.getContract(), leaf, searchStartBlock, searchEndBlock);
|
|
535
|
+
|
|
536
|
+
if (message) {
|
|
537
|
+
return message;
|
|
538
|
+
}
|
|
539
|
+
} while (searchEndBlock < currentL1BlockNumber);
|
|
540
|
+
|
|
541
|
+
return undefined;
|
|
527
542
|
}
|
|
528
543
|
|
|
529
544
|
private async rollbackL1ToL2Messages(localLastMessage: InboxMessage, messagesSyncPoint: L1BlockId) {
|
|
@@ -624,6 +639,15 @@ export class Archiver extends EventEmitter implements ArchiveSource, Traceable {
|
|
|
624
639
|
this.log.info(`Updated proven chain to block ${provenBlockNumber}`, {
|
|
625
640
|
provenBlockNumber,
|
|
626
641
|
});
|
|
642
|
+
const provenSlotNumber =
|
|
643
|
+
localBlockForDestinationProvenBlockNumber.header.globalVariables.slotNumber.toBigInt();
|
|
644
|
+
const provenEpochNumber = getEpochAtSlot(provenSlotNumber, this.l1constants);
|
|
645
|
+
this.emit(L2BlockSourceEvents.L2BlockProven, {
|
|
646
|
+
type: L2BlockSourceEvents.L2BlockProven,
|
|
647
|
+
blockNumber: provenBlockNumber,
|
|
648
|
+
slotNumber: provenSlotNumber,
|
|
649
|
+
epochNumber: provenEpochNumber,
|
|
650
|
+
});
|
|
627
651
|
} else {
|
|
628
652
|
this.log.trace(`Proven block ${provenBlockNumber} already stored.`);
|
|
629
653
|
}
|
|
@@ -8,12 +8,11 @@ import { makeTuple } from '@aztec/foundation/array';
|
|
|
8
8
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
9
9
|
import { times, timesParallel } from '@aztec/foundation/collection';
|
|
10
10
|
import { randomInt } from '@aztec/foundation/crypto';
|
|
11
|
-
import { Signature } from '@aztec/foundation/eth-signature';
|
|
12
11
|
import { Fr } from '@aztec/foundation/fields';
|
|
13
12
|
import { toArray } from '@aztec/foundation/iterable';
|
|
14
13
|
import { sleep } from '@aztec/foundation/sleep';
|
|
15
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
16
|
-
import { L2Block, wrapInBlock } from '@aztec/stdlib/block';
|
|
15
|
+
import { CommitteeAttestation, L2Block, wrapInBlock } from '@aztec/stdlib/block';
|
|
17
16
|
import {
|
|
18
17
|
type ContractClassPublic,
|
|
19
18
|
type ContractInstanceWithAddress,
|
|
@@ -64,7 +63,7 @@ export function describeArchiverDataStore(
|
|
|
64
63
|
blockHash: `0x${l1BlockNumber}`,
|
|
65
64
|
timestamp: BigInt(l1BlockNumber * 1000),
|
|
66
65
|
},
|
|
67
|
-
|
|
66
|
+
attestations: times(3, CommitteeAttestation.random),
|
|
68
67
|
});
|
|
69
68
|
|
|
70
69
|
const expectBlocksEqual = (actual: PublishedL2Block[], expected: PublishedL2Block[]) => {
|
|
@@ -74,7 +73,7 @@ export function describeArchiverDataStore(
|
|
|
74
73
|
const actualBlock = actual[i];
|
|
75
74
|
expect(actualBlock.l1).toEqual(expectedBlock.l1);
|
|
76
75
|
expect(actualBlock.block.equals(expectedBlock.block)).toBe(true);
|
|
77
|
-
expect(actualBlock.
|
|
76
|
+
expect(actualBlock.attestations.every((a, i) => a.equals(expectedBlock.attestations[i]))).toBe(true);
|
|
78
77
|
}
|
|
79
78
|
};
|
|
80
79
|
|
|
@@ -758,7 +757,7 @@ export function describeArchiverDataStore(
|
|
|
758
757
|
|
|
759
758
|
return {
|
|
760
759
|
block: block,
|
|
761
|
-
|
|
760
|
+
attestations: times(3, CommitteeAttestation.random),
|
|
762
761
|
l1: { blockNumber: BigInt(blockNumber), blockHash: `0x${blockNumber}`, timestamp: BigInt(blockNumber) },
|
|
763
762
|
};
|
|
764
763
|
};
|
|
@@ -876,7 +875,7 @@ export function describeArchiverDataStore(
|
|
|
876
875
|
blocks = await timesParallel(numBlocks, async (index: number) => ({
|
|
877
876
|
block: await L2Block.random(index + 1, txsPerBlock, numPublicFunctionCalls, numPublicLogs),
|
|
878
877
|
l1: { blockNumber: BigInt(index), blockHash: `0x${index}`, timestamp: BigInt(index) },
|
|
879
|
-
|
|
878
|
+
attestations: times(3, CommitteeAttestation.random),
|
|
880
879
|
}));
|
|
881
880
|
|
|
882
881
|
await store.addBlocks(blocks);
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import { Blob, BlobDeserializationError } from '@aztec/blob-lib';
|
|
2
2
|
import type { BlobSinkClientInterface } from '@aztec/blob-sink/client';
|
|
3
|
-
import type {
|
|
3
|
+
import type {
|
|
4
|
+
EpochProofPublicInputArgs,
|
|
5
|
+
ViemClient,
|
|
6
|
+
ViemCommitteeAttestation,
|
|
7
|
+
ViemPublicClient,
|
|
8
|
+
} from '@aztec/ethereum';
|
|
4
9
|
import { asyncPool } from '@aztec/foundation/async-pool';
|
|
5
10
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
6
11
|
import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
7
|
-
import { Signature, type ViemSignature } from '@aztec/foundation/eth-signature';
|
|
8
12
|
import { Fr } from '@aztec/foundation/fields';
|
|
9
13
|
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
10
14
|
import { ForwarderAbi, type InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
11
|
-
import { Body, L2Block } from '@aztec/stdlib/block';
|
|
15
|
+
import { Body, CommitteeAttestation, L2Block } from '@aztec/stdlib/block';
|
|
12
16
|
import { Proof } from '@aztec/stdlib/proofs';
|
|
13
17
|
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
14
18
|
import { BlockHeader, GlobalVariables, ProposedBlockHeader, StateReference } from '@aztec/stdlib/tx';
|
|
@@ -36,7 +40,7 @@ export type RetrievedL2Block = {
|
|
|
36
40
|
l1: L1PublishedData;
|
|
37
41
|
chainId: Fr;
|
|
38
42
|
version: Fr;
|
|
39
|
-
|
|
43
|
+
attestations: CommitteeAttestation[];
|
|
40
44
|
};
|
|
41
45
|
|
|
42
46
|
export function retrievedBlockToPublishedL2Block(retrievedBlock: RetrievedL2Block): PublishedL2Block {
|
|
@@ -49,7 +53,7 @@ export function retrievedBlockToPublishedL2Block(retrievedBlock: RetrievedL2Bloc
|
|
|
49
53
|
l1,
|
|
50
54
|
chainId,
|
|
51
55
|
version,
|
|
52
|
-
|
|
56
|
+
attestations,
|
|
53
57
|
} = retrievedBlock;
|
|
54
58
|
|
|
55
59
|
const archive = new AppendOnlyTreeSnapshot(
|
|
@@ -82,7 +86,7 @@ export function retrievedBlockToPublishedL2Block(retrievedBlock: RetrievedL2Bloc
|
|
|
82
86
|
return {
|
|
83
87
|
block,
|
|
84
88
|
l1,
|
|
85
|
-
|
|
89
|
+
attestations,
|
|
86
90
|
};
|
|
87
91
|
}
|
|
88
92
|
|
|
@@ -196,7 +200,7 @@ async function processL2BlockProposedLogs(
|
|
|
196
200
|
l1BlockNumber: log.blockNumber,
|
|
197
201
|
l2BlockNumber,
|
|
198
202
|
archive: archive.toString(),
|
|
199
|
-
|
|
203
|
+
attestations: block.attestations,
|
|
200
204
|
});
|
|
201
205
|
} else {
|
|
202
206
|
logger.warn(`Ignoring L2 block ${l2BlockNumber} due to archive root mismatch`, {
|
|
@@ -295,7 +299,7 @@ async function getBlockFromRollupTx(
|
|
|
295
299
|
throw new Error(`Unexpected rollup method called ${rollupFunctionName}`);
|
|
296
300
|
}
|
|
297
301
|
|
|
298
|
-
const [decodedArgs,
|
|
302
|
+
const [decodedArgs, attestations, _blobInput] = rollupArgs! as readonly [
|
|
299
303
|
{
|
|
300
304
|
header: Hex;
|
|
301
305
|
archive: Hex;
|
|
@@ -306,7 +310,7 @@ async function getBlockFromRollupTx(
|
|
|
306
310
|
};
|
|
307
311
|
txHashes: Hex[];
|
|
308
312
|
},
|
|
309
|
-
|
|
313
|
+
ViemCommitteeAttestation[],
|
|
310
314
|
Hex,
|
|
311
315
|
];
|
|
312
316
|
|
|
@@ -341,18 +345,21 @@ async function getBlockFromRollupTx(
|
|
|
341
345
|
stateReference,
|
|
342
346
|
header,
|
|
343
347
|
body,
|
|
344
|
-
|
|
348
|
+
attestations: attestations.map(CommitteeAttestation.fromViem),
|
|
345
349
|
};
|
|
346
350
|
}
|
|
347
351
|
|
|
348
|
-
/** Given an L1 to L2 message, retrieves its corresponding event from the Inbox. */
|
|
352
|
+
/** Given an L1 to L2 message, retrieves its corresponding event from the Inbox within a specific block range. */
|
|
349
353
|
export async function retrieveL1ToL2Message(
|
|
350
354
|
inbox: GetContractReturnType<typeof InboxAbi, ViemClient>,
|
|
351
355
|
leaf: Fr,
|
|
352
356
|
fromBlock: bigint,
|
|
357
|
+
toBlock: bigint,
|
|
353
358
|
): Promise<InboxMessage | undefined> {
|
|
354
|
-
const logs = await inbox.getEvents.MessageSent({ hash: leaf.toString() }, { fromBlock });
|
|
355
|
-
|
|
359
|
+
const logs = await inbox.getEvents.MessageSent({ hash: leaf.toString() }, { fromBlock, toBlock });
|
|
360
|
+
|
|
361
|
+
const messages = mapLogsInboxMessage(logs);
|
|
362
|
+
return messages.length > 0 ? messages[0] : undefined;
|
|
356
363
|
}
|
|
357
364
|
|
|
358
365
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
2
|
-
import {
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
3
3
|
import { toArray } from '@aztec/foundation/iterable';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import type { AztecAsyncKVStore, AztecAsyncMap, AztecAsyncSingleton, Range } from '@aztec/kv-store';
|
|
6
6
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
7
|
-
import { Body, L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
7
|
+
import { Body, CommitteeAttestation, L2Block, L2BlockHash } from '@aztec/stdlib/block';
|
|
8
8
|
import { AppendOnlyTreeSnapshot } from '@aztec/stdlib/trees';
|
|
9
9
|
import { BlockHeader, type IndexedTxEffect, TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
10
10
|
|
|
@@ -17,9 +17,10 @@ type BlockIndexValue = [blockNumber: number, index: number];
|
|
|
17
17
|
|
|
18
18
|
type BlockStorage = {
|
|
19
19
|
header: Buffer;
|
|
20
|
+
blockHash: Buffer;
|
|
20
21
|
archive: Buffer;
|
|
21
22
|
l1: L1PublishedData;
|
|
22
|
-
|
|
23
|
+
attestations: Buffer[];
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
/**
|
|
@@ -85,12 +86,14 @@ export class BlockStore {
|
|
|
85
86
|
throw new BlockNumberNotSequentialError(block.block.number, previousBlock.block.number);
|
|
86
87
|
}
|
|
87
88
|
previousBlock = block;
|
|
89
|
+
const blockHash = (await block.block.hash()).toBuffer();
|
|
88
90
|
|
|
89
91
|
await this.#blocks.set(block.block.number, {
|
|
90
92
|
header: block.block.header.toBuffer(),
|
|
93
|
+
blockHash: blockHash,
|
|
91
94
|
archive: block.block.archive.toBuffer(),
|
|
92
95
|
l1: block.l1,
|
|
93
|
-
|
|
96
|
+
attestations: block.attestations.map(attestation => attestation.toBuffer()),
|
|
94
97
|
});
|
|
95
98
|
|
|
96
99
|
for (let i = 0; i < block.block.body.txEffects.length; i++) {
|
|
@@ -98,7 +101,7 @@ export class BlockStore {
|
|
|
98
101
|
await this.#txIndex.set(txEffect.txHash.toString(), [block.block.number, i]);
|
|
99
102
|
}
|
|
100
103
|
|
|
101
|
-
await this.#blockBodies.set(
|
|
104
|
+
await this.#blockBodies.set(blockHash.toString(), block.block.body.toBuffer());
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
await this.#lastSynchedL1Block.set(blocks[blocks.length - 1].l1.blockNumber);
|
|
@@ -206,23 +209,24 @@ export class BlockStore {
|
|
|
206
209
|
private async getBlockFromBlockStorage(blockNumber: number, blockStorage: BlockStorage) {
|
|
207
210
|
const header = BlockHeader.fromBuffer(blockStorage.header);
|
|
208
211
|
const archive = AppendOnlyTreeSnapshot.fromBuffer(blockStorage.archive);
|
|
209
|
-
const blockHash =
|
|
210
|
-
const
|
|
212
|
+
const blockHash = blockStorage.blockHash;
|
|
213
|
+
const blockHashString = blockHash.toString();
|
|
214
|
+
const blockBodyBuffer = await this.#blockBodies.getAsync(blockHashString);
|
|
211
215
|
if (blockBodyBuffer === undefined) {
|
|
212
216
|
this.#log.warn(`Could not find body for block ${header.globalVariables.blockNumber.toNumber()} ${blockHash}`);
|
|
213
217
|
return undefined;
|
|
214
218
|
}
|
|
215
219
|
const body = Body.fromBuffer(blockBodyBuffer);
|
|
216
|
-
const block = new L2Block(archive, header, body);
|
|
220
|
+
const block = new L2Block(archive, header, body, Fr.fromBuffer(blockHash));
|
|
217
221
|
if (block.number !== blockNumber) {
|
|
218
222
|
throw new Error(
|
|
219
223
|
`Block number mismatch when retrieving block from archive (expected ${blockNumber} but got ${
|
|
220
224
|
block.number
|
|
221
|
-
} with hash ${
|
|
225
|
+
} with hash ${blockHashString})`,
|
|
222
226
|
);
|
|
223
227
|
}
|
|
224
|
-
const
|
|
225
|
-
return { block, l1: blockStorage.l1,
|
|
228
|
+
const attestations = blockStorage.attestations.map(CommitteeAttestation.fromBuffer);
|
|
229
|
+
return { block, l1: blockStorage.l1, attestations };
|
|
226
230
|
}
|
|
227
231
|
|
|
228
232
|
/**
|