rippled
Config.h
1 //------------------------------------------------------------------------------
2 /*
3  This file is part of rippled: https://github.com/ripple/rippled
4  Copyright (c) 2012, 2013 Ripple Labs Inc.
5 
6  Permission to use, copy, modify, and/or distribute this software for any
7  purpose with or without fee is hereby granted, provided that the above
8  copyright notice and this permission notice appear in all copies.
9 
10  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13  ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 */
18 //==============================================================================
19 
20 #ifndef RIPPLE_CORE_CONFIG_H_INCLUDED
21 #define RIPPLE_CORE_CONFIG_H_INCLUDED
22 
23 #include <ripple/basics/BasicConfig.h>
24 #include <ripple/basics/FeeUnits.h>
25 #include <ripple/basics/base_uint.h>
26 #include <ripple/beast/net/IPEndpoint.h>
27 #include <ripple/beast/utility/Journal.h>
28 #include <ripple/protocol/SystemParameters.h> // VFALCO Breaks levelization
29 #include <boost/beast/core/string.hpp>
30 #include <boost/filesystem.hpp> // VFALCO FIX: This include should not be here
31 #include <boost/lexical_cast.hpp>
32 #include <algorithm>
33 #include <chrono>
34 #include <cstdint>
35 #include <map>
36 #include <optional>
37 #include <string>
38 #include <type_traits>
39 #include <unordered_set>
40 #include <vector>
41 
42 namespace ripple {
43 
44 class Rules;
45 
46 //------------------------------------------------------------------------------
47 
48 enum class SizedItem : std::size_t {
49  sweepInterval = 0,
52  ledgerSize,
53  ledgerAge,
56  txnDBCache,
57  lgrDBCache,
59  burstSize,
60  ramSizeGB,
62 };
63 
64 // This entire derived class is deprecated.
65 // For new config information use the style implied
66 // in the base class. For existing config information
67 // try to refactor code to use the new style.
68 //
69 class Config : public BasicConfig
70 {
71 public:
72  // Settings related to the configuration file location and directories
73  static char const* const configFileName;
74  static char const* const databaseDirName;
75  static char const* const validatorsFileName;
76 
78  boost::filesystem::path
79  getDebugLogFile() const;
80 
81 private:
82  boost::filesystem::path CONFIG_FILE;
83 
84 public:
85  boost::filesystem::path CONFIG_DIR;
86 
87 private:
88  boost::filesystem::path DEBUG_LOGFILE;
89 
90  void
91  load();
93 
94  bool QUIET = false; // Minimize logging verbosity.
95  bool SILENT = false; // No output to console after startup.
105  bool RUN_STANDALONE = false;
106 
107  bool RUN_REPORTING = false;
108 
109  bool REPORTING_READ_ONLY = false;
110 
111  bool USE_TX_TABLES = true;
112 
119  bool signingEnabled_ = false;
120 
121  // The amount of RAM, in bytes, that we detected on this system.
123 
124 public:
125  bool doImport = false;
126  bool nodeToShard = false;
127  bool ELB_SUPPORT = false;
128 
129  std::vector<std::string> IPS; // Peer IPs from rippled.cfg.
130  std::vector<std::string> IPS_FIXED; // Fixed Peer IPs from rippled.cfg.
131  std::vector<std::string> SNTP_SERVERS; // SNTP servers from rippled.cfg.
132 
135 
136  bool START_VALID = false;
137 
139 
140  // Network parameters
141 
142  // The number of fee units a reference transaction costs
143  static constexpr FeeUnit32 TRANSACTION_FEE_BASE{10};
144 
145  // Note: The following parameters do not relate to the UNL or trust at all
146  // Minimum number of nodes to consider the network present
148 
149  // Peer networking parameters
150  // 1 = relay, 0 = do not relay (but process), -1 = drop completely (do NOT
151  // process)
154 
155  // True to ask peers not to relay current IP.
156  bool PEER_PRIVATE = false;
157  // peers_max is a legacy configuration, which is going to be replaced
158  // with individual inbound peers peers_in_max and outbound peers
159  // peers_out_max configuration. for now we support both the legacy and
160  // the new configuration. if peers_max is configured then peers_in_max and
161  // peers_out_max are ignored.
165 
166  // Path searching: these were reasonable default values at some point but
167  // further research is needed to decide if they still are
168  // and whether all of them are needed.
169  //
170  // The performance and resource consumption of a server can
171  // be dramatically impacted by changing these configuration
172  // options; higher values result in exponentially higher
173  // resource usage.
174  //
175  // Servers operating as validators disable path finding by
176  // default by setting the `PATH_SEARCH_MAX` option to 0
177  // unless it is explicitly set in the configuration file.
179  int PATH_SEARCH = 2;
182 
183  // Validation
185  VALIDATION_QUORUM; // validations to consider ledger authoritative
186 
190 
191  // Node storage configuration
194 
195  // Tunable that adjusts various parameters, typically associated
196  // with hardware parameters (RAM size and CPU cores). The default
197  // is 'tiny'.
199 
200  bool SSL_VERIFY = true;
203 
204  // Compression
205  bool COMPRESSION = false;
206 
207  // Enable the experimental Ledger Replay functionality
208  bool LEDGER_REPLAY = false;
209 
210  // Work queue limits
211  int MAX_TRANSACTIONS = 250;
212  static constexpr int MAX_JOB_QUEUE_TX = 1000;
213  static constexpr int MIN_JOB_QUEUE_TX = 100;
214 
215  // Amendment majority time
217 
218  // Thread pool configuration (0 = choose for me)
219  int WORKERS = 0; // jobqueue thread count. default: upto 6
220  int IO_WORKERS = 0; // io svc thread count. default: 2
221  int PREFETCH_WORKERS = 0; // prefetch thread count. default: 4
222 
223  // Can only be set in code, specifically unit tests
224  bool FORCE_MULTI_THREAD = false;
225 
226  // Normally the sweep timer is automatically deduced based on the node
227  // size, but we allow admins to explicitly set it in the config.
229 
230  // Reduce-relay - these parameters are experimental.
231  // Enable reduce-relay features
232  // Validation/proposal reduce-relay feature
234  // Send squelch message to peers. Generally this config should
235  // have the same value as VP_REDUCE_RELAY_ENABLE. It can be
236  // used for testing the feature's function without
237  // affecting the message relaying. To use it for testing,
238  // set it to false and set VP_REDUCE_RELAY_ENABLE to true.
239  // Squelch messages will not be sent to the peers in this case.
240  // Set log level to debug so that the feature function can be
241  // analyzed.
243  // Transaction reduce-relay feature
245  // If tx reduce-relay feature is disabled
246  // and this flag is enabled then some
247  // tx-related metrics is collected. It
248  // is ignored if tx reduce-relay feature is
249  // enabled. It is used in debugging to compare
250  // metrics with the feature disabled/enabled.
252  // Minimum peers a server should have before
253  // selecting random peers
255  // Percentage of peers with the tx reduce-relay feature enabled
256  // to relay to out of total active peers
258 
259  // These override the command line client settings
261 
263 
265 
266  // How long can a peer remain in the "unknown" state
268 
269  // How long can a peer remain in the "diverged" state
271 
272  // Enable the beta API version
273  bool BETA_RPC_API = false;
274 
275  // First, attempt to load the latest ledger directly from disk.
276  bool FAST_LOAD = false;
277 
278 public:
279  Config();
280 
281  /* Be very careful to make sure these bool params
282  are in the right order. */
283  void
284  setup(
285  std::string const& strConf,
286  bool bQuiet,
287  bool bSilent,
288  bool bStandalone);
289 
290  void
291  setupControl(bool bQuiet, bool bSilent, bool bStandalone);
292 
298  void
299  loadFromString(std::string const& fileContents);
300 
301  bool
302  quiet() const
303  {
304  return QUIET;
305  }
306  bool
307  silent() const
308  {
309  return SILENT;
310  }
311  bool
312  standalone() const
313  {
314  return RUN_STANDALONE;
315  }
316  bool
317  reporting() const
318  {
319  return RUN_REPORTING;
320  }
321 
322  bool
323  useTxTables() const
324  {
325  return USE_TX_TABLES;
326  }
327 
328  bool
330  {
331  return REPORTING_READ_ONLY;
332  }
333 
334  void
336  {
338  }
339 
340  bool
341  canSign() const
342  {
343  return signingEnabled_;
344  }
345 
363  int
364  getValueFor(SizedItem item, std::optional<std::size_t> node = std::nullopt)
365  const;
366 };
367 
368 } // namespace ripple
369 
370 #endif
ripple::SizedItem::openFinalLimit
@ openFinalLimit
ripple::Config::NORMAL
@ NORMAL
Definition: Config.h:133
ripple::Config::SWEEP_INTERVAL
std::optional< int > SWEEP_INTERVAL
Definition: Config.h:228
std::string
STL class.
ripple::SizedItem
SizedItem
Definition: Config.h:48
ripple::Config::PATH_SEARCH
int PATH_SEARCH
Definition: Config.h:179
ripple::Config::VALIDATION_QUORUM
std::optional< std::size_t > VALIDATION_QUORUM
Definition: Config.h:185
unordered_set
ripple::Config::LEDGER_REPLAY
bool LEDGER_REPLAY
Definition: Config.h:208
ripple::Config::Config
Config()
Definition: Config.cpp:266
ripple::SizedItem::accountIdCacheSize
@ accountIdCacheSize
ripple::Config::validatorsFileName
static char const *const validatorsFileName
Definition: Config.h:75
vector
ripple::Config::SSL_VERIFY_DIR
std::string SSL_VERIFY_DIR
Definition: Config.h:202
ripple::Config::CONFIG_FILE
boost::filesystem::path CONFIG_FILE
Definition: Config.h:82
std::chrono::seconds
ripple::Config::NODE_SIZE
std::size_t NODE_SIZE
Definition: Config.h:198
ripple::Config::PEER_PRIVATE
bool PEER_PRIVATE
Definition: Config.h:156
ripple::Config::DEBUG_LOGFILE
boost::filesystem::path DEBUG_LOGFILE
Definition: Config.h:88
ripple::Config::silent
bool silent() const
Definition: Config.h:307
ripple::Config::setupControl
void setupControl(bool bQuiet, bool bSilent, bool bStandalone)
Definition: Config.cpp:272
ripple::SizedItem::treeCacheAge
@ treeCacheAge
ripple::Config::LOAD
@ LOAD
Definition: Config.h:133
ripple::Config::ramSize_
const std::uint64_t ramSize_
Definition: Config.h:122
ripple::Config::StartUpType
StartUpType
Definition: Config.h:133
ripple::SizedItem::hashNodeDBCache
@ hashNodeDBCache
ripple::Config::MIN_JOB_QUEUE_TX
static constexpr int MIN_JOB_QUEUE_TX
Definition: Config.h:213
ripple::SizedItem::ledgerFetch
@ ledgerFetch
ripple::Config::MAX_TRANSACTIONS
int MAX_TRANSACTIONS
Definition: Config.h:211
ripple::Config::quiet
bool quiet() const
Definition: Config.h:302
ripple::Config::FETCH_DEPTH
std::uint32_t FETCH_DEPTH
Definition: Config.h:193
algorithm
ripple::Config::PATH_SEARCH_MAX
int PATH_SEARCH_MAX
Definition: Config.h:181
ripple::Config::VP_REDUCE_RELAY_SQUELCH
bool VP_REDUCE_RELAY_SQUELCH
Definition: Config.h:242
ripple::Config::IO_WORKERS
int IO_WORKERS
Definition: Config.h:220
ripple::Config::RUN_STANDALONE
bool RUN_STANDALONE
Operate in stand-alone mode.
Definition: Config.h:105
ripple::SizedItem::ramSizeGB
@ ramSizeGB
ripple::Config::load
void load()
Definition: Config.cpp:434
ripple::Config::j_
const beast::Journal j_
Definition: Config.h:92
ripple::Config::RELAY_UNTRUSTED_PROPOSALS
int RELAY_UNTRUSTED_PROPOSALS
Definition: Config.h:153
ripple::Config::reporting
bool reporting() const
Definition: Config.h:317
ripple::Config::SSL_VERIFY_FILE
std::string SSL_VERIFY_FILE
Definition: Config.h:201
ripple::Config::loadFromString
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
Definition: Config.cpp:456
ripple::Config::getValueFor
int getValueFor(SizedItem item, std::optional< std::size_t > node=std::nullopt) const
Retrieve the default value for the item at the specified node size.
Definition: Config.cpp:989
ripple::Config::FORCE_MULTI_THREAD
bool FORCE_MULTI_THREAD
Definition: Config.h:224
ripple::Config::FAST_LOAD
bool FAST_LOAD
Definition: Config.h:276
ripple::Config
Definition: Config.h:69
ripple::Config::TRANSACTION_FEE_BASE
static constexpr FeeUnit32 TRANSACTION_FEE_BASE
Definition: Config.h:143
chrono
ripple::Config::NETWORK
@ NETWORK
Definition: Config.h:133
ripple::Config::SNTP_SERVERS
std::vector< std::string > SNTP_SERVERS
Definition: Config.h:131
ripple::Config::IPS_FIXED
std::vector< std::string > IPS_FIXED
Definition: Config.h:130
ripple::Config::FEE_OWNER_RESERVE
XRPAmount FEE_OWNER_RESERVE
Definition: Config.h:189
ripple::Config::standalone
bool standalone() const
Definition: Config.h:312
ripple::Config::SSL_VERIFY
bool SSL_VERIFY
Definition: Config.h:200
ripple::Config::USE_TX_TABLES
bool USE_TX_TABLES
Definition: Config.h:111
ripple::Config::useTxTables
bool useTxTables() const
Definition: Config.h:323
ripple::Config::FEE_ACCOUNT_RESERVE
XRPAmount FEE_ACCOUNT_RESERVE
Definition: Config.h:188
ripple::Config::BETA_RPC_API
bool BETA_RPC_API
Definition: Config.h:273
cstdint
ripple::Config::PEERS_OUT_MAX
std::size_t PEERS_OUT_MAX
Definition: Config.h:163
ripple::Config::START_UP
StartUpType START_UP
Definition: Config.h:134
ripple::Config::AMENDMENT_MAJORITY_TIME
std::chrono::seconds AMENDMENT_MAJORITY_TIME
Definition: Config.h:216
ripple::SizedItem::lgrDBCache
@ lgrDBCache
ripple::Config::MAX_JOB_QUEUE_TX
static constexpr int MAX_JOB_QUEUE_TX
Definition: Config.h:212
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::SizedItem::burstSize
@ burstSize
ripple::Config::nodeToShard
bool nodeToShard
Definition: Config.h:126
std::uint64_t
ripple::Config::WORKERS
int WORKERS
Definition: Config.h:219
ripple::Config::canSign
bool canSign() const
Definition: Config.h:341
ripple::Config::PEERS_IN_MAX
std::size_t PEERS_IN_MAX
Definition: Config.h:164
ripple::Config::databaseDirName
static char const *const databaseDirName
Definition: Config.h:74
ripple::feeunit::TaggedFee
Definition: FeeUnits.h:70
ripple::Config::START_VALID
bool START_VALID
Definition: Config.h:136
map
ripple::SizedItem::txnDBCache
@ txnDBCache
ripple::Config::PREFETCH_WORKERS
int PREFETCH_WORKERS
Definition: Config.h:221
ripple::Config::PATH_SEARCH_OLD
int PATH_SEARCH_OLD
Definition: Config.h:178
ripple::Config::LEDGER_HISTORY
std::uint32_t LEDGER_HISTORY
Definition: Config.h:192
ripple::Config::NETWORK_QUORUM
std::size_t NETWORK_QUORUM
Definition: Config.h:147
ripple::Config::VP_REDUCE_RELAY_ENABLE
bool VP_REDUCE_RELAY_ENABLE
Definition: Config.h:233
ripple::DROPS_PER_XRP
constexpr XRPAmount DROPS_PER_XRP
Number of drops per 1 XRP.
Definition: XRPAmount.h:250
ripple::Config::CONFIG_DIR
boost::filesystem::path CONFIG_DIR
Definition: Config.h:85
ripple::Config::PEERS_MAX
std::size_t PEERS_MAX
Definition: Config.h:162
ripple::Config::setReportingReadOnly
void setReportingReadOnly(bool b)
Definition: Config.h:335
ripple::Config::FEE_DEFAULT
XRPAmount FEE_DEFAULT
Definition: Config.h:187
ripple
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition: RCLCensorshipDetector.h:29
ripple::Config::FRESH
@ FRESH
Definition: Config.h:133
ripple::Config::features
std::unordered_set< uint256, beast::uhash<> > features
Definition: Config.h:262
ripple::Config::PATH_SEARCH_FAST
int PATH_SEARCH_FAST
Definition: Config.h:180
ripple::Config::setup
void setup(std::string const &strConf, bool bQuiet, bool bSilent, bool bStandalone)
Definition: Config.cpp:314
ripple::SizedItem::treeCacheSize
@ treeCacheSize
ripple::Config::TX_REDUCE_RELAY_MIN_PEERS
std::size_t TX_REDUCE_RELAY_MIN_PEERS
Definition: Config.h:254
ripple::Config::SERVER_DOMAIN
std::string SERVER_DOMAIN
Definition: Config.h:264
ripple::Config::TX_REDUCE_RELAY_METRICS
bool TX_REDUCE_RELAY_METRICS
Definition: Config.h:251
ripple::Config::REPLAY
@ REPLAY
Definition: Config.h:133
ripple::Config::RELAY_UNTRUSTED_VALIDATIONS
int RELAY_UNTRUSTED_VALIDATIONS
Definition: Config.h:152
ripple::Config::doImport
bool doImport
Definition: Config.h:125
ripple::SizedItem::sweepInterval
@ sweepInterval
ripple::Config::COMPRESSION
bool COMPRESSION
Definition: Config.h:205
ripple::defaultAmendmentMajorityTime
constexpr const std::chrono::seconds defaultAmendmentMajorityTime
The minimum amount of time an amendment must hold a majority.
Definition: SystemParameters.h:76
ripple::SizedItem::ledgerSize
@ ledgerSize
optional
ripple::Config::IPS
std::vector< std::string > IPS
Definition: Config.h:129
ripple::Config::configFileName
static char const *const configFileName
Definition: Config.h:73
std::size_t
ripple::Config::TX_RELAY_PERCENTAGE
std::size_t TX_RELAY_PERCENTAGE
Definition: Config.h:257
ripple::Config::QUIET
bool QUIET
Definition: Config.h:94
ripple::Config::TX_REDUCE_RELAY_ENABLE
bool TX_REDUCE_RELAY_ENABLE
Definition: Config.h:244
ripple::Config::reportingReadOnly
bool reportingReadOnly() const
Definition: Config.h:329
ripple::Config::SILENT
bool SILENT
Definition: Config.h:95
ripple::Config::getDebugLogFile
boost::filesystem::path getDebugLogFile() const
Returns the full path and filename of the debug log file.
Definition: Config.cpp:955
ripple::Config::signingEnabled_
bool signingEnabled_
Determines if the server will sign a tx, given an account's secret seed.
Definition: Config.h:119
ripple::Config::LOAD_FILE
@ LOAD_FILE
Definition: Config.h:133
ripple::Config::ELB_SUPPORT
bool ELB_SUPPORT
Definition: Config.h:127
type_traits
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:215
ripple::Config::START_LEDGER
std::string START_LEDGER
Definition: Config.h:138
ripple::SizedItem::ledgerAge
@ ledgerAge
ripple::Config::MAX_UNKNOWN_TIME
std::chrono::seconds MAX_UNKNOWN_TIME
Definition: Config.h:267
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::Config::REPORTING_READ_ONLY
bool REPORTING_READ_ONLY
Definition: Config.h:109
ripple::Config::MAX_DIVERGED_TIME
std::chrono::seconds MAX_DIVERGED_TIME
Definition: Config.h:270
ripple::Config::RUN_REPORTING
bool RUN_REPORTING
Definition: Config.h:107
ripple::Config::rpc_ip
std::optional< beast::IP::Endpoint > rpc_ip
Definition: Config.h:260
string