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

Validations refactor (RIPD-1412) #2084

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
28 changes: 18 additions & 10 deletions Builds/VisualStudio2015/RippleD.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -835,6 +835,12 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\consensus\RCLCxTx.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\consensus\RCLValidations.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\consensus\RCLValidations.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\ledger\AbstractFetchPackContainer.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\ledger\AcceptedLedger.cpp">
Expand Down Expand Up @@ -1093,12 +1099,6 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\misc\TxQ.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\misc\Validations.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\misc\Validations.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\misc\ValidatorList.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\misc\ValidatorSite.h">
Expand Down Expand Up @@ -1827,18 +1827,22 @@
</ClInclude>
<ClInclude Include="..\..\src\ripple\conditions\impl\utils.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\consensus\Consensus.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\consensus\Consensus.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\ConsensusParms.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\ConsensusProposal.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\DisputedTx.h">
</ClInclude>
<ClCompile Include="..\..\src\ripple\consensus\LedgerTiming.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClInclude Include="..\..\src\ripple\consensus\LedgerTiming.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\Validations.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\core\Config.h">
</ClInclude>
<ClInclude Include="..\..\src\ripple\core\ConfigSections.h">
Expand Down Expand Up @@ -4423,6 +4427,10 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\Validations_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
</ClCompile>
<ClCompile Include="..\..\src\test\core\Config_test.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='debug|x64'">True</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='release|x64'">True</ExcludedFromBuild>
Expand Down
27 changes: 18 additions & 9 deletions Builds/VisualStudio2015/RippleD.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,12 @@
<ClInclude Include="..\..\src\ripple\app\consensus\RCLCxTx.h">
<Filter>ripple\app\consensus</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\consensus\RCLValidations.cpp">
<Filter>ripple\app\consensus</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\consensus\RCLValidations.h">
<Filter>ripple\app\consensus</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\ledger\AbstractFetchPackContainer.h">
<Filter>ripple\app\ledger</Filter>
</ClInclude>
Expand Down Expand Up @@ -1617,12 +1623,6 @@
<ClInclude Include="..\..\src\ripple\app\misc\TxQ.h">
<Filter>ripple\app\misc</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\app\misc\Validations.cpp">
<Filter>ripple\app\misc</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\app\misc\Validations.h">
<Filter>ripple\app\misc</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\app\misc\ValidatorList.h">
<Filter>ripple\app\misc</Filter>
</ClInclude>
Expand Down Expand Up @@ -2454,21 +2454,27 @@
<ClInclude Include="..\..\src\ripple\conditions\impl\utils.h">
<Filter>ripple\conditions\impl</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\consensus\Consensus.cpp">
<Filter>ripple\consensus</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\consensus\Consensus.h">
<Filter>ripple\consensus</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\ConsensusParms.h">
<Filter>ripple\consensus</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\ConsensusProposal.h">
<Filter>ripple\consensus</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\DisputedTx.h">
<Filter>ripple\consensus</Filter>
</ClInclude>
<ClCompile Include="..\..\src\ripple\consensus\LedgerTiming.cpp">
<Filter>ripple\consensus</Filter>
</ClCompile>
<ClInclude Include="..\..\src\ripple\consensus\LedgerTiming.h">
<Filter>ripple\consensus</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\consensus\Validations.h">
<Filter>ripple\consensus</Filter>
</ClInclude>
<ClInclude Include="..\..\src\ripple\core\Config.h">
<Filter>ripple\core</Filter>
</ClInclude>
Expand Down Expand Up @@ -5169,6 +5175,9 @@
<ClCompile Include="..\..\src\test\consensus\LedgerTiming_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\consensus\Validations_test.cpp">
<Filter>test\consensus</Filter>
</ClCompile>
<ClCompile Include="..\..\src\test\core\Config_test.cpp">
<Filter>test\core</Filter>
</ClCompile>
Expand Down
3 changes: 3 additions & 0 deletions docs/source.dox
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,16 @@ INPUT = \
../src/ripple/consensus/ConsensusProposal.h \
../src/ripple/consensus/DisputedTx.h \
../src/ripple/consensus/LedgerTiming.h \
../src/ripple/consensus/Validations.h \
../src/ripple/consensus/ConsensusParms.h \
../src/ripple/app/consensus/RCLCxTx.h \
../src/ripple/app/consensus/RCLCxLedger.h \
../src/ripple/app/consensus/RCLConsensus.h \
../src/ripple/app/consensus/RCLCxPeerPos.h \
../src/ripple/app/tx/apply.h \
../src/ripple/app/tx/applySteps.h \
../src/ripple/app/tx/impl/InvariantCheck.h \
../src/ripple/app/consensus/RCLValidations.h \

INPUT_ENCODING = UTF-8
FILE_PATTERNS =
Expand Down
30 changes: 14 additions & 16 deletions src/ripple/app/consensus/RCLConsensus.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

#include <BeastConfig.h>
#include <ripple/app/consensus/RCLConsensus.h>
#include <ripple/app/consensus/RCLValidations.h>
#include <ripple/app/ledger/InboundLedgers.h>
#include <ripple/app/ledger/InboundTransactions.h>
#include <ripple/app/ledger/LedgerMaster.h>
Expand Down Expand Up @@ -49,7 +50,7 @@ RCLConsensus::RCLConsensus(
InboundTransactions& inboundTransactions,
typename Base::clock_type const& clock,
beast::Journal journal)
: Base(clock, journal)
: Base(clock, ConsensusParms{}, journal)
, app_(app)
, feeVote_(std::move(feeVote))
, ledgerMaster_(ledgerMaster)
Expand Down Expand Up @@ -222,7 +223,7 @@ RCLConsensus::hasOpenTransactions() const
std::size_t
RCLConsensus::proposersValidated(LedgerHash const& h) const
{
return app_.getValidations().getTrustedValidationCount(h);
return app_.getValidations().numTrustedForLedger(h);
}

std::size_t
Expand All @@ -244,20 +245,21 @@ RCLConsensus::getPrevLedger(

// Get validators that are on our ledger, or "close" to being on
// our ledger.
auto vals = app_.getValidations().getCurrentValidations(
ledgerID, parentID, ledgerMaster_.getValidLedgerIndex());
auto vals =
app_.getValidations().currentTrustedDistribution(
ledgerID, parentID, ledgerMaster_.getValidLedgerIndex());

uint256 netLgr = ledgerID;
int netLgrCount = 0;
for (auto& it : vals)
{
// Switch to ledger supported by more peers
// Or stick with ours on a tie
if ((it.second.first > netLgrCount) ||
((it.second.first == netLgrCount) && (it.first == ledgerID)))
if ((it.second.count > netLgrCount) ||
((it.second.count== netLgrCount) && (it.first == ledgerID)))
{
netLgr = it.first;
netLgrCount = it.second.first;
netLgrCount = it.second.count;
}
}

Expand All @@ -269,7 +271,7 @@ RCLConsensus::getPrevLedger(
if (auto stream = j_.debug())
{
for (auto& it : vals)
stream << "V: " << it.first << ", " << it.second.first;
stream << "V: " << it.first << ", " << it.second.count;
stream << getJson(true);
}
}
Expand Down Expand Up @@ -317,14 +319,10 @@ RCLConsensus::onClose(
{
// previous ledger was flag ledger, add pseudo-transactions
auto const validations =
app_.getValidations().getValidations(prevLedger->info().parentHash);
app_.getValidations().getTrustedForLedger (
prevLedger->info().parentHash);

std::size_t const count = std::count_if(
validations.begin(), validations.end(), [](auto const& v) {
return v.second->isTrusted();
});

if (count >= app_.validators().quorum())
if (validations.size() >= app_.validators ().quorum ())
{
feeVote_->doVoting(prevLedger, validations, initialSet);
app_.getAmendmentTable().doVoting(
Expand Down Expand Up @@ -843,7 +841,7 @@ 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");
handleNewValidation(app_, v, "local");
Blob validation = v->getSerialized();
protocol::TMValidation val;
val.set_validation(&validation[0], validation.size());
Expand Down
Loading