Kagome
Polkadot Runtime Engine in C++17
app_configuration.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_APP_CONFIGURATION_HPP
7 #define KAGOME_APP_CONFIGURATION_HPP
8 
9 #include <memory>
10 #include <optional>
11 #include <string>
12 
13 #include <boost/asio/ip/tcp.hpp>
14 #include <boost/filesystem.hpp>
15 #include <libp2p/multi/multiaddress.hpp>
16 
17 #include "crypto/ed25519_types.hpp"
18 #include "log/logger.hpp"
20 #include "network/types/roles.hpp"
21 #include "primitives/block_id.hpp"
22 #include "telemetry/endpoint.hpp"
23 
24 namespace kagome::application {
25 
30  public:
31  static constexpr uint32_t kAbsolutMinBlocksInResponse = 1;
32  static constexpr uint32_t kAbsolutMaxBlocksInResponse = 128;
33  static constexpr uint32_t kNodeNameMaxLength = 64;
34 
35  static_assert(kAbsolutMinBlocksInResponse <= kAbsolutMaxBlocksInResponse,
36  "Check max and min page bounding values!");
37 
38  virtual ~AppConfiguration() = default;
39 
43  virtual network::Roles roles() const = 0;
44 
48  virtual boost::filesystem::path chainSpecPath() const = 0;
49 
53  virtual boost::filesystem::path runtimeCacheDirPath() const = 0;
54 
58  virtual boost::filesystem::path runtimeCachePath(
59  std::string runtime_hash) const = 0;
60 
65  virtual boost::filesystem::path chainPath(std::string chain_id) const = 0;
66 
70  virtual boost::filesystem::path databasePath(
71  std::string chain_id) const = 0;
72 
76  virtual boost::filesystem::path keystorePath(
77  std::string chain_id) const = 0;
78 
82  virtual const std::optional<crypto::Ed25519PrivateKey> &nodeKey() const = 0;
83 
87  virtual const std::optional<std::string> &nodeKeyFile() const = 0;
88 
92  virtual bool shouldSaveNodeKey() const = 0;
93 
97  virtual uint16_t p2pPort() const = 0;
98 
102  virtual uint32_t outPeers() const = 0;
103 
107  virtual uint32_t inPeers() const = 0;
108 
112  virtual uint32_t inPeersLight() const = 0;
113 
117  virtual int32_t luckyPeers() const = 0;
118 
122  virtual const std::vector<libp2p::multi::Multiaddress> &bootNodes()
123  const = 0;
124 
128  virtual const std::vector<libp2p::multi::Multiaddress> &listenAddresses()
129  const = 0;
130 
134  virtual const std::vector<libp2p::multi::Multiaddress> &publicAddresses()
135  const = 0;
136 
140  virtual const boost::asio::ip::tcp::endpoint &rpcHttpEndpoint() const = 0;
141 
145  virtual const boost::asio::ip::tcp::endpoint &rpcWsEndpoint() const = 0;
146 
150  virtual const boost::asio::ip::tcp::endpoint &openmetricsHttpEndpoint()
151  const = 0;
152 
156  virtual uint32_t maxWsConnections() const = 0;
157 
161  virtual std::chrono::seconds getRandomWalkInterval() const = 0;
162 
166  virtual const std::vector<std::string> &log() const = 0;
167 
171  virtual uint32_t maxBlocksInResponse() const = 0;
172 
176  virtual const network::PeeringConfig &peeringConfig() const = 0;
177 
181  virtual bool isRunInDevMode() const = 0;
182 
187  virtual const std::string &nodeName() const = 0;
188 
193  virtual const std::string &nodeVersion() const = 0;
194 
198  virtual bool isTelemetryEnabled() const = 0;
199 
204  virtual const std::vector<telemetry::TelemetryEndpoint>
205  &telemetryEndpoints() const = 0;
206 
207  enum class SyncMethod { Full, Fast };
211  virtual SyncMethod syncMethod() const = 0;
212 
213  enum class RuntimeExecutionMethod { Compile, Interpret };
217  virtual RuntimeExecutionMethod runtimeExecMethod() const = 0;
218 
224  virtual bool useWavmCache() const = 0;
225 
229  virtual bool purgeWavmCache() const = 0;
230 
231  enum class OffchainWorkerMode { WhenValidating, Always, Never };
235  virtual OffchainWorkerMode offchainWorkerMode() const = 0;
236 
237  virtual bool isOffchainIndexingEnabled() const = 0;
238 
239  virtual bool subcommandChainInfo() const = 0;
240 
241  virtual std::optional<primitives::BlockId> recoverState() const = 0;
242 
243  enum class StorageBackend { RocksDB };
244 
248  virtual StorageBackend storageBackend() const = 0;
249 
253  virtual std::optional<std::string_view> devMnemonicPhrase() const = 0;
254  };
255 
256 } // namespace kagome::application
257 
258 #endif // KAGOME_APP_CONFIGURATION_HPP
virtual OffchainWorkerMode offchainWorkerMode() const =0
virtual bool isTelemetryEnabled() const =0
virtual boost::filesystem::path chainPath(std::string chain_id) const =0
virtual uint32_t outPeers() const =0
virtual const boost::asio::ip::tcp::endpoint & openmetricsHttpEndpoint() const =0
virtual boost::filesystem::path databasePath(std::string chain_id) const =0
virtual std::optional< primitives::BlockId > recoverState() const =0
virtual uint32_t inPeersLight() const =0
virtual const std::vector< libp2p::multi::Multiaddress > & listenAddresses() const =0
virtual uint32_t inPeers() const =0
virtual boost::filesystem::path runtimeCachePath(std::string runtime_hash) const =0
virtual network::Roles roles() const =0
static constexpr uint32_t kAbsolutMinBlocksInResponse
virtual const std::vector< telemetry::TelemetryEndpoint > & telemetryEndpoints() const =0
virtual bool purgeWavmCache() const =0
virtual bool useWavmCache() const =0
virtual uint16_t p2pPort() const =0
virtual const std::optional< crypto::Ed25519PrivateKey > & nodeKey() const =0
virtual boost::filesystem::path keystorePath(std::string chain_id) const =0
virtual bool isRunInDevMode() const =0
virtual boost::filesystem::path chainSpecPath() const =0
virtual bool subcommandChainInfo() const =0
virtual const network::PeeringConfig & peeringConfig() const =0
virtual int32_t luckyPeers() const =0
static constexpr uint32_t kAbsolutMaxBlocksInResponse
virtual const std::vector< std::string > & log() const =0
virtual const std::string & nodeVersion() const =0
virtual std::chrono::seconds getRandomWalkInterval() const =0
virtual bool isOffchainIndexingEnabled() const =0
static constexpr uint32_t kNodeNameMaxLength
virtual uint32_t maxBlocksInResponse() const =0
virtual bool shouldSaveNodeKey() const =0
virtual SyncMethod syncMethod() const =0
virtual uint32_t maxWsConnections() const =0
virtual const boost::asio::ip::tcp::endpoint & rpcHttpEndpoint() const =0
virtual StorageBackend storageBackend() const =0
virtual const boost::asio::ip::tcp::endpoint & rpcWsEndpoint() const =0
virtual const std::string & nodeName() const =0
virtual RuntimeExecutionMethod runtimeExecMethod() const =0
virtual boost::filesystem::path runtimeCacheDirPath() const =0
virtual const std::vector< libp2p::multi::Multiaddress > & bootNodes() const =0
virtual std::optional< std::string_view > devMnemonicPhrase() const =0
virtual const std::vector< libp2p::multi::Multiaddress > & publicAddresses() const =0
virtual const std::optional< std::string > & nodeKeyFile() const =0