@aztec/archiver 3.0.0-nightly.20250910 → 3.0.0-nightly.20250912
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 +25 -4
- package/dest/archiver/archiver.d.ts +8 -4
- package/dest/archiver/archiver.d.ts.map +1 -1
- package/dest/archiver/archiver.js +50 -25
- package/dest/archiver/archiver_store.d.ts +5 -1
- 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 +103 -5
- package/dest/archiver/config.d.ts +4 -18
- package/dest/archiver/config.d.ts.map +1 -1
- package/dest/archiver/config.js +5 -1
- package/dest/archiver/data_retrieval.d.ts +2 -2
- package/dest/archiver/data_retrieval.d.ts.map +1 -1
- package/dest/archiver/data_retrieval.js +3 -3
- package/dest/archiver/kv_archiver_store/block_store.d.ts +11 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/block_store.js +27 -3
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts +3 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +1 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.js +6 -0
- package/dest/archiver/validation.d.ts.map +1 -1
- package/dest/archiver/validation.js +7 -4
- package/dest/test/mock_l2_block_source.d.ts +2 -10
- package/dest/test/mock_l2_block_source.d.ts.map +1 -1
- package/dest/test/mock_l2_block_source.js +2 -2
- package/package.json +13 -13
- package/src/archiver/archiver.ts +54 -27
- package/src/archiver/archiver_store.ts +7 -1
- package/src/archiver/archiver_store_test_suite.ts +120 -18
- package/src/archiver/config.ts +13 -28
- package/src/archiver/data_retrieval.ts +3 -7
- package/src/archiver/kv_archiver_store/block_store.ts +44 -4
- package/src/archiver/kv_archiver_store/kv_archiver_store.ts +9 -1
- package/src/archiver/validation.ts +22 -2
- package/src/test/mock_l2_block_source.ts +19 -10
package/README.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# Archiver
|
|
2
2
|
|
|
3
3
|
Archiver is a service which is used to fetch data on-chain data and present them in a nice-to-consume form.
|
|
4
|
+
|
|
4
5
|
The on-chain data specifically are the following events:
|
|
5
6
|
|
|
6
7
|
1. `L2BlockProposed` event emitted on Rollup contract,
|
|
@@ -8,9 +9,29 @@ The on-chain data specifically are the following events:
|
|
|
8
9
|
|
|
9
10
|
The interfaces defining how the data can be consumed from the archiver are `L2BlockSource`, `L2LogsSource` and `ContractDataSource`.
|
|
10
11
|
|
|
11
|
-
##
|
|
12
|
+
## Sync process
|
|
13
|
+
|
|
14
|
+
The archiver sync process periodically checks its current state against the Rollup contract on L1 and updates its local state.
|
|
15
|
+
|
|
16
|
+
### Handling invalid blocks
|
|
17
|
+
|
|
18
|
+
After the implementation of [delayed attestation verification](https://github.com/AztecProtocol/engineering-designs/pull/69), the Rollup contract on L1 no longer validates committee attestations. Instead, these are posted in calldata, and L2 nodes are expected to verify them as they download blocks. The archiver handles this validation during its sync process.
|
|
19
|
+
|
|
20
|
+
Whenever the archiver detects a block with invalid attestations, it skips it. These blocks are not meant to be part of the chain, so the archiver ignores them and continues processing the next blocks. It is expected that an honest proposer will eventually invalidate these blocks, removing them from the chain on L1, and then resume the sequence of valid blocks.
|
|
21
|
+
|
|
22
|
+
> [!WARNING]
|
|
23
|
+
> If the committee for the epoch is also malicious and attests to a descendant of an invalid block, nodes should also ignore these descendants, unless they become proven. This is currently not implemented. Nodes assume that the majority of the committee is honest.
|
|
24
|
+
|
|
25
|
+
When the current node is elected as proposer, the `sequencer` needs to know whether there is an invalid block in L1 that needs to be purged before posting their own block. To support this, the archiver exposes a `pendingChainValidationStatus`, which is the state of the tip of the pending chain. This status can be valid in the happy path, or invalid if the tip of the pending chain has invalid attestations. If invalid, this status also contains all the data needed for purging the block from L1 via an `invalidate` call to the Rollup contract. Note that, if the head of the chain has more than one invalid consecutive block, this status will reference the earliest one that needs to be purged, since a call to purge an invalid block will automatically purge all descendants. Refer to the [InvalidateLib.sol](`l1-contracts/src/core/libraries/rollup/InvalidateLib.sol`) for more info.
|
|
26
|
+
|
|
27
|
+
> [!TIP]
|
|
28
|
+
> The archiver can be configured to `skipValidateBlockAttestations`, which will make it skip this validation. This cannot be set via environment variables, only via a call to `nodeAdmin_setConfig`. This setting is only meant for testing purposes.
|
|
12
29
|
|
|
13
|
-
|
|
14
|
-
|
|
30
|
+
As an example, let's say the chain has been progressing normally up until block 10, and then:
|
|
31
|
+
1. Block 11 is posted with invalid attestations. The archiver will report 10 as the latest block, but the `pendingChainValidationStatus` will point to block 11.
|
|
32
|
+
2. Block 11 is purged, but another block 11 with invalid attestations is posted in its place. The archiver will still report 10 as latest, and the `pendingChainValidationStatus` will point to the new block 11 that needs to be purged.
|
|
33
|
+
3. Block 12 with invalid attestations is posted. No changes in the archiver.
|
|
34
|
+
4. Block 13 is posted with valid attestations, due to a malicious committee. The archiver will try to sync it and fail, since 13 does not follow 10. This scenario is not gracefully handled yet.
|
|
35
|
+
5. Blocks 11 to 13 are purged. The archiver status will not yet be changed: 10 will still be the latest block, and the `pendingChainValidationStatus` will point to 11. This is because the archiver does **not** follow `BlockInvalidated` events.
|
|
36
|
+
6. Block 11 with valid attestations is posted. The archiver pending chain now reports 11 as latest, and its status is valid.
|
|
15
37
|
|
|
16
|
-
To start the service export `ETHEREUM_HOSTS` (defaults to `http://127.0.0.1:8545/`), `ARCHIVER_POLLING_INTERVAL_MS` (defaults to `1000 ms`), `ROLLUP_CONTRACT_ADDRESS`, `INBOX_CONTRACT_ADDRESS` environmental variables and start the service with `yarn start`.
|
|
@@ -45,7 +45,7 @@ export declare class Archiver extends Archiver_base implements ArchiveSource, Tr
|
|
|
45
45
|
private readonly publicClient;
|
|
46
46
|
private readonly l1Addresses;
|
|
47
47
|
readonly dataStore: ArchiverDataStore;
|
|
48
|
-
private
|
|
48
|
+
private config;
|
|
49
49
|
private readonly blobSinkClient;
|
|
50
50
|
private readonly epochCache;
|
|
51
51
|
private readonly instrumentation;
|
|
@@ -60,7 +60,6 @@ export declare class Archiver extends Archiver_base implements ArchiveSource, Tr
|
|
|
60
60
|
private store;
|
|
61
61
|
private l1BlockNumber;
|
|
62
62
|
private l1Timestamp;
|
|
63
|
-
private pendingChainValidationStatus;
|
|
64
63
|
private initialSyncComplete;
|
|
65
64
|
readonly tracer: Tracer;
|
|
66
65
|
/**
|
|
@@ -80,6 +79,7 @@ export declare class Archiver extends Archiver_base implements ArchiveSource, Tr
|
|
|
80
79
|
}, dataStore: ArchiverDataStore, config: {
|
|
81
80
|
pollingIntervalMs: number;
|
|
82
81
|
batchSize: number;
|
|
82
|
+
skipValidateBlockAttestations?: boolean;
|
|
83
83
|
}, blobSinkClient: BlobSinkClientInterface, epochCache: EpochCache, instrumentation: ArchiverInstrumentation, l1constants: L1RollupConstants & {
|
|
84
84
|
l1StartBlockHash: Buffer32;
|
|
85
85
|
}, log?: Logger);
|
|
@@ -91,6 +91,8 @@ export declare class Archiver extends Archiver_base implements ArchiveSource, Tr
|
|
|
91
91
|
* @returns - An instance of the archiver.
|
|
92
92
|
*/
|
|
93
93
|
static createAndSync(config: ArchiverConfig, archiverStore: ArchiverDataStore, deps: ArchiverDeps, blockUntilSynced?: boolean): Promise<Archiver>;
|
|
94
|
+
/** Updates archiver config */
|
|
95
|
+
updateConfig(newConfig: Partial<ArchiverConfig>): void;
|
|
94
96
|
/**
|
|
95
97
|
* Starts sync process.
|
|
96
98
|
* @param blockUntilSynced - If true, blocks until the archiver has fully synced.
|
|
@@ -215,11 +217,11 @@ export declare class Archiver extends Archiver_base implements ArchiveSource, Tr
|
|
|
215
217
|
* I would have preferred to not have this type. But it is useful for handling the logic that any
|
|
216
218
|
* store would need to include otherwise while exposing fewer functions and logic directly to the archiver.
|
|
217
219
|
*/
|
|
218
|
-
export declare class ArchiverStoreHelper implements Omit<ArchiverDataStore, 'addLogs' | 'deleteLogs' | 'addContractClasses' | 'deleteContractClasses' | 'addContractInstances' | 'deleteContractInstances' | 'addContractInstanceUpdates' | 'deleteContractInstanceUpdates' | 'addFunctions' | 'backupTo' | 'close' | 'transactionAsync'> {
|
|
220
|
+
export declare class ArchiverStoreHelper implements Omit<ArchiverDataStore, 'addLogs' | 'deleteLogs' | 'addContractClasses' | 'deleteContractClasses' | 'addContractInstances' | 'deleteContractInstances' | 'addContractInstanceUpdates' | 'deleteContractInstanceUpdates' | 'addFunctions' | 'backupTo' | 'close' | 'transactionAsync' | 'addBlocks'> {
|
|
219
221
|
#private;
|
|
220
222
|
protected readonly store: ArchiverDataStore;
|
|
221
223
|
constructor(store: ArchiverDataStore);
|
|
222
|
-
addBlocks(blocks: PublishedL2Block[]): Promise<boolean>;
|
|
224
|
+
addBlocks(blocks: PublishedL2Block[], pendingChainValidationStatus?: ValidateBlockResult): Promise<boolean>;
|
|
223
225
|
unwindBlocks(from: number, blocksToUnwind: number): Promise<boolean>;
|
|
224
226
|
getPublishedBlocks(from: number, limit: number): Promise<PublishedL2Block[]>;
|
|
225
227
|
getPublishedBlock(number: number): Promise<PublishedL2Block | undefined>;
|
|
@@ -256,6 +258,8 @@ export declare class ArchiverStoreHelper implements Omit<ArchiverDataStore, 'add
|
|
|
256
258
|
iterateL1ToL2Messages(range?: CustomRange<bigint>): AsyncIterableIterator<InboxMessage>;
|
|
257
259
|
removeL1ToL2Messages(startIndex: bigint): Promise<void>;
|
|
258
260
|
getLastL1ToL2Message(): Promise<InboxMessage | undefined>;
|
|
261
|
+
getPendingChainValidationStatus(): Promise<ValidateBlockResult | undefined>;
|
|
262
|
+
setPendingChainValidationStatus(status: ValidateBlockResult | undefined): Promise<void>;
|
|
259
263
|
}
|
|
260
264
|
export {};
|
|
261
265
|
//# sourceMappingURL=archiver.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,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,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IAGpG,0BAA0B,IAAI,OAAO,CAAC,MAAM,CAAC;IAG7C,YAAY,IAAI,OAAO,CAAC;QAAE,WAAW,EAAE,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,OAAO,CAAC,IAAI,CAAC;IAGzE,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;IAGzD,+BAA+B,IAAI,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC;IAG3E,+BAA+B,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC;CAIxF"}
|
|
@@ -8,7 +8,7 @@ import { EpochCache } from '@aztec/epoch-cache';
|
|
|
8
8
|
import { BlockTagTooOldError, InboxContract, RollupContract, createEthereumChain } from '@aztec/ethereum';
|
|
9
9
|
import { maxBigint } from '@aztec/foundation/bigint';
|
|
10
10
|
import { Buffer16, Buffer32 } from '@aztec/foundation/buffer';
|
|
11
|
-
import { pick } from '@aztec/foundation/collection';
|
|
11
|
+
import { merge, pick } from '@aztec/foundation/collection';
|
|
12
12
|
import { Fr } from '@aztec/foundation/fields';
|
|
13
13
|
import { createLogger } from '@aztec/foundation/log';
|
|
14
14
|
import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
|
|
@@ -28,6 +28,13 @@ import { retrieveBlocksFromRollup, retrieveL1ToL2Message, retrieveL1ToL2Messages
|
|
|
28
28
|
import { InitialBlockNumberNotSequentialError, NoBlobBodiesFoundError } from './errors.js';
|
|
29
29
|
import { ArchiverInstrumentation } from './instrumentation.js';
|
|
30
30
|
import { validateBlockAttestations } from './validation.js';
|
|
31
|
+
function mapArchiverConfig(config) {
|
|
32
|
+
return {
|
|
33
|
+
pollingIntervalMs: config.archiverPollingIntervalMS,
|
|
34
|
+
batchSize: config.archiverBatchSize,
|
|
35
|
+
skipValidateBlockAttestations: config.skipValidateBlockAttestations
|
|
36
|
+
};
|
|
37
|
+
}
|
|
31
38
|
/**
|
|
32
39
|
* Pulls L2 blocks in a non-blocking manner and provides interface for their retrieval.
|
|
33
40
|
* Responsible for handling robust L1 polling so that other components do not need to
|
|
@@ -50,7 +57,6 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
50
57
|
store;
|
|
51
58
|
l1BlockNumber;
|
|
52
59
|
l1Timestamp;
|
|
53
|
-
pendingChainValidationStatus;
|
|
54
60
|
initialSyncComplete;
|
|
55
61
|
tracer;
|
|
56
62
|
/**
|
|
@@ -63,9 +69,7 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
63
69
|
* @param store - An archiver data store for storage & retrieval of blocks, encrypted logs & contract data.
|
|
64
70
|
* @param log - A logger.
|
|
65
71
|
*/ constructor(publicClient, l1Addresses, dataStore, config, blobSinkClient, epochCache, instrumentation, l1constants, log = createLogger('archiver')){
|
|
66
|
-
super(), this.publicClient = publicClient, this.l1Addresses = l1Addresses, this.dataStore = dataStore, this.config = config, this.blobSinkClient = blobSinkClient, this.epochCache = epochCache, this.instrumentation = instrumentation, this.l1constants = l1constants, this.log = log, this.
|
|
67
|
-
valid: true
|
|
68
|
-
}, this.initialSyncComplete = false;
|
|
72
|
+
super(), this.publicClient = publicClient, this.l1Addresses = l1Addresses, this.dataStore = dataStore, this.config = config, this.blobSinkClient = blobSinkClient, this.epochCache = epochCache, this.instrumentation = instrumentation, this.l1constants = l1constants, this.log = log, this.initialSyncComplete = false;
|
|
69
73
|
this.tracer = instrumentation.tracer;
|
|
70
74
|
this.store = new ArchiverStoreHelper(dataStore);
|
|
71
75
|
this.rollup = new RollupContract(publicClient, l1Addresses.rollupAddress);
|
|
@@ -104,16 +108,19 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
104
108
|
ethereumSlotDuration,
|
|
105
109
|
proofSubmissionEpochs: Number(proofSubmissionEpochs)
|
|
106
110
|
};
|
|
107
|
-
const opts = {
|
|
108
|
-
pollingIntervalMs:
|
|
109
|
-
batchSize:
|
|
110
|
-
};
|
|
111
|
+
const opts = merge({
|
|
112
|
+
pollingIntervalMs: 10_000,
|
|
113
|
+
batchSize: 100
|
|
114
|
+
}, mapArchiverConfig(config));
|
|
111
115
|
const epochCache = deps.epochCache ?? await EpochCache.create(config.l1Contracts.rollupAddress, config, deps);
|
|
112
116
|
const telemetry = deps.telemetry ?? getTelemetryClient();
|
|
113
117
|
const archiver = new Archiver(publicClient, config.l1Contracts, archiverStore, opts, deps.blobSinkClient, epochCache, await ArchiverInstrumentation.new(telemetry, ()=>archiverStore.estimateSize()), l1Constants);
|
|
114
118
|
await archiver.start(blockUntilSynced);
|
|
115
119
|
return archiver;
|
|
116
120
|
}
|
|
121
|
+
/** Updates archiver config */ updateConfig(newConfig) {
|
|
122
|
+
this.config = merge(this.config, mapArchiverConfig(newConfig));
|
|
123
|
+
}
|
|
117
124
|
/**
|
|
118
125
|
* Starts sync process.
|
|
119
126
|
* @param blockUntilSynced - If true, blocks until the archiver has fully synced.
|
|
@@ -208,7 +215,8 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
208
215
|
})).timestamp : this.l1Timestamp;
|
|
209
216
|
// ********** Events that are processed per L2 block **********
|
|
210
217
|
if (currentL1BlockNumber > blocksSynchedTo) {
|
|
211
|
-
// First we retrieve new L2 blocks
|
|
218
|
+
// First we retrieve new L2 blocks and store them in the DB. This will also update the
|
|
219
|
+
// pending chain validation status, proven block number, and synched L1 block number.
|
|
212
220
|
const rollupStatus = await this.handleL2blocks(blocksSynchedTo, currentL1BlockNumber);
|
|
213
221
|
// Then we prune the current epoch if it'd reorg on next submission.
|
|
214
222
|
// Note that we don't do this before retrieving L2 blocks because we may need to retrieve
|
|
@@ -216,17 +224,11 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
216
224
|
// the chain locally before we start unwinding stuff. This can be optimized by figuring out
|
|
217
225
|
// up to which point we're pruning, and then requesting L2 blocks up to that point only.
|
|
218
226
|
const { rollupCanPrune } = await this.handleEpochPrune(rollupStatus.provenBlockNumber, currentL1BlockNumber, currentL1Timestamp);
|
|
219
|
-
// Update the pending chain validation status with the last block validation result.
|
|
220
|
-
// Again, we only update if validation status changed, so in a sequence of invalid blocks
|
|
221
|
-
// we keep track of the first invalid block so we can invalidate that one if needed.
|
|
222
|
-
if (rollupStatus.validationResult && rollupStatus.validationResult?.valid !== this.pendingChainValidationStatus.valid) {
|
|
223
|
-
this.pendingChainValidationStatus = rollupStatus.validationResult;
|
|
224
|
-
}
|
|
225
227
|
// And lastly we check if we are missing any L2 blocks behind us due to a possible L1 reorg.
|
|
226
228
|
// We only do this if rollup cant prune on the next submission. Otherwise we will end up
|
|
227
229
|
// re-syncing the blocks we have just unwound above. We also dont do this if the last block is invalid,
|
|
228
230
|
// since the archiver will rightfully refuse to sync up to it.
|
|
229
|
-
if (!rollupCanPrune &&
|
|
231
|
+
if (!rollupCanPrune && rollupStatus.validationResult?.valid) {
|
|
230
232
|
await this.checkForNewBlocksBeforeL1SyncPoint(rollupStatus, blocksSynchedTo, currentL1BlockNumber);
|
|
231
233
|
}
|
|
232
234
|
this.instrumentation.updateL1BlockHeight(currentL1BlockNumber);
|
|
@@ -453,6 +455,7 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
453
455
|
}
|
|
454
456
|
async handleL2blocks(blocksSynchedTo, currentL1BlockNumber) {
|
|
455
457
|
const localPendingBlockNumber = await this.getBlockNumber();
|
|
458
|
+
const initialValidationResult = await this.store.getPendingChainValidationStatus();
|
|
456
459
|
const [provenBlockNumber, provenArchive, pendingBlockNumber, pendingArchive, archiveForLocalPendingBlockNumber] = await this.rollup.status(BigInt(localPendingBlockNumber), {
|
|
457
460
|
blockNumber: currentL1BlockNumber
|
|
458
461
|
});
|
|
@@ -461,7 +464,7 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
461
464
|
provenArchive,
|
|
462
465
|
pendingBlockNumber: Number(pendingBlockNumber),
|
|
463
466
|
pendingArchive,
|
|
464
|
-
validationResult:
|
|
467
|
+
validationResult: initialValidationResult
|
|
465
468
|
};
|
|
466
469
|
this.log.trace(`Retrieved rollup status at current L1 block ${currentL1BlockNumber}.`, {
|
|
467
470
|
localPendingBlockNumber,
|
|
@@ -591,10 +594,15 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
591
594
|
const publishedBlocks = retrievedBlocks.map((b)=>retrievedBlockToPublishedL2Block(b));
|
|
592
595
|
const validBlocks = [];
|
|
593
596
|
for (const block of publishedBlocks){
|
|
594
|
-
const validationResult =
|
|
597
|
+
const validationResult = this.config.skipValidateBlockAttestations ? {
|
|
598
|
+
valid: true
|
|
599
|
+
} : await validateBlockAttestations(block, this.epochCache, this.l1constants, this.log);
|
|
595
600
|
// Only update the validation result if it has changed, so we can keep track of the first invalid block
|
|
596
601
|
// in case there is a sequence of more than one invalid block, as we need to invalidate the first one.
|
|
597
|
-
if
|
|
602
|
+
// There is an exception though: if an invalid block is invalidated and replaced with another invalid block,
|
|
603
|
+
// we need to update the validation result, since we need to be able to invalidate the new one.
|
|
604
|
+
// See test 'chain progresses if an invalid block is invalidated with an invalid one' for more info.
|
|
605
|
+
if (rollupStatus.validationResult?.valid !== validationResult.valid || !rollupStatus.validationResult.valid && !validationResult.valid && rollupStatus.validationResult.block.blockNumber === validationResult.block.blockNumber) {
|
|
598
606
|
rollupStatus.validationResult = validationResult;
|
|
599
607
|
}
|
|
600
608
|
if (!validationResult.valid) {
|
|
@@ -619,7 +627,8 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
619
627
|
});
|
|
620
628
|
}
|
|
621
629
|
try {
|
|
622
|
-
const
|
|
630
|
+
const updatedValidationResult = rollupStatus.validationResult === initialValidationResult ? undefined : rollupStatus.validationResult;
|
|
631
|
+
const [processDuration] = await elapsed(()=>this.store.addBlocks(validBlocks, updatedValidationResult));
|
|
623
632
|
this.instrumentation.processNewBlocks(processDuration / validBlocks.length, validBlocks.map((b)=>b.block));
|
|
624
633
|
} catch (err) {
|
|
625
634
|
if (err instanceof InitialBlockNumberNotSequentialError) {
|
|
@@ -919,11 +928,13 @@ import { validateBlockAttestations } from './validation.js';
|
|
|
919
928
|
getDebugFunctionName(address, selector) {
|
|
920
929
|
return this.store.getDebugFunctionName(address, selector);
|
|
921
930
|
}
|
|
922
|
-
getPendingChainValidationStatus() {
|
|
923
|
-
return
|
|
931
|
+
async getPendingChainValidationStatus() {
|
|
932
|
+
return await this.store.getPendingChainValidationStatus() ?? {
|
|
933
|
+
valid: true
|
|
934
|
+
};
|
|
924
935
|
}
|
|
925
936
|
isPendingChainInvalid() {
|
|
926
|
-
return
|
|
937
|
+
return this.getPendingChainValidationStatus().then((status)=>!status.valid);
|
|
927
938
|
}
|
|
928
939
|
async getL2Tips() {
|
|
929
940
|
const [latestBlockNumber, provenBlockNumber] = await Promise.all([
|
|
@@ -1124,12 +1135,15 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
1124
1135
|
}
|
|
1125
1136
|
return true;
|
|
1126
1137
|
}
|
|
1127
|
-
addBlocks(blocks) {
|
|
1138
|
+
addBlocks(blocks, pendingChainValidationStatus) {
|
|
1128
1139
|
// Add the blocks to the store. Store will throw if the blocks are not in order, there are gaps,
|
|
1129
1140
|
// or if the previous block is not in the store.
|
|
1130
1141
|
return this.store.transactionAsync(async ()=>{
|
|
1131
1142
|
await this.store.addBlocks(blocks);
|
|
1132
1143
|
const opResults = await Promise.all([
|
|
1144
|
+
// Update the pending chain validation status if provided
|
|
1145
|
+
pendingChainValidationStatus && this.store.setPendingChainValidationStatus(pendingChainValidationStatus),
|
|
1146
|
+
// Add any logs emitted during the retrieved blocks
|
|
1133
1147
|
this.store.addLogs(blocks.map((block)=>block.block)),
|
|
1134
1148
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
1135
1149
|
...blocks.map(async (block)=>{
|
|
@@ -1159,6 +1173,10 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
1159
1173
|
// from - blocksToUnwind = the new head, so + 1 for what we need to remove
|
|
1160
1174
|
const blocks = await this.getPublishedBlocks(from - blocksToUnwind + 1, blocksToUnwind);
|
|
1161
1175
|
const opResults = await Promise.all([
|
|
1176
|
+
// Prune rolls back to the last proven block, which is by definition valid
|
|
1177
|
+
this.store.setPendingChainValidationStatus({
|
|
1178
|
+
valid: true
|
|
1179
|
+
}),
|
|
1162
1180
|
// Unroll all logs emitted during the retrieved blocks and extract any contract classes and instances from them
|
|
1163
1181
|
...blocks.map(async (block)=>{
|
|
1164
1182
|
const contractClassLogs = block.block.body.txEffects.flatMap((txEffect)=>txEffect.contractClassLogs);
|
|
@@ -1266,4 +1284,11 @@ var Operation = /*#__PURE__*/ function(Operation) {
|
|
|
1266
1284
|
getLastL1ToL2Message() {
|
|
1267
1285
|
return this.store.getLastL1ToL2Message();
|
|
1268
1286
|
}
|
|
1287
|
+
getPendingChainValidationStatus() {
|
|
1288
|
+
return this.store.getPendingChainValidationStatus();
|
|
1289
|
+
}
|
|
1290
|
+
setPendingChainValidationStatus(status) {
|
|
1291
|
+
this.#log.debug(`Setting pending chain validation status to valid ${status?.valid}`, status);
|
|
1292
|
+
return this.store.setPendingChainValidationStatus(status);
|
|
1293
|
+
}
|
|
1269
1294
|
}
|
|
@@ -3,7 +3,7 @@ import type { Fr } from '@aztec/foundation/fields';
|
|
|
3
3
|
import type { CustomRange } from '@aztec/kv-store';
|
|
4
4
|
import type { FunctionSelector } from '@aztec/stdlib/abi';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import type { L2Block } from '@aztec/stdlib/block';
|
|
6
|
+
import type { L2Block, ValidateBlockResult } from '@aztec/stdlib/block';
|
|
7
7
|
import type { ContractClassPublic, ContractInstanceUpdateWithAddress, ContractInstanceWithAddress, ExecutablePrivateFunctionWithMembershipProof, UtilityFunctionWithMembershipProof } from '@aztec/stdlib/contract';
|
|
8
8
|
import type { GetContractClassLogsResponse, GetPublicLogsResponse } from '@aztec/stdlib/interfaces/client';
|
|
9
9
|
import type { LogFilter, PrivateLog, TxScopedL2Log } from '@aztec/stdlib/logs';
|
|
@@ -227,5 +227,9 @@ export interface ArchiverDataStore {
|
|
|
227
227
|
removeL1ToL2Messages(startIndex: bigint): Promise<void>;
|
|
228
228
|
/** Returns the last L1 to L2 message stored. */
|
|
229
229
|
getLastL1ToL2Message(): Promise<InboxMessage | undefined>;
|
|
230
|
+
/** Returns the last synced validation status of the pending chain. */
|
|
231
|
+
getPendingChainValidationStatus(): Promise<ValidateBlockResult | undefined>;
|
|
232
|
+
/** Sets the last synced validation status of the pending chain. */
|
|
233
|
+
setPendingChainValidationStatus(status: ValidateBlockResult | undefined): Promise<void>;
|
|
230
234
|
}
|
|
231
235
|
//# sourceMappingURL=archiver_store.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"archiver_store.d.ts","sourceRoot":"","sources":["../../src/archiver/archiver_store.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;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AO,CAAC,IAAI,CAAC,CAAC;IAExE,wDAAwD;IACxD,oBAAoB,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;IAErG,gDAAgD;IAChD,YAAY,IAAI,OAAO,CAAC;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,gBAAgB,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAEjH,qFAAqF;IACrF,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAExC,wCAAwC;IACxC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvB,qFAAqF;IACrF,+BAA+B,CAAC,iBAAiB,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1E,uEAAuE;IACvE,qBAAqB,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC,GAAG,qBAAqB,CAAC,YAAY,CAAC,CAAC;IAExF,+EAA+E;IAC/E,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAExD,gDAAgD;IAChD,oBAAoB,IAAI,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAAC;IAE1D,sEAAsE;IACtE,+BAA+B,IAAI,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAAC,CAAC;IAE5E,mEAAmE;IACnE,+BAA+B,CAAC,MAAM,EAAE,mBAAmB,GAAG,SAAS,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACzF"}
|
|
@@ -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":"AAqCA,OAAO,4BAA4B,CAAC;AAIpC,OAAO,KAAK,EAAE,iBAAiB,EAAwB,MAAM,qBAAqB,CAAC;AAKnF;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,iBAAiB,GAAG,OAAO,CAAC,iBAAiB,CAAC,QAqlC/D"}
|
|
@@ -7,7 +7,7 @@ import { Fr } from '@aztec/foundation/fields';
|
|
|
7
7
|
import { toArray } from '@aztec/foundation/iterable';
|
|
8
8
|
import { sleep } from '@aztec/foundation/sleep';
|
|
9
9
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
10
|
-
import { CommitteeAttestation, L2Block, L2BlockHash, wrapInBlock } from '@aztec/stdlib/block';
|
|
10
|
+
import { CommitteeAttestation, EthAddress, L2Block, L2BlockHash, PublishedL2Block, randomBlockInfo, wrapInBlock } from '@aztec/stdlib/block';
|
|
11
11
|
import { SerializableContractInstance, computePublicBytecodeCommitment } from '@aztec/stdlib/contract';
|
|
12
12
|
import { LogId, PrivateLog, PublicLog } from '@aztec/stdlib/logs';
|
|
13
13
|
import { InboxLeaf } from '@aztec/stdlib/messaging';
|
|
@@ -52,7 +52,7 @@ import { MessageStoreError } from './kv_archiver_store/message_store.js';
|
|
|
52
52
|
]
|
|
53
53
|
];
|
|
54
54
|
const makeBlockHash = (blockNumber)=>`0x${blockNumber.toString(16).padStart(64, '0')}`;
|
|
55
|
-
const makePublished = (block, l1BlockNumber)=>({
|
|
55
|
+
const makePublished = (block, l1BlockNumber)=>PublishedL2Block.fromFields({
|
|
56
56
|
block: block,
|
|
57
57
|
l1: {
|
|
58
58
|
blockNumber: BigInt(l1BlockNumber),
|
|
@@ -788,7 +788,7 @@ import { MessageStoreError } from './kv_archiver_store/message_store.js';
|
|
|
788
788
|
txEffect.publicLogs = mockPublicLogs(blockNumber, txIndex);
|
|
789
789
|
return txEffect;
|
|
790
790
|
});
|
|
791
|
-
return {
|
|
791
|
+
return PublishedL2Block.fromFields({
|
|
792
792
|
block: block,
|
|
793
793
|
attestations: times(3, CommitteeAttestation.random),
|
|
794
794
|
l1: {
|
|
@@ -796,7 +796,7 @@ import { MessageStoreError } from './kv_archiver_store/message_store.js';
|
|
|
796
796
|
blockHash: makeBlockHash(blockNumber),
|
|
797
797
|
timestamp: BigInt(blockNumber)
|
|
798
798
|
}
|
|
799
|
-
};
|
|
799
|
+
});
|
|
800
800
|
};
|
|
801
801
|
beforeEach(async ()=>{
|
|
802
802
|
blocks = await timesParallel(numBlocks, (index)=>mockBlockWithLogs(index + 1));
|
|
@@ -904,7 +904,7 @@ import { MessageStoreError } from './kv_archiver_store/message_store.js';
|
|
|
904
904
|
const numBlocks = 10;
|
|
905
905
|
let blocks;
|
|
906
906
|
beforeEach(async ()=>{
|
|
907
|
-
blocks = await timesParallel(numBlocks, async (index)=>({
|
|
907
|
+
blocks = await timesParallel(numBlocks, async (index)=>PublishedL2Block.fromFields({
|
|
908
908
|
block: await L2Block.random(index + 1, txsPerBlock, numPublicFunctionCalls, numPublicLogs),
|
|
909
909
|
l1: {
|
|
910
910
|
blockNumber: BigInt(index),
|
|
@@ -1096,5 +1096,103 @@ import { MessageStoreError } from './kv_archiver_store/message_store.js';
|
|
|
1096
1096
|
}
|
|
1097
1097
|
});
|
|
1098
1098
|
});
|
|
1099
|
+
describe('pendingChainValidationStatus', ()=>{
|
|
1100
|
+
it('should return undefined when no status is set', async ()=>{
|
|
1101
|
+
const status = await store.getPendingChainValidationStatus();
|
|
1102
|
+
expect(status).toBeUndefined();
|
|
1103
|
+
});
|
|
1104
|
+
it('should store and retrieve a valid validation status', async ()=>{
|
|
1105
|
+
const validStatus = {
|
|
1106
|
+
valid: true
|
|
1107
|
+
};
|
|
1108
|
+
await store.setPendingChainValidationStatus(validStatus);
|
|
1109
|
+
const retrievedStatus = await store.getPendingChainValidationStatus();
|
|
1110
|
+
expect(retrievedStatus).toEqual(validStatus);
|
|
1111
|
+
});
|
|
1112
|
+
it('should store and retrieve an invalid validation status with insufficient attestations', async ()=>{
|
|
1113
|
+
const invalidStatus = {
|
|
1114
|
+
valid: false,
|
|
1115
|
+
block: randomBlockInfo(1),
|
|
1116
|
+
committee: [
|
|
1117
|
+
EthAddress.random(),
|
|
1118
|
+
EthAddress.random()
|
|
1119
|
+
],
|
|
1120
|
+
epoch: 123n,
|
|
1121
|
+
seed: 456n,
|
|
1122
|
+
attestors: [
|
|
1123
|
+
EthAddress.random()
|
|
1124
|
+
],
|
|
1125
|
+
attestations: [
|
|
1126
|
+
CommitteeAttestation.random()
|
|
1127
|
+
],
|
|
1128
|
+
reason: 'insufficient-attestations'
|
|
1129
|
+
};
|
|
1130
|
+
await store.setPendingChainValidationStatus(invalidStatus);
|
|
1131
|
+
const retrievedStatus = await store.getPendingChainValidationStatus();
|
|
1132
|
+
expect(retrievedStatus).toEqual(invalidStatus);
|
|
1133
|
+
});
|
|
1134
|
+
it('should store and retrieve an invalid validation status with invalid attestation', async ()=>{
|
|
1135
|
+
const invalidStatus = {
|
|
1136
|
+
valid: false,
|
|
1137
|
+
block: randomBlockInfo(2),
|
|
1138
|
+
committee: [
|
|
1139
|
+
EthAddress.random()
|
|
1140
|
+
],
|
|
1141
|
+
attestors: [
|
|
1142
|
+
EthAddress.random()
|
|
1143
|
+
],
|
|
1144
|
+
epoch: 789n,
|
|
1145
|
+
seed: 101n,
|
|
1146
|
+
attestations: [
|
|
1147
|
+
CommitteeAttestation.random()
|
|
1148
|
+
],
|
|
1149
|
+
reason: 'invalid-attestation',
|
|
1150
|
+
invalidIndex: 5
|
|
1151
|
+
};
|
|
1152
|
+
await store.setPendingChainValidationStatus(invalidStatus);
|
|
1153
|
+
const retrievedStatus = await store.getPendingChainValidationStatus();
|
|
1154
|
+
expect(retrievedStatus).toEqual(invalidStatus);
|
|
1155
|
+
});
|
|
1156
|
+
it('should overwrite existing status when setting a new one', async ()=>{
|
|
1157
|
+
const firstStatus = {
|
|
1158
|
+
valid: true
|
|
1159
|
+
};
|
|
1160
|
+
const secondStatus = {
|
|
1161
|
+
valid: false,
|
|
1162
|
+
block: randomBlockInfo(3),
|
|
1163
|
+
committee: [
|
|
1164
|
+
EthAddress.random()
|
|
1165
|
+
],
|
|
1166
|
+
epoch: 999n,
|
|
1167
|
+
seed: 888n,
|
|
1168
|
+
attestors: [
|
|
1169
|
+
EthAddress.random()
|
|
1170
|
+
],
|
|
1171
|
+
attestations: [
|
|
1172
|
+
CommitteeAttestation.random()
|
|
1173
|
+
],
|
|
1174
|
+
reason: 'insufficient-attestations'
|
|
1175
|
+
};
|
|
1176
|
+
await store.setPendingChainValidationStatus(firstStatus);
|
|
1177
|
+
await store.setPendingChainValidationStatus(secondStatus);
|
|
1178
|
+
const retrievedStatus = await store.getPendingChainValidationStatus();
|
|
1179
|
+
expect(retrievedStatus).toEqual(secondStatus);
|
|
1180
|
+
});
|
|
1181
|
+
it('should handle empty committee and attestations arrays', async ()=>{
|
|
1182
|
+
const statusWithEmptyArrays = {
|
|
1183
|
+
valid: false,
|
|
1184
|
+
block: randomBlockInfo(4),
|
|
1185
|
+
committee: [],
|
|
1186
|
+
epoch: 0n,
|
|
1187
|
+
seed: 0n,
|
|
1188
|
+
attestors: [],
|
|
1189
|
+
attestations: [],
|
|
1190
|
+
reason: 'insufficient-attestations'
|
|
1191
|
+
};
|
|
1192
|
+
await store.setPendingChainValidationStatus(statusWithEmptyArrays);
|
|
1193
|
+
const retrievedStatus = await store.getPendingChainValidationStatus();
|
|
1194
|
+
expect(retrievedStatus).toEqual(statusWithEmptyArrays);
|
|
1195
|
+
});
|
|
1196
|
+
});
|
|
1099
1197
|
});
|
|
1100
1198
|
}
|
|
@@ -1,30 +1,16 @@
|
|
|
1
1
|
import { type BlobSinkConfig } from '@aztec/blob-sink/client';
|
|
2
|
-
import { type
|
|
2
|
+
import { type L1ContractsConfig, type L1ReaderConfig } from '@aztec/ethereum';
|
|
3
3
|
import { type ConfigMappingsType } from '@aztec/foundation/config';
|
|
4
4
|
import { type ChainConfig } from '@aztec/stdlib/config';
|
|
5
|
+
import type { ArchiverSpecificConfig } from '@aztec/stdlib/interfaces/server';
|
|
5
6
|
/**
|
|
7
|
+
* The archiver configuration.
|
|
6
8
|
* There are 2 polling intervals used in this configuration. The first is the archiver polling interval, archiverPollingIntervalMS.
|
|
7
9
|
* This is the interval between successive calls to eth_blockNumber via viem.
|
|
8
10
|
* Results of calls to eth_blockNumber are cached by viem with this cache being updated periodically at the interval specified by viemPollingIntervalMS.
|
|
9
11
|
* As a result the maximum observed polling time for new blocks will be viemPollingIntervalMS + archiverPollingIntervalMS.
|
|
10
12
|
*/
|
|
11
|
-
|
|
12
|
-
* The archiver configuration.
|
|
13
|
-
*/
|
|
14
|
-
export type ArchiverConfig = {
|
|
15
|
-
/** The polling interval in ms for retrieving new L2 blocks and encrypted logs. */
|
|
16
|
-
archiverPollingIntervalMS?: number;
|
|
17
|
-
/** The number of L2 blocks the archiver will attempt to download at a time. */
|
|
18
|
-
archiverBatchSize?: number;
|
|
19
|
-
/** The polling interval viem uses in ms */
|
|
20
|
-
viemPollingIntervalMS?: number;
|
|
21
|
-
/** The deployed L1 contract addresses */
|
|
22
|
-
l1Contracts: L1ContractAddresses;
|
|
23
|
-
/** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
|
|
24
|
-
maxLogs?: number;
|
|
25
|
-
/** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB. */
|
|
26
|
-
archiverStoreMapSizeKb?: number;
|
|
27
|
-
} & L1ReaderConfig & L1ContractsConfig & BlobSinkConfig & ChainConfig;
|
|
13
|
+
export type ArchiverConfig = ArchiverSpecificConfig & L1ReaderConfig & L1ContractsConfig & BlobSinkConfig & ChainConfig;
|
|
28
14
|
export declare const archiverConfigMappings: ConfigMappingsType<ArchiverConfig>;
|
|
29
15
|
/**
|
|
30
16
|
* Returns the archiver configuration from the environment variables.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/archiver/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/archiver/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,cAAc,EAAyB,MAAM,yBAAyB,CAAC;AACrF,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EAIpB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,KAAK,WAAW,EAAuB,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG,sBAAsB,GAAG,cAAc,GAAG,iBAAiB,GAAG,cAAc,GAAG,WAAW,CAAC;AAExH,eAAO,MAAM,sBAAsB,EAAE,kBAAkB,CAAC,cAAc,CAsCrE,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,wBAAwB,IAAI,cAAc,CAEzD"}
|
package/dest/archiver/config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { blobSinkConfigMapping } from '@aztec/blob-sink/client';
|
|
2
2
|
import { l1ContractAddressesMapping, l1ContractsConfigMappings, l1ReaderConfigMappings } from '@aztec/ethereum';
|
|
3
|
-
import { getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
3
|
+
import { booleanConfigHelper, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
|
|
4
4
|
import { chainConfigMappings } from '@aztec/stdlib/config';
|
|
5
5
|
export const archiverConfigMappings = {
|
|
6
6
|
...blobSinkConfigMapping,
|
|
@@ -24,6 +24,10 @@ export const archiverConfigMappings = {
|
|
|
24
24
|
parseEnv: (val)=>val ? +val : undefined,
|
|
25
25
|
description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB.'
|
|
26
26
|
},
|
|
27
|
+
skipValidateBlockAttestations: {
|
|
28
|
+
description: 'Whether to skip validating block attestations (use only for testing).',
|
|
29
|
+
...booleanConfigHelper(false)
|
|
30
|
+
},
|
|
27
31
|
...chainConfigMappings,
|
|
28
32
|
...l1ReaderConfigMappings,
|
|
29
33
|
viemPollingIntervalMS: {
|
|
@@ -4,13 +4,13 @@ import type { EthAddress } from '@aztec/foundation/eth-address';
|
|
|
4
4
|
import { Fr } from '@aztec/foundation/fields';
|
|
5
5
|
import { type Logger } from '@aztec/foundation/log';
|
|
6
6
|
import { type InboxAbi, RollupAbi } from '@aztec/l1-artifacts';
|
|
7
|
-
import { Body, CommitteeAttestation } from '@aztec/stdlib/block';
|
|
7
|
+
import { Body, CommitteeAttestation, PublishedL2Block } from '@aztec/stdlib/block';
|
|
8
8
|
import { Proof } from '@aztec/stdlib/proofs';
|
|
9
9
|
import { ProposedBlockHeader, StateReference } from '@aztec/stdlib/tx';
|
|
10
10
|
import { type GetContractReturnType, type Hex } from 'viem';
|
|
11
11
|
import type { DataRetrieval } from './structs/data_retrieval.js';
|
|
12
12
|
import type { InboxMessage } from './structs/inbox_message.js';
|
|
13
|
-
import type { L1PublishedData
|
|
13
|
+
import type { L1PublishedData } from './structs/published.js';
|
|
14
14
|
export type RetrievedL2Block = {
|
|
15
15
|
l2BlockNumber: number;
|
|
16
16
|
archiveRoot: Fr;
|