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
74
79
84
85 /* (Remember to update the example cfg files when changing any of these
86 * values.) */
87
91 [[nodiscard]] Fees
97};
98
99// This entire derived class is deprecated.
100// For new config information use the style implied
101// in the base class. For existing config information
102// try to refactor code to use the new style.
103//
104class Config : public BasicConfig
105{
106public:
107 // Settings related to the configuration file location and directories
108 static constexpr std::string_view kConfigFileName = "xrpld.cfg";
109 static constexpr std::string_view kConfigLegacyName = "rippled.cfg";
110 static constexpr std::string_view kDatabaseDirName = "db";
111 static constexpr std::string_view kValidatorsFileName = "validators.txt";
112
116 [[nodiscard]] std::filesystem::path
117 getDebugLogFile() const;
118
119private:
121
122public:
124
125private:
127
128 void
129 load();
131
132 bool quiet_ = false; // Minimize logging verbosity.
133 bool silent_ = false; // No output to console after startup.
144 bool runStandalone_ = false;
145
146 bool useTxTables_ = true;
147
155 bool signingEnabled_ = false;
156
157 // The amount of RAM, in bytes, that we detected on this system.
159
160public:
161 bool doImport = false;
162 bool elbSupport = false;
163
164 // Entries from [ips] config stanza
166
167 // Entries from [ips_fixed] config stanza
169
171
172 bool startValid = false;
173
175
177
178 // Network parameters
179 uint32_t networkId = 0;
180
181 // Note: The following parameters do not relate to the UNL or trust at all
182 // Minimum number of nodes to consider the network present
184
185 // Peer networking parameters
186 // 1 = relay, 0 = do not relay (but process), -1 = drop completely (do NOT
187 // process)
190
191 // True to ask peers not to relay current IP.
192 bool peerPrivate = false;
193 // peers_max is a legacy configuration, which is going to be replaced
194 // with individual inbound peers peers_in_max and outbound peers
195 // peers_out_max configuration. for now we support both the legacy and
196 // the new configuration. if peers_max is configured then peers_in_max and
197 // peers_out_max are ignored.
201
202 // Path searching: these were reasonable default values at some point but
203 // further research is needed to decide if they still are
204 // and whether all of them are needed.
205 //
206 // The performance and resource consumption of a server can
207 // be dramatically impacted by changing these configuration
208 // options; higher values result in exponentially higher
209 // resource usage.
210 //
211 // Servers operating as validators disable path finding by
212 // default by setting the `PATH_SEARCH_MAX` option to 0
213 // unless it is explicitly set in the configuration file.
215 int pathSearch = 2;
218
219 // Validation
220 std::optional<std::size_t> validationQuorum; // validations to consider ledger authoritative
221
223
224 // Node storage configuration
227
228 // Tunable that adjusts various parameters, typically associated
229 // with hardware parameters (RAM size and CPU cores). The default
230 // is 'tiny'.
232
233 bool sslVerify = true;
236
237 // Compression
238 bool compression = false;
239
240 // Enable the experimental Ledger Replay functionality
241 bool ledgerReplay = false;
242
243 // Work queue limits
245 static constexpr int kMaxJobQueueTx = 1000;
246 static constexpr int kMinJobQueueTx = 100;
247
248 // Optional override for the per-connection subscription cap. Unset means
249 // use the built-in default (kMaxSubscriptionsPerConnection in InfoSub.h).
250 // Kept as an override here, rather than the default itself, so the core
251 // module need not depend on the server module that owns the constant.
253
254 // Amendment majority time
256
257 // Thread pool configuration (0 = choose for me)
258 int workers = 0; // jobqueue thread count. default: upto 6
259 int ioWorkers = 0; // io svc thread count. default: 2
260 int prefetchWorkers = 0; // prefetch thread count. default: 4
261
262 // Can only be set in code, specifically unit tests
263 bool forceMultiThread = false;
264
265 // Normally the sweep timer is automatically deduced based on the node
266 // size, but we allow admins to explicitly set it in the config.
268
269 // Reduce-relay - Experimental parameters to control p2p routing algorithms
270
271 // Enable base squelching of duplicate validation/proposal messages
273
277 // Temporary squelching config for the peers selected as a source of //
278 // validator messages. The config must be removed once squelching is //
279 // made the default routing algorithm //
284
285 // Transaction reduce-relay feature
287 // If tx reduce-relay feature is disabled
288 // and this flag is enabled then some
289 // tx-related metrics is collected. It
290 // is ignored if tx reduce-relay feature is
291 // enabled. It is used in debugging to compare
292 // metrics with the feature disabled/enabled.
294 // Minimum peers a server should have before
295 // selecting random peers
297 // Percentage of peers with the tx reduce-relay feature enabled
298 // to relay to out of total active peers
300
301 // These override the command line client settings
303
305
307
308 // How long can a peer remain in the "unknown" state
310
311 // How long can a peer remain in the "diverged" state
313
314 // Optional overrides for how many manifests are kept in the cache and
315 // carried in one TMManifests message, split by whether this node lists the
316 // validator. Unset means use the built-in defaults (kMaxUntrustedCount and
317 // kMaxTrustedCount in Manifest.h). Kept as overrides here, rather than the
318 // defaults themselves, so the core module need not depend on the server
319 // module that owns the constants.
322
323 // Bounds for both counts above. The lower bound leaves room for a small
324 // network or a deliberately tight limit; note that setting a count below
325 // what peers actually send means their manifest messages are dropped for
326 // being oversized. The upper bound keeps the implied message size well
327 // under the overall protocol message limit.
328 static constexpr std::size_t kMinManifestCount = 50;
329 static constexpr std::size_t kMaxManifestCount = 1000;
330
331 // Enable the beta API version
332 bool betaRpcApi = false;
333
334 // First, attempt to load the latest ledger directly from disk.
335 bool fastLoad = false;
336 // When starting xrpld with existing database it do not know it has those
337 // ledgers locally until the server naturally tries to backfill. This makes
338 // is difficult to test some functionality (in particular performance
339 // testing sidechains). With this variable the user is able to force xrpld
340 // to consider the ledger range to be present. It should be used for testing
341 // only.
343
345
346public:
347 Config();
348
364 void
365 setup(std::string const& strConf, bool bQuiet, bool bSilent, bool bStandalone);
366
367 void
368 setupControl(bool bQuiet, bool bSilent, bool bStandalone);
369
375 void
376 loadFromString(std::string const& fileContents);
377
378 [[nodiscard]] bool
379 quiet() const
380 {
381 return quiet_;
382 }
383 [[nodiscard]] bool
384 silent() const
385 {
386 return silent_;
387 }
388 [[nodiscard]] bool
390 {
391 return runStandalone_;
392 }
393
394 [[nodiscard]] bool
396 {
397 return useTxTables_;
398 }
399
400 [[nodiscard]] bool
401 canSign() const
402 {
403 return signingEnabled_;
404 }
405
424 [[nodiscard]] int
425 getValueFor(SizedItem item, std::optional<std::size_t> node = std::nullopt) const;
426
427 [[nodiscard]] beast::Journal
428 journal() const
429 {
430 return j_;
431 }
432};
433
434FeeSetup
435setupFeeVote(Section const& section);
436
437DatabaseCon::Setup
438setupDatabaseCon(Config const& c, std::optional<beast::Journal> j = std::nullopt);
439
440} // 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)
Set up the configuration and determine the config and data directories.
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
constexpr std::uint32_t kDefaultGasLimit
FeeSetup setupFeeVote(Section const &section)
constexpr XRPAmount kDropsPerXrp
Number of drops per 1 XRP.
Definition XRPAmount.h:247
constexpr std::chrono::seconds const kDefaultAmendmentMajorityTime
The minimum amount of time an amendment must hold a majority.
constexpr std::uint32_t kDefaultGasPrice
constexpr std::uint32_t kDefaultBytecodeSizeLimit
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.
std::uint32_t gasPrice
The price of 1 WASM gas, in micro-drops.
std::uint32_t bytecodeSizeLimit
The bytecode size limit for Feature Extensions.
std::uint32_t gasLimit
The gas limit for Feature Extensions.
Reflects the fee settings for a particular ledger.