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