mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 22:15:52 +00:00
Block operation if a feature we don't support is enabled in the ledger.
This commit is contained in:
@@ -547,6 +547,12 @@ bool serverOkay(std::string& reason)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (theApp->getOPs().isFeatureBlocked())
|
||||
{
|
||||
reason = "Server version too old";
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -85,6 +85,10 @@ TER ChangeTransactor::applyFeature()
|
||||
featureObject->setFieldV256(sfFeatures, features);
|
||||
mEngine->entryModify(featureObject);
|
||||
|
||||
theApp->getFeatureTable().enableFeature(feature);
|
||||
if (!theApp->getFeatureTable().isFeatureSupported(feature))
|
||||
theApp->getOPs().setFeatureBlocked();
|
||||
|
||||
return tesSUCCESS;
|
||||
}
|
||||
|
||||
|
||||
@@ -87,6 +87,13 @@ bool FeatureTable::isFeatureEnabled(const uint256& feature)
|
||||
return s && s->mEnabled;
|
||||
}
|
||||
|
||||
bool FeatureTable::isFeatureSupported(const uint256& feature)
|
||||
{
|
||||
boost::mutex::scoped_lock sl(mMutex);
|
||||
FeatureState *s = getCreateFeature(feature, false);
|
||||
return s && s->mSupported;
|
||||
}
|
||||
|
||||
FeatureTable::featureList_t FeatureTable::getVetoedFeatures()
|
||||
{
|
||||
featureList_t ret;
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
bool disableFeature(const uint256& feature);
|
||||
|
||||
bool isFeatureEnabled(const uint256& feature);
|
||||
bool isFeatureSupported(const uint256& feature);
|
||||
|
||||
void setEnabledFeatures(const std::vector<uint256>& features);
|
||||
void setSupportedFeatures(const std::vector<uint256>& features);
|
||||
|
||||
@@ -1327,15 +1327,12 @@ std::vector< std::pair<uint32, uint256> > Ledger::getLedgerHashes()
|
||||
return ret;
|
||||
}
|
||||
|
||||
boost::unordered_set<uint256> Ledger::getLedgerFeatures()
|
||||
std::vector<uint256> Ledger::getLedgerFeatures()
|
||||
{
|
||||
boost::unordered_set<uint256> usFeatures;
|
||||
std::vector<uint256> usFeatures;
|
||||
SLE::pointer sleFeatures = getSLEi(getLedgerFeatureIndex());
|
||||
if (sleFeatures)
|
||||
{
|
||||
BOOST_FOREACH(const uint256& uFeature, sleFeatures->getFieldV256(sfFeatures).peekValue())
|
||||
usFeatures.insert(uFeature);
|
||||
}
|
||||
usFeatures = sleFeatures->getFieldV256(sfFeatures).peekValue();
|
||||
return usFeatures;
|
||||
}
|
||||
|
||||
|
||||
@@ -220,7 +220,7 @@ public:
|
||||
|
||||
static uint256 getLedgerFeatureIndex();
|
||||
static uint256 getLedgerFeeIndex();
|
||||
boost::unordered_set<uint256> getLedgerFeatures();
|
||||
std::vector<uint256> getLedgerFeatures();
|
||||
|
||||
std::vector<uint256> getNeededTransactionHashes(int max, SHAMapSyncFilter* filter);
|
||||
std::vector<uint256> getNeededAccountStateHashes(int max, SHAMapSyncFilter* filter);
|
||||
|
||||
@@ -31,6 +31,7 @@ void InfoSub::onSendEmpty()
|
||||
|
||||
NetworkOPs::NetworkOPs(boost::asio::io_service& io_service, LedgerMaster* pLedgerMaster) :
|
||||
mMode(omDISCONNECTED), mNeedNetworkLedger(false), mProposing(false), mValidating(false),
|
||||
mFeatureBlocked(false),
|
||||
mNetTimer(io_service), mLedgerMaster(pLedgerMaster), mCloseTimeOffset(0), mLastCloseProposers(0),
|
||||
mLastCloseConvergeTime(1000 * LEDGER_IDLE_INTERVAL), mLastCloseTime(0), mLastValidationTime(0),
|
||||
mFetchPack("FetchPack", 2048, 20), mLastFetchPack(0), mFetchSeq(static_cast<uint32>(-1)),
|
||||
@@ -553,6 +554,12 @@ Json::Value NetworkOPs::getOwnerInfo(Ledger::pointer lpLedger, const RippleAddre
|
||||
// Other
|
||||
//
|
||||
|
||||
void NetworkOPs::setFeatureBlocked()
|
||||
{
|
||||
mFeatureBlocked = true;
|
||||
setMode(omTRACKING);
|
||||
}
|
||||
|
||||
void NetworkOPs::setStateTimer()
|
||||
{
|
||||
mNetTimer.expires_from_now(boost::posix_time::milliseconds(LEDGER_GRANULARITY));
|
||||
@@ -1047,6 +1054,9 @@ void NetworkOPs::setMode(OperatingMode om)
|
||||
om = omCONNECTED;
|
||||
}
|
||||
|
||||
if ((om > omTRACKING) && mFeatureBlocked)
|
||||
om = omTRACKING;
|
||||
|
||||
if (mMode == om)
|
||||
return;
|
||||
|
||||
@@ -1265,6 +1275,8 @@ Json::Value NetworkOPs::getServerInfo(bool human, bool admin)
|
||||
|
||||
info["complete_ledgers"] = theApp->getLedgerMaster().getCompleteLedgers();
|
||||
|
||||
if (mFeatureBlocked)
|
||||
info["feature_blocked"] = true;
|
||||
|
||||
size_t fp = mFetchPack.getCacheSize();
|
||||
if (fp != 0)
|
||||
|
||||
@@ -115,6 +115,7 @@ protected:
|
||||
OperatingMode mMode;
|
||||
bool mNeedNetworkLedger;
|
||||
bool mProposing, mValidating;
|
||||
bool mFeatureBlocked;
|
||||
boost::posix_time::ptime mConnectTime;
|
||||
boost::asio::deadline_timer mNetTimer;
|
||||
boost::shared_ptr<LedgerConsensus> mConsensus;
|
||||
@@ -309,6 +310,8 @@ public:
|
||||
void setProposing(bool p, bool v) { mProposing = p; mValidating = v; }
|
||||
bool isProposing() { return mProposing; }
|
||||
bool isValidating() { return mValidating; }
|
||||
bool isFeatureBlocked() { return mFeatureBlocked; }
|
||||
void setFeatureBlocked();
|
||||
void consensusViewChange();
|
||||
int getPreviousProposers() { return mLastCloseProposers; }
|
||||
int getPreviousConvergeTime() { return mLastCloseConvergeTime; }
|
||||
|
||||
Reference in New Issue
Block a user