Enable amendment support

This commit is contained in:
Nik Bougalis
2016-02-03 15:51:09 -08:00
parent 2b640532f2
commit ce31e26f58
6 changed files with 50 additions and 39 deletions

View File

@@ -149,13 +149,6 @@
#define RIPPLE_USE_VALIDATORS 0 #define RIPPLE_USE_VALIDATORS 0
#endif #endif
/** Config: RIPPLE_PROPOSE_FEATURES
This determines whether to add any features to the proposed transaction set.
*/
#ifndef RIPPLE_PROPOSE_AMENDMENTS
#define RIPPLE_PROPOSE_AMENDMENTS 0
#endif
/** Config: RIPPLE_SINGLE_IO_SERVICE_THREAD /** Config: RIPPLE_SINGLE_IO_SERVICE_THREAD
When set, restricts the number of threads calling io_service::run to one. When set, restricts the number of threads calling io_service::run to one.
This is useful when debugging. This is useful when debugging.

View File

@@ -39,6 +39,11 @@ supportedAmendments ()
{ {
return return
{ {
{ "4C97EBA926031A7CF7D7B36FDE3ED66DDA5421192D63DE53FFB46E43B9DC8373 MultiSign" },
{ "C1B8D934087225F509BEB5A8EC24447854713EE447D277F69545ABFA0E0FD490 Tickets" },
{ "DA1BD556B42D85EA9C84066D028D355B52416734D3283F85E216EA5DA6DB7E13 SusPay" },
{ "6781F8368C4771B83E8B821D88F580202BCB4228075297B19E4FDC5233F1EFDC TrustSetAuth" },
{ "42426C4D4F1009EE67080A9B7965B44656D7714D104A72F9B4369F97ABF044EE FeeEscalation" }
}; };
} }

View File

@@ -115,7 +115,6 @@ public:
getMajorityAmendments(*lastClosedLedger), getMajorityAmendments(*lastClosedLedger),
parentValidations); parentValidations);
#if RIPPLE_PROPOSE_AMENDMENTS
// Inject appropriate pseudo-transactions // Inject appropriate pseudo-transactions
for (auto const& it : actions) for (auto const& it : actions)
{ {
@@ -140,7 +139,6 @@ public:
true, true,
false); false);
} }
#endif
} }
}; };

View File

@@ -227,33 +227,44 @@ AmendmentTableImpl::AmendmentTableImpl (
for (auto const& a : parseSection(supported)) for (auto const& a : parseSection(supported))
{ {
auto s = add (a.first); if (auto s = add (a.first))
{
JLOG (j_.debug) <<
"Amendment " << a.first << " is supported.";
if (!a.second.empty ()) if (!a.second.empty ())
s->name = a.second; s->name = a.second;
s->supported = true; s->supported = true;
}
} }
for (auto const& a : parseSection (enabled)) for (auto const& a : parseSection (enabled))
{ {
auto s = add (a.first); if (auto s = add (a.first))
{
JLOG (j_.debug) <<
"Amendment " << a.first << " is enabled.";
if (!a.second.empty ()) if (!a.second.empty ())
s->name = a.second; s->name = a.second;
s->supported = true;
s->enabled = true; s->supported = true;
s->enabled = true;
}
} }
for (auto const& a : parseSection (vetoed)) for (auto const& a : parseSection (vetoed))
{ {
// Unknown amendments are effectively vetoed already // Unknown amendments are effectively vetoed already
auto s = get (a.first); if (auto s = get (a.first))
if (s)
{ {
JLOG (j_.info) <<
"Amendment " << a.first << " is vetoed.";
if (!a.second.empty ()) if (!a.second.empty ())
s->name = a.second; s->name = a.second;
s->vetoed = true; s->vetoed = true;
} }
} }

View File

@@ -167,6 +167,13 @@ Change::applyAmendment()
entry.emplace_back (STHash256 (sfAmendment, amendment)); entry.emplace_back (STHash256 (sfAmendment, amendment));
entry.emplace_back (STUInt32 (sfCloseTime, entry.emplace_back (STUInt32 (sfCloseTime,
view().parentCloseTime().time_since_epoch().count())); view().parentCloseTime().time_since_epoch().count()));
if (!ctx_.app.getAmendmentTable ().isSupported (amendment))
{
JLOG (j_.warning) <<
"Unsupported amendment " << amendment <<
" received a majority.";
}
} }
else if (!lostMajority) else if (!lostMajority)
{ {
@@ -177,7 +184,12 @@ Change::applyAmendment()
ctx_.app.getAmendmentTable ().enable (amendment); ctx_.app.getAmendmentTable ().enable (amendment);
if (!ctx_.app.getAmendmentTable ().isSupported (amendment)) if (!ctx_.app.getAmendmentTable ().isSupported (amendment))
{
JLOG (j_.error) <<
"Unsupported amendment " << amendment <<
" activated: server blocked.";
ctx_.app.getOPs ().setAmendmentBlocked (); ctx_.app.getOPs ().setAmendmentBlocked ();
}
} }
if (newMajorities.empty ()) if (newMajorities.empty ())
@@ -203,10 +215,6 @@ Change::applyFee()
view().insert(feeObject); view().insert(feeObject);
} }
// VFALCO-FIXME this generates errors
// j_.trace <<
// "Previous fee object: " << feeObject->getJson (0);
feeObject->setFieldU64 ( feeObject->setFieldU64 (
sfBaseFee, ctx_.tx.getFieldU64 (sfBaseFee)); sfBaseFee, ctx_.tx.getFieldU64 (sfBaseFee));
feeObject->setFieldU32 ( feeObject->setFieldU32 (
@@ -218,9 +226,6 @@ Change::applyFee()
view().update (feeObject); view().update (feeObject);
// VFALCO-FIXME this generates errors
// j_.trace <<
// "New fee object: " << feeObject->getJson (0);
j_.warning << "Fees have been changed"; j_.warning << "Fees have been changed";
return tesSUCCESS; return tesSUCCESS;
} }

View File

@@ -476,12 +476,11 @@ getEnabledAmendments (ReadView const& view)
if (auto const sle = view.read(keylet::amendments())) if (auto const sle = view.read(keylet::amendments()))
{ {
if (!sle->isFieldPresent (sfAmendments)) if (sle->isFieldPresent (sfAmendments))
LogicError ("No amendments field is present"); {
auto const& v = sle->getFieldV256 (sfAmendments);
auto const& v = sle->getFieldV256 (sfAmendments); amendments.insert (v.begin(), v.end());
}
amendments.insert (v.begin(), v.end());
} }
return amendments; return amendments;
@@ -517,7 +516,7 @@ hashOfSeq (ReadView const& ledger, LedgerIndex seq,
// Easy cases... // Easy cases...
if (seq > ledger.seq()) if (seq > ledger.seq())
{ {
if (journal.warning) journal.warning << JLOG (journal.warning) <<
"Can't get seq " << seq << "Can't get seq " << seq <<
" from " << ledger.seq() << " future"; " from " << ledger.seq() << " future";
return boost::none; return boost::none;
@@ -541,21 +540,21 @@ hashOfSeq (ReadView const& ledger, LedgerIndex seq,
STVector256 vec = hashIndex->getFieldV256 (sfHashes); STVector256 vec = hashIndex->getFieldV256 (sfHashes);
if (vec.size () >= diff) if (vec.size () >= diff)
return vec[vec.size () - diff]; return vec[vec.size () - diff];
if (journal.warning) journal.warning << JLOG (journal.warning) <<
"Ledger " << ledger.seq() << "Ledger " << ledger.seq() <<
" missing hash for " << seq << " missing hash for " << seq <<
" (" << vec.size () << "," << diff << ")"; " (" << vec.size () << "," << diff << ")";
} }
else else
{ {
if (journal.warning) journal.warning << JLOG (journal.warning) <<
"Ledger " << ledger.seq() << "Ledger " << ledger.seq() <<
":" << ledger.info().hash << " missing normal list"; ":" << ledger.info().hash << " missing normal list";
} }
} }
if ((seq & 0xff) != 0) if ((seq & 0xff) != 0)
{ {
if (journal.debug) journal.debug << JLOG (journal.debug) <<
"Can't get seq " << seq << "Can't get seq " << seq <<
" from " << ledger.seq() << " past"; " from " << ledger.seq() << " past";
return boost::none; return boost::none;
@@ -576,7 +575,7 @@ hashOfSeq (ReadView const& ledger, LedgerIndex seq,
if (vec.size () > diff) if (vec.size () > diff)
return vec[vec.size () - diff - 1]; return vec[vec.size () - diff - 1];
} }
if (journal.warning) journal.warning << JLOG (journal.warning) <<
"Can't get seq " << seq << "Can't get seq " << seq <<
" from " << ledger.seq() << " error"; " from " << ledger.seq() << " error";
return boost::none; return boost::none;