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

Expose consensus parameters for simulation (RIPD-1355) #2094

Closed
wants to merge 1 commit into from

Conversation

bachase
Copy link
Collaborator

@bachase bachase commented Apr 25, 2017

In order to use the consensus simulation framework, we need the ability to change consensus parameters.

@@ -206,12 +206,12 @@ class ValidationsImp : public Validations

auto const now = app_.timeKeeper().closeTime();
auto const signTime = val->getSignTime();

auto const p = ConsensusParms{};
Copy link
Collaborator Author

@bachase bachase Apr 25, 2017

Choose a reason for hiding this comment

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

The changes in this file will be replaced by #2084

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 not sure how p will look in the replacement, but here it could be made constexpr instead of const, assuming VS will swallow that. Doing so will ensure these constants are compile-time initialized, and will therefore be a little more efficient at run time.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It won't be compile time constant there. Instead Validations has its own parameters that it takes in its constructor which will allow simulations to vary those values too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok.

@param j The journal to log debug output
*/
Consensus(clock_type const& clock, beast::Journal j);
Consensus(clock_type const& clock, ConsensusParms p, beast::Journal j);
Copy link
Contributor

Choose a reason for hiding this comment

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

This will be more efficient if you pass by ConsensusParms const& p.

// Vary the time it takes to process validations to exercise detecting
// the wrong LCL at different phases of consensus
for (auto validationDelay : {0s, LEDGER_MIN_CLOSE})
for (auto validationDelay : {milliseconds{0}, parms.ledgerMIN_CLOSE})
Copy link
Contributor

Choose a reason for hiding this comment

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

Nitpick: or 0ms?

@@ -202,7 +202,7 @@ struct Peer : public Consensus<Peer, Traits>
[ this, ledgerHash, ledger = it->second ]() {
ledgers.emplace(ledgerHash, ledger);
});
if (missingLedgerDelay == 0ms)
if (missingLedgerDelay == std::chrono::milliseconds{0})
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not prefer the 0ms syntax?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No good reason and I can't recall why I switched it. I'll switch back to 0ms.

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.

Looks very good to me. I just left a couple of nitpicky (and optional) comments.

@codecov-io
Copy link

codecov-io commented Apr 26, 2017

Codecov Report

Merging #2094 into develop will decrease coverage by <.01%.
The diff coverage is 97.67%.

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2094      +/-   ##
===========================================
- Coverage    68.98%   68.97%   -0.01%     
===========================================
  Files          684      684              
  Lines        50394    50400       +6     
===========================================
+ Hits         34764    34765       +1     
- Misses       15630    15635       +5
Impacted Files Coverage Δ
src/ripple/app/consensus/RCLConsensus.cpp 63.09% <ø> (ø) ⬆️
src/ripple/consensus/LedgerTiming.h 95.83% <ø> (ø) ⬆️
src/ripple/app/misc/NetworkOPs.cpp 58.7% <0%> (ø) ⬆️
src/ripple/app/misc/Validations.cpp 59.68% <100%> (+0.15%) ⬆️
src/ripple/consensus/DisputedTx.h 81.94% <100%> (ø) ⬆️
src/ripple/consensus/Consensus.h 85.16% <100%> (+0.06%) ⬆️
src/ripple/consensus/Consensus.cpp 82.69% <100%> (ø)
src/ripple/basics/DecayingSample.h 77.77% <0%> (-8.34%) ⬇️
src/ripple/server/impl/BaseWSPeer.h 67.5% <0%> (-0.63%) ⬇️
src/ripple/app/main/Application.cpp 60.82% <0%> (-0.13%) ⬇️

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 24e1b99...7e34fa3. Read the comment docs.

@HowardHinnant
Copy link
Contributor

Latest update tests good for me. 👍

@bachase bachase requested review from mellery451 and removed request for miguelportilla May 2, 2017 14:49
@bachase bachase assigned mellery451 and unassigned miguelportilla May 2, 2017
@bachase
Copy link
Collaborator Author

bachase commented May 2, 2017

@miguelportilla looks to have quite a few review requests on his plate, so thought @mellery451 could be the next victim volunteer.

Copy link
Contributor

@mellery451 mellery451 left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -98,7 +102,7 @@ checkConsensusReached(std::size_t agreeing, std::size_t total, bool count_self)

int currentPercentage = (agreeing * 100) / total;
Copy link
Contributor

Choose a reason for hiding this comment

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

minor: I wonder if currentPercentage should be declared auto here so the types match.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good idea. This was actually a torn refactor--parms.minCONSENSUS_PCT is an int, but I'm using std::size_t everywhere else. I'll fix.

std::size_t agreeing,
std::size_t total,
bool count_self,
std::size_t minConsensusPct)
Copy link
Contributor

Choose a reason for hiding this comment

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

just so I understand - what's the motivation for passing minConsensusPct directly and not the parms object like you do in other places?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Just to keep things narrow since this function only needs the one parameter.

@bachase bachase added the Passed Passed code review & PR owner thinks it's ready to merge. Perf sign-off may still be required. label May 4, 2017
@bachase bachase force-pushed the consensus-parms branch from 685530a to 7e34fa3 Compare May 18, 2017 13:15
@bachase
Copy link
Collaborator Author

bachase commented May 18, 2017

Squashed and rebased on 0.70.0-b6

@bachase bachase added Rebase 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 Jun 2, 2017
@bachase
Copy link
Collaborator Author

bachase commented Jun 14, 2017

Rebased and moved to #2084 since there are merge conflicts.

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