Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cleanup #3326

Closed
wants to merge 7 commits into from
Closed

Cleanup #3326

wants to merge 7 commits into from

Conversation

nbougalis
Copy link
Contributor

@nbougalis nbougalis commented Mar 30, 2020

This PR includes commits that:

  1. address an issue that can occur during the loading of validator tokens, where a deliberately malformed token could cause the server to crash during startup. The issue was identified by @guidovranken.
  2. Cleanup & modernize code, remove obsolete workarounds, code and comments.

@nbougalis nbougalis requested review from HowardHinnant, undertome and a user March 30, 2020 18:46
HowardHinnant
HowardHinnant previously approved these changes Apr 3, 2020
Copy link
Contributor

@HowardHinnant HowardHinnant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left just one nit-picky suggestion in my wake.

@codecov-io
Copy link

codecov-io commented Apr 11, 2020

Codecov Report

Merging #3326 into develop will increase coverage by 0.14%.
The diff coverage is 87.73%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3326      +/-   ##
===========================================
+ Coverage    70.23%   70.38%   +0.14%     
===========================================
  Files          683      682       -1     
  Lines        54630    54449     -181     
===========================================
- Hits         38370    38323      -47     
+ Misses       16260    16126     -134     
Impacted Files Coverage Δ
src/ripple/app/consensus/RCLConsensus.h 80.00% <ø> (ø)
src/ripple/app/ledger/LedgerMaster.h 53.33% <ø> (ø)
src/ripple/app/misc/AmendmentTable.h 100.00% <ø> (ø)
src/ripple/app/misc/FeeVote.h 100.00% <ø> (ø)
src/ripple/app/misc/HashRouter.h 100.00% <ø> (ø)
src/ripple/app/misc/Manifest.h 51.51% <ø> (-1.43%) ⬇️
src/ripple/app/misc/NetworkOPs.h 100.00% <ø> (ø)
src/ripple/app/misc/impl/AmendmentTable.cpp 94.14% <ø> (ø)
src/ripple/basics/Log.h 62.50% <ø> (ø)
src/ripple/beast/clock/basic_seconds_clock.h 100.00% <ø> (ø)
... and 75 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2bf3b19...6c92b82. Read the comment docs.

undertome
undertome previously approved these changes Apr 14, 2020
Copy link
Contributor

@undertome undertome left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good.

{
return { ltCHILD, key };
}

Keylet skip_t::operator()() const
Keylet const& skip() noexcept
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using a static and returning a const& instead of value may be a pessimization because of RVO, it's going to depend on how it's called. If it's used in a function call and bound to a const& paramter (foo(skip())) then this is an optimization. If it's used to initialize a value (auto const a = skip()) then it's a pessimization (there's extra coping because of missed RVO).

I think I'd keep this as Keylet skip() noexcept, but I'm OK if you want to keep the const&. I really just wanted to make sure you knew there was a trade-off here to consider. (same somment for fees as well)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The thing is that these particular keylets are actually constants; they accept no arguments and their value is a fixed part of the protocol and will never change. From that perspective, I think that the return value being a const& is relevant.

However, you raise a good point that it may, actually, result in a pessimization. I'll take a look.

saReceiverLimit,
0,
0,
j);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: formatting

@carlhua carlhua requested a review from seelabs April 21, 2020 21:06
@HowardHinnant HowardHinnant self-requested a review April 23, 2020 20:44
HowardHinnant
HowardHinnant previously approved these changes Apr 23, 2020
seelabs
seelabs previously approved these changes Apr 27, 2020
Copy link
Collaborator

@seelabs seelabs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@carlhua carlhua added Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. and removed Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. labels Apr 28, 2020
@nbougalis
Copy link
Contributor Author

nbougalis commented Apr 29, 2020

I am going to rebase this against #3291, which is rebased against 1.6.0-b4.

@nbougalis nbougalis dismissed stale reviews from seelabs, HowardHinnant, and undertome via da75e5b April 29, 2020 06:23
src/ripple/app/consensus/RCLConsensus.cpp Show resolved Hide resolved
constexpr std::uint32_t vfFullValidation = 0x00000001;

// The signature is fully canonical
constexpr std::uint32_t vfFullyCanonicalSig = 0x80000000;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be have a sense to use prefix 'u' because 0x80000000 is too big?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, I think that's safe, but let me ask the gurus: @HowardHinnant, @scottschurr, any suggestions here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's safe as is, but I like using the u suffix when initializing unsigned. But I also alphabetize my socks. So you can't always go by me. :-)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧦

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤣 All of my socks are identical so I don't have to alphabetize them. I also never need to match them.

src/ripple/app/consensus/RCLConsensus.cpp Show resolved Hide resolved
getEncodedVersion()
{
static std::uint64_t const cookie = []() {
std::uint64_t c = 0x183B000000000000;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May be 'ull' prefix?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@HowardHinnant, @scottschurr, any suggestions here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the ull suffix here. You could try it as a prefix, but I don't think it will compile. :-) That being said, it's optional. Just a readability issue.

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.
Currently there is no mechanism for a validator to report the
version of the software it is currently running. Such reports
can be useful for those who are developing network monitoring
dashboards and server operators in general.

This commit, if merged, defines an encoding scheme to encode
a version string into a 64-bit unsigned integer and adds an
additional optional field to validations.

This commit piggybacks on "HardenedValidations" amendment to
determine whether version information should be propagated
or not.

The general encoding scheme is:

XXXXXXXX-XXXXXXXX-YYYYYYYY-YYYYYYYY-YYYYYYYY-YYYYYYYY-YYYYYYYY-YYYYYYYY

X: 16 bits identifying the particular implementation
Y: 48 bits of data specific to the implementation

The rippled-specific format (implementation ID is: 0x18 0x3B) is:

00011000-00111011-MMMMMMMM-mmmmmmmm-pppppppp-TTNNNNNN-00000000-00000000

    M: 8-bit major version (0-255)
    m: 8-bit minor version (0-255)
    p: 8-bit patch version (0-255)
    T: 11 if neither an RC nor a beta
       10 if an RC
       01 if a beta
    N: 6-bit rc/beta number (1-63)
A deliberately malformed token can cause the server to crash during
startup. This is not remotely exploitable and would require someone
with access to the configuration file of the server to make changes
and then restart the server.

Acknowledgements:
Guido Vranken 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 they may find.

Ripple is generously sponsoring a bug bounty program for the
rippled project. For more information please visit:

    https://ripple.com/bug-bounty
This commit removes obsolete comments, dead or no longer useful
code, and workarounds for several issues that were present in older
compilers that we no longer support.

Specifically:

- It improves the transaction metadata handling class, simplifying
  its use and making it less error-prone.
- It reduces the footprint of the Serializer class by consolidating
  code and leveraging templates.
- It cleanups the ST* class hierarchy, removing dead code, improving
  and consolidating code to reduce complexity and code duplication.
- It shores up the handling of currency codes and the conversation
  between 160-bit currency codes and their string representation.
- It migrates beast::secure_erase to the ripple namespace and uses
  a call to OpenSSL_cleanse instead of the custom implementation.
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.
The built-in watchdog is simplistic and can, sometimes, cause problems
especially on systems that have the ability to automatically start and
monitor processes.

This commit removes the sustain system entirely, changes the handling
of the SIGTERM signal to properly terminate the process and improves
the error message reported to the user when the command line used to
start `rippled` is incorrect and malformed.
@nbougalis nbougalis mentioned this pull request May 3, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants