-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Allow a newly-started validator to participate #2167
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes all look good. Left some style nits. https://github.com/bachase/rippled/commits/bc-recover has version rebased on the proposed 0.80.0-b1 and another commit with the style changes (feel free to ignore them).
Additionally, the commit message is formatted oddly in github; I believe we shoot for 80 character width.
It would be nice to write a unit test for these changes, but I don't see a nice way with the current framework.
src/ripple/app/misc/Validations.cpp
Outdated
@@ -87,6 +87,16 @@ class ValidationsImp : public Validations | |||
private: | |||
bool addValidation (STValidation::ref val, std::string const& source) override | |||
{ | |||
if (val->getFieldU32 (sfLedgerSequence) <= app_.getMaxLedger()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Heads up that this will need to go to RCLValidations.cpp
after rebasing on 0.80.0-b1
src/ripple/app/main/Application.cpp
Outdated
@@ -1126,6 +1138,7 @@ bool ApplicationImp::setup() | |||
getWalletDB (), "PublisherManifests"); | |||
|
|||
m_networkOPs->setValidationKeys (valSecret, valPublic); | |||
setMaxLedger(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider just inlining to the call site since it isn't reused.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd rather keep this broken out as a separate function because the calling function is so big already.
src/ripple/app/ledger/LedgerMaster.h
Outdated
std::atomic <std::uint32_t> mValidLedgerSign; | ||
std::atomic <std::uint32_t> mValidLedgerSeq; | ||
std::atomic <std::uint32_t> mBuildingLedgerSeq; | ||
std::atomic <LedgerIndex> mValidLedgerSeq {0}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like this is initialized in the constructor already (https://github.com/ripple/rippled/blob/develop/src/ripple/app/ledger/impl/LedgerMaster.cpp#L83). I actually prefer the inline initialization you have here. Consider treating the other atomics the same way.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/ripple/app/ledger/LedgerMaster.h
Outdated
@@ -343,6 +344,8 @@ class LedgerMaster | |||
|
|||
std::uint32_t fetch_seq_; | |||
|
|||
LedgerIndex const max_ledger_difference_ {1000000}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment on the purpose?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like an explanation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
src/ripple/app/main/Application.cpp
Outdated
@@ -937,8 +940,15 @@ class ApplicationImp | |||
std::chrono::seconds {config_->getSize (siSweepInterval)}); | |||
} | |||
|
|||
LedgerIndex getMaxLedger() override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this is only the maximum ledger persisted during the last run of the program and is not updated once we start running, consider renaming to getMinAllowedLedger
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also in favor of a rename
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed. It's not minAllowed, it's minAllowed - 1 which doesn't flow off the tongue nicely. So I made it maxDisallowedLedger
@bachase I'll wait for David & Brandon's comments before incorporating the changes you suggested. |
src/ripple/app/ledger/LedgerMaster.h
Outdated
@@ -343,6 +344,8 @@ class LedgerMaster | |||
|
|||
std::uint32_t fetch_seq_; | |||
|
|||
LedgerIndex const max_ledger_difference_ {1000000}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd also like an explanation
src/ripple/app/main/Application.cpp
Outdated
@@ -937,8 +940,15 @@ class ApplicationImp | |||
std::chrono::seconds {config_->getSize (siSweepInterval)}); | |||
} | |||
|
|||
LedgerIndex getMaxLedger() override |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm also in favor of a rename
src/ripple/app/main/Application.cpp
Outdated
if (!seq) | ||
maxLedger_= 0; | ||
else | ||
maxLedger_ = *seq; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maxLedger_
is already initialized to 0, so do we need the else
? setMaxLedger
is currently only being a called once, but even if we added subsequent calls, it might make sense to leave maxLedger_
with its previous value if we can't look it up.
Otherwise, this could be
maxLedger_ = seq ? *seq : 0;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -843,7 +843,8 @@ RCLConsensus::validate(RCLCxLedger const& ledger, bool proposing) | |||
v->setTrusted(); | |||
// suppress it if we receive it - FIXME: wrong suppression | |||
app_.getHashRouter().addSuppression(signingHash); | |||
app_.getValidations().addValidation(v, "local"); | |||
if (! app_.getValidations().addValidation(v, "local")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if we can move the getMaxLedger
check to earlier in this function. It seems like we only need to be checking our own validations, not all received validations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you suggesting we only need to prevent ourselves from issuing the in the past validations, since that would usually prevent receiving them from others? If so, I like the idea. You could eliminate the check inside addValidation
and instead just check when considering whether to validate the consensus ledger https://github.com/mtrippled/rippled/blob/22536534936b9508f8b4dfc54d5abae869579e8e/src/ripple/app/consensus/RCLConsensus.cpp#L438
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or even simpler, just make it the condition for validating when you start the round https://github.com/mtrippled/rippled/blob/22536534936b9508f8b4dfc54d5abae869579e8e/src/ripple/app/consensus/RCLConsensus.cpp#L917
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed: it's now just part of the condition to be a validator.
Codecov Report
@@ Coverage Diff @@
## develop #2167 +/- ##
===========================================
+ Coverage 69.87% 69.87% +<.01%
===========================================
Files 689 689
Lines 50587 50599 +12
===========================================
+ Hits 35347 35358 +11
- Misses 15240 15241 +1
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One last nit but otherwise 👍
@@ -171,6 +172,8 @@ class Application : public beast::PropertyStream::Source | |||
|
|||
/** Retrieve the "wallet database" */ | |||
virtual DatabaseCon& getWalletDB () = 0; | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider documenting getMaxDisallowedLedger
since it is public.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 LGTM
In 0.80.0-b4 |
in consensus.