xrpld
Loading...
Searching...
No Matches
src/xrpld/core/Config.h
1#pragma once
2
3#include <xrpl/basics/base_uint.h>
4#include <xrpl/beast/hash/uhash.h>
5#include <xrpl/beast/net/IPEndpoint.h>
6#include <xrpl/beast/utility/Journal.h>
7#include <xrpl/config/BasicConfig.h>
8#include <xrpl/core/StartUpType.h>
9#include <xrpl/protocol/Fees.h>
10#include <xrpl/protocol/SystemParameters.h> // VFALCO Breaks levelization
11#include <xrpl/protocol/XRPAmount.h>
12#include <xrpl/rdb/DatabaseCon.h>
13
14#include <chrono>
15#include <cstddef>
16#include <cstdint>
17#include <filesystem>
18#include <optional>
19#include <string>
20#include <unordered_set>
21#include <utility>
22#include <vector>
23
24namespace xrpl {
25
26class Rules;
27
28//------------------------------------------------------------------------------
29
45
53{
58
63
68
69 /* (Remember to update the example cfg files when changing any of these
70 * values.) */
71
75 [[nodiscard]] Fees
76 toFees() const
77 {
79 }
80};
81
82// This entire derived class is deprecated.
83// For new config information use the style implied
84// in the base class. For existing config information
85// try to refactor code to use the new style.
86//
87class Config : public BasicConfig
88{
89public:
90 // Settings related to the configuration file location and directories
91 static char const* const kConfigFileName;
92 static char const* const kConfigLegacyName;
93 static char const* const kDatabaseDirName;
94 static char const* const kValidatorsFileName;
95
99 [[nodiscard]] std::filesystem::path
100 getDebugLogFile() const;
101
102private:
104
105public:
107
108private:
110
111 void
112 load();
114
115 bool quiet_ = false; // Minimize logging verbosity.
116 bool silent_ = false; // No output to console after startup.
127 bool runStandalone_ = false;
128
129 bool useTxTables_ = true;
130
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 elbSupport = false;
146
147 // Entries from [ips] config stanza
149
150 // Entries from [ips_fixed] config stanza
152
154
155 bool startValid = false;
156
158
160
161 // Network parameters
162 uint32_t networkId = 0;
163
164 // Note: The following parameters do not relate to the UNL or trust at all
165 // Minimum number of nodes to consider the network present
167
168 // Peer networking parameters
169 // 1 = relay, 0 = do not relay (but process), -1 = drop completely (do NOT
170 // process)
173
174 // True to ask peers not to relay current IP.
175 bool peerPrivate = false;
176 // peers_max is a legacy configuration, which is going to be replaced
177 // with individual inbound peers peers_in_max and outbound peers
178 // peers_out_max configuration. for now we support both the legacy and
179 // the new configuration. if peers_max is configured then peers_in_max and
180 // peers_out_max are ignored.
184
185 // Path searching: these were reasonable default values at some point but
186 // further research is needed to decide if they still are
187 // and whether all of them are needed.
188 //
189 // The performance and resource consumption of a server can
190 // be dramatically impacted by changing these configuration
191 // options; higher values result in exponentially higher
192 // resource usage.
193 //
194 // Servers operating as validators disable path finding by
195 // default by setting the `PATH_SEARCH_MAX` option to 0
196 // unless it is explicitly set in the configuration file.
198 int pathSearch = 2;
201
202 // Validation
203 std::optional<std::size_t> validationQuorum; // validations to consider ledger authoritative
204
206
207 // Node storage configuration
210
211 // Tunable that adjusts various parameters, typically associated
212 // with hardware parameters (RAM size and CPU cores). The default
213 // is 'tiny'.
215
216 bool sslVerify = true;
219
220 // Compression
221 bool compression = false;
222
223 // Enable the experimental Ledger Replay functionality
224 bool ledgerReplay = false;
225
226 // Work queue limits
228 static constexpr int kMaxJobQueueTx = 1000;
229 static constexpr int kMinJobQueueTx = 100;
230
231 // Optional override for the per-connection subscription cap. Unset means
232 // use the built-in default (kMaxSubscriptionsPerConnection in InfoSub.h).
233 // Kept as an override here, rather than the default itself, so the core
234 // module need not depend on the server module that owns the constant.
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 ioWorkers = 0; // io svc thread count. default: 2
243 int prefetchWorkers = 0; // prefetch thread count. default: 4
244
245 // Can only be set in code, specifically unit tests
246 bool forceMultiThread = 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 - Experimental parameters to control p2p routing algorithms
253
254 // Enable base squelching of duplicate validation/proposal messages
256
260 // Temporary squelching config for the peers selected as a source of //
261 // validator messages. The config must be removed once squelching is //
262 // made the default routing algorithm //
267
268 // Transaction reduce-relay feature
270 // If tx reduce-relay feature is disabled
271 // and this flag is enabled then some
272 // tx-related metrics is collected. It
273 // is ignored if tx reduce-relay feature is
274 // enabled. It is used in debugging to compare
275 // metrics with the feature disabled/enabled.
277 // Minimum peers a server should have before
278 // selecting random peers
280 // Percentage of peers with the tx reduce-relay feature enabled
281 // to relay to out of total active peers
283
284 // These override the command line client settings
286
288
290
291 // How long can a peer remain in the "unknown" state
293
294 // How long can a peer remain in the "diverged" state
296
297 // Optional overrides for how many manifests are kept in the cache and
298 // carried in one TMManifests message, split by whether this node lists the
299 // validator. Unset means use the built-in defaults (kMaxUntrustedCount and
300 // kMaxTrustedCount in Manifest.h). Kept as overrides here, rather than the
301 // defaults themselves, so the core module need not depend on the server
302 // module that owns the constants.
305
306 // Bounds for both counts above. The lower bound leaves room for a small
307 // network or a deliberately tight limit; note that setting a count below
308 // what peers actually send means their manifest messages are dropped for
309 // being oversized. The upper bound keeps the implied message size well
310 // under the overall protocol message limit.
311 static constexpr std::size_t kMinManifestCount = 50;
312 static constexpr std::size_t kMaxManifestCount = 1000;
313
314 // Enable the beta API version
315 bool betaRpcApi = false;
316
317 // First, attempt to load the latest ledger directly from disk.
318 bool fastLoad = false;
319 // When starting xrpld with existing database it do not know it has those
320 // ledgers locally until the server naturally tries to backfill. This makes
321 // is difficult to test some functionality (in particular performance
322 // testing sidechains). With this variable the user is able to force xrpld
323 // to consider the ledger range to be present. It should be used for testing
324 // only.
326
328
329public:
330 Config();
331
332 /* Be very careful to make sure these bool params
333 are in the right order. */
334 void
335 setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStandalone);
336
337 void
338 setupControl(bool bQuiet, bool bSilent, bool bStandalone);
339
345 void
346 loadFromString(std::string const& fileContents);
347
348 [[nodiscard]] bool
349 quiet() const
350 {
351 return quiet_;
352 }
353 [[nodiscard]] bool
354 silent() const
355 {
356 return silent_;
357 }
358 [[nodiscard]] bool
360 {
361 return runStandalone_;
362 }
363
364 [[nodiscard]] bool
366 {
367 return useTxTables_;
368 }
369
370 [[nodiscard]] bool
371 canSign() const
372 {
373 return signingEnabled_;
374 }
375
394 [[nodiscard]] int
395 getValueFor(SizedItem item, std::optional<std::size_t> node = std::nullopt) const;
396
397 [[nodiscard]] beast::Journal
398 journal() const
399 {
400 return j_;
401 }
402};
403
404FeeSetup
405setupFeeVote(Section const& section);
406
407DatabaseCon::Setup
408setupDatabaseCon(Config const& c, std::optional<beast::Journal> j = std::nullopt);
409
410} // namespace xrpl
A generic endpoint for log messages.
Definition Journal.h:44
Holds unparsed configuration information.
static constexpr int kMinJobQueueTx
std::filesystem::path configFile_
std::optional< std::size_t > maxUntrustedCount
std::chrono::seconds maxDivergedTime
std::unordered_set< uint256, beast::Uhash<> > features
static constexpr int kMaxJobQueueTx
std::optional< int > sweepInterval
std::uint32_t fetchDepth
beast::Journal const j_
bool standalone() const
std::size_t txReduceRelayMinPeers
static constexpr std::size_t kMinManifestCount
std::optional< std::size_t > maxTrustedCount
std::size_t vpReduceRelaySquelchMaxSelectedPeers
////////////////// !
std::optional< beast::ip::Endpoint > rpcIp
std::filesystem::path getDebugLogFile() const
Returns the full path and filename of the debug log file.
std::optional< uint256 > trapTxHash
static constexpr std::size_t kMaxManifestCount
void setup(std::string const &strConf, bool bQuiet, bool bSilent, bool bStandalone)
std::chrono::seconds maxUnknownTime
static char const *const kDatabaseDirName
beast::Journal journal() const
std::uint64_t const ramSize_
std::optional< std::pair< std::uint32_t, std::uint32_t > > forcedLedgerRangePresent
std::vector< std::string > ipsFixed
void loadFromString(std::string const &fileContents)
Load the config from the contents of the string.
std::string sslVerifyFile
std::optional< std::size_t > maxSubscriptionsPerConnection
std::size_t txRelayPercentage
static char const *const kConfigLegacyName
std::optional< std::size_t > validatorListThreshold
std::filesystem::path debugLogfile_
bool runStandalone_
Operate in stand-alone mode.
bool txReduceRelayEnable
////////////// END OF TEMPORARY CODE BLOCK /////////////////////
bool useTxTables() const
static char const *const kConfigFileName
std::vector< std::string > ips
bool signingEnabled_
Determines if the server will sign a tx, given an account's secret seed.
void setupControl(bool bQuiet, bool bSilent, bool bStandalone)
std::optional< std::size_t > validationQuorum
std::uint32_t ledgerHistory
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.
static char const *const kValidatorsFileName
std::size_t networkQuorum
std::filesystem::path configDir
std::chrono::seconds amendmentMajorityTime
Rules controlling protocol behavior.
Definition Rules.h:40
Use hash_* containers for keys that do not need a cryptographically secure hashing algorithm.
Definition algorithm.h:5
FeeSetup setupFeeVote(Section const &section)
constexpr XRPAmount kDropsPerXrp
Number of drops per 1 XRP.
Definition XRPAmount.h:254
constexpr std::chrono::seconds const kDefaultAmendmentMajorityTime
The minimum amount of time an amendment must hold a majority.
DatabaseCon::Setup setupDatabaseCon(Config const &c, std::optional< beast::Journal > j=std::nullopt)
StartUpType
Definition StartUpType.h:8
Fee schedule for startup / standalone, and to vote for.
XRPAmount accountReserve
The account reserve requirement in drops.
Fees toFees() const
Convert to a Fees object for use with Ledger construction.
XRPAmount ownerReserve
The per-owned item reserve requirement in drops.
XRPAmount referenceFee
The cost of a reference transaction in drops.
Reflects the fee settings for a particular ledger.