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 <string_view>
21#include <unordered_set>
22#include <utility>
23#include <vector>
24
25namespace xrpl {
26
27class Rules;
28
29//------------------------------------------------------------------------------
30
46
54{
59
64
69
70 /* (Remember to update the example cfg files when changing any of these
71 * values.) */
72
76 [[nodiscard]] Fees
77 toFees() const
78 {
80 }
81};
82
83// This entire derived class is deprecated.
84// For new config information use the style implied
85// in the base class. For existing config information
86// try to refactor code to use the new style.
87//
88class Config : public BasicConfig
89{
90public:
91 // Settings related to the configuration file location and directories
92 static constexpr std::string_view kConfigFileName = "xrpld.cfg";
93 static constexpr std::string_view kConfigLegacyName = "rippled.cfg";
94 static constexpr std::string_view kDatabaseDirName = "db";
95 static constexpr std::string_view kValidatorsFileName = "validators.txt";
96
100 [[nodiscard]] std::filesystem::path
101 getDebugLogFile() const;
102
103private:
105
106public:
108
109private:
111
112 void
113 load();
115
116 bool quiet_ = false; // Minimize logging verbosity.
117 bool silent_ = false; // No output to console after startup.
128 bool runStandalone_ = false;
129
130 bool useTxTables_ = true;
131
139 bool signingEnabled_ = false;
140
141 // The amount of RAM, in bytes, that we detected on this system.
143
144public:
145 bool doImport = false;
146 bool elbSupport = false;
147
148 // Entries from [ips] config stanza
150
151 // Entries from [ips_fixed] config stanza
153
155
156 bool startValid = false;
157
159
161
162 // Network parameters
163 uint32_t networkId = 0;
164
165 // Note: The following parameters do not relate to the UNL or trust at all
166 // Minimum number of nodes to consider the network present
168
169 // Peer networking parameters
170 // 1 = relay, 0 = do not relay (but process), -1 = drop completely (do NOT
171 // process)
174
175 // True to ask peers not to relay current IP.
176 bool peerPrivate = false;
177 // peers_max is a legacy configuration, which is going to be replaced
178 // with individual inbound peers peers_in_max and outbound peers
179 // peers_out_max configuration. for now we support both the legacy and
180 // the new configuration. if peers_max is configured then peers_in_max and
181 // peers_out_max are ignored.
185
186 // Path searching: these were reasonable default values at some point but
187 // further research is needed to decide if they still are
188 // and whether all of them are needed.
189 //
190 // The performance and resource consumption of a server can
191 // be dramatically impacted by changing these configuration
192 // options; higher values result in exponentially higher
193 // resource usage.
194 //
195 // Servers operating as validators disable path finding by
196 // default by setting the `PATH_SEARCH_MAX` option to 0
197 // unless it is explicitly set in the configuration file.
199 int pathSearch = 2;
202
203 // Validation
204 std::optional<std::size_t> validationQuorum; // validations to consider ledger authoritative
205
207
208 // Node storage configuration
211
212 // Tunable that adjusts various parameters, typically associated
213 // with hardware parameters (RAM size and CPU cores). The default
214 // is 'tiny'.
216
217 bool sslVerify = true;
220
221 // Compression
222 bool compression = false;
223
224 // Enable the experimental Ledger Replay functionality
225 bool ledgerReplay = false;
226
227 // Work queue limits
229 static constexpr int kMaxJobQueueTx = 1000;
230 static constexpr int kMinJobQueueTx = 100;
231
232 // Optional override for the per-connection subscription cap. Unset means
233 // use the built-in default (kMaxSubscriptionsPerConnection in InfoSub.h).
234 // Kept as an override here, rather than the default itself, so the core
235 // module need not depend on the server module that owns the constant.
237
238 // Amendment majority time
240
241 // Thread pool configuration (0 = choose for me)
242 int workers = 0; // jobqueue thread count. default: upto 6
243 int ioWorkers = 0; // io svc thread count. default: 2
244 int prefetchWorkers = 0; // prefetch thread count. default: 4
245
246 // Can only be set in code, specifically unit tests
247 bool forceMultiThread = false;
248
249 // Normally the sweep timer is automatically deduced based on the node
250 // size, but we allow admins to explicitly set it in the config.
252
253 // Reduce-relay - Experimental parameters to control p2p routing algorithms
254
255 // Enable base squelching of duplicate validation/proposal messages
257
261 // Temporary squelching config for the peers selected as a source of //
262 // validator messages. The config must be removed once squelching is //
263 // made the default routing algorithm //
268
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 // Optional overrides for how many manifests are kept in the cache and
299 // carried in one TMManifests message, split by whether this node lists the
300 // validator. Unset means use the built-in defaults (kMaxUntrustedCount and
301 // kMaxTrustedCount in Manifest.h). Kept as overrides here, rather than the
302 // defaults themselves, so the core module need not depend on the server
303 // module that owns the constants.
306
307 // Bounds for both counts above. The lower bound leaves room for a small
308 // network or a deliberately tight limit; note that setting a count below
309 // what peers actually send means their manifest messages are dropped for
310 // being oversized. The upper bound keeps the implied message size well
311 // under the overall protocol message limit.
312 static constexpr std::size_t kMinManifestCount = 50;
313 static constexpr std::size_t kMaxManifestCount = 1000;
314
315 // Enable the beta API version
316 bool betaRpcApi = false;
317
318 // First, attempt to load the latest ledger directly from disk.
319 bool fastLoad = false;
320 // When starting xrpld with existing database it do not know it has those
321 // ledgers locally until the server naturally tries to backfill. This makes
322 // is difficult to test some functionality (in particular performance
323 // testing sidechains). With this variable the user is able to force xrpld
324 // to consider the ledger range to be present. It should be used for testing
325 // only.
327
329
330public:
331 Config();
332
333 /* Be very careful to make sure these bool params
334 are in the right order. */
335 void
336 setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStandalone);
337
338 void
339 setupControl(bool bQuiet, bool bSilent, bool bStandalone);
340
346 void
347 loadFromString(std::string const& fileContents);
348
349 [[nodiscard]] bool
350 quiet() const
351 {
352 return quiet_;
353 }
354 [[nodiscard]] bool
355 silent() const
356 {
357 return silent_;
358 }
359 [[nodiscard]] bool
361 {
362 return runStandalone_;
363 }
364
365 [[nodiscard]] bool
367 {
368 return useTxTables_;
369 }
370
371 [[nodiscard]] bool
372 canSign() const
373 {
374 return signingEnabled_;
375 }
376
395 [[nodiscard]] int
396 getValueFor(SizedItem item, std::optional<std::size_t> node = std::nullopt) const;
397
398 [[nodiscard]] beast::Journal
399 journal() const
400 {
401 return j_;
402 }
403};
404
405FeeSetup
406setupFeeVote(Section const& section);
407
408DatabaseCon::Setup
409setupDatabaseCon(Config const& c, std::optional<beast::Journal> j = std::nullopt);
410
411} // 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::unordered_set< UInt256, beast::Uhash<> > features
static constexpr std::string_view kConfigLegacyName
std::optional< std::size_t > maxUntrustedCount
std::chrono::seconds maxDivergedTime
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
static constexpr std::string_view kDatabaseDirName
std::size_t vpReduceRelaySquelchMaxSelectedPeers
////////////////// !
std::optional< beast::ip::Endpoint > rpcIp
static constexpr std::string_view kConfigFileName
std::filesystem::path getDebugLogFile() const
Returns the full path and filename of the debug log file.
static constexpr std::size_t kMaxManifestCount
void setup(std::string const &strConf, bool bQuiet, bool bSilent, bool bStandalone)
std::chrono::seconds maxUnknownTime
beast::Journal journal() const
std::uint64_t const ramSize_
std::optional< UInt256 > trapTxHash
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
std::optional< std::size_t > validatorListThreshold
std::filesystem::path debugLogfile_
bool runStandalone_
Operate in stand-alone mode.
static constexpr std::string_view kValidatorsFileName
bool txReduceRelayEnable
////////////// END OF TEMPORARY CODE BLOCK /////////////////////
bool useTxTables() const
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.
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.