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 
30 #include <boost/beast/core/string.hpp>
31 #include <boost/filesystem.hpp> // VFALCO FIX: This include should not be here
32 #include <boost/lexical_cast.hpp>
33 
34 #include <algorithm>
35 #include <chrono>
36 #include <cstdint>
37 #include <map>
38 #include <optional>
39 #include <string>
40 #include <type_traits>
41 #include <unordered_set>
42 #include <utility>
43 #include <vector>
44 
45 namespace ripple {
46 
47 class Rules;
48 
49 //------------------------------------------------------------------------------
50 
51 enum class SizedItem : std::size_t {
52  sweepInterval = 0,
55  ledgerSize,
56  ledgerAge,
59  txnDBCache,
60  lgrDBCache,
62  burstSize,
63  ramSizeGB,
65 };
66 
72 struct FeeSetup
73 {
76 
79 
82 
83  /* (Remember to update the example cfg files when changing any of these
84  * values.) */
85 };
86 
87 // This entire derived class is deprecated.
88 // For new config information use the style implied
89 // in the base class. For existing config information
90 // try to refactor code to use the new style.
91 //
92 class Config : public BasicConfig
93 {
94 public:
95  // Settings related to the configuration file location and directories
96  static char const* const configFileName;
97  static char const* const databaseDirName;
98  static char const* const validatorsFileName;
99 
101  boost::filesystem::path
102  getDebugLogFile() const;
103 
104 private:
105  boost::filesystem::path CONFIG_FILE;
106 
107 public:
108  boost::filesystem::path CONFIG_DIR;
109 
110 private:
111  boost::filesystem::path DEBUG_LOGFILE;
112 
113  void
114  load();
116 
117  bool QUIET = false; // Minimize logging verbosity.
118  bool SILENT = false; // No output to console after startup.
128  bool RUN_STANDALONE = false;
129 
130  bool RUN_REPORTING = false;
131 
132  bool REPORTING_READ_ONLY = false;
133 
134  bool USE_TX_TABLES = true;
135 
142  bool signingEnabled_ = false;
143 
144  // The amount of RAM, in bytes, that we detected on this system.
146 
147 public:
148  bool doImport = false;
149  bool nodeToShard = false;
150  bool ELB_SUPPORT = false;
151 
152  // Entries from [ips] config stanza
154 
155  // Entries from [ips_fixed] config stanza
157 
160 
161  bool START_VALID = false;
162 
164 
165  // Network parameters
166  uint32_t NETWORK_ID = 0;
167 
168  // DEPRECATED - Fee units for a reference transction.
169  // Only provided for backwards compatibility in a couple of places
170  static constexpr std::uint32_t FEE_UNITS_DEPRECATED = 10;
171 
172  // Note: The following parameters do not relate to the UNL or trust at all
173  // Minimum number of nodes to consider the network present
175 
176  // Peer networking parameters
177  // 1 = relay, 0 = do not relay (but process), -1 = drop completely (do NOT
178  // process)
181 
182  // True to ask peers not to relay current IP.
183  bool PEER_PRIVATE = false;
184  // peers_max is a legacy configuration, which is going to be replaced
185  // with individual inbound peers peers_in_max and outbound peers
186  // peers_out_max configuration. for now we support both the legacy and
187  // the new configuration. if peers_max is configured then peers_in_max and
188  // peers_out_max are ignored.
192 
193  // Path searching: these were reasonable default values at some point but
194  // further research is needed to decide if they still are
195  // and whether all of them are needed.
196  //
197  // The performance and resource consumption of a server can
198  // be dramatically impacted by changing these configuration
199  // options; higher values result in exponentially higher
200  // resource usage.
201  //
202  // Servers operating as validators disable path finding by
203  // default by setting the `PATH_SEARCH_MAX` option to 0
204  // unless it is explicitly set in the configuration file.
206  int PATH_SEARCH = 2;
209 
210  // Validation
212  VALIDATION_QUORUM; // validations to consider ledger authoritative
213 
215 
216  // Node storage configuration
218  std::uint32_t FETCH_DEPTH = 1'000'000'000;
219 
220  // Tunable that adjusts various parameters, typically associated
221  // with hardware parameters (RAM size and CPU cores). The default
222  // is 'tiny'.
223  std::size_t NODE_SIZE = 0;
224 
225  bool SSL_VERIFY = true;
226  std::string SSL_VERIFY_FILE;
227  std::string SSL_VERIFY_DIR;
228 
229  // Compression
230  bool COMPRESSION = false;
231 
232  // Enable the experimental Ledger Replay functionality
233  bool LEDGER_REPLAY = false;
234 
235  // Work queue limits. 10000 transactions is 2 full seconds of slowdown at
236  // 5000/s.
237  int MAX_TRANSACTIONS = 10'000;
238  static constexpr int MAX_JOB_QUEUE_TX = 100'000;
239  static constexpr int MIN_JOB_QUEUE_TX = 1'000;
240 
241  // Amendment majority time
243 
244  // Thread pool configuration (0 = choose for me)
245  int WORKERS = 0; // jobqueue thread count. default: upto 6
246  int IO_WORKERS = 0; // io svc thread count. default: 2
247  int PREFETCH_WORKERS = 0; // prefetch thread count. default: 4
248 
249  // Can only be set in code, specifically unit tests
250  bool FORCE_MULTI_THREAD = false;
251 
252  // Normally the sweep timer is automatically deduced based on the node
253  // size, but we allow admins to explicitly set it in the config.
255 
256  // Reduce-relay - these parameters are experimental.
257  // Enable reduce-relay features
258  // Validation/proposal reduce-relay feature
260  // Send squelch message to peers. Generally this config should
261  // have the same value as VP_REDUCE_RELAY_ENABLE. It can be
262  // used for testing the feature's function without
263  // affecting the message relaying. To use it for testing,
264  // set it to false and set VP_REDUCE_RELAY_ENABLE to true.
265  // Squelch messages will not be sent to the peers in this case.
266  // Set log level to debug so that the feature function can be
267  // analyzed.
269  // Transaction reduce-relay feature
271  // If tx reduce-relay feature is disabled
272  // and this flag is enabled then some
273  // tx-related metrics is collected. It
274  // is ignored if tx reduce-relay feature is
275  // enabled. It is used in debugging to compare
276  // metrics with the feature disabled/enabled.
278  // Minimum peers a server should have before
279  // selecting random peers
281  // Percentage of peers with the tx reduce-relay feature enabled
282  // to relay to out of total active peers
284 
285  // These override the command line client settings
287 
289 
291 
292  // How long can a peer remain in the "unknown" state
294 
295  // How long can a peer remain in the "diverged" state
297 
298  // Enable the beta API version
299  bool BETA_RPC_API = false;
300 
301  // First, attempt to load the latest ledger directly from disk.
302  bool FAST_LOAD = false;
303  // When starting rippled with existing database it do not know it has those
304  // ledgers locally until the server naturally tries to backfill. This makes
305  // is difficult to test some functionality (in particular performance
306  // testing sidechains). With this variable the user is able to force rippled
307  // to consider the ledger range to be present. It should be used for testing
308  // only.
311 
312 public:
313  Config();
314 
315  /* Be very careful to make sure these bool params
316  are in the right order. */
317  void
318  setup(
319  std::string const& strConf,
320  bool bQuiet,
321  bool bSilent,
322  bool bStandalone);
323 
324  void
325  setupControl(bool bQuiet, bool bSilent, bool bStandalone);
326 
332  void
333  loadFromString(std::string const& fileContents);
334 
335  bool
336  quiet() const
337  {
338  return QUIET;
339  }
340  bool
341  silent() const
342  {
343  return SILENT;
344  }
345  bool
346  standalone() const
347  {
348  return RUN_STANDALONE;
349  }
350  bool
351  reporting() const
352  {
353  return RUN_REPORTING;
354  }
355 
356  bool
357  useTxTables() const
358  {
359  return USE_TX_TABLES;
360  }
361 
362  bool
364  {
365  return REPORTING_READ_ONLY;
366  }
367 
368  void
370  {
372  }
373 
374  bool
375  canSign() const
376  {
377  return signingEnabled_;
378  }
379 
397  int
398  getValueFor(SizedItem item, std::optional<std::size_t> node = std::nullopt)
399  const;
400 };
401 
402 FeeSetup
403 setup_FeeVote(Section const& section);
404 
405 } // namespace ripple
406 
407 #endif
ripple::SizedItem::openFinalLimit
@ openFinalLimit
ripple::FeeSetup::reference_fee
XRPAmount reference_fee
The cost of a reference transaction in drops.
Definition: Config.h:75
ripple::Config::NORMAL
@ NORMAL
Definition: Config.h:158
ripple::Config::SWEEP_INTERVAL
std::optional< int > SWEEP_INTERVAL
Definition: Config.h:254
std::string
STL class.
utility
ripple::SizedItem
SizedItem
Definition: Config.h:51
ripple::Config::PATH_SEARCH
int PATH_SEARCH
Definition: Config.h:206
ripple::Config::VALIDATION_QUORUM
std::optional< std::size_t > VALIDATION_QUORUM
Definition: Config.h:212
unordered_set
ripple::Config::Config
Config()
Definition: Config.cpp:260
ripple::SizedItem::accountIdCacheSize
@ accountIdCacheSize
ripple::Config::validatorsFileName
static char const *const validatorsFileName
Definition: Config.h:98
vector
ripple::Config::CONFIG_FILE
boost::filesystem::path CONFIG_FILE
Definition: Config.h:105
std::chrono::seconds
ripple::Config::PEER_PRIVATE
bool PEER_PRIVATE
Definition: Config.h:183
ripple::Config::DEBUG_LOGFILE
boost::filesystem::path DEBUG_LOGFILE
Definition: Config.h:111
ripple::Config::silent
bool silent() const
Definition: Config.h:341
ripple::Config::setupControl
void setupControl(bool bQuiet, bool bSilent, bool bStandalone)
Definition: Config.cpp:267
ripple::SizedItem::treeCacheAge
@ treeCacheAge
ripple::Config::LOAD
@ LOAD
Definition: Config.h:158
ripple::Config::ramSize_
const std::uint64_t ramSize_
Definition: Config.h:145
ripple::Config::StartUpType
StartUpType
Definition: Config.h:158
ripple::SizedItem::hashNodeDBCache
@ hashNodeDBCache
ripple::SizedItem::ledgerFetch
@ ledgerFetch
ripple::Config::quiet
bool quiet() const
Definition: Config.h:336
ripple::Config::FETCH_DEPTH
std::uint32_t FETCH_DEPTH
Definition: Config.h:218
algorithm
ripple::Config::PATH_SEARCH_MAX
int PATH_SEARCH_MAX
Definition: Config.h:208
ripple::Config::VP_REDUCE_RELAY_SQUELCH
bool VP_REDUCE_RELAY_SQUELCH
Definition: Config.h:268
ripple::Config::IO_WORKERS
int IO_WORKERS
Definition: Config.h:246
ripple::Config::RUN_STANDALONE
bool RUN_STANDALONE
Operate in stand-alone mode.
Definition: Config.h:128
ripple::SizedItem::ramSizeGB
@ ramSizeGB
ripple::Config::load
void load()
Definition: Config.cpp:425
ripple::Config::j_
const beast::Journal j_
Definition: Config.h:115
ripple::Config::RELAY_UNTRUSTED_PROPOSALS
int RELAY_UNTRUSTED_PROPOSALS
Definition: Config.h:180
ripple::Config::reporting
bool reporting() const
Definition: Config.h:351
ripple::Config::loadFromString
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
Definition: Config.cpp:447
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:1009
ripple::Config::FORCE_MULTI_THREAD
bool FORCE_MULTI_THREAD
Definition: Config.h:250
ripple::Config::FAST_LOAD
bool FAST_LOAD
Definition: Config.h:302
ripple::Config
Definition: Config.h:92
chrono
ripple::Config::NETWORK
@ NETWORK
Definition: Config.h:158
ripple::Config::IPS_FIXED
std::vector< std::string > IPS_FIXED
Definition: Config.h:156
ripple::Config::standalone
bool standalone() const
Definition: Config.h:346
ripple::Config::USE_TX_TABLES
bool USE_TX_TABLES
Definition: Config.h:134
ripple::Config::useTxTables
bool useTxTables() const
Definition: Config.h:357
ripple::Config::BETA_RPC_API
bool BETA_RPC_API
Definition: Config.h:299
cstdint
ripple::setup_FeeVote
FeeSetup setup_FeeVote(Section const &section)
Definition: Config.cpp:1018
ripple::Config::PEERS_OUT_MAX
std::size_t PEERS_OUT_MAX
Definition: Config.h:190
ripple::Config::START_UP
StartUpType START_UP
Definition: Config.h:159
ripple::Config::AMENDMENT_MAJORITY_TIME
std::chrono::seconds AMENDMENT_MAJORITY_TIME
Definition: Config.h:242
ripple::SizedItem::lgrDBCache
@ lgrDBCache
ripple::Config::MAX_JOB_QUEUE_TX
static constexpr int MAX_JOB_QUEUE_TX
Definition: Config.h:238
beast::Journal
A generic endpoint for log messages.
Definition: Journal.h:58
ripple::FeeSetup::account_reserve
XRPAmount account_reserve
The account reserve requirement in drops.
Definition: Config.h:78
ripple::SizedItem::burstSize
@ burstSize
ripple::Config::nodeToShard
bool nodeToShard
Definition: Config.h:149
std::uint64_t
ripple::Config::WORKERS
int WORKERS
Definition: Config.h:245
ripple::Config::canSign
bool canSign() const
Definition: Config.h:375
ripple::Config::PEERS_IN_MAX
std::size_t PEERS_IN_MAX
Definition: Config.h:191
ripple::Config::databaseDirName
static char const *const databaseDirName
Definition: Config.h:97
ripple::Config::START_VALID
bool START_VALID
Definition: Config.h:161
map
ripple::SizedItem::txnDBCache
@ txnDBCache
ripple::Config::PREFETCH_WORKERS
int PREFETCH_WORKERS
Definition: Config.h:247
ripple::Config::FEE_UNITS_DEPRECATED
static constexpr std::uint32_t FEE_UNITS_DEPRECATED
Definition: Config.h:170
ripple::Config::PATH_SEARCH_OLD
int PATH_SEARCH_OLD
Definition: Config.h:205
ripple::Config::LEDGER_HISTORY
std::uint32_t LEDGER_HISTORY
Definition: Config.h:217
ripple::Config::NETWORK_QUORUM
std::size_t NETWORK_QUORUM
Definition: Config.h:174
ripple::Config::VP_REDUCE_RELAY_ENABLE
bool VP_REDUCE_RELAY_ENABLE
Definition: Config.h:259
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:108
ripple::Config::PEERS_MAX
std::size_t PEERS_MAX
Definition: Config.h:189
ripple::Config::setReportingReadOnly
void setReportingReadOnly(bool b)
Definition: Config.h:369
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:158
ripple::Config::features
std::unordered_set< uint256, beast::uhash<> > features
Definition: Config.h:288
ripple::Config::PATH_SEARCH_FAST
int PATH_SEARCH_FAST
Definition: Config.h:207
ripple::Config::setup
void setup(std::string const &strConf, bool bQuiet, bool bSilent, bool bStandalone)
Definition: Config.cpp:305
ripple::Config::NETWORK_ID
uint32_t NETWORK_ID
Definition: Config.h:166
ripple::SizedItem::treeCacheSize
@ treeCacheSize
ripple::Config::TX_REDUCE_RELAY_MIN_PEERS
std::size_t TX_REDUCE_RELAY_MIN_PEERS
Definition: Config.h:280
ripple::Config::SERVER_DOMAIN
std::string SERVER_DOMAIN
Definition: Config.h:290
ripple::Config::TX_REDUCE_RELAY_METRICS
bool TX_REDUCE_RELAY_METRICS
Definition: Config.h:277
ripple::Config::REPLAY
@ REPLAY
Definition: Config.h:158
ripple::FeeSetup::owner_reserve
XRPAmount owner_reserve
The per-owned item reserve requirement in drops.
Definition: Config.h:81
ripple::Config::RELAY_UNTRUSTED_VALIDATIONS
int RELAY_UNTRUSTED_VALIDATIONS
Definition: Config.h:179
ripple::Config::doImport
bool doImport
Definition: Config.h:148
ripple::SizedItem::sweepInterval
@ sweepInterval
ripple::Config::FORCED_LEDGER_RANGE_PRESENT
std::optional< std::pair< std::uint32_t, std::uint32_t > > FORCED_LEDGER_RANGE_PRESENT
Definition: Config.h:310
ripple::defaultAmendmentMajorityTime
constexpr const std::chrono::seconds defaultAmendmentMajorityTime
The minimum amount of time an amendment must hold a majority.
Definition: SystemParameters.h:88
ripple::SizedItem::ledgerSize
@ ledgerSize
optional
ripple::Config::IPS
std::vector< std::string > IPS
Definition: Config.h:153
ripple::Config::configFileName
static char const *const configFileName
Definition: Config.h:96
std::size_t
ripple::Config::TX_RELAY_PERCENTAGE
std::size_t TX_RELAY_PERCENTAGE
Definition: Config.h:283
ripple::FeeSetup
Fee schedule for startup / standalone, and to vote for.
Definition: Config.h:72
ripple::Config::QUIET
bool QUIET
Definition: Config.h:117
ripple::Config::TX_REDUCE_RELAY_ENABLE
bool TX_REDUCE_RELAY_ENABLE
Definition: Config.h:270
ripple::Config::reportingReadOnly
bool reportingReadOnly() const
Definition: Config.h:363
ripple::Config::SILENT
bool SILENT
Definition: Config.h:118
ripple::Config::getDebugLogFile
boost::filesystem::path getDebugLogFile() const
Returns the full path and filename of the debug log file.
Definition: Config.cpp:975
ripple::Config::FEES
FeeSetup FEES
Definition: Config.h:214
ripple::Config::signingEnabled_
bool signingEnabled_
Determines if the server will sign a tx, given an account's secret seed.
Definition: Config.h:142
ripple::Config::LOAD_FILE
@ LOAD_FILE
Definition: Config.h:158
ripple::Config::ELB_SUPPORT
bool ELB_SUPPORT
Definition: Config.h:150
type_traits
ripple::BasicConfig
Holds unparsed configuration information.
Definition: BasicConfig.h:215
ripple::Config::START_LEDGER
std::string START_LEDGER
Definition: Config.h:163
ripple::SizedItem::ledgerAge
@ ledgerAge
ripple::Config::MAX_UNKNOWN_TIME
std::chrono::seconds MAX_UNKNOWN_TIME
Definition: Config.h:293
ripple::XRPAmount
Definition: XRPAmount.h:46
ripple::Config::REPORTING_READ_ONLY
bool REPORTING_READ_ONLY
Definition: Config.h:132
ripple::Config::MAX_DIVERGED_TIME
std::chrono::seconds MAX_DIVERGED_TIME
Definition: Config.h:296
ripple::Config::RUN_REPORTING
bool RUN_REPORTING
Definition: Config.h:130
ripple::Config::rpc_ip
std::optional< beast::IP::Endpoint > rpc_ip
Definition: Config.h:286
string