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

Prefer ledger by branch #2300

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
36de9a2
[FOLD] Prepare preferred ledger by branch test:
bachase Dec 7, 2017
5e35cf9
[FOLD] Add LedgerTrie and tests
bachase Dec 7, 2017
72e7ac9
[FOLD] Switch to Adaptor design in Validations:
bachase Dec 15, 2017
0685beb
[FOLD] Add full/partial to validation type
bachase Dec 15, 2017
62a9c73
[FOLD] Simplify Validations test harness:
bachase Dec 15, 2017
892caad
[FOLD] Hoist and rename AddOutcome to ValStatus
bachase Dec 15, 2017
085e400
[FOLD] Make lock use explicit
bachase Dec 15, 2017
2abf766
[FOLD] Require full validations for trusted calculations
bachase Dec 15, 2017
f4c8644
[FOLD] Simplify Validations::add:
bachase Dec 15, 2017
9187516
[FOLD] Require increasing full validation sequence numbers:
bachase Dec 15, 2017
6d3c2e0
[FOLD] Use Ledgers in Validations_test:
bachase Dec 15, 2017
fa1a96e
[FOLD] Add RCLValidatedLedger:
bachase Dec 15, 2017
bd2b860
[FOLD] Don't save partial validations to database
bachase Dec 15, 2017
f0e6efd
[FOLD] Use LedgerTrie in generic validations:
bachase Dec 15, 2017
c614718
[FOLD] Use trie in generic Consensus:
bachase Dec 15, 2017
8315578
Use LedgerTrie for preferred ledger (RIPD-1551):
bachase Dec 15, 2017
b5f528a
[FOLD] Update docs
bachase Dec 15, 2017
fa576e5
[FOLD] Remove old validation code
bachase Dec 15, 2017
9501278
[FOLD] Fix misspellings
seelabs Dec 15, 2017
329ca88
[FOLD] Fix clang PeerGroup warnings
bachase Dec 18, 2017
ad35ee2
[FOLD] Address PR suggestions
bachase Dec 20, 2017
cff3191
[FOLD] Make a few memer functions const
HowardHinnant Dec 21, 2017
f9de5be
[FOLD] Change full validation sequence number invariant:
bachase Dec 21, 2017
fd58f28
[FOLD] Address PR comments
bachase Dec 27, 2017
2b2ba69
[FOLD] Explicitly initialize zero IDs
bachase Dec 28, 2017
0b58ac4
[FOLD] Address PR comments:
bachase Jan 8, 2018
7cdd0e7
[FOLD] Move support classes to namespace
bachase Jan 8, 2018
961747f
[FOLD] Fix assert
bachase Jan 8, 2018
37c583d
[FOLD] Enforce increasing sequence invariant on all validations:
bachase Jan 19, 2018
b6e19b7
[FOLD] Use uncommitted support in preferred branch:
bachase Jan 24, 2018
0ccf0a8
[FOLD] Reduce log warnings:
bachase Jan 25, 2018
277134b
[FOLD] Address PR comments
bachase Jan 26, 2018
83d5d55
[FOLD] Fix typos
bachase Jan 31, 2018
944527d
[FOLD] Only acquire ledgers we are not yet acquiring
bachase Jan 31, 2018
ea18089
[FOLD] Add SpanTip:
bachase Jan 31, 2018
2a97f83
[FOLD] Address PR comments
bachase Feb 2, 2018
5fd14de
[FOLD] Track seq and ID in acquiring ledgers
bachase Feb 3, 2018
f0bdfe1
[FOLD] Fallback to acquiring ledgers:
bachase Feb 3, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Builds/VisualStudio2015/RippleD.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1634,6 +1634,8 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\LedgerTiming.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\LedgerTrie.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\Validations.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\core\ClosureCounter.h">
Expand Down Expand Up @@ -4501,6 +4503,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\app\RCLValidations_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\app\Regression_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
Expand Down Expand Up @@ -4685,6 +4691,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\LedgerTrie_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\ScaleFreeSim_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
Expand Down
9 changes: 9 additions & 0 deletions Builds/VisualStudio2015/RippleD.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -2151,6 +2151,9 @@
<ClInclude Include="..\..\src\ripple\consensus\LedgerTiming.h">
<Filter>ripple\consensus</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\LedgerTrie.h">
<Filter>ripple\consensus</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\Validations.h">
<Filter>ripple\consensus</Filter>
</ClInclude>
Expand Down Expand Up @@ -5268,6 +5271,9 @@
<ClCompile Include="..\..\src\test\app\PseudoTx_test.cpp">
<Filter>test\app</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\app\RCLValidations_test.cpp">
<Filter>test\app</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\app\Regression_test.cpp">
<Filter>test\app</Filter>
</ClCompile>
Expand Down Expand Up @@ -5406,6 +5412,9 @@
<ClCompile Include="..\..\src\test\consensus\LedgerTiming_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\LedgerTrie_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\ScaleFreeSim_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
Expand Down
1 change: 1 addition & 0 deletions docs/source.dox
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ INPUT = \
../src/ripple/consensus/ConsensusTypes.h \
../src/ripple/consensus/DisputedTx.h \
../src/ripple/consensus/LedgerTiming.h \
../src/ripple/consensus/LedgerTrie.h \
../src/ripple/consensus/Validations.h \
../src/ripple/consensus/ConsensusParms.h \
../src/ripple/app/consensus/RCLCxTx.h \
Expand Down
38 changes: 17 additions & 21 deletions src/ripple/app/consensus/RCLConsensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,13 @@ RCLConsensus::Adaptor::proposersValidated(LedgerHash const& h) const
}

std::size_t
RCLConsensus::Adaptor::proposersFinished(LedgerHash const& h) const
RCLConsensus::Adaptor::proposersFinished(
RCLCxLedger const& ledger,
LedgerHash const& h) const
{
return app_.getValidations().getNodesAfter(h);
RCLValidations& vals = app_.getValidations();
return vals.getNodesAfter(
RCLValidatedLedger(ledger.ledger_, vals.adaptor().journal()), h);
}

uint256
Expand All @@ -244,29 +248,17 @@ RCLConsensus::Adaptor::getPrevLedger(
RCLCxLedger const& ledger,
ConsensusMode mode)
{
uint256 parentID;
// Only set the parent ID if we believe ledger is the right ledger
if (mode != ConsensusMode::wrongLedger)
parentID = ledger.parentID();

// Get validators that are on our ledger, or "close" to being on
// our ledger.
hash_map<uint256, std::uint32_t> ledgerCounts =
app_.getValidations().currentTrustedDistribution(
ledgerID, parentID, ledgerMaster_.getValidLedgerIndex());

uint256 netLgr = getPreferredLedger(ledgerID, ledgerCounts);
RCLValidations& vals = app_.getValidations();
uint256 netLgr = vals.getPreferred(
RCLValidatedLedger{ledger.ledger_, vals.adaptor().journal()},
ledgerMaster_.getValidLedgerIndex());

if (netLgr != ledgerID)
{
if (mode != ConsensusMode::wrongLedger)
app_.getOPs().consensusViewChange();

if (auto stream = j_.debug())
{
for (auto const & it : ledgerCounts)
stream << "V: " << it.first << ", " << it.second;
}
JLOG(j_.debug())<< Json::Compact(app_.getValidations().getJsonTrie());
}

return netLgr;
Expand Down Expand Up @@ -454,7 +446,8 @@ RCLConsensus::Adaptor::doAccept(
app_.journal("LedgerConsensus").warn(),
"Not validating");

if (validating_ && !consensusFail)
if (validating_ && !consensusFail &&
app_.getValidations().canValidateSeq(sharedLCL.seq()))
{
validate(sharedLCL, proposing);
JLOG(j_.info()) << "CNF Val " << newLCLHash;
Expand Down Expand Up @@ -841,7 +834,10 @@ RCLConsensus::Adaptor::validate(RCLCxLedger const& ledger, bool proposing)

// Build validation
auto v = std::make_shared<STValidation>(
ledger.id(), validationTime, valPublic_, proposing);
ledger.id(),
validationTime,
valPublic_,
proposing /* full if proposed */);
v->setFieldU32(sfLedgerSequence, ledger.seq());

// Add our load fee to the validation
Expand Down
7 changes: 4 additions & 3 deletions src/ripple/app/consensus/RCLConsensus.h
Original file line number Diff line number Diff line change
Expand Up @@ -201,12 +201,13 @@ class RCLConsensus
/** Number of proposers that have validated a ledger descended from
requested ledger.

@param h The hash of the ledger of interest.
@param ledger The current working ledger
@param h The hash of the preferred working ledger
@return The number of validating peers that have validated a ledger
succeeding the one provided.
descended from the preferred working ledger.
*/
std::size_t
proposersFinished(LedgerHash const& h) const;
proposersFinished(RCLCxLedger const & ledger, LedgerHash const& h) const;

/** Propose the given position to my peers.

Expand Down
Loading