Check consensus hash consistency (RIPD-1456):

These changes use the hash of the consensus transaction set when
characterizing the mismatch between a locally built ledger and fully
validated network ledger. This allows detection of non-determinism in
transaction process, in which consensus succeeded, but a node somehow
generated a different subsequent ledger.
This commit is contained in:
Brad Chase
2018-03-01 13:22:45 -05:00
committed by seelabs
parent 3a5a6c3637
commit 1507ed66a8
20 changed files with 402 additions and 86 deletions

View File

@@ -182,12 +182,19 @@ void
LedgerMaster::setValidLedger(
std::shared_ptr<Ledger const> const& l)
{
std::vector <NetClock::time_point> times;
boost::optional<uint256> consensusHash;
if (! standalone_)
{
times = app_.getValidations().getTrustedValidationTimes(
l->info().hash);
auto const vals = app_.getValidations().getTrustedForLedger(l->info().hash);
times.reserve(vals.size());
for(auto const& val: vals)
times.push_back(val->getSignTime());
if(!vals.empty())
consensusHash = vals.front()->getConsensusHash();
}
NetClock::time_point signTime;
@@ -216,7 +223,7 @@ LedgerMaster::setValidLedger(
app_.getOPs().updateLocalTx (*l);
app_.getSHAMapStore().onLedgerClosed (getValidatedLedger());
mLedgerHistory.validatedLedger (l);
mLedgerHistory.validatedLedger (l, consensusHash);
app_.getAmendmentTable().doValidatedLedger (l);
if (!app_.getOPs().isAmendmentBlocked() &&
app_.getAmendmentTable().hasUnsupportedEnabled ())
@@ -804,7 +811,9 @@ LedgerMaster::checkAccept (
/** Report that the consensus process built a particular ledger */
void
LedgerMaster::consensusBuilt(
std::shared_ptr<Ledger const> const& ledger, Json::Value consensus)
std::shared_ptr<Ledger const> const& ledger,
uint256 const& consensusHash,
Json::Value consensus)
{
// Because we just built a ledger, we are no longer building one
@@ -814,7 +823,7 @@ LedgerMaster::consensusBuilt(
if (standalone_)
return;
mLedgerHistory.builtLedger (ledger, std::move (consensus));
mLedgerHistory.builtLedger (ledger, consensusHash, std::move (consensus));
if (ledger->info().seq <= mValidLedgerSeq)
{