-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathapp_configuration.hpp
335 lines (261 loc) · 8.75 KB
/
app_configuration.hpp
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
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
/**
* Copyright Quadrivium LLC
* All Rights Reserved
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include <memory>
#include <optional>
#include <string>
#include <boost/asio/ip/tcp.hpp>
#include <libp2p/multi/multiaddress.hpp>
#include "application/sync_method.hpp"
#include "crypto/ed25519_types.hpp"
#include "filesystem/common.hpp"
#include "log/logger.hpp"
#include "network/peering_config.hpp"
#include "network/types/roles.hpp"
#include "primitives/block_id.hpp"
#include "telemetry/endpoint.hpp"
namespace kagome::application {
enum class Subcommand : uint8_t {
ChainInfo,
};
struct BlockBenchmarkConfig {
primitives::BlockNumber from;
primitives::BlockNumber to;
uint16_t times;
};
struct PrecompileWasmConfig {
std::vector<filesystem::path> parachains;
};
using BenchmarkConfigSection = std::variant<BlockBenchmarkConfig>;
/**
* Parse and store application config.
*/
class AppConfiguration {
public:
static constexpr uint32_t kAbsolutMinBlocksInResponse = 1;
static constexpr uint32_t kAbsolutMaxBlocksInResponse = 128;
static constexpr uint32_t kNodeNameMaxLength = 64;
static_assert(kAbsolutMinBlocksInResponse <= kAbsolutMaxBlocksInResponse,
"Check max and min page bounding values!");
virtual ~AppConfiguration() = default;
/**
* @return roles of current run
*/
virtual network::Roles roles() const = 0;
/**
* @return file path with genesis configuration.
*/
virtual kagome::filesystem::path chainSpecPath() const = 0;
/**
* @return path to precompiled WAVM runtime cache directory
*/
virtual kagome::filesystem::path runtimeCacheDirPath() const = 0;
/**
* @return path to cached precompiled WAVM runtime
*/
virtual kagome::filesystem::path runtimeCachePath(
std::string runtime_hash) const = 0;
/**
* @return path to the node's directory for the chain \arg chain_id
* (contains key storage and database)
*/
virtual kagome::filesystem::path chainPath(std::string chain_id) const = 0;
/**
* @return path to the node's database for the chain \arg chain_id
*/
virtual kagome::filesystem::path databasePath(
std::string chain_id) const = 0;
/**
* @return path to the node's keystore for the chain \arg chain_id
*/
virtual kagome::filesystem::path keystorePath(
std::string chain_id) const = 0;
/**
* @return the secret key to use for libp2p networking
*/
virtual const std::optional<crypto::Ed25519Seed> &nodeKey() const = 0;
/**
* @return the path to key used for libp2p networking
*/
virtual const std::optional<std::string> &nodeKeyFile() const = 0;
/**
* @return true if generated libp2p networking key should be saved
*/
virtual bool shouldSaveNodeKey() const = 0;
/**
* @return port for peer to peer interactions.
*/
virtual uint16_t p2pPort() const = 0;
/**
* @return number of outgoing connections we're trying to maintain
*/
virtual uint32_t outPeers() const = 0;
/**
* @return maximum number of inbound full nodes peers
*/
virtual uint32_t inPeers() const = 0;
/**
* @return maximum number of inbound light nodes peers
*/
virtual uint32_t inPeersLight() const = 0;
/**
* @return uint32_t maximum number or lucky peers (peers being gossiped to)
*/
virtual uint32_t luckyPeers() const = 0;
/**
* @return maximum number of peer connections
*/
virtual uint32_t maxPeers() const = 0;
/**
* @return multiaddresses of bootstrat nodes
*/
virtual const std::vector<libp2p::multi::Multiaddress> &bootNodes()
const = 0;
/**
* @return multiaddresses the node listens for open connections on
*/
virtual const std::vector<libp2p::multi::Multiaddress> &listenAddresses()
const = 0;
/**
* @return multiaddresses the node could be accessed from the network
*/
virtual const std::vector<libp2p::multi::Multiaddress> &publicAddresses()
const = 0;
/**
* @return endpoint for RPC over HTTP and Websocket.
*/
virtual const boost::asio::ip::tcp::endpoint &rpcEndpoint() const = 0;
/**
* @return endpoint for OpenMetrics over HTTP protocol.
*/
virtual const boost::asio::ip::tcp::endpoint &openmetricsHttpEndpoint()
const = 0;
/**
* @return maximum number of WS RPC connections
*/
virtual uint32_t maxWsConnections() const = 0;
/**
* @return Kademlia random walk interval
*/
virtual std::chrono::seconds getRandomWalkInterval() const = 0;
/**
* @return logging system tuning config
*/
virtual const std::vector<std::string> &log() const = 0;
/**
* @return max blocks count per response while syncing
*/
virtual uint32_t maxBlocksInResponse() const = 0;
/**
* Config for PeerManager
*/
virtual const network::PeeringConfig &peeringConfig() const = 0;
/**
* @return true if node allowed to run in development mode
*/
virtual bool isRunInDevMode() const = 0;
/**
* @return string representation of human-readable node name.
* The name of node is going to be used in telemetry, etc.
*/
virtual const std::string &nodeName() const = 0;
/**
* @return string representation of node version .
* The version of node is going to be used in telemetry, etc.
*/
virtual const std::string &nodeVersion() const = 0;
/**
* @return true when telemetry broadcasting is enabled, otherwise - false
*/
virtual bool isTelemetryEnabled() const = 0;
/**
* List of telemetry endpoints specified via CLI argument or config file
* @return a vector of parsed telemetry endpoints
*/
virtual const std::vector<telemetry::TelemetryEndpoint>
&telemetryEndpoints() const = 0;
/**
* @return enum constant of the chosen sync method
*/
virtual SyncMethod syncMethod() const = 0;
enum class RuntimeExecutionMethod : uint8_t {
Compile,
Interpret,
};
/**
* @return enum constant of the chosen runtime backend
*/
virtual RuntimeExecutionMethod runtimeExecMethod() const = 0;
enum class RuntimeInterpreter : uint8_t {
WasmEdge,
Binaryen,
};
virtual RuntimeInterpreter runtimeInterpreter() const = 0;
/**
* A flag marking if we must force-purge WAVM runtime cache
*/
virtual bool purgeWavmCache() const = 0;
virtual uint32_t parachainRuntimeInstanceCacheSize() const = 0;
virtual uint32_t parachainPrecompilationThreadNum() const = 0;
virtual bool shouldPrecompileParachainModules() const = 0;
/**
* Whether to use a separate process for Pvf check calls.
* Allows to terminate long lasting checks by a deadline timeout.
*
* Defaulted to true.
*/
virtual bool usePvfSubprocess() const = 0;
/**
* Max PVF execution threads or processes.
*/
virtual size_t pvfMaxWorkers() const = 0;
/**
* Whether secure validator mode should be disabled.
*/
virtual bool disableSecureMode() const = 0;
/**
* Whether to enable automatic database migration.
*/
virtual bool enableDbMigration() const = 0;
enum class OffchainWorkerMode : uint8_t {
WhenValidating,
Always,
Never,
};
/**
* @return enum constant of the mode of run offchain workers
*/
virtual OffchainWorkerMode offchainWorkerMode() const = 0;
virtual bool isOffchainIndexingEnabled() const = 0;
virtual std::optional<Subcommand> subcommand() const = 0;
virtual std::optional<primitives::BlockId> recoverState() const = 0;
enum class StorageBackend : uint8_t {
RocksDB,
};
/**
* @return enum constant of the chosen storage backend
*/
virtual StorageBackend storageBackend() const = 0;
virtual std::optional<size_t> statePruningDepth() const = 0;
virtual bool shouldPruneDiscardedStates() const = 0;
virtual bool enableThoroughPruning() const = 0;
virtual std::optional<uint32_t> blocksPruning() const = 0;
/**
* @return database state cache size in MiB
*/
virtual uint32_t dbCacheSize() const = 0;
/**
* Optional phrase to use dev account (e.g. Alice and Bob)
*/
virtual std::optional<std::string_view> devMnemonicPhrase() const = 0;
virtual std::string nodeWssPem() const = 0;
enum class AllowUnsafeRpc : uint8_t { kAuto, kUnsafe, kSafe };
virtual AllowUnsafeRpc allowUnsafeRpc() const = 0;
virtual std::optional<BenchmarkConfigSection> getBenchmarkConfig()
const = 0;
virtual std::optional<PrecompileWasmConfig> precompileWasm() const = 0;
};
} // namespace kagome::application