@aztec/archiver 4.0.0-nightly.20260114 → 4.0.0-nightly.20260116
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/archiver.d.ts +134 -0
- package/dest/archiver.d.ts.map +1 -0
- package/dest/archiver.js +768 -0
- package/dest/{archiver/config.d.ts → config.d.ts} +9 -1
- package/dest/config.d.ts.map +1 -0
- package/dest/{archiver/config.js → config.js} +9 -0
- package/dest/{archiver/errors.d.ts → errors.d.ts} +1 -1
- package/dest/errors.d.ts.map +1 -0
- package/dest/factory.d.ts +5 -6
- package/dest/factory.d.ts.map +1 -1
- package/dest/factory.js +82 -5
- package/dest/index.d.ts +10 -4
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +8 -3
- package/dest/interfaces.d.ts +9 -0
- package/dest/interfaces.d.ts.map +1 -0
- package/dest/interfaces.js +3 -0
- package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.d.ts +1 -1
- package/dest/l1/bin/retrieve-calldata.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/calldata_retriever.d.ts +2 -2
- package/dest/l1/calldata_retriever.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/data_retrieval.d.ts +2 -2
- package/dest/l1/data_retrieval.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/debug_tx.d.ts +1 -1
- package/dest/l1/debug_tx.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/spire_proposer.d.ts +1 -1
- package/dest/l1/spire_proposer.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/trace_tx.d.ts +1 -1
- package/dest/l1/trace_tx.d.ts.map +1 -0
- package/dest/l1/types.d.ts +12 -0
- package/dest/l1/types.d.ts.map +1 -0
- package/dest/{archiver/l1 → l1}/validate_trace.d.ts +1 -1
- package/dest/l1/validate_trace.d.ts.map +1 -0
- package/dest/modules/data_source_base.d.ts +83 -0
- package/dest/modules/data_source_base.d.ts.map +1 -0
- package/dest/{archiver/archive_source_base.js → modules/data_source_base.js} +109 -10
- package/dest/modules/data_store_updater.d.ts +46 -0
- package/dest/modules/data_store_updater.d.ts.map +1 -0
- package/dest/modules/data_store_updater.js +216 -0
- package/dest/modules/instrumentation.d.ts +37 -0
- package/dest/modules/instrumentation.d.ts.map +1 -0
- package/dest/modules/l1_synchronizer.d.ts +73 -0
- package/dest/modules/l1_synchronizer.d.ts.map +1 -0
- package/dest/{archiver/archiver.js → modules/l1_synchronizer.js} +62 -542
- package/dest/{archiver → modules}/validation.d.ts +1 -1
- package/dest/modules/validation.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/block_store.d.ts +1 -1
- package/dest/store/block_store.d.ts.map +1 -0
- package/dest/store/contract_class_store.d.ts +18 -0
- package/dest/store/contract_class_store.d.ts.map +1 -0
- package/dest/store/contract_instance_store.d.ts +24 -0
- package/dest/store/contract_instance_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/kv_archiver_store.d.ts +2 -2
- package/dest/store/kv_archiver_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/log_store.d.ts +1 -1
- package/dest/store/log_store.d.ts.map +1 -0
- package/dest/{archiver/kv_archiver_store → store}/message_store.d.ts +1 -1
- package/dest/store/message_store.d.ts.map +1 -0
- package/dest/{archiver/structs → structs}/data_retrieval.d.ts +1 -1
- package/dest/structs/data_retrieval.d.ts.map +1 -0
- package/dest/structs/inbox_message.d.ts +15 -0
- package/dest/structs/inbox_message.d.ts.map +1 -0
- package/dest/{archiver/structs → structs}/published.d.ts +1 -1
- package/dest/structs/published.d.ts.map +1 -0
- package/dest/{archiver/test → test}/fake_l1_state.d.ts +1 -1
- package/dest/test/fake_l1_state.d.ts.map +1 -0
- package/dest/test/index.d.ts +2 -1
- package/dest/test/index.d.ts.map +1 -1
- package/dest/test/index.js +1 -0
- package/dest/test/mock_structs.d.ts +76 -2
- package/dest/test/mock_structs.d.ts.map +1 -1
- package/dest/test/mock_structs.js +133 -2
- package/package.json +15 -17
- package/src/archiver.ts +523 -0
- package/src/{archiver/config.ts → config.ts} +11 -0
- package/src/factory.ts +118 -6
- package/src/index.ts +10 -3
- package/src/interfaces.ts +9 -0
- package/src/{archiver/l1 → l1}/calldata_retriever.ts +1 -1
- package/src/{archiver/l1 → l1}/data_retrieval.ts +1 -1
- package/src/{archiver/archive_source_base.ts → modules/data_source_base.ts} +130 -30
- package/src/modules/data_store_updater.ts +318 -0
- package/src/{archiver/archiver.ts → modules/l1_synchronizer.ts} +74 -714
- package/src/test/index.ts +1 -0
- package/src/test/mock_structs.ts +247 -2
- package/dest/archiver/archive_source_base.d.ts +0 -75
- package/dest/archiver/archive_source_base.d.ts.map +0 -1
- package/dest/archiver/archiver.d.ts +0 -168
- package/dest/archiver/archiver.d.ts.map +0 -1
- package/dest/archiver/archiver_store_updates.d.ts +0 -38
- package/dest/archiver/archiver_store_updates.d.ts.map +0 -1
- package/dest/archiver/archiver_store_updates.js +0 -212
- package/dest/archiver/config.d.ts.map +0 -1
- package/dest/archiver/errors.d.ts.map +0 -1
- package/dest/archiver/index.d.ts +0 -8
- package/dest/archiver/index.d.ts.map +0 -1
- package/dest/archiver/index.js +0 -6
- package/dest/archiver/instrumentation.d.ts +0 -37
- package/dest/archiver/instrumentation.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/block_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts +0 -18
- package/dest/archiver/kv_archiver_store/contract_class_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts +0 -24
- package/dest/archiver/kv_archiver_store/contract_instance_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/kv_archiver_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/log_store.d.ts.map +0 -1
- package/dest/archiver/kv_archiver_store/message_store.d.ts.map +0 -1
- package/dest/archiver/l1/bin/retrieve-calldata.d.ts.map +0 -1
- package/dest/archiver/l1/calldata_retriever.d.ts.map +0 -1
- package/dest/archiver/l1/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/l1/debug_tx.d.ts.map +0 -1
- package/dest/archiver/l1/spire_proposer.d.ts.map +0 -1
- package/dest/archiver/l1/trace_tx.d.ts.map +0 -1
- package/dest/archiver/l1/types.d.ts +0 -12
- package/dest/archiver/l1/types.d.ts.map +0 -1
- package/dest/archiver/l1/validate_trace.d.ts.map +0 -1
- package/dest/archiver/structs/data_retrieval.d.ts.map +0 -1
- package/dest/archiver/structs/inbox_message.d.ts +0 -15
- package/dest/archiver/structs/inbox_message.d.ts.map +0 -1
- package/dest/archiver/structs/published.d.ts.map +0 -1
- package/dest/archiver/test/fake_l1_state.d.ts.map +0 -1
- package/dest/archiver/validation.d.ts.map +0 -1
- package/dest/rpc/index.d.ts +0 -9
- package/dest/rpc/index.d.ts.map +0 -1
- package/dest/rpc/index.js +0 -15
- package/src/archiver/archiver_store_updates.ts +0 -321
- package/src/archiver/index.ts +0 -7
- package/src/rpc/index.ts +0 -16
- /package/dest/{archiver/errors.js → errors.js} +0 -0
- /package/dest/{archiver/l1 → l1}/bin/retrieve-calldata.js +0 -0
- /package/dest/{archiver/l1 → l1}/calldata_retriever.js +0 -0
- /package/dest/{archiver/l1 → l1}/data_retrieval.js +0 -0
- /package/dest/{archiver/l1 → l1}/debug_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/spire_proposer.js +0 -0
- /package/dest/{archiver/l1 → l1}/trace_tx.js +0 -0
- /package/dest/{archiver/l1 → l1}/types.js +0 -0
- /package/dest/{archiver/l1 → l1}/validate_trace.js +0 -0
- /package/dest/{archiver → modules}/instrumentation.js +0 -0
- /package/dest/{archiver → modules}/validation.js +0 -0
- /package/dest/{archiver/kv_archiver_store → store}/block_store.js +0 -0
- /package/dest/{archiver/kv_archiver_store → store}/contract_class_store.js +0 -0
- /package/dest/{archiver/kv_archiver_store → store}/contract_instance_store.js +0 -0
- /package/dest/{archiver/kv_archiver_store → store}/kv_archiver_store.js +0 -0
- /package/dest/{archiver/kv_archiver_store → store}/log_store.js +0 -0
- /package/dest/{archiver/kv_archiver_store → store}/message_store.js +0 -0
- /package/dest/{archiver/structs → structs}/data_retrieval.js +0 -0
- /package/dest/{archiver/structs → structs}/inbox_message.js +0 -0
- /package/dest/{archiver/structs → structs}/published.js +0 -0
- /package/dest/{archiver/test → test}/fake_l1_state.js +0 -0
- /package/src/{archiver/errors.ts → errors.ts} +0 -0
- /package/src/{archiver/l1 → l1}/README.md +0 -0
- /package/src/{archiver/l1 → l1}/bin/retrieve-calldata.ts +0 -0
- /package/src/{archiver/l1 → l1}/debug_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/spire_proposer.ts +0 -0
- /package/src/{archiver/l1 → l1}/trace_tx.ts +0 -0
- /package/src/{archiver/l1 → l1}/types.ts +0 -0
- /package/src/{archiver/l1 → l1}/validate_trace.ts +0 -0
- /package/src/{archiver → modules}/instrumentation.ts +0 -0
- /package/src/{archiver → modules}/validation.ts +0 -0
- /package/src/{archiver/kv_archiver_store → store}/block_store.ts +0 -0
- /package/src/{archiver/kv_archiver_store → store}/contract_class_store.ts +0 -0
- /package/src/{archiver/kv_archiver_store → store}/contract_instance_store.ts +0 -0
- /package/src/{archiver/kv_archiver_store → store}/kv_archiver_store.ts +0 -0
- /package/src/{archiver/kv_archiver_store → store}/log_store.ts +0 -0
- /package/src/{archiver/kv_archiver_store → store}/message_store.ts +0 -0
- /package/src/{archiver/structs → structs}/data_retrieval.ts +0 -0
- /package/src/{archiver/structs → structs}/inbox_message.ts +0 -0
- /package/src/{archiver/structs → structs}/published.ts +0 -0
- /package/src/{archiver/test → test}/fake_l1_state.ts +0 -0
package/package.json
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/archiver",
|
|
3
|
-
"version": "4.0.0-nightly.
|
|
3
|
+
"version": "4.0.0-nightly.20260116",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./dest/index.js",
|
|
7
|
-
"./data-retrieval": "./dest/archiver/data_retrieval.js",
|
|
8
|
-
"./epoch": "./dest/archiver/epoch_helpers.js",
|
|
9
7
|
"./test": "./dest/test/index.js",
|
|
10
|
-
"./config": "./dest/
|
|
8
|
+
"./config": "./dest/config.js"
|
|
11
9
|
},
|
|
12
10
|
"typedocOptions": {
|
|
13
11
|
"entryPoints": [
|
|
@@ -66,18 +64,18 @@
|
|
|
66
64
|
]
|
|
67
65
|
},
|
|
68
66
|
"dependencies": {
|
|
69
|
-
"@aztec/blob-client": "4.0.0-nightly.
|
|
70
|
-
"@aztec/blob-lib": "4.0.0-nightly.
|
|
71
|
-
"@aztec/constants": "4.0.0-nightly.
|
|
72
|
-
"@aztec/epoch-cache": "4.0.0-nightly.
|
|
73
|
-
"@aztec/ethereum": "4.0.0-nightly.
|
|
74
|
-
"@aztec/foundation": "4.0.0-nightly.
|
|
75
|
-
"@aztec/kv-store": "4.0.0-nightly.
|
|
76
|
-
"@aztec/l1-artifacts": "4.0.0-nightly.
|
|
77
|
-
"@aztec/noir-protocol-circuits-types": "4.0.0-nightly.
|
|
78
|
-
"@aztec/protocol-contracts": "4.0.0-nightly.
|
|
79
|
-
"@aztec/stdlib": "4.0.0-nightly.
|
|
80
|
-
"@aztec/telemetry-client": "4.0.0-nightly.
|
|
67
|
+
"@aztec/blob-client": "4.0.0-nightly.20260116",
|
|
68
|
+
"@aztec/blob-lib": "4.0.0-nightly.20260116",
|
|
69
|
+
"@aztec/constants": "4.0.0-nightly.20260116",
|
|
70
|
+
"@aztec/epoch-cache": "4.0.0-nightly.20260116",
|
|
71
|
+
"@aztec/ethereum": "4.0.0-nightly.20260116",
|
|
72
|
+
"@aztec/foundation": "4.0.0-nightly.20260116",
|
|
73
|
+
"@aztec/kv-store": "4.0.0-nightly.20260116",
|
|
74
|
+
"@aztec/l1-artifacts": "4.0.0-nightly.20260116",
|
|
75
|
+
"@aztec/noir-protocol-circuits-types": "4.0.0-nightly.20260116",
|
|
76
|
+
"@aztec/protocol-contracts": "4.0.0-nightly.20260116",
|
|
77
|
+
"@aztec/stdlib": "4.0.0-nightly.20260116",
|
|
78
|
+
"@aztec/telemetry-client": "4.0.0-nightly.20260116",
|
|
81
79
|
"lodash.groupby": "^4.6.0",
|
|
82
80
|
"lodash.omit": "^4.5.0",
|
|
83
81
|
"tslib": "^2.5.0",
|
|
@@ -90,7 +88,7 @@
|
|
|
90
88
|
"@types/lodash.groupby": "^4.6.9",
|
|
91
89
|
"@types/lodash.omit": "^4.5.7",
|
|
92
90
|
"@types/node": "^22.15.17",
|
|
93
|
-
"@typescript/native-preview": "7.0.0-dev.
|
|
91
|
+
"@typescript/native-preview": "7.0.0-dev.20260113.1",
|
|
94
92
|
"concurrently": "^8.0.1",
|
|
95
93
|
"jest": "^30.0.0",
|
|
96
94
|
"jest-mock-extended": "^4.0.0",
|
package/src/archiver.ts
ADDED
|
@@ -0,0 +1,523 @@
|
|
|
1
|
+
import type { BlobClientInterface } from '@aztec/blob-client/client';
|
|
2
|
+
import { GENESIS_BLOCK_HEADER_HASH, INITIAL_L2_BLOCK_NUM } from '@aztec/constants';
|
|
3
|
+
import { EpochCache } from '@aztec/epoch-cache';
|
|
4
|
+
import { BlockTagTooOldError, RollupContract } from '@aztec/ethereum/contracts';
|
|
5
|
+
import type { L1ContractAddresses } from '@aztec/ethereum/l1-contract-addresses';
|
|
6
|
+
import type { ViemPublicClient, ViemPublicDebugClient } from '@aztec/ethereum/types';
|
|
7
|
+
import { BlockNumber, CheckpointNumber, EpochNumber, SlotNumber } from '@aztec/foundation/branded-types';
|
|
8
|
+
import { Buffer32 } from '@aztec/foundation/buffer';
|
|
9
|
+
import { merge } from '@aztec/foundation/collection';
|
|
10
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
11
|
+
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
|
+
import { type Logger, createLogger } from '@aztec/foundation/log';
|
|
13
|
+
import { type PromiseWithResolvers, promiseWithResolvers } from '@aztec/foundation/promise';
|
|
14
|
+
import { RunningPromise, makeLoggingErrorHandler } from '@aztec/foundation/running-promise';
|
|
15
|
+
import { DateProvider } from '@aztec/foundation/timer';
|
|
16
|
+
import {
|
|
17
|
+
type ArchiverEmitter,
|
|
18
|
+
type CheckpointId,
|
|
19
|
+
GENESIS_CHECKPOINT_HEADER_HASH,
|
|
20
|
+
L2BlockNew,
|
|
21
|
+
type L2BlockSink,
|
|
22
|
+
type L2Tips,
|
|
23
|
+
type ValidateCheckpointResult,
|
|
24
|
+
} from '@aztec/stdlib/block';
|
|
25
|
+
import { PublishedCheckpoint } from '@aztec/stdlib/checkpoint';
|
|
26
|
+
import {
|
|
27
|
+
type L1RollupConstants,
|
|
28
|
+
getEpochNumberAtTimestamp,
|
|
29
|
+
getSlotAtTimestamp,
|
|
30
|
+
getSlotRangeForEpoch,
|
|
31
|
+
getTimestampRangeForEpoch,
|
|
32
|
+
} from '@aztec/stdlib/epoch-helpers';
|
|
33
|
+
import { type TelemetryClient, type Traceable, type Tracer, trackSpan } from '@aztec/telemetry-client';
|
|
34
|
+
|
|
35
|
+
import { type ArchiverConfig, mapArchiverConfig } from './config.js';
|
|
36
|
+
import { NoBlobBodiesFoundError } from './errors.js';
|
|
37
|
+
import { validateAndLogTraceAvailability } from './l1/validate_trace.js';
|
|
38
|
+
import { ArchiverDataSourceBase } from './modules/data_source_base.js';
|
|
39
|
+
import { ArchiverDataStoreUpdater } from './modules/data_store_updater.js';
|
|
40
|
+
import type { ArchiverInstrumentation } from './modules/instrumentation.js';
|
|
41
|
+
import type { ArchiverL1Synchronizer } from './modules/l1_synchronizer.js';
|
|
42
|
+
import type { KVArchiverDataStore } from './store/kv_archiver_store.js';
|
|
43
|
+
|
|
44
|
+
/** Export ArchiverEmitter for use in factory and tests. */
|
|
45
|
+
export type { ArchiverEmitter };
|
|
46
|
+
|
|
47
|
+
/** Request to add a block to the archiver, queued for processing by the sync loop. */
|
|
48
|
+
type AddBlockRequest = {
|
|
49
|
+
block: L2BlockNew;
|
|
50
|
+
resolve: () => void;
|
|
51
|
+
reject: (err: Error) => void;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type ArchiverDeps = {
|
|
55
|
+
telemetry?: TelemetryClient;
|
|
56
|
+
blobClient: BlobClientInterface;
|
|
57
|
+
epochCache?: EpochCache;
|
|
58
|
+
dateProvider?: DateProvider;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Pulls checkpoints in a non-blocking manner and provides interface for their retrieval.
|
|
63
|
+
* Responsible for handling robust L1 polling so that other components do not need to
|
|
64
|
+
* concern themselves with it.
|
|
65
|
+
*/
|
|
66
|
+
export class Archiver extends ArchiverDataSourceBase implements L2BlockSink, Traceable {
|
|
67
|
+
/** Event emitter for archiver events (L2BlockProven, L2PruneDetected, etc). */
|
|
68
|
+
public readonly events: ArchiverEmitter;
|
|
69
|
+
|
|
70
|
+
/** A loop in which we will be continually fetching new checkpoints. */
|
|
71
|
+
private runningPromise: RunningPromise;
|
|
72
|
+
|
|
73
|
+
/** L1 synchronizer that handles fetching checkpoints and messages from L1. */
|
|
74
|
+
private readonly synchronizer: ArchiverL1Synchronizer;
|
|
75
|
+
|
|
76
|
+
private initialSyncComplete: boolean = false;
|
|
77
|
+
private initialSyncPromise: PromiseWithResolvers<void>;
|
|
78
|
+
|
|
79
|
+
/** Queue of blocks to be added to the store, processed by the sync loop. */
|
|
80
|
+
private blockQueue: AddBlockRequest[] = [];
|
|
81
|
+
|
|
82
|
+
/** Helper to handle updates to the store */
|
|
83
|
+
private readonly updater: ArchiverDataStoreUpdater;
|
|
84
|
+
|
|
85
|
+
public readonly tracer: Tracer;
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Creates a new instance of the Archiver.
|
|
89
|
+
* @param publicClient - A client for interacting with the Ethereum node.
|
|
90
|
+
* @param debugClient - A client for interacting with the Ethereum node for debug/trace methods.
|
|
91
|
+
* @param rollup - Rollup contract instance.
|
|
92
|
+
* @param inbox - Inbox contract instance.
|
|
93
|
+
* @param l1Addresses - L1 contract addresses (registry, governance proposer, slash factory, slashing proposer).
|
|
94
|
+
* @param dataStore - An archiver data store for storage & retrieval of blocks, encrypted logs & contract data.
|
|
95
|
+
* @param config - Archiver configuration options.
|
|
96
|
+
* @param blobClient - Client for retrieving blob data.
|
|
97
|
+
* @param epochCache - Cache for epoch-related data.
|
|
98
|
+
* @param dateProvider - Provider for current date/time.
|
|
99
|
+
* @param instrumentation - Instrumentation for metrics and tracing.
|
|
100
|
+
* @param l1Constants - L1 rollup constants.
|
|
101
|
+
* @param log - A logger.
|
|
102
|
+
*/
|
|
103
|
+
constructor(
|
|
104
|
+
private readonly publicClient: ViemPublicClient,
|
|
105
|
+
private readonly debugClient: ViemPublicDebugClient,
|
|
106
|
+
private readonly rollup: RollupContract,
|
|
107
|
+
private readonly l1Addresses: Pick<
|
|
108
|
+
L1ContractAddresses,
|
|
109
|
+
'registryAddress' | 'governanceProposerAddress' | 'slashFactoryAddress'
|
|
110
|
+
> & { slashingProposerAddress: EthAddress },
|
|
111
|
+
readonly dataStore: KVArchiverDataStore,
|
|
112
|
+
private config: {
|
|
113
|
+
pollingIntervalMs: number;
|
|
114
|
+
batchSize: number;
|
|
115
|
+
skipValidateCheckpointAttestations?: boolean;
|
|
116
|
+
maxAllowedEthClientDriftSeconds: number;
|
|
117
|
+
ethereumAllowNoDebugHosts?: boolean;
|
|
118
|
+
},
|
|
119
|
+
private readonly blobClient: BlobClientInterface,
|
|
120
|
+
instrumentation: ArchiverInstrumentation,
|
|
121
|
+
protected override readonly l1Constants: L1RollupConstants & { l1StartBlockHash: Buffer32; genesisArchiveRoot: Fr },
|
|
122
|
+
synchronizer: ArchiverL1Synchronizer,
|
|
123
|
+
events: ArchiverEmitter,
|
|
124
|
+
private readonly log: Logger = createLogger('archiver'),
|
|
125
|
+
) {
|
|
126
|
+
super(dataStore, l1Constants);
|
|
127
|
+
|
|
128
|
+
this.tracer = instrumentation.tracer;
|
|
129
|
+
this.initialSyncPromise = promiseWithResolvers();
|
|
130
|
+
this.synchronizer = synchronizer;
|
|
131
|
+
this.events = events;
|
|
132
|
+
this.updater = new ArchiverDataStoreUpdater(this.dataStore);
|
|
133
|
+
|
|
134
|
+
// Running promise starts with a small interval inbetween runs, so all iterations needed for the initial sync
|
|
135
|
+
// are done as fast as possible. This then gets updated once the initial sync completes.
|
|
136
|
+
this.runningPromise = new RunningPromise(
|
|
137
|
+
() => this.sync(),
|
|
138
|
+
this.log,
|
|
139
|
+
this.config.pollingIntervalMs / 10,
|
|
140
|
+
makeLoggingErrorHandler(this.log, NoBlobBodiesFoundError, BlockTagTooOldError),
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** Updates archiver config */
|
|
145
|
+
public updateConfig(newConfig: Partial<ArchiverConfig>) {
|
|
146
|
+
this.config = merge(this.config, mapArchiverConfig(newConfig));
|
|
147
|
+
this.synchronizer.setConfig(this.config);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* Starts sync process.
|
|
152
|
+
* @param blockUntilSynced - If true, blocks until the archiver has fully synced.
|
|
153
|
+
*/
|
|
154
|
+
public async start(blockUntilSynced: boolean): Promise<void> {
|
|
155
|
+
if (this.runningPromise.isRunning()) {
|
|
156
|
+
throw new Error('Archiver is already running');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
await this.blobClient.testSources();
|
|
160
|
+
await this.synchronizer.testEthereumNodeSynced();
|
|
161
|
+
await validateAndLogTraceAvailability(this.debugClient, this.config.ethereumAllowNoDebugHosts ?? false);
|
|
162
|
+
|
|
163
|
+
// Log initial state for the archiver
|
|
164
|
+
const { l1StartBlock } = this.l1Constants;
|
|
165
|
+
const { blocksSynchedTo = l1StartBlock, messagesSynchedTo = l1StartBlock } = await this.store.getSynchPoint();
|
|
166
|
+
const currentL2Checkpoint = await this.getSynchedCheckpointNumber();
|
|
167
|
+
this.log.info(
|
|
168
|
+
`Starting archiver sync to rollup contract ${this.rollup.address} from L1 block ${blocksSynchedTo} and L2 checkpoint ${currentL2Checkpoint}`,
|
|
169
|
+
{ blocksSynchedTo, messagesSynchedTo, currentL2Checkpoint },
|
|
170
|
+
);
|
|
171
|
+
|
|
172
|
+
// Start sync loop, and return the wait for initial sync if we are asked to block until synced
|
|
173
|
+
this.runningPromise.start();
|
|
174
|
+
if (blockUntilSynced) {
|
|
175
|
+
return this.waitForInitialSync();
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
public syncImmediate() {
|
|
180
|
+
return this.runningPromise.trigger();
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Queues a block to be added to the archiver store and triggers processing.
|
|
185
|
+
* The block will be processed by the sync loop.
|
|
186
|
+
* Implements the L2BlockSink interface.
|
|
187
|
+
* @param block - The L2 block to add.
|
|
188
|
+
* @returns A promise that resolves when the block has been added to the store, or rejects on error.
|
|
189
|
+
*/
|
|
190
|
+
public addBlock(block: L2BlockNew): Promise<void> {
|
|
191
|
+
return new Promise<void>((resolve, reject) => {
|
|
192
|
+
this.blockQueue.push({ block, resolve, reject });
|
|
193
|
+
this.log.debug(`Queued block ${block.number} for processing`);
|
|
194
|
+
// Trigger an immediate sync, but don't wait for it - the promise resolves when the block is processed
|
|
195
|
+
this.syncImmediate().catch(err => {
|
|
196
|
+
this.log.error(`Sync immediate call failed: ${err}`);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Processes all queued blocks, adding them to the store.
|
|
203
|
+
* Called at the beginning of each sync iteration.
|
|
204
|
+
* Blocks are processed in the order they were queued.
|
|
205
|
+
*/
|
|
206
|
+
private async processQueuedBlocks(): Promise<void> {
|
|
207
|
+
if (this.blockQueue.length === 0) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
// Take all blocks from the queue
|
|
212
|
+
const queuedItems = this.blockQueue.splice(0, this.blockQueue.length);
|
|
213
|
+
this.log.debug(`Processing ${queuedItems.length} queued block(s)`);
|
|
214
|
+
|
|
215
|
+
// Process each block individually to properly resolve/reject each promise
|
|
216
|
+
for (const { block, resolve, reject } of queuedItems) {
|
|
217
|
+
try {
|
|
218
|
+
await this.updater.addBlocksWithContractData([block]);
|
|
219
|
+
this.log.debug(`Added block ${block.number} to store`);
|
|
220
|
+
resolve();
|
|
221
|
+
} catch (err: any) {
|
|
222
|
+
this.log.error(`Failed to add block ${block.number} to store: ${err.message}`);
|
|
223
|
+
reject(err);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
public waitForInitialSync() {
|
|
229
|
+
return this.initialSyncPromise.promise;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Fetches logs from L1 contracts and processes them.
|
|
234
|
+
*/
|
|
235
|
+
@trackSpan('Archiver.sync')
|
|
236
|
+
private async sync() {
|
|
237
|
+
// Process any queued blocks first, before doing L1 sync
|
|
238
|
+
await this.processQueuedBlocks();
|
|
239
|
+
// Now perform L1 sync
|
|
240
|
+
await this.syncFromL1();
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
private async syncFromL1() {
|
|
244
|
+
// Delegate to the L1 synchronizer
|
|
245
|
+
await this.synchronizer.syncFromL1(this.initialSyncComplete);
|
|
246
|
+
|
|
247
|
+
// Check if we've completed initial sync
|
|
248
|
+
const currentL1BlockNumber = this.synchronizer.getL1BlockNumber();
|
|
249
|
+
if (currentL1BlockNumber !== undefined && !this.initialSyncComplete) {
|
|
250
|
+
const l1BlockNumberAtEnd = await this.publicClient.getBlockNumber();
|
|
251
|
+
if (currentL1BlockNumber + 1n >= l1BlockNumberAtEnd) {
|
|
252
|
+
this.log.info(`Initial archiver sync to L1 block ${currentL1BlockNumber} complete`, {
|
|
253
|
+
l1BlockNumber: currentL1BlockNumber,
|
|
254
|
+
syncPoint: await this.store.getSynchPoint(),
|
|
255
|
+
...(await this.getL2Tips()),
|
|
256
|
+
});
|
|
257
|
+
this.runningPromise.setPollingIntervalMS(this.config.pollingIntervalMs);
|
|
258
|
+
this.initialSyncComplete = true;
|
|
259
|
+
this.initialSyncPromise.resolve();
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/** Resumes the archiver after a stop. */
|
|
265
|
+
public resume() {
|
|
266
|
+
if (this.runningPromise.isRunning()) {
|
|
267
|
+
this.log.warn(`Archiver already running`);
|
|
268
|
+
}
|
|
269
|
+
this.log.info(`Restarting archiver`);
|
|
270
|
+
this.runningPromise.start();
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* Stops the archiver.
|
|
275
|
+
* @returns A promise signalling completion of the stop process.
|
|
276
|
+
*/
|
|
277
|
+
public async stop(): Promise<void> {
|
|
278
|
+
this.log.debug('Stopping...');
|
|
279
|
+
await this.runningPromise.stop();
|
|
280
|
+
|
|
281
|
+
this.log.info('Stopped.');
|
|
282
|
+
return Promise.resolve();
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
public backupTo(destPath: string): Promise<string> {
|
|
286
|
+
return this.dataStore.backupTo(destPath);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
public getL1Constants(): Promise<L1RollupConstants> {
|
|
290
|
+
return Promise.resolve(this.l1Constants);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
public getGenesisValues(): Promise<{ genesisArchiveRoot: Fr }> {
|
|
294
|
+
return Promise.resolve({ genesisArchiveRoot: this.l1Constants.genesisArchiveRoot });
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
public getRollupAddress(): Promise<EthAddress> {
|
|
298
|
+
return Promise.resolve(EthAddress.fromString(this.rollup.address));
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
public getRegistryAddress(): Promise<EthAddress> {
|
|
302
|
+
return Promise.resolve(this.l1Addresses.registryAddress);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
public getL1BlockNumber(): bigint | undefined {
|
|
306
|
+
return this.synchronizer.getL1BlockNumber();
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
public getL1Timestamp(): Promise<bigint | undefined> {
|
|
310
|
+
return Promise.resolve(this.synchronizer.getL1Timestamp());
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
public getL2SlotNumber(): Promise<SlotNumber | undefined> {
|
|
314
|
+
const l1Timestamp = this.synchronizer.getL1Timestamp();
|
|
315
|
+
return Promise.resolve(l1Timestamp === undefined ? undefined : getSlotAtTimestamp(l1Timestamp, this.l1Constants));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
public getL2EpochNumber(): Promise<EpochNumber | undefined> {
|
|
319
|
+
const l1Timestamp = this.synchronizer.getL1Timestamp();
|
|
320
|
+
return Promise.resolve(
|
|
321
|
+
l1Timestamp === undefined ? undefined : getEpochNumberAtTimestamp(l1Timestamp, this.l1Constants),
|
|
322
|
+
);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
public async isEpochComplete(epochNumber: EpochNumber): Promise<boolean> {
|
|
326
|
+
// The epoch is complete if the current L2 block is the last one in the epoch (or later)
|
|
327
|
+
const header = await this.getBlockHeader('latest');
|
|
328
|
+
const slot = header ? header.globalVariables.slotNumber : undefined;
|
|
329
|
+
const [_startSlot, endSlot] = getSlotRangeForEpoch(epochNumber, this.l1Constants);
|
|
330
|
+
if (slot && slot >= endSlot) {
|
|
331
|
+
return true;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// If we haven't run an initial sync, just return false.
|
|
335
|
+
const l1Timestamp = this.synchronizer.getL1Timestamp();
|
|
336
|
+
if (l1Timestamp === undefined) {
|
|
337
|
+
return false;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// If not, the epoch may also be complete if the L2 slot has passed without a block
|
|
341
|
+
// We compute this based on the end timestamp for the given epoch and the timestamp of the last L1 block
|
|
342
|
+
const [_startTimestamp, endTimestamp] = getTimestampRangeForEpoch(epochNumber, this.l1Constants);
|
|
343
|
+
|
|
344
|
+
// For this computation, we throw in a few extra seconds just for good measure,
|
|
345
|
+
// since we know the next L1 block won't be mined within this range. Remember that
|
|
346
|
+
// l1timestamp is the timestamp of the last l1 block we've seen, so this relies on
|
|
347
|
+
// the fact that L1 won't mine two blocks within this time of each other.
|
|
348
|
+
// TODO(palla/reorg): Is the above a safe assumption?
|
|
349
|
+
const leeway = 1n;
|
|
350
|
+
return l1Timestamp + leeway >= endTimestamp;
|
|
351
|
+
}
|
|
352
|
+
|
|
353
|
+
/** Returns whether the archiver has completed an initial sync run successfully. */
|
|
354
|
+
public isInitialSyncComplete(): boolean {
|
|
355
|
+
return this.initialSyncComplete;
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
public unwindCheckpoints(from: CheckpointNumber, checkpointsToUnwind: number): Promise<boolean> {
|
|
359
|
+
return this.updater.unwindCheckpointsWithContractData(from, checkpointsToUnwind);
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
public addCheckpoints(
|
|
363
|
+
checkpoints: PublishedCheckpoint[],
|
|
364
|
+
pendingChainValidationStatus?: ValidateCheckpointResult,
|
|
365
|
+
): Promise<boolean> {
|
|
366
|
+
return this.updater.addCheckpointsWithContractData(checkpoints, pendingChainValidationStatus);
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
public async getL2Tips(): Promise<L2Tips> {
|
|
370
|
+
const [latestBlockNumber, provenBlockNumber, checkpointedBlockNumber] = await Promise.all([
|
|
371
|
+
this.getBlockNumber(),
|
|
372
|
+
this.getProvenBlockNumber(),
|
|
373
|
+
this.getCheckpointedBlockNumber(),
|
|
374
|
+
] as const);
|
|
375
|
+
|
|
376
|
+
// TODO(#13569): Compute proper finalized block number based on L1 finalized block.
|
|
377
|
+
// We just force it 2 epochs worth of proven data for now.
|
|
378
|
+
// NOTE: update end-to-end/src/e2e_epochs/epochs_empty_blocks.test.ts as that uses finalized blocks in computations
|
|
379
|
+
const finalizedBlockNumber = BlockNumber(Math.max(provenBlockNumber - this.l1Constants.epochDuration * 2, 0));
|
|
380
|
+
|
|
381
|
+
const beforeInitialblockNumber = BlockNumber(INITIAL_L2_BLOCK_NUM - 1);
|
|
382
|
+
|
|
383
|
+
// Get the latest block header and checkpointed blocks for proven, finalised and checkpointed blocks
|
|
384
|
+
const [latestBlockHeader, provenCheckpointedBlock, finalizedCheckpointedBlock, checkpointedBlock] =
|
|
385
|
+
await Promise.all([
|
|
386
|
+
latestBlockNumber > beforeInitialblockNumber ? this.getBlockHeader(latestBlockNumber) : undefined,
|
|
387
|
+
provenBlockNumber > beforeInitialblockNumber ? this.getCheckpointedBlock(provenBlockNumber) : undefined,
|
|
388
|
+
finalizedBlockNumber > beforeInitialblockNumber ? this.getCheckpointedBlock(finalizedBlockNumber) : undefined,
|
|
389
|
+
checkpointedBlockNumber > beforeInitialblockNumber
|
|
390
|
+
? this.getCheckpointedBlock(checkpointedBlockNumber)
|
|
391
|
+
: undefined,
|
|
392
|
+
] as const);
|
|
393
|
+
|
|
394
|
+
if (latestBlockNumber > beforeInitialblockNumber && !latestBlockHeader) {
|
|
395
|
+
throw new Error(`Failed to retrieve latest block header for block ${latestBlockNumber}`);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// Checkpointed blocks must exist for proven, finalized and checkpointed tips if they are beyond the initial block number.
|
|
399
|
+
if (checkpointedBlockNumber > beforeInitialblockNumber && !checkpointedBlock?.block.header) {
|
|
400
|
+
throw new Error(
|
|
401
|
+
`Failed to retrieve checkpointed block header for block ${checkpointedBlockNumber} (latest block is ${latestBlockNumber})`,
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
if (provenBlockNumber > beforeInitialblockNumber && !provenCheckpointedBlock?.block.header) {
|
|
406
|
+
throw new Error(
|
|
407
|
+
`Failed to retrieve proven checkpointed for block ${provenBlockNumber} (latest block is ${latestBlockNumber})`,
|
|
408
|
+
);
|
|
409
|
+
}
|
|
410
|
+
|
|
411
|
+
if (finalizedBlockNumber > beforeInitialblockNumber && !finalizedCheckpointedBlock?.block.header) {
|
|
412
|
+
throw new Error(
|
|
413
|
+
`Failed to retrieve finalized block header for block ${finalizedBlockNumber} (latest block is ${latestBlockNumber})`,
|
|
414
|
+
);
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
const latestBlockHeaderHash = (await latestBlockHeader?.hash()) ?? GENESIS_BLOCK_HEADER_HASH;
|
|
418
|
+
const provenBlockHeaderHash = (await provenCheckpointedBlock?.block.header?.hash()) ?? GENESIS_BLOCK_HEADER_HASH;
|
|
419
|
+
const finalizedBlockHeaderHash =
|
|
420
|
+
(await finalizedCheckpointedBlock?.block.header?.hash()) ?? GENESIS_BLOCK_HEADER_HASH;
|
|
421
|
+
const checkpointedBlockHeaderHash = (await checkpointedBlock?.block.header?.hash()) ?? GENESIS_BLOCK_HEADER_HASH;
|
|
422
|
+
|
|
423
|
+
// Now attempt to retrieve checkpoints for proven, finalised and checkpointed blocks
|
|
424
|
+
const [[provenBlockCheckpoint], [finalizedBlockCheckpoint], [checkpointedBlockCheckpoint]] = await Promise.all([
|
|
425
|
+
provenCheckpointedBlock !== undefined
|
|
426
|
+
? await this.getPublishedCheckpoints(provenCheckpointedBlock?.checkpointNumber, 1)
|
|
427
|
+
: [undefined],
|
|
428
|
+
finalizedCheckpointedBlock !== undefined
|
|
429
|
+
? await this.getPublishedCheckpoints(finalizedCheckpointedBlock?.checkpointNumber, 1)
|
|
430
|
+
: [undefined],
|
|
431
|
+
checkpointedBlock !== undefined
|
|
432
|
+
? await this.getPublishedCheckpoints(checkpointedBlock?.checkpointNumber, 1)
|
|
433
|
+
: [undefined],
|
|
434
|
+
]);
|
|
435
|
+
|
|
436
|
+
const initialcheckpointId: CheckpointId = {
|
|
437
|
+
number: CheckpointNumber.ZERO,
|
|
438
|
+
hash: GENESIS_CHECKPOINT_HEADER_HASH.toString(),
|
|
439
|
+
};
|
|
440
|
+
|
|
441
|
+
const makeCheckpointId = (checkpoint: PublishedCheckpoint | undefined) => {
|
|
442
|
+
if (checkpoint === undefined) {
|
|
443
|
+
return initialcheckpointId;
|
|
444
|
+
}
|
|
445
|
+
return {
|
|
446
|
+
number: checkpoint.checkpoint.number,
|
|
447
|
+
hash: checkpoint.checkpoint.hash().toString(),
|
|
448
|
+
};
|
|
449
|
+
};
|
|
450
|
+
|
|
451
|
+
const l2Tips: L2Tips = {
|
|
452
|
+
proposed: {
|
|
453
|
+
number: latestBlockNumber,
|
|
454
|
+
hash: latestBlockHeaderHash.toString(),
|
|
455
|
+
},
|
|
456
|
+
proven: {
|
|
457
|
+
block: {
|
|
458
|
+
number: provenBlockNumber,
|
|
459
|
+
hash: provenBlockHeaderHash.toString(),
|
|
460
|
+
},
|
|
461
|
+
checkpoint: makeCheckpointId(provenBlockCheckpoint),
|
|
462
|
+
},
|
|
463
|
+
finalized: {
|
|
464
|
+
block: {
|
|
465
|
+
number: finalizedBlockNumber,
|
|
466
|
+
hash: finalizedBlockHeaderHash.toString(),
|
|
467
|
+
},
|
|
468
|
+
checkpoint: makeCheckpointId(finalizedBlockCheckpoint),
|
|
469
|
+
},
|
|
470
|
+
checkpointed: {
|
|
471
|
+
block: {
|
|
472
|
+
number: checkpointedBlockNumber,
|
|
473
|
+
hash: checkpointedBlockHeaderHash.toString(),
|
|
474
|
+
},
|
|
475
|
+
checkpoint: makeCheckpointId(checkpointedBlockCheckpoint),
|
|
476
|
+
},
|
|
477
|
+
};
|
|
478
|
+
|
|
479
|
+
return l2Tips;
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
public async rollbackTo(targetL2BlockNumber: BlockNumber): Promise<void> {
|
|
483
|
+
// TODO(pw/mbps): This still assumes 1 block per checkpoint
|
|
484
|
+
const currentBlocks = await this.getL2Tips();
|
|
485
|
+
const currentL2Block = currentBlocks.proposed.number;
|
|
486
|
+
const currentProvenBlock = currentBlocks.proven.block.number;
|
|
487
|
+
|
|
488
|
+
if (targetL2BlockNumber >= currentL2Block) {
|
|
489
|
+
throw new Error(`Target L2 block ${targetL2BlockNumber} must be less than current L2 block ${currentL2Block}`);
|
|
490
|
+
}
|
|
491
|
+
const blocksToUnwind = currentL2Block - targetL2BlockNumber;
|
|
492
|
+
const targetL2Block = await this.store.getCheckpointedBlock(targetL2BlockNumber);
|
|
493
|
+
if (!targetL2Block) {
|
|
494
|
+
throw new Error(`Target L2 block ${targetL2BlockNumber} not found`);
|
|
495
|
+
}
|
|
496
|
+
const targetL1BlockNumber = targetL2Block.l1.blockNumber;
|
|
497
|
+
const targetCheckpointNumber = CheckpointNumber.fromBlockNumber(targetL2BlockNumber);
|
|
498
|
+
const targetL1Block = await this.publicClient.getBlock({
|
|
499
|
+
blockNumber: targetL1BlockNumber,
|
|
500
|
+
includeTransactions: false,
|
|
501
|
+
});
|
|
502
|
+
if (!targetL1Block) {
|
|
503
|
+
throw new Error(`Missing L1 block ${targetL1BlockNumber}`);
|
|
504
|
+
}
|
|
505
|
+
const targetL1BlockHash = Buffer32.fromString(targetL1Block.hash);
|
|
506
|
+
this.log.info(`Unwinding ${blocksToUnwind} checkpoints from L2 block ${currentL2Block}`);
|
|
507
|
+
await this.updater.unwindCheckpointsWithContractData(CheckpointNumber(currentL2Block), blocksToUnwind);
|
|
508
|
+
this.log.info(`Unwinding L1 to L2 messages to checkpoint ${targetCheckpointNumber}`);
|
|
509
|
+
await this.store.rollbackL1ToL2MessagesToCheckpoint(targetCheckpointNumber);
|
|
510
|
+
this.log.info(`Setting L1 syncpoints to ${targetL1BlockNumber}`);
|
|
511
|
+
await this.store.setCheckpointSynchedL1BlockNumber(targetL1BlockNumber);
|
|
512
|
+
await this.store.setMessageSynchedL1Block({ l1BlockNumber: targetL1BlockNumber, l1BlockHash: targetL1BlockHash });
|
|
513
|
+
if (targetL2BlockNumber < currentProvenBlock) {
|
|
514
|
+
this.log.info(`Clearing proven L2 block number`);
|
|
515
|
+
await this.store.setProvenCheckpointNumber(CheckpointNumber.ZERO);
|
|
516
|
+
}
|
|
517
|
+
// TODO(palla/reorg): Set the finalized block when we add support for it.
|
|
518
|
+
// if (targetL2BlockNumber < currentFinalizedBlock) {
|
|
519
|
+
// this.log.info(`Clearing finalized L2 block number`);
|
|
520
|
+
// await this.store.setFinalizedL2BlockNumber(0);
|
|
521
|
+
// }
|
|
522
|
+
}
|
|
523
|
+
}
|
|
@@ -82,3 +82,14 @@ export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
|
|
|
82
82
|
export function getArchiverConfigFromEnv(): ArchiverConfig {
|
|
83
83
|
return getConfigFromMappings<ArchiverConfig>(archiverConfigMappings);
|
|
84
84
|
}
|
|
85
|
+
|
|
86
|
+
/** Extracts the archiver-specific configuration from the full ArchiverConfig */
|
|
87
|
+
export function mapArchiverConfig(config: Partial<ArchiverConfig>) {
|
|
88
|
+
return {
|
|
89
|
+
pollingIntervalMs: config.archiverPollingIntervalMS,
|
|
90
|
+
batchSize: config.archiverBatchSize,
|
|
91
|
+
skipValidateCheckpointAttestations: config.skipValidateCheckpointAttestations,
|
|
92
|
+
maxAllowedEthClientDriftSeconds: config.maxAllowedEthClientDriftSeconds,
|
|
93
|
+
ethereumAllowNoDebugHosts: config.ethereumAllowNoDebugHosts,
|
|
94
|
+
};
|
|
95
|
+
}
|