mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Allow a newly-started validator to participate in consensus.
This commit is contained in:
@@ -934,12 +934,11 @@ RCLConsensus::peerProposal(
|
|||||||
bool
|
bool
|
||||||
RCLConsensus::Adaptor::preStartRound(RCLCxLedger const & prevLgr)
|
RCLConsensus::Adaptor::preStartRound(RCLCxLedger const & prevLgr)
|
||||||
{
|
{
|
||||||
// We have a key, we have some idea what the ledger is, and we are not
|
// We have a key and do not want out of sync validations after a restart,
|
||||||
// amendment blocked
|
// and are not amendment blocked.
|
||||||
validating_ =
|
validating_ = valPublic_.size() != 0 &&
|
||||||
!app_.getOPs().isNeedNetworkLedger() &&
|
prevLgr.seq() >= app_.getMaxDisallowedLedger() &&
|
||||||
(valPublic_.size() != 0) &&
|
!app_.getOPs().isAmendmentBlocked();
|
||||||
!app_.getOPs().isAmendmentBlocked();
|
|
||||||
|
|
||||||
if (validating_)
|
if (validating_)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -35,6 +35,7 @@
|
|||||||
#include <ripple/protocol/STValidation.h>
|
#include <ripple/protocol/STValidation.h>
|
||||||
#include <ripple/beast/insight/Collector.h>
|
#include <ripple/beast/insight/Collector.h>
|
||||||
#include <ripple/core/Stoppable.h>
|
#include <ripple/core/Stoppable.h>
|
||||||
|
#include <ripple/protocol/Protocol.h>
|
||||||
#include <ripple/beast/utility/PropertyStream.h>
|
#include <ripple/beast/utility/PropertyStream.h>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
@@ -299,11 +300,11 @@ private:
|
|||||||
std::shared_ptr<Ledger const> mHistLedger;
|
std::shared_ptr<Ledger const> mHistLedger;
|
||||||
|
|
||||||
// Fully validated ledger, whether or not we have the ledger resident.
|
// Fully validated ledger, whether or not we have the ledger resident.
|
||||||
std::pair <uint256, LedgerIndex> mLastValidLedger;
|
std::pair <uint256, LedgerIndex> mLastValidLedger {uint256(), 0};
|
||||||
|
|
||||||
LedgerHistory mLedgerHistory;
|
LedgerHistory mLedgerHistory;
|
||||||
|
|
||||||
CanonicalTXSet mHeldTransactions;
|
CanonicalTXSet mHeldTransactions {uint256()};
|
||||||
|
|
||||||
// A set of transactions to replay during the next close
|
// A set of transactions to replay during the next close
|
||||||
std::unique_ptr<LedgerReplay> replayData;
|
std::unique_ptr<LedgerReplay> replayData;
|
||||||
@@ -314,23 +315,23 @@ private:
|
|||||||
std::unique_ptr <detail::LedgerCleaner> mLedgerCleaner;
|
std::unique_ptr <detail::LedgerCleaner> mLedgerCleaner;
|
||||||
|
|
||||||
uint256 mLastValidateHash;
|
uint256 mLastValidateHash;
|
||||||
std::uint32_t mLastValidateSeq;
|
std::uint32_t mLastValidateSeq {0};
|
||||||
|
|
||||||
// Publish thread is running.
|
// Publish thread is running.
|
||||||
bool mAdvanceThread;
|
bool mAdvanceThread {false};
|
||||||
|
|
||||||
// Publish thread has work to do.
|
// Publish thread has work to do.
|
||||||
bool mAdvanceWork;
|
bool mAdvanceWork {false};
|
||||||
int mFillInProgress;
|
int mFillInProgress {0};
|
||||||
|
|
||||||
int mPathFindThread; // Pathfinder jobs dispatched
|
int mPathFindThread {0}; // Pathfinder jobs dispatched
|
||||||
bool mPathFindNewRequest;
|
bool mPathFindNewRequest {false};
|
||||||
|
|
||||||
std::atomic <std::uint32_t> mPubLedgerClose;
|
std::atomic <std::uint32_t> mPubLedgerClose {0};
|
||||||
std::atomic <std::uint32_t> mPubLedgerSeq;
|
std::atomic <LedgerIndex> mPubLedgerSeq {0};
|
||||||
std::atomic <std::uint32_t> mValidLedgerSign;
|
std::atomic <std::uint32_t> mValidLedgerSign {0};
|
||||||
std::atomic <std::uint32_t> mValidLedgerSeq;
|
std::atomic <LedgerIndex> mValidLedgerSeq {0};
|
||||||
std::atomic <std::uint32_t> mBuildingLedgerSeq;
|
std::atomic <LedgerIndex> mBuildingLedgerSeq {0};
|
||||||
|
|
||||||
// The server is in standalone mode
|
// The server is in standalone mode
|
||||||
bool const standalone_;
|
bool const standalone_;
|
||||||
@@ -345,7 +346,11 @@ private:
|
|||||||
|
|
||||||
TaggedCache<uint256, Blob> fetch_packs_;
|
TaggedCache<uint256, Blob> fetch_packs_;
|
||||||
|
|
||||||
std::uint32_t fetch_seq_;
|
std::uint32_t fetch_seq_ {0};
|
||||||
|
|
||||||
|
// Try to keep a validator from switching from test to live network
|
||||||
|
// without first wiping the database.
|
||||||
|
LedgerIndex const max_ledger_difference_ {1000000};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -66,22 +66,9 @@ LedgerMaster::LedgerMaster (Application& app, Stopwatch& stopwatch,
|
|||||||
: Stoppable ("LedgerMaster", parent)
|
: Stoppable ("LedgerMaster", parent)
|
||||||
, app_ (app)
|
, app_ (app)
|
||||||
, m_journal (journal)
|
, m_journal (journal)
|
||||||
, mLastValidLedger (std::make_pair (uint256(), 0))
|
|
||||||
, mLedgerHistory (collector, app)
|
, mLedgerHistory (collector, app)
|
||||||
, mHeldTransactions (uint256 ())
|
|
||||||
, mLedgerCleaner (detail::make_LedgerCleaner (
|
, mLedgerCleaner (detail::make_LedgerCleaner (
|
||||||
app, *this, app_.journal("LedgerCleaner")))
|
app, *this, app_.journal("LedgerCleaner")))
|
||||||
, mLastValidateSeq (0)
|
|
||||||
, mAdvanceThread (false)
|
|
||||||
, mAdvanceWork (false)
|
|
||||||
, mFillInProgress (0)
|
|
||||||
, mPathFindThread (0)
|
|
||||||
, mPathFindNewRequest (false)
|
|
||||||
, mPubLedgerClose (0)
|
|
||||||
, mPubLedgerSeq (0)
|
|
||||||
, mValidLedgerSign (0)
|
|
||||||
, mValidLedgerSeq (0)
|
|
||||||
, mBuildingLedgerSeq (0)
|
|
||||||
, standalone_ (app_.config().standalone())
|
, standalone_ (app_.config().standalone())
|
||||||
, fetch_depth_ (app_.getSHAMapStore ().clampFetchDepth (
|
, fetch_depth_ (app_.getSHAMapStore ().clampFetchDepth (
|
||||||
app_.config().FETCH_DEPTH))
|
app_.config().FETCH_DEPTH))
|
||||||
@@ -89,7 +76,6 @@ LedgerMaster::LedgerMaster (Application& app, Stopwatch& stopwatch,
|
|||||||
, ledger_fetch_size_ (app_.config().getSize (siLedgerFetch))
|
, ledger_fetch_size_ (app_.config().getSize (siLedgerFetch))
|
||||||
, fetch_packs_ ("FetchPack", 65536, 45, stopwatch,
|
, fetch_packs_ ("FetchPack", 65536, 45, stopwatch,
|
||||||
app_.journal("TaggedCache"))
|
app_.journal("TaggedCache"))
|
||||||
, fetch_seq_ (0)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,6 +207,10 @@ LedgerMaster::setValidLedger(
|
|||||||
|
|
||||||
mValidLedger.set (l);
|
mValidLedger.set (l);
|
||||||
mValidLedgerSign = signTime.time_since_epoch().count();
|
mValidLedgerSign = signTime.time_since_epoch().count();
|
||||||
|
assert (mValidLedgerSeq ||
|
||||||
|
!app_.getMaxDisallowedLedger() ||
|
||||||
|
l->info().seq + max_ledger_difference_ >
|
||||||
|
app_.getMaxDisallowedLedger());
|
||||||
mValidLedgerSeq = l->info().seq;
|
mValidLedgerSeq = l->info().seq;
|
||||||
|
|
||||||
app_.getOPs().updateLocalTx (*l);
|
app_.getOPs().updateLocalTx (*l);
|
||||||
|
|||||||
@@ -52,11 +52,14 @@
|
|||||||
#include <ripple/overlay/Cluster.h>
|
#include <ripple/overlay/Cluster.h>
|
||||||
#include <ripple/overlay/make_Overlay.h>
|
#include <ripple/overlay/make_Overlay.h>
|
||||||
#include <ripple/protocol/STParsedJSON.h>
|
#include <ripple/protocol/STParsedJSON.h>
|
||||||
|
#include <ripple/protocol/Protocol.h>
|
||||||
#include <ripple/resource/Fees.h>
|
#include <ripple/resource/Fees.h>
|
||||||
#include <ripple/beast/asio/io_latency_probe.h>
|
#include <ripple/beast/asio/io_latency_probe.h>
|
||||||
#include <ripple/beast/core/LexicalCast.h>
|
#include <ripple/beast/core/LexicalCast.h>
|
||||||
#include <boost/asio/steady_timer.hpp>
|
#include <boost/asio/steady_timer.hpp>
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
namespace ripple {
|
namespace ripple {
|
||||||
|
|
||||||
@@ -77,7 +80,7 @@ private:
|
|||||||
beast::Journal j_;
|
beast::Journal j_;
|
||||||
|
|
||||||
// missing node handler
|
// missing node handler
|
||||||
std::uint32_t maxSeq = 0;
|
LedgerIndex maxSeq = 0;
|
||||||
std::mutex maxSeqLock;
|
std::mutex maxSeqLock;
|
||||||
|
|
||||||
void acquire (
|
void acquire (
|
||||||
@@ -1006,8 +1009,17 @@ public:
|
|||||||
setSweepTimer();
|
setSweepTimer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LedgerIndex getMaxDisallowedLedger() override
|
||||||
|
{
|
||||||
|
return maxDisallowedLedger_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
// For a newly-started validator, this is the greatest persisted ledger
|
||||||
|
// and new validations must be greater than this.
|
||||||
|
std::atomic<LedgerIndex> maxDisallowedLedger_ {0};
|
||||||
|
|
||||||
void addTxnSeqField();
|
void addTxnSeqField();
|
||||||
void addValidationSeqFields();
|
void addValidationSeqFields();
|
||||||
bool updateTables ();
|
bool updateTables ();
|
||||||
@@ -1024,6 +1036,8 @@ private:
|
|||||||
std::string const& ledgerID,
|
std::string const& ledgerID,
|
||||||
bool replay,
|
bool replay,
|
||||||
bool isFilename);
|
bool isFilename);
|
||||||
|
|
||||||
|
void setMaxDisallowedLedger();
|
||||||
};
|
};
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
@@ -1073,6 +1087,9 @@ bool ApplicationImp::setup()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (validatorKeys_.publicKey.size())
|
||||||
|
setMaxDisallowedLedger();
|
||||||
|
|
||||||
getLedgerDB ().getSession ()
|
getLedgerDB ().getSession ()
|
||||||
<< boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
<< boost::str (boost::format ("PRAGMA cache_size=-%d;") %
|
||||||
(config_->getSize (siLgrDBCache) * 1024));
|
(config_->getSize (siLgrDBCache) * 1024));
|
||||||
@@ -1988,6 +2005,21 @@ bool ApplicationImp::updateTables ()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApplicationImp::setMaxDisallowedLedger()
|
||||||
|
{
|
||||||
|
boost::optional <LedgerIndex> seq;
|
||||||
|
{
|
||||||
|
auto db = getLedgerDB().checkoutDb();
|
||||||
|
*db << "SELECT MAX(LedgerSeq) FROM Ledgers;", soci::into(seq);
|
||||||
|
}
|
||||||
|
if (seq)
|
||||||
|
maxDisallowedLedger_ = *seq;
|
||||||
|
|
||||||
|
JLOG (m_journal.trace()) << "Max persisted ledger is "
|
||||||
|
<< maxDisallowedLedger_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//------------------------------------------------------------------------------
|
//------------------------------------------------------------------------------
|
||||||
|
|
||||||
Application::Application ()
|
Application::Application ()
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include <ripple/shamap/TreeNodeCache.h>
|
#include <ripple/shamap/TreeNodeCache.h>
|
||||||
#include <ripple/basics/TaggedCache.h>
|
#include <ripple/basics/TaggedCache.h>
|
||||||
#include <ripple/core/Config.h>
|
#include <ripple/core/Config.h>
|
||||||
|
#include <ripple/protocol/Protocol.h>
|
||||||
#include <ripple/beast/utility/PropertyStream.h>
|
#include <ripple/beast/utility/PropertyStream.h>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@@ -175,6 +176,10 @@ public:
|
|||||||
|
|
||||||
/** Retrieve the "wallet database" */
|
/** Retrieve the "wallet database" */
|
||||||
virtual DatabaseCon& getWalletDB () = 0;
|
virtual DatabaseCon& getWalletDB () = 0;
|
||||||
|
|
||||||
|
/** Ensure that a newly-started validator does not sign proposals older
|
||||||
|
* than the last ledger it persisted. */
|
||||||
|
virtual LedgerIndex getMaxDisallowedLedger() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
std::unique_ptr <Application>
|
std::unique_ptr <Application>
|
||||||
|
|||||||
Reference in New Issue
Block a user