mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Enable amendments in genesis ledger (RIPD-1281)
When started with "--start", put all known, non-vetoed amendments in the genesis ledger. This avoids the need to wait 256 ledgers before amendments are enabled when testing with a fresh ledger.
This commit is contained in:
@@ -186,7 +186,11 @@ public:
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
Ledger::Ledger (create_genesis_t, Config const& config, Family& family)
|
||||
Ledger::Ledger (
|
||||
create_genesis_t,
|
||||
Config const& config,
|
||||
std::vector<uint256> const& amendments,
|
||||
Family& family)
|
||||
: mImmutable (false)
|
||||
, txMap_ (std::make_shared <SHAMap> (SHAMapType::TRANSACTION,
|
||||
family, SHAMap::version{1}))
|
||||
@@ -205,6 +209,14 @@ Ledger::Ledger (create_genesis_t, Config const& config, Family& family)
|
||||
sle->setAccountID (sfAccount, id);
|
||||
sle->setFieldAmount (sfBalance, info_.drops);
|
||||
rawInsert(sle);
|
||||
|
||||
if (! amendments.empty())
|
||||
{
|
||||
auto const sle = std::make_shared<SLE>(keylet::amendments());
|
||||
sle->setFieldV256 (sfAmendments, STVector256{amendments});
|
||||
rawInsert(sle);
|
||||
}
|
||||
|
||||
stateMap_->flushDirty (hotACCOUNT_NODE, info_.seq);
|
||||
setImmutable(config);
|
||||
}
|
||||
|
||||
@@ -94,8 +94,14 @@ public:
|
||||
of XRP in the system. No more XRP than the amount which
|
||||
starts in this account can ever exist, with amounts
|
||||
used to pay fees being destroyed.
|
||||
|
||||
Amendments specified are enabled in the genesis ledger
|
||||
*/
|
||||
Ledger (create_genesis_t, Config const& config, Family& family);
|
||||
Ledger (
|
||||
create_genesis_t,
|
||||
Config const& config,
|
||||
std::vector<uint256> const& amendments,
|
||||
Family& family);
|
||||
|
||||
Ledger (
|
||||
LedgerInfo const& info,
|
||||
|
||||
@@ -1248,9 +1248,17 @@ int ApplicationImp::fdlimit() const
|
||||
void
|
||||
ApplicationImp::startGenesisLedger()
|
||||
{
|
||||
std::vector<uint256> initialAmendments =
|
||||
(config_->START_UP == Config::FRESH) ?
|
||||
m_amendmentTable->getDesired() :
|
||||
std::vector<uint256>{};
|
||||
|
||||
std::shared_ptr<Ledger> const genesis =
|
||||
std::make_shared<Ledger>(
|
||||
create_genesis, *config_, family());
|
||||
create_genesis,
|
||||
*config_,
|
||||
initialAmendments,
|
||||
family());
|
||||
m_ledgerMaster->storeLedger (genesis);
|
||||
|
||||
auto const next = std::make_shared<Ledger>(
|
||||
|
||||
@@ -85,6 +85,13 @@ public:
|
||||
virtual std::vector <uint256>
|
||||
doValidation (std::set <uint256> const& enabled) = 0;
|
||||
|
||||
// The set of amendments to enable in the genesis ledger
|
||||
// This will return all known, non-vetoed amendments.
|
||||
// If we ever have two amendments that should not both be
|
||||
// enabled at the same time, we should ensure one is vetoed.
|
||||
virtual std::vector <uint256>
|
||||
getDesired () = 0;
|
||||
|
||||
// The two function below adapt the API callers expect to the
|
||||
// internal amendment table API. This allows the amendment
|
||||
// table implementation to be independent of the ledger
|
||||
|
||||
@@ -199,6 +199,9 @@ public:
|
||||
std::vector <uint256>
|
||||
doValidation (std::set<uint256> const& enabledAmendments) override;
|
||||
|
||||
std::vector <uint256>
|
||||
getDesired () override;
|
||||
|
||||
std::map <uint256, std::uint32_t>
|
||||
doVoting (
|
||||
NetClock::time_point closeTime,
|
||||
@@ -396,6 +399,31 @@ AmendmentTableImpl::doValidation (
|
||||
return amendments;
|
||||
}
|
||||
|
||||
std::vector <uint256>
|
||||
AmendmentTableImpl::getDesired ()
|
||||
{
|
||||
// Get the list of amendments we support and do not
|
||||
// veto
|
||||
std::vector <uint256> amendments;
|
||||
amendments.reserve (amendmentMap_.size());
|
||||
|
||||
{
|
||||
std::lock_guard <std::mutex> sl (mutex_);
|
||||
for (auto const& e : amendmentMap_)
|
||||
{
|
||||
if (e.second.supported && ! e.second.vetoed)
|
||||
{
|
||||
amendments.push_back (e.first);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!amendments.empty())
|
||||
std::sort (amendments.begin (), amendments.end ());
|
||||
|
||||
return amendments;
|
||||
}
|
||||
|
||||
std::map <uint256, std::uint32_t>
|
||||
AmendmentTableImpl::doVoting (
|
||||
NetClock::time_point closeTime,
|
||||
|
||||
Reference in New Issue
Block a user