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

Tune relaying of untrusted proposals & validations: #3391

Closed
wants to merge 10 commits into from
Closed

Tune relaying of untrusted proposals & validations: #3391

wants to merge 10 commits into from

Conversation

nbougalis
Copy link
Contributor

In deciding whether to relay a proposal or validation, a server would consider whether it was issued by a validator on that server's UNL.

While both trusted proposals and validations were always relayed, the code prioritized relaying of untrusted proposals over untrusted validations. While not technically incorrect, validations are generally more "valuable" because they are required during the consensus process, whereas proposals are not, strictly, required.

The commit introduces two new configuration options, allowing server operators to fine-tune the relaying behavior:

The [relay_proposals] option controls the relaying behavior for proposals received by this server. It has two settings: "trusted" and "all" and the default is "trusted".

The [relay_validations] options controls the relaying behavior for validations received by this server. It has two settings: "trusted" and "all" and the default is "all".

This change does not require an amendment as it does not affect transaction processing.

nbougalis added 2 commits May 5, 2020 23:51
The sfLedgerSequence field is designated as optional in the object
template but it is effectively required and validations which do not
include it were, correctly, rejected.

This commit migrates the check outside of the peer code and into the
constructor used for validations being deserialized for the network.

Furthermore, the code will generate an error if a validation that is
generated by a server does not include the field.
In deciding whether to relay a proposal or validation, a server would
consider whether it was issued by a validator on that server's UNL.

While both trusted proposals and validations were always relayed,
the code prioritized relaying of untrusted proposals over untrusted
validations. While not technically incorrect, validations are
generally more "valuable" because they are required during the
consensus process, whereas proposals are not, strictly, required.

The commit introduces two new configuration options, allowing server
operators to fine-tune the relaying behavior:

The `[relay_proposals]` option controls the relaying behavior for
proposals received by this server. It has two settings: "trusted"
and "all" and the default is "trusted".

The `[relay_validations]` options controls the relaying behavior for
validations received by this server. It has two settings: "trusted"
and "all" and the default is "all".

This change does not require an amendment as it does not affect
transaction processing.
@nbougalis nbougalis requested review from pwang200 and gregtatcam May 6, 2020 06:58
@MarkusTeufelberger
Copy link
Collaborator

Proposals are necessary to be able to even do validations though, right?

I would prefer if both untrusted proposals and validations are by default relayed (as it is already the case). If server operators want to limit this for some reason, they now have the option to do so. Otherwise this creates incentives to collaborate more than maybe healthy or necessary with other node operators to even be able to reliably broadcast proposals.

@nbougalis
Copy link
Contributor Author

nbougalis commented May 6, 2020

Proposals are necessary to be able to even do validations though, right?

Even if you never see a single trusted proposal, as long as you see the validation you will continue. Of course, if nobody else sees a trusted proposal either, that's a problem.

I would prefer if both untrusted proposals and validations are by default relayed (as it is already the case).

This is not already the case: currently trusted proposals and validations are always relayed. Untrusted validations are, at present, never relayed and untrusted proposal are only if they're from a cluster peer or they're proposals on top of the last ledger we consider part of the consensus set. The not relaying untrusted validations but relaying some untrusted proposals is topsy-turvy. Again, validations are more important than proposals.

With that said, I do see your point (even if I don't entirely agree with it) and we can certainly make the default for proposals be all instead of trusted.

At some point, we ought to try and use a slot-based relay mechanism anyways.

src/ripple/protocol/STValidation.h Outdated Show resolved Hide resolved
src/ripple/overlay/impl/PeerImp.cpp Show resolved Hide resolved
src/ripple/app/consensus/RCLValidations.cpp Outdated Show resolved Hide resolved
src/ripple/app/consensus/RCLValidations.cpp Show resolved Hide resolved
src/ripple/app/consensus/RCLValidations.cpp Outdated Show resolved Hide resolved
src/ripple/app/consensus/RCLConsensus.cpp Outdated Show resolved Hide resolved
src/ripple/app/misc/NetworkOPs.cpp Outdated Show resolved Hide resolved
gregtatcam
gregtatcam previously approved these changes May 6, 2020
@codecov-io
Copy link

codecov-io commented May 6, 2020

Codecov Report

Merging #3391 into develop will increase coverage by 0.01%.
The diff coverage is 38.88%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #3391      +/-   ##
===========================================
+ Coverage    70.44%   70.46%   +0.01%     
===========================================
  Files          682      682              
  Lines        54392    54387       -5     
===========================================
+ Hits         38315    38322       +7     
+ Misses       16077    16065      -12     
Impacted Files Coverage Δ
src/ripple/app/consensus/RCLValidations.h 80.00% <ø> (ø)
src/ripple/app/misc/NetworkOPs.cpp 63.92% <0.00%> (+0.08%) ⬆️
src/ripple/app/misc/NetworkOPs.h 100.00% <ø> (ø)
src/ripple/core/Config.h 100.00% <ø> (ø)
src/ripple/core/ConfigSections.h 100.00% <ø> (ø)
src/ripple/overlay/Overlay.h 88.88% <ø> (ø)
src/ripple/overlay/impl/OverlayImpl.h 32.39% <ø> (ø)
src/ripple/overlay/impl/PeerImp.cpp 0.00% <0.00%> (ø)
src/ripple/protocol/impl/STValidation.cpp 82.35% <ø> (+20.58%) ⬆️
src/ripple/core/impl/Config.cpp 65.62% <16.66%> (-2.13%) ⬇️
... and 8 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 9771210...f6c4a58. Read the comment docs.

Copy link
Contributor

@pwang200 pwang200 left a comment

Choose a reason for hiding this comment

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

Looks great and easy to follow. I only have a couple minor comments.

sfLedgerSequence is still marked as soeOPTIONAL in STValidation::validationFormat, but is required now. The reason is we don't want to change the API of RPC etc, right? Maybe add a comment in STValidation::validationFormat to explain?

src/ripple/overlay/impl/PeerImp.cpp Show resolved Hide resolved
cfg/rippled-example.cfg Outdated Show resolved Hide resolved
@nbougalis
Copy link
Contributor Author

@pwang200:

sfLedgerSequence is still marked as soeOPTIONAL in STValidation::validationFormat, but is required now. The reason is we don't want to change the API of RPC etc, right? Maybe add a comment in STValidation::validationFormat to explain?

I don't think there's any reason to not change it to soeREQUIRED. I'll double-check and do that.

@pwang200
Copy link
Contributor

pwang200 commented May 6, 2020

Right, changing from optional to required is not a breaking change.

@nbougalis
Copy link
Contributor Author

@pwang200: addressed the typo and marked the sfLedgerSequence field as required in validations. Courtesy unit test included.

pwang200
pwang200 previously approved these changes May 7, 2020
Copy link
Contributor

@pwang200 pwang200 left a comment

Choose a reason for hiding this comment

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

Looks great!

gregtatcam
gregtatcam previously approved these changes May 7, 2020
@nbougalis nbougalis dismissed stale reviews from gregtatcam and pwang200 via 64300db May 7, 2020 21:48
@nbougalis nbougalis added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label May 9, 2020
This was referenced May 21, 2020
@@ -136,6 +136,8 @@ class Config : public BasicConfig
std::size_t NETWORK_QUORUM = 1;

// Peer networking parameters
bool RELAY_UNTRUSTED_VALIDATIONS = true;
bool RELAY_UNTRUSTED_PROPOSALS = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
bool RELAY_UNTRUSTED_PROPOSALS = false;
bool RELAY_UNTRUSTED_PROPOSALS = true;

@manojsdoshi manojsdoshi mentioned this pull request May 27, 2020
@carlhua carlhua added the Documentation README changes, code comments, etc. label Jul 27, 2020
@nbougalis nbougalis deleted the relay branch October 16, 2023 06:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation README changes, code comments, etc. Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants