mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Check amendment block status and update w/ ledgers:
Check and modify amendment blocked status with each new ledger (provided by @wilsonianb). Honor blocked status in certain RPC commands and when deciding whether to propose/validate. Fixes: RIPD-1479 Fixes: RIPD-1447 Release Notes ------------- This resolves an issue whereby an amendment blocked server would still serve some RPC requests that are unreliable in blocked state and would continue to publish validations.
This commit is contained in:
@@ -934,9 +934,12 @@ RCLConsensus::peerProposal(
|
||||
bool
|
||||
RCLConsensus::Adaptor::preStartRound(RCLCxLedger const & prevLgr)
|
||||
{
|
||||
// We have a key, and we have some idea what the ledger is
|
||||
// We have a key, we have some idea what the ledger is, and we are not
|
||||
// amendment blocked
|
||||
validating_ =
|
||||
!app_.getOPs().isNeedNetworkLedger() && (valPublic_.size() != 0);
|
||||
!app_.getOPs().isNeedNetworkLedger() &&
|
||||
(valPublic_.size() != 0) &&
|
||||
!app_.getOPs().isAmendmentBlocked();
|
||||
|
||||
if (validating_)
|
||||
{
|
||||
|
||||
@@ -227,6 +227,13 @@ LedgerMaster::setValidLedger(
|
||||
app_.getSHAMapStore().onLedgerClosed (getValidatedLedger());
|
||||
mLedgerHistory.validatedLedger (l);
|
||||
app_.getAmendmentTable().doValidatedLedger (l);
|
||||
if (!app_.getOPs().isAmendmentBlocked() &&
|
||||
app_.getAmendmentTable().hasUnsupportedEnabled ())
|
||||
{
|
||||
JLOG (m_journal.error()) <<
|
||||
"One or more unsupported amendments activated: server blocked.";
|
||||
app_.getOPs().setAmendmentBlocked();
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -47,6 +47,14 @@ public:
|
||||
virtual bool isEnabled (uint256 const& amendment) = 0;
|
||||
virtual bool isSupported (uint256 const& amendment) = 0;
|
||||
|
||||
/**
|
||||
* @brief returns true if one or more amendments on the network
|
||||
* have been enabled that this server does not support
|
||||
*
|
||||
* @return true if an unsupported feature is enabled on the network
|
||||
*/
|
||||
virtual bool hasUnsupportedEnabled () = 0;
|
||||
|
||||
virtual Json::Value getJson (int) = 0;
|
||||
|
||||
/** Returns a Json::objectValue. */
|
||||
|
||||
@@ -157,6 +157,9 @@ protected:
|
||||
// we haven't participated in one yet.
|
||||
std::unique_ptr <AmendmentSet> lastVote_;
|
||||
|
||||
// True if an unsupported amendment is enabled
|
||||
bool unsupportedEnabled_;
|
||||
|
||||
beast::Journal j_;
|
||||
|
||||
// Finds or creates state
|
||||
@@ -187,6 +190,8 @@ public:
|
||||
bool isEnabled (uint256 const& amendment) override;
|
||||
bool isSupported (uint256 const& amendment) override;
|
||||
|
||||
bool hasUnsupportedEnabled () override;
|
||||
|
||||
Json::Value getJson (int) override;
|
||||
Json::Value getJson (uint256 const&) override;
|
||||
|
||||
@@ -222,6 +227,7 @@ AmendmentTableImpl::AmendmentTableImpl (
|
||||
: lastUpdateSeq_ (0)
|
||||
, majorityTime_ (majorityTime)
|
||||
, majorityFraction_ (majorityFraction)
|
||||
, unsupportedEnabled_ (false)
|
||||
, j_ (journal)
|
||||
{
|
||||
assert (majorityFraction_ != 0);
|
||||
@@ -340,6 +346,14 @@ AmendmentTableImpl::enable (uint256 const& amendment)
|
||||
return false;
|
||||
|
||||
s->enabled = true;
|
||||
|
||||
if (! s->supported)
|
||||
{
|
||||
JLOG (j_.error()) <<
|
||||
"Unsupported amendment " << amendment << " activated.";
|
||||
unsupportedEnabled_ = true;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -372,6 +386,13 @@ AmendmentTableImpl::isSupported (uint256 const& amendment)
|
||||
return s && s->supported;
|
||||
}
|
||||
|
||||
bool
|
||||
AmendmentTableImpl::hasUnsupportedEnabled ()
|
||||
{
|
||||
std::lock_guard <std::mutex> sl (mutex_);
|
||||
return unsupportedEnabled_;
|
||||
}
|
||||
|
||||
std::vector <uint256>
|
||||
AmendmentTableImpl::doValidation (
|
||||
std::set<uint256> const& enabled)
|
||||
@@ -523,10 +544,8 @@ AmendmentTableImpl::doValidatedLedger (
|
||||
LedgerIndex ledgerSeq,
|
||||
std::set<uint256> const& enabled)
|
||||
{
|
||||
std::lock_guard <std::mutex> sl (mutex_);
|
||||
|
||||
for (auto& e : amendmentMap_)
|
||||
e.second.enabled = (enabled.count (e.first) != 0);
|
||||
for (auto& e : enabled)
|
||||
enable(e);
|
||||
}
|
||||
|
||||
void
|
||||
|
||||
@@ -51,6 +51,7 @@ enum error_code_i
|
||||
rpcHIGH_FEE,
|
||||
rpcNOT_ENABLED,
|
||||
rpcNOT_READY,
|
||||
rpcAMENDMENT_BLOCKED,
|
||||
|
||||
// Networking
|
||||
rpcNO_CLOSED,
|
||||
|
||||
@@ -53,6 +53,7 @@ public:
|
||||
add (rpcACT_EXISTS, "actExists", "Account already exists.");
|
||||
add (rpcACT_MALFORMED, "actMalformed", "Account malformed.");
|
||||
add (rpcACT_NOT_FOUND, "actNotFound", "Account not found.");
|
||||
add (rpcAMENDMENT_BLOCKED, "amendmentBlocked", "Amendment blocked, need upgrade.");
|
||||
add (rpcATX_DEPRECATED, "deprecated", "Use the new API or specify a ledger range.");
|
||||
add (rpcBAD_BLOB, "badBlob", "Blob must be a non-empty hex string.");
|
||||
add (rpcBAD_FEATURE, "badFeature", "Feature unknown or invalid.");
|
||||
|
||||
@@ -157,6 +157,13 @@ error_code_i fillHandler (Context& context,
|
||||
return rpcNO_NETWORK;
|
||||
}
|
||||
|
||||
if (context.app.getOPs().isAmendmentBlocked() &&
|
||||
(handler->condition_ & NEEDS_CURRENT_LEDGER ||
|
||||
handler->condition_ & NEEDS_CLOSED_LEDGER))
|
||||
{
|
||||
return rpcAMENDMENT_BLOCKED;
|
||||
}
|
||||
|
||||
if (!context.app.config().standalone() &&
|
||||
handler->condition_ & NEEDS_CURRENT_LEDGER)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user