From 428009c8ca4715b86599455b91cc8b73d2fcced8 Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Mon, 9 Oct 2023 12:15:24 +0000 Subject: [PATCH] ensure XahauGenesis is enabled correctly just after the genesis ledger --- src/ripple/app/ledger/Ledger.cpp | 9 +++++++- src/ripple/app/main/Application.cpp | 32 +++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/src/ripple/app/ledger/Ledger.cpp b/src/ripple/app/ledger/Ledger.cpp index 1d381115f..f19fa5125 100644 --- a/src/ripple/app/ledger/Ledger.cpp +++ b/src/ripple/app/ledger/Ledger.cpp @@ -206,7 +206,14 @@ Ledger::Ledger( if (!amendments.empty()) { auto const sle = std::make_shared(keylet::amendments()); - sle->setFieldV256(sfAmendments, STVector256{amendments}); + + // filter out XahauGenesis, which should be always activated with an EnableAmendment txn + std::vector amendmentsLessXahauGenesis; + for (auto a: amendments) + if (a != featureXahauGenesis) + amendmentsLessXahauGenesis.push_back(a); + + sle->setFieldV256(sfAmendments, STVector256{amendmentsLessXahauGenesis}); rawInsert(sle); } diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index 7446c7d33..21b39131c 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -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(); + 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