forked from AztecProtocol/aztec-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.ts
More file actions
100 lines (89 loc) · 3.75 KB
/
config.ts
File metadata and controls
100 lines (89 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
import { type BlobSinkConfig, blobSinkConfigMapping } from '@aztec/blob-sink/client';
import {
type L1ContractAddresses,
type L1ContractsConfig,
type L1ReaderConfig,
l1ContractsConfigMappings,
l1ReaderConfigMappings,
} from '@aztec/ethereum';
import { type ConfigMappingsType, getConfigFromMappings, numberConfigHelper } from '@aztec/foundation/config';
import { type ChainConfig, chainConfigMappings } from '@aztec/stdlib/config';
/**
* There are 2 polling intervals used in this configuration. The first is the archiver polling interval, archiverPollingIntervalMS.
* This is the interval between successive calls to eth_blockNumber via viem.
* Results of calls to eth_blockNumber are cached by viem with this cache being updated periodically at the interval specified by viemPollingIntervalMS.
* As a result the maximum observed polling time for new blocks will be viemPollingIntervalMS + archiverPollingIntervalMS.
*/
/**
* The archiver configuration.
*/
export type ArchiverConfig = {
/** URL for an archiver service. If set, will return an archiver client as opposed to starting a new one. */
archiverUrl?: string;
/** List of URLS for L1 consensus clients */
l1ConsensusHostUrls?: string[];
/** The polling interval in ms for retrieving new L2 blocks and encrypted logs. */
archiverPollingIntervalMS?: number;
/** The number of L2 blocks the archiver will attempt to download at a time. */
archiverBatchSize?: number;
/** The polling interval viem uses in ms */
viemPollingIntervalMS?: number;
/** The deployed L1 contract addresses */
l1Contracts: L1ContractAddresses;
/** The max number of logs that can be obtained in 1 "getPublicLogs" call. */
maxLogs?: number;
/** The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB. */
archiverStoreMapSizeKb?: number;
} & L1ReaderConfig &
L1ContractsConfig &
BlobSinkConfig &
ChainConfig;
export const archiverConfigMappings: ConfigMappingsType<ArchiverConfig> = {
...blobSinkConfigMapping,
archiverUrl: {
env: 'ARCHIVER_URL',
description:
'URL for an archiver service. If set, will return an archiver client as opposed to starting a new one.',
},
l1ConsensusHostUrls: {
env: 'L1_CONSENSUS_HOST_URLS',
description: 'List of URLS for L1 consensus clients.',
parseEnv: (val: string) => val.split(',').map(url => url.trim().replace(/\/$/, '')),
},
archiverPollingIntervalMS: {
env: 'ARCHIVER_POLLING_INTERVAL_MS',
description: 'The polling interval in ms for retrieving new L2 blocks and encrypted logs.',
...numberConfigHelper(500),
},
archiverBatchSize: {
env: 'ARCHIVER_BATCH_SIZE',
description: 'The number of L2 blocks the archiver will attempt to download at a time.',
...numberConfigHelper(100),
},
maxLogs: {
env: 'ARCHIVER_MAX_LOGS',
description: 'The max number of logs that can be obtained in 1 "getPublicLogs" call.',
...numberConfigHelper(1_000),
},
archiverStoreMapSizeKb: {
env: 'ARCHIVER_STORE_MAP_SIZE_KB',
parseEnv: (val: string | undefined) => (val ? +val : undefined),
description: 'The maximum possible size of the archiver DB in KB. Overwrites the general dataStoreMapSizeKB.',
},
...chainConfigMappings,
...l1ReaderConfigMappings,
viemPollingIntervalMS: {
env: 'ARCHIVER_VIEM_POLLING_INTERVAL_MS',
description: 'The polling interval viem uses in ms',
...numberConfigHelper(1000),
},
...l1ContractsConfigMappings,
};
/**
* Returns the archiver configuration from the environment variables.
* Note: If an environment variable is not set, the default value is used.
* @returns The archiver configuration.
*/
export function getArchiverConfigFromEnv(): ArchiverConfig {
return getConfigFromMappings<ArchiverConfig>(archiverConfigMappings);
}