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
#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
When set, restricts the number of threads calling io_service::run to one.
This is useful when debugging.

View File

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

View File

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

View File

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

View File

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

View File

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