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

Allow a newly-started validator to participate #2167

Closed
wants to merge 1 commit into from

Conversation

mtrippled
Copy link
Collaborator

in consensus.

Copy link
Collaborator

@bachase bachase left a 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.

@@ -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())
Copy link
Collaborator

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

@@ -1126,6 +1138,7 @@ bool ApplicationImp::setup()
getWalletDB (), "PublisherManifests");

m_networkOPs->setValidationKeys (valSecret, valPublic);
setMaxLedger();
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

std::atomic <std::uint32_t> mValidLedgerSign;
std::atomic <std::uint32_t> mValidLedgerSeq;
std::atomic <std::uint32_t> mBuildingLedgerSeq;
std::atomic <LedgerIndex> mValidLedgerSeq {0};
Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@@ -343,6 +344,8 @@ class LedgerMaster

std::uint32_t fetch_seq_;

LedgerIndex const max_ledger_difference_ {1000000};
Copy link
Collaborator

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?

Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

@@ -937,8 +940,15 @@ class ApplicationImp
std::chrono::seconds {config_->getSize (siSweepInterval)});
}

LedgerIndex getMaxLedger() override
Copy link
Collaborator

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.

Copy link
Contributor

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

Copy link
Collaborator Author

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

@mtrippled mtrippled closed this Jul 11, 2017
@mtrippled mtrippled reopened this Jul 11, 2017
@mtrippled
Copy link
Collaborator Author

@bachase I'll wait for David & Brandon's comments before incorporating the changes you suggested.

@@ -343,6 +344,8 @@ class LedgerMaster

std::uint32_t fetch_seq_;

LedgerIndex const max_ledger_difference_ {1000000};
Copy link
Contributor

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

@@ -937,8 +940,15 @@ class ApplicationImp
std::chrono::seconds {config_->getSize (siSweepInterval)});
}

LedgerIndex getMaxLedger() override
Copy link
Contributor

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

if (!seq)
maxLedger_= 0;
else
maxLedger_ = *seq;
Copy link
Contributor

@wilsonianb wilsonianb Jul 12, 2017

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;

Copy link
Collaborator Author

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"))
Copy link
Contributor

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.

Copy link
Collaborator

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

Copy link
Collaborator

Choose a reason for hiding this comment

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

Copy link
Collaborator Author

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-io
Copy link

codecov-io commented Jul 17, 2017

Codecov Report

Merging #2167 into develop will increase coverage by <.01%.
The diff coverage is 94.44%.

Impacted file tree graph

@@             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
Impacted Files Coverage Δ
src/ripple/app/main/Application.h 100% <ø> (ø) ⬆️
src/ripple/app/ledger/LedgerMaster.h 83.33% <ø> (ø) ⬆️
src/ripple/app/ledger/impl/LedgerMaster.cpp 46.25% <100%> (ø) ⬆️
src/ripple/app/consensus/RCLConsensus.cpp 64.6% <100%> (-0.09%) ⬇️
src/ripple/app/main/Application.cpp 62.4% <92.3%> (+0.49%) ⬆️

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 4308b12...e07fb7f. Read the comment docs.

Copy link
Collaborator

@bachase bachase left a 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;

Copy link
Collaborator

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.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fixed

Copy link
Contributor

@wilsonianb wilsonianb left a comment

Choose a reason for hiding this comment

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

👍 LGTM

@mtrippled mtrippled mentioned this pull request Jul 20, 2017
@mtrippled mtrippled removed the request for review from JoelKatz July 21, 2017 23:37
@mtrippled mtrippled added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label Jul 31, 2017
@seelabs
Copy link
Collaborator

seelabs commented Jul 31, 2017

In 0.80.0-b4

@seelabs seelabs closed this Jul 31, 2017
@mtrippled mtrippled deleted the recover branch October 16, 2017 18:37
@bachase bachase mentioned this pull request Dec 18, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

5 participants