-
Notifications
You must be signed in to change notification settings - Fork 333
/
Copy pathconfig.ts
182 lines (171 loc) · 5.71 KB
/
config.ts
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
import {
type L1ContractsConfig,
type L1ReaderConfig,
l1ContractsConfigMappings,
l1ReaderConfigMappings,
} from '@aztec/ethereum';
import {
type ConfigMappingsType,
booleanConfigHelper,
getConfigFromMappings,
numberConfigHelper,
pickConfigMappings,
} from '@aztec/foundation/config';
import { EthAddress } from '@aztec/foundation/eth-address';
import { Fr } from '@aztec/foundation/fields';
import { FunctionSelector } from '@aztec/stdlib/abi';
import { AztecAddress } from '@aztec/stdlib/aztec-address';
import { type AllowedElement, type ChainConfig, type SequencerConfig, chainConfigMappings } from '@aztec/stdlib/config';
import { type ValidatorClientConfig, validatorClientConfigMappings } from '@aztec/validator-client';
import {
type PublisherConfig,
type TxSenderConfig,
getPublisherConfigMappings,
getTxSenderConfigMappings,
} from './publisher/config.js';
export * from './publisher/config.js';
export type { SequencerConfig };
/**
* Configuration settings for the SequencerClient.
*/
export type SequencerClientConfig = PublisherConfig &
ValidatorClientConfig &
TxSenderConfig &
SequencerConfig &
L1ReaderConfig &
ChainConfig &
Pick<L1ContractsConfig, 'ethereumSlotDuration' | 'aztecSlotDuration' | 'aztecEpochDuration'>;
export const sequencerConfigMappings: ConfigMappingsType<SequencerConfig> = {
transactionPollingIntervalMS: {
env: 'SEQ_TX_POLLING_INTERVAL_MS',
description: 'The number of ms to wait between polling for pending txs.',
...numberConfigHelper(500),
},
maxTxsPerBlock: {
env: 'SEQ_MAX_TX_PER_BLOCK',
description: 'The maximum number of txs to include in a block.',
...numberConfigHelper(32),
},
minTxsPerBlock: {
env: 'SEQ_MIN_TX_PER_BLOCK',
description: 'The minimum number of txs to include in a block.',
...numberConfigHelper(1),
},
maxL2BlockGas: {
env: 'SEQ_MAX_L2_BLOCK_GAS',
description: 'The maximum L2 block gas.',
...numberConfigHelper(10e9),
},
maxDABlockGas: {
env: 'SEQ_MAX_DA_BLOCK_GAS',
description: 'The maximum DA block gas.',
...numberConfigHelper(10e9),
},
coinbase: {
env: 'COINBASE',
parseEnv: (val: string) => (val ? EthAddress.fromString(val) : undefined),
description: 'Recipient of block reward.',
},
feeRecipient: {
env: 'FEE_RECIPIENT',
parseEnv: (val: string) => AztecAddress.fromString(val),
description: 'Address to receive fees.',
},
acvmWorkingDirectory: {
env: 'ACVM_WORKING_DIRECTORY',
description: 'The working directory to use for simulation/proving',
},
acvmBinaryPath: {
env: 'ACVM_BINARY_PATH',
description: 'The path to the ACVM binary',
},
allowedInSetup: {
env: 'SEQ_ALLOWED_SETUP_FN',
parseEnv: (val: string) => parseSequencerAllowList(val),
description: 'The list of functions calls allowed to run in setup',
printDefault: () =>
'AuthRegistry, FeeJuice.increase_public_balance, Token.increase_public_balance, FPC.prepare_fee',
},
maxBlockSizeInBytes: {
env: 'SEQ_MAX_BLOCK_SIZE_IN_BYTES',
description: 'Max block size',
...numberConfigHelper(1024 * 1024),
},
enforceTimeTable: {
env: 'SEQ_ENFORCE_TIME_TABLE',
description: 'Whether to enforce the time table when building blocks',
...booleanConfigHelper(),
defaultValue: false,
},
governanceProposerPayload: {
env: 'GOVERNANCE_PROPOSER_PAYLOAD_ADDRESS',
description: 'The address of the payload for the governanceProposer',
parseEnv: (val: string) => EthAddress.fromString(val),
defaultValue: EthAddress.ZERO,
},
maxL1TxInclusionTimeIntoSlot: {
env: 'SEQ_MAX_L1_TX_INCLUSION_TIME_INTO_SLOT',
description: 'How many seconds into an L1 slot we can still send a tx and get it mined.',
parseEnv: (val: string) => (val ? parseInt(val, 10) : undefined),
},
};
export const sequencerClientConfigMappings: ConfigMappingsType<SequencerClientConfig> = {
...validatorClientConfigMappings,
...sequencerConfigMappings,
...l1ReaderConfigMappings,
...getTxSenderConfigMappings('SEQ'),
...getPublisherConfigMappings('SEQ'),
...chainConfigMappings,
...pickConfigMappings(l1ContractsConfigMappings, ['ethereumSlotDuration', 'aztecSlotDuration', 'aztecEpochDuration']),
};
/**
* Creates an instance of SequencerClientConfig out of environment variables using sensible defaults for integration testing if not set.
*/
export function getConfigEnvVars(): SequencerClientConfig {
return getConfigFromMappings<SequencerClientConfig>(sequencerClientConfigMappings);
}
/**
* Parses a string to a list of allowed elements.
* Each encoded is expected to be of one of the following formats
* `I:${address}`
* `I:${address}:${selector}`
* `C:${classId}`
* `C:${classId}:${selector}`
*
* @param value The string to parse
* @returns A list of allowed elements
*/
export function parseSequencerAllowList(value: string): AllowedElement[] {
const entries: AllowedElement[] = [];
if (!value) {
return entries;
}
for (const val of value.split(',')) {
const [typeString, identifierString, selectorString] = val.split(':');
const selector = selectorString !== undefined ? FunctionSelector.fromString(selectorString) : undefined;
if (typeString === 'I') {
if (selector) {
entries.push({
address: AztecAddress.fromString(identifierString),
selector,
});
} else {
entries.push({
address: AztecAddress.fromString(identifierString),
});
}
} else if (typeString === 'C') {
if (selector) {
entries.push({
classId: Fr.fromHexString(identifierString),
selector,
});
} else {
entries.push({
classId: Fr.fromHexString(identifierString),
});
}
}
}
return entries;
}