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