Warn operators about upcoming unknown amendments:

* When an unknown amendment reaches majority, log an error-level
  message, and return a `warnings` array on all successful
  admin-level RPC calls to `server_info` and `server_state` with
  a message describing the problem, and the expected deadline.
* In addition to the `amendment_blocked` flag returned by
  `server_info` and `server_state`, return a warning with a more
  verbose description when the server is amendment blocked.
* Check on every flag ledger to see if the amendment(s) lose majority.
  Logs again if they don't, resumes normal operations if they did.

The intention is to give operators earlier warning that their
instances are in danger of being amendment blocked, which will
hopefully motivate them to update ahead of time.
This commit is contained in:
Edward Hennis
2020-01-09 19:04:20 -05:00
committed by Manoj doshi
parent 4315913a5d
commit 5ff23f8f31
11 changed files with 418 additions and 50 deletions

View File

@@ -87,6 +87,7 @@ private:
std::vector<std::string> const m_set2;
std::vector<std::string> const m_set3;
std::vector<std::string> const m_set4;
std::vector<std::string> const m_set5;
Section const emptySection;
@@ -98,6 +99,7 @@ public:
, m_set2 (createSet (2, 12))
, m_set3 (createSet (3, 12))
, m_set4 (createSet (4, 12))
, m_set5 (createSet (5, 12))
, journal ("AmendmentTable_test", *this)
{
}
@@ -168,6 +170,8 @@ public:
BEAST_EXPECT(!table->find (a));
for (auto const& a : m_set4)
BEAST_EXPECT(!table->find (a));
for (auto const& a : m_set5)
BEAST_EXPECT(!table->find (a));
}
void testBadConfig ()
@@ -283,6 +287,7 @@ public:
track (m_set2);
track (m_set3);
track (m_set4);
track (m_set5);
for (auto const& a : exclude)
state.erase(a);
@@ -304,6 +309,7 @@ public:
enabled.insert (amendmentId(m_set2[0]));
enabled.insert (amendmentId(m_set3[0]));
enabled.insert (amendmentId(m_set4[0]));
enabled.insert (amendmentId(m_set5[0]));
// Get the state before, excluding the items we'll change:
auto const pre_state = getState (table.get(), enabled);
@@ -741,14 +747,31 @@ public:
{
testcase ("hasUnsupportedEnabled");
auto table = makeTable(1);
using namespace std::chrono_literals;
int constexpr w = 1;
auto table = makeTable(w);
BEAST_EXPECT(! table->hasUnsupportedEnabled());
BEAST_EXPECT(! table->firstUnsupportedExpected());
std::set <uint256> enabled;
majorityAmendments_t majority;
std::for_each(m_set4.begin(), m_set4.end(),
[&enabled](auto const &s){ enabled.insert(amendmentId(s)); });
table->doValidatedLedger(1, enabled);
table->doValidatedLedger(1, enabled, majority);
BEAST_EXPECT(table->hasUnsupportedEnabled());
BEAST_EXPECT(!table->firstUnsupportedExpected());
NetClock::duration t{1000s};
std::for_each(
m_set5.begin(), m_set5.end(), [&majority, &t](auto const& s) {
majority[amendmentId(s)] = NetClock::time_point{--t};
});
table->doValidatedLedger(1, enabled, majority);
BEAST_EXPECT(table->hasUnsupportedEnabled());
BEAST_EXPECT(
table->firstUnsupportedExpected() &&
*table->firstUnsupportedExpected() ==
NetClock::time_point{t} + weeks{w});
}
void run () override