ensure XahauGenesis is enabled correctly just after the genesis ledger

This commit is contained in:
Richard Holland
2023-10-09 12:15:24 +00:00
parent 58dec112f5
commit 428009c8ca
2 changed files with 40 additions and 1 deletions

View File

@@ -206,7 +206,14 @@ Ledger::Ledger(
if (!amendments.empty())
{
auto const sle = std::make_shared<SLE>(keylet::amendments());
sle->setFieldV256(sfAmendments, STVector256{amendments});
// filter out XahauGenesis, which should be always activated with an EnableAmendment txn
std::vector<uint256> amendmentsLessXahauGenesis;
for (auto a: amendments)
if (a != featureXahauGenesis)
amendmentsLessXahauGenesis.push_back(a);
sle->setFieldV256(sfAmendments, STVector256{amendmentsLessXahauGenesis});
rawInsert(sle);
}

View File

@@ -1726,6 +1726,38 @@ ApplicationImp::startGenesisLedger()
openLedger_.emplace(next, cachedSLEs_, logs_->journal("OpenLedger"));
m_ledgerMaster->storeLedger(next);
m_ledgerMaster->switchLCL(next);
// XahauGenesis must be activated via an enable amendment pseudo txn, otherwise it does nothing
// so rather than add it directly to the amendments table, here is its activation on the first open
// ledger.
for (auto const& a: initialAmendments)
{
if (a == featureXahauGenesis)
{
STTx amendTx(
ttAMENDMENT,
[&](auto& obj) {
obj.setAccountID(sfAccount, AccountID());
obj.setFieldH256(sfAmendment, featureXahauGenesis);
obj.setFieldU32(sfLedgerSequence, openLedger_->current()->info().seq);
});
auto txID = amendTx.getTransactionID();
auto s = std::make_shared<Serializer>();
amendTx.add(*s);
forceValidity(getHashRouter(), txID, Validity::SigGoodOnly);
openLedger_->modify(
[&txID, &s](OpenView& view, beast::Journal j) {
view.rawTxInsert(txID, std::move(s), nullptr);
return true;
});
break;
}
}
}
std::shared_ptr<Ledger>