Commit Graph

229 Commits

Author SHA1 Message Date
John Freeman
5b5226d518 Cleanup the 'PeerSet' hierarchy:
This commit introduces no functional changes but cleans up the
code and shrinks the surface area by removing dead and unused
code, leveraging std:: alternatives to hand-rolled code and
improving comments and documentation.
2020-05-05 16:05:23 -07:00
Nik Bougalis
74f9edef07 Prefer keylets instead of naked hashes:
Entries in the ledger are located using 256-bit locators. The locators
are calculated using a wide range of parameters specific to the entry
whose locator we are calculating (e.g. an account's locator is derived
from the account's address, whereas the locator for an offer is derived
from the account and the offer sequence.)

Keylets enhance type safety during lookup and make the code more robust,
so this commit removes most of the earlier code, which used naked
uint256 values.
2020-05-05 16:05:22 -07:00
Nik Bougalis
381606aba2 Harden validations:
This commit introduces the "HardenedValidations" amendment which,
if enabled, allows validators to include additional information in
their validations that can increase the robustness of consensus.

Specifically, the commit introduces a new optional field that can
be set in validation messages can be used to attest to the hash of
the latest ledger that a validator considers to be fully validated.

Additionally, the commit leverages the previously introduced "cookie"
field to improve the robustness of the network by making it possible
for servers to automatically detect accidental misconfiguration which
results in two or more validators using the same validation key.
2020-05-01 12:55:11 -07:00
Pretty Printer
50760c6935 Format first-party source according to .clang-format 2020-04-23 10:02:04 -07:00
Howard Hinnant
f22fcb3b2a Rename canonicalize into two functions:
* canonicalize_replace_cache
* canonicalize_replace_client

Now it is clear at the call site that if there are
duplicate copies of the data between the cache and
the caller, which copy gets replaced.

Additionally data parameter is now const-correct.
If it is not going to be replaced (canonicalize_replace_cache),
then the shared_ptr to the client data is const.
2020-04-07 16:25:09 -07:00
CJ Cobb
2a2ad898b1 Set applied field to true even if engine result is not tesSUCCESS 2020-03-10 16:07:10 -07:00
CJ Cobb
e7ce3909d2 gRPC support for account_tx and tx
- Add support for all transaction types and ledger object types to gRPC
  implementation of tx and account_tx.

- Create common handlers for tx and account_tx.

- Remove mutex and abort() from gRPC server. JobQueue is stopped before
  gRPC server, with all coroutines executed to completion, so no need for
  synchronization.
2020-02-25 19:21:55 -08:00
Edward Hennis
5ff23f8f31 Warn operators about upcoming unknown amendments:
* When an unknown amendment reaches majority, log an error-level
  message, and return a `warnings` array on all successful
  admin-level RPC calls to `server_info` and `server_state` with
  a message describing the problem, and the expected deadline.
* In addition to the `amendment_blocked` flag returned by
  `server_info` and `server_state`, return a warning with a more
  verbose description when the server is amendment blocked.
* Check on every flag ledger to see if the amendment(s) lose majority.
  Logs again if they don't, resumes normal operations if they did.

The intention is to give operators earlier warning that their
instances are in danger of being amendment blocked, which will
hopefully motivate them to update ahead of time.
2020-02-12 10:19:23 -08:00
mbhandary
facb627786 Improve reporting of StateAccounting metrics:
* Metrics are now exported over insight.
* Fixes a minor bug that affected the reporting of gauges
2020-02-12 10:19:23 -08:00
Devon White
cd9732b47a Change how fail_hard transactions are handled.
FIXES: #2847

* Transactions that are submitted with the fail_hard flag
  and that result in any TER code besides tesSUCCESS shall
  be neither queued nor held.

[FOLD] Keep tec results out of the open ledger when fail_hard:

* Improve TransactionStatus const correctness, and remove redundant
  `local` check
* Check open ledger tx count in fail_hard tests
* Fix some wrapping
* Remove duplicate test
2020-01-10 12:40:31 -08:00
Edward Hennis
e3b5b808c5 Add units to all fee calculations:
* Uses existing XRPAmount with units for drops, and a new TaggedFee for
  fee units (LoadFeeTrack), and fee levels (TxQ).
* Resolves #2451
2020-01-08 18:44:01 -05:00
p2peer
79e9085dd1 Augment "submit" command response:
If merged, this commit will report additional information in the
response to the submit command; this will make it easier for developers
to accurately track the status of transaction submission.

Fixes #2851
2020-01-01 18:12:38 -08:00
Nik Bougalis
607328e1a0 Improve the 'network_id' configuration option:
The 'network_id' option allows an administrator to specify to which
network they intend a server to connect. Servers can leverage this
information to optimize routing and prune automatically discovered
cross-network connections.

This commit will, if merged:

- add support for the devnet keyword, which corresponds to network ID #2;
- report the network ID, if one is configured, in server_info
2019-12-30 20:20:34 -08:00
Nik Bougalis
63503ee8f0 Improve platform detection and reduce includes:
The existing platform detection code was derived from the old Beast
library, which was, itself, derived from JUCE.

This commit removes that code and replaces it with the Boost.Predef
library which defines a consistent set of compiler, architecture,
operating system, library, and other version numbers.

For more on Boost.Predef, please see the Boost documentation. The
documentation for the current version as of this writing is at:
https://www.boost.org/doc/libs/1_71_0/doc/html/predef.html
2019-12-30 20:20:31 -08:00
Mo Morsi
15c5f9c111 Report consensus phase changes in the server subscription stream 2019-10-30 12:23:57 -07:00
Devon White
9196d9541a Include validator's master public key in validation stream:
The validation stream only reported the ephemeral signing key for validators
which use manifests. This made tracking unnecessarily difficult for clients
processing the data stream.

With this change, the validator's long-term master public key is also
included.

This commit fixes #3005

* Provide proposing validator's master key in the validation stream
  subscription JSON responses.

Implement code review changes.

FIXES: #3005
2019-10-15 12:01:37 -07:00
Mark Travis
e5b61c9ac9 Update operating mode upon network disagreement. 2019-09-07 11:44:00 -07:00
seelabs
7912ee6f7b Use structured bindings in some places:
Most of the new uses either:
* Replace some uses of `tie`
* bind to pairs when iterating through maps
2019-08-23 11:33:59 -07:00
seelabs
5d1728cc96 Use class template argument deduction for locks 2019-08-23 08:47:43 -07:00
Mo Morsi
1942fee581 Modernize code and clean up out-of-date or obsolete comments:
- Remove references to nodestore ledger index. This was removed
  in f946d7b447.
2019-08-19 06:58:50 -07:00
seelabs
6d8988b78a Improve handling of revoked manifests:
Manifests which are revoked can include ephemeral keys although doing
so does not make sense: a revoked manifest isn't used for signing and
so don't need to define an ephemeral key.
2019-07-09 13:38:59 -07:00
Mo Morsi
f8365f5009 Add JsonOptions enum class to contain options passed to getJSON methods 2019-06-13 20:40:33 -07:00
Howard Hinnant
595b7b194c Improve locking:
- Use `std::lock` when grabbing multiple mutexes to ensure consistent
locking order and avoid deadlocks.
- Reduce the scope of the master mutex lock by relesing it prior to
calling setHeartbeatTimer
2019-05-22 13:15:43 -07:00
seelabs
c5d215d901 Add delivered amount to the ledger RPC command 2019-02-25 13:01:12 -08:00
Nik Bougalis
2529edd2b6 Properly transition state to disconnected:
If the number of peers a server has is below the configured
minimum peer limit, this commit will properly transition the
server's state to "disconnected".

The default limit for the minimum number of peers required was
0 meaning that a server that was connected but lost all its
peers would never transition to disconnected, since it could
never drop below zero peers.

This commit redefines the default minimum number of peers to 1
and produces a warning if the server is configured in a way
that will prevent it from ever achieving sufficient connectivity.
2019-02-25 12:59:35 -08:00
Nik Bougalis
c6ab880c03 Display validator status only to admin requests:
Several commands allow a user to retrieve a server's status. Commands
will typically limit disclosure of information that can reveal that a
particular server is a validator to connections that are not verified
to make it more difficult to determine validators via fingerprinting.

Prior to this commit, servers configured to operate as validators
would, instead of simply reporting their server state as 'full',
augment their state information to indicate whether they are
'proposing' or 'validating'.

Servers will only provide this enhanced state information for
connections that have elevated privileges.

Acknowledgements:
Ripple thanks Markus Teufelberger for responsibly disclosing this issue.

Bug Bounties and Responsible Disclosures:
We welcome reviews of the rippled code and urge researchers to responsibly
disclose any issues that they may find. For more on Ripple's Bug Bounty
program, please visit: https://ripple.com/bug-bounty
2019-02-25 12:59:31 -08:00
Howard Hinnant
148bbf4e8f Add safe_cast (RIPD-1702):
This change ensures that no overflow can occur when casting
between enums and integral types.
2019-01-18 12:13:21 -08:00
Mark Travis
fbdbffed67 Report duration in current state. 2018-11-25 17:37:31 -08:00
JoelKatz
be70d81bd7 Perform some extra checks on ledger changes
Perform some extra checks on the close time and sequence number
of a candidate for network consensus ledger. This tightens
defenses against some "insane/hostile supermajority" attacks.
2018-11-09 07:40:41 -08:00
Edward Hennis
58f786cbb4 Make the FeeEscalation amendment permanent (RIPD-1654):
The FeeEscalation amendment has been enabled on the XRP Ledger network
since May 19, 2016. The transaction which activated this amendment is:
5B1F1E8E791A9C243DD728680F108FEF1F28F21BA3B202B8F66E7833CA71D3C3.

This change removes all conditional code based around the FeeEscalation
amendment, but leaves the amendment definition itself since removing the
definition would cause nodes to think an unknown amendment was activate
causing them to become amendment blocked.

The commit also removes the redundant precomputed hashes from the
supportedAmendments vector.
2018-11-06 10:26:29 -08:00
Nik Bougalis
b36e11bc49 Properly handle expired validator lists when validating (RIPD-1661):
A validator that was configured to use a published validator list could
exhibit aberrent behavior if that validator list expired.

This commit introduces additional logic that makes validators operating
with an expired validator list bow out of the consensus process instead
of continuing to publish validations. Normal operation will resume once
a non-expired validator list becomes available.

This commit also enhances status reporting when using the `server_info`
and `validators` commands. Before, only the expiration time of the list
would be returned; now, its current status is also reported in a format
that is clearer.
2018-10-19 12:15:36 -07:00
Edward Hennis
e14f913244 Update TxQ developer docs:
* Rename a couple of member variables for clarity.
2018-10-01 11:26:22 -07:00
wilsonianb
8c14002c25 Do not use beast base64 encoding without fix:
Boost 1.67 and 1.68 are missing this fix
0439dcfa7a
2018-08-21 10:05:45 -05:00
Scott Schurr
2901577be7 Remove using namespace declarations at namespace scope in headers 2018-08-08 21:07:54 -04:00
Howard Hinnant
d98c4992dd Supply ConsensusTimer with milliseconds or finer precision 2018-07-20 08:58:04 -07:00
Joe Loser
70d9d88cda Remove using namespace beast in base_uint.h 2018-07-20 08:58:04 -07:00
Edward Hennis
16b9bbb517 Retried transactions that tec move from TxQ to open ledger:
* Unit test of tec code handling.
* Extra TxQ debug logging
2018-06-25 13:52:16 -07:00
Joe Loser
57ab0a00b5 Rename member function in NetworkOPs.h 2018-06-01 13:29:52 -04:00
seelabs
27703859e7 Convert code to use boost::beast 2018-05-15 16:58:30 -04:00
Howard Hinnant
7d163a45dc Replace UptimeTimer with UptimeClock
* UptimeClock is a chrono-compatible seconds-precision clock.

* Like UptimeTimer, its purpose is to make it possible for clients
  to query the uptime thousands of times per second without a
  significant performance hit.

* UptimeClock decouples itself from LoadManager by managing its
  own once-per-second update loop.

* Clients now traffic in chrono time_points and durations instead
  of int.
2018-05-15 09:56:47 -04:00
Brad Chase
681df58b61 Refactor ledger replay logic (RIPD-1547):
Also switch to use ReadView for TxQ updates.
2018-05-15 09:54:00 -04:00
Mark Travis
8eb8c77886 Performance logging and counters:
* Tally and duration counters for Job Queue tasks and RPC calls
    optionally rendered by server_info and server_state, and
    optionally printed to a distinct log file.
    - Tally each Job Queue task as it is queued, starts, and
      finishes running. Track total duration queued and running.
    - Tally each RPC call as it starts and either finishes
      successfully or throws an exception. Track total running
      duration for each.
  * Track currently executing Job Queue tasks and RPC methods
    along with durations.
  * Json-formatted performance log file written by a dedicated
    thread, for above-described data.
  * New optional parameter, "counters", for server_info and
    server_state. If set, render Job Queue and RPC call counters
    as well as currently executing tasks.
  * New configuration section, "[perf]", to optionally control
    performance logging to a file.
  * Support optional sub-second periods when rendering human-readable
    time points.
2018-04-08 02:24:38 -07:00
Mike Ellery
deb9e4ce3c Remove BeastConfig.h (RIPD-1167) 2018-04-08 01:52:12 -07:00
Howard Hinnant
db3b4dd396 Prevent accidental aggregates
*  The compiler can provide many non-explicit constructors for
   aggregate types.  This is sometimes desired, but it can
   happen accidentally, resulting in run-time errors.

*  This commit assures that no types are aggregates unless existing
   code is using aggregate initialization.
2018-04-08 01:52:11 -07:00
Nikolaos D. Bougalis
2b8893dfca Merge master (0.90.1) into develop (1.0.0-b2):
The merge also updates the RELEASENOTES.md with the release
notes for the 0.90.1 which were accidentally not included
in that release.
2018-03-24 12:51:23 -07:00
Nikolaos D. Bougalis
d5f981f5fc Address issues identified by external review:
* RIPD-1617, RIPD-1619, RIPD-1621:
  Verify serialized public keys more strictly before
  using them.

* RIPD-1618:
    * Simplify the base58 decoder logic.
    * Reduce the complexity of the base58 encoder and
      eliminate a potential out-of-bounds memory access.
    * Improve type safety by using an `enum class` to
      enforce strict type checking for token types.

* RIPD-1616:
  Avoid calling `memcpy` with a null pointer even if the
  size is specified as zero, since it results in undefined
  behavior.

Acknowledgements:
Ripple thanks Guido Vranken for responsibly disclosing these
issues.

Bug Bounties and Responsible Disclosures:
We welcome reviews of the rippled code and urge researchers
to responsibly disclose any issues that they may find. For
more on Ripple's Bug Bounty program, please visit:
https://ripple.com/bug-bounty
2018-03-21 20:39:18 -07:00
Mike Ellery
deef322b07 Remove outputDebugString, replace getComputerName 2018-03-15 14:19:29 -04:00
Brad Chase
20defb4844 Update validations on UNL change (RIPD-1566):
Change the trust status of existing validations based when nodes are
added or removed from the UNL.
2018-03-01 13:27:28 -08:00
seelabs
9a210cfda5 Revert "Convert code to use boost::beast"
This reverts commit cc9c976b76.
2018-02-12 11:55:59 -05:00
Brad Chase
94c6a2a850 Use LedgerTrie for preferred ledger (RIPD-1551):
These changes augment the Validations class with a LedgerTrie to better
track the history of support for validated ledgers. This improves the
selection of the preferred working ledger for consensus. The Validations
class now tracks both full and partial validations. Partial validations
are only used to determine the working ledger; full validations are
required for any quorum related function. Validators are also now
explicitly restricted to sending validations with increasing ledger
sequence number.
2018-02-02 20:38:38 -05:00