compiling

This commit is contained in:
Richard Holland
2026-08-22 16:21:12 +10:00
parent bf378592c9
commit abc4fbd204
11 changed files with 61 additions and 35 deletions

View File

@@ -89,6 +89,7 @@ enum class LedgerNameSpace : std::uint16_t {
ORACLE = LEDGER_NAMESPACE2(0x01, 'R'),
MPTOKEN_ISSUANCE = '~',
MPTOKEN = 't',
MANIFEST = 'M',
CREDENTIAL = LEDGER_NAMESPACE2(0x01, 'D'),
PERMISSIONED_DOMAIN = 'm',
@@ -671,9 +672,9 @@ permissionedDomain(uint256 const& domainID) noexcept
}
Keylet
manifest(PublicKey const& pk)
manifest(PublicKey const& pk) noexcept
{
return {ltMANIFEST, pk};
return {ltMANIFEST, indexHash(LedgerNameSpace::MANIFEST, pk.slice())};
}
} // namespace keylet

View File

@@ -8445,6 +8445,11 @@ private:
}
}
void testSetManifestTSH(FeatureBitset features)
{
// RH TODO
}
void
testTSH(FeatureBitset features)
{

View File

@@ -173,6 +173,16 @@ deserializeManifest(
return deserializeManifest(makeSlice(s), journal);
}
inline std::optional<Manifest>
deserializeManifest(
STObject const& st,
beast::Journal journal = beast::Journal(beast::Journal::getNullSink()))
{
Serializer s;
st.add(s);
return deserializeManifest(makeSlice(s.peekData()), journal);
}
template <
class T,
class = std::enable_if_t<

View File

@@ -27,7 +27,7 @@
#include <xrpl/protocol/Quality.h>
#include <xrpl/protocol/TxFlags.h>
#include <xrpl/protocol/st.h>
#include <xrpl/app/misc/Manifest.h>
#include <xrpld/app/misc/Manifest.h>
namespace ripple {
@@ -65,7 +65,7 @@ SetManifest::preflight(PreflightContext const& ctx)
.downcast<STObject>();
// 1. sfManifest must match the manifest template and be validly signed
auto manifest = Manifest::deserializeManifest(obj, j);
auto manifest = deserializeManifest(obj, j);
if (!manifest.has_value())
{
@@ -118,10 +118,10 @@ SetManifest::preclaim(PreclaimContext const& ctx)
.getField(sfManifest)
.downcast<STObject>();
auto newManifest = Manifest::deserializeManifest(newObj, j);
auto newManifest = deserializeManifest(newObj, ctx.j);
auto const sleOld = view.read(Keylet{ltMANIFEST, sle->getFieldH256(sfManifestID));
auto const sleOld = ctx.view.read(Keylet{ltMANIFEST, sle->getFieldH256(sfManifestID)});
if (!sleOld)
{
@@ -166,7 +166,7 @@ SetManifest::doApply()
auto sleMan1 = view().peek(Keylet{ltMANIFEST, firstID});
if (!sleMan1)
{
JLOG(ctx.j.error())
JLOG(j_.error())
<< "SetManifest: Old manifest object referenced but missing (ID1) !! " << strHex(firstID);
return tefBAD_LEDGER;
}
@@ -174,7 +174,7 @@ SetManifest::doApply()
uint256 const secondID = sle->getFieldH256(sfManifestID);
if (secondID == firstID)
{
JLOG(ctx.j.error())
JLOG(j_.error())
<< "SetManifest: Manifest second ID references first object!! " << strHex(firstID);
return tefBAD_LEDGER;
}
@@ -182,7 +182,7 @@ SetManifest::doApply()
auto sleMan2 = view().peek(Keylet{ltMANIFEST, secondID});
if (!sleMan2)
{
JLOG(ctx.j.error())
JLOG(j_.error())
<< "SetManifest: Old manifest object referenced but missing (ID2) !! " << strHex(secondID);
return tefBAD_LEDGER;
}
@@ -190,7 +190,7 @@ SetManifest::doApply()
if (sleMan1->getAccountID(sfAccount) != account_ ||
sleMan2->getAccountID(sfAccount) != account_)
{
JLOG(ctx.j.error())
JLOG(j_.error())
<< "SetManifest: One or more manifest IDs point at incorrect account!!";
return tefBAD_LEDGER;
}
@@ -206,21 +206,21 @@ SetManifest::doApply()
.getField(sfManifest)
.downcast<STObject>();
auto manifest = Manifest::deserializeManifest(obj, j);
auto manifest = deserializeManifest(obj, j_);
if (!manifest.has_value())
{
JLOG(j.warn()) << "SetManifest: invalid manifest passed (parseManifest failed).";
JLOG(j_.warn()) << "SetManifest: invalid manifest passed (parseManifest failed).";
return temMALFORMED;
}
if (calcAccountID(manifest->masterKey) != account_)
return tefINTERNAL;
Keylet klMan1 = Keylet::manifest(manifest->masterKey);
Keylet klMan1 = keylet::manifest(manifest->masterKey);
std::optional<Keylet> klMan2;
if (!manifest->revoked() && manifest->signingKey.has_value())
klMan2 = Keylet::manifest(manifest->signingKey);
klMan2 = keylet::manifest(*manifest->signingKey);
auto setManifest = [&](std::shared_ptr<SLE>& sle, std::optional<uint256> otherKey) -> void
{
@@ -230,19 +230,19 @@ SetManifest::doApply()
sle->setFieldVL(sfSigningPubKey, *(manifest->signingKey));
sle->setFieldU32(sfSequence, manifest->sequence);
sle->setFieldU16(sfVersion, 0);
if (manifest->domain.has_value() && manifest->domain != "")
sle->setFieldVL(sfDomain, manifest->domain);
if (manifest->domain != "")
sle->setFieldVL(sfDomain, makeSlice(manifest->domain));
if (otherKey.has_value())
sle>setFieldH256(sfManifestID, *otherKey);
sle->setFieldH256(sfManifestID, *otherKey);
};
std::shared_ptr<SLE> sleMan1 = std::make_shared<SLE>(klMan1);
setManifest(sleMan1, klMan2);
auto sleMan1 = std::make_shared<SLE>(klMan1);
setManifest(sleMan1, klMan2->key);
if (klMan2.has_value())
{
sleMan2 = std::make_shared<SLE>(*klMan2);
setManifest(sleMan2, klMan1);
auto sleMan2 = std::make_shared<SLE>(*klMan2);
setManifest(sleMan2, klMan1.key);
view().insert(sleMan2);
}
@@ -265,6 +265,8 @@ SetManifest::calculateBaseFee(ReadView const& view, STTx const& tx)
.getField(sfManifest)
.downcast<STObject>();
// one drop per byte
manifestFee = XRPAmount { newObj.getSerializer().getDataLength() };
}

View File

@@ -22,6 +22,7 @@
#include <xrpld/app/tx/applySteps.h>
#include <xrpl/basics/Log.h>
#include <xrpl/protocol/Feature.h>
#include <xrpld/app/misc/Manifest.h>
namespace ripple {
@@ -74,7 +75,7 @@ checkValidity(
}
if (rules.enabled(featureOnChainManifests) &&
tx.getTxType() == ttMANIFEST_SET &&
tx.getTxnType() == ttMANIFEST_SET &&
tx.isFieldPresent(sfTxnSignature) &&
tx.getFieldVL(sfTxnSignature).empty() &&
tx.isFieldPresent(sfSigningPubKey) &&
@@ -82,12 +83,12 @@ checkValidity(
tx.isFieldPresent(sfManifest))
{
// perform alternative signature check over manifest
STObject const& man = const_cast<ripple::STTx&>(ctx.tx)
STObject const& manObj = const_cast<ripple::STTx&>(tx)
.getField(sfManifest)
.downcast<STObject>();
auto man = Manifest::deserializeManifest(newObj, j);
if (!man->valid())
auto man = deserializeManifest(manObj);
if (!man.has_value() || !man->verify())
return {
Validity::SigBad,
"Manifest signature is bad"};

View File

@@ -72,6 +72,7 @@
#include <xrpld/app/tx/detail/URIToken.h>
#include <xrpld/app/tx/detail/XChainBridge.h>
#include <xrpld/app/tx/detail/XahauGenesis.h>
#include <xrpld/app/tx/detail/SetManifest.h>
#include <xrpl/protocol/TxFormats.h>
#include <stdexcept>

View File

@@ -30,6 +30,8 @@
#include <xrpl/protocol/ErrorCodes.h>
#include <xrpl/protocol/RPCErr.h>
#include <xrpl/resource/Fees.h>
#include <xrpl/basics/strHex.h>
#include <xrpld/app/ledger/OpenLedger.h>
namespace ripple {
@@ -94,7 +96,7 @@ doSubmit(RPC::JsonContext& context)
context.loadType = Resource::feeMediumBurdenRPC;
bool const hasManifest = context.params.isMemeber(jss::manifest);
bool const hasManifest = context.params.isMember(jss::manifest);
bool const hasTxBlob = context.params.isMember(jss::tx_blob);
if (hasManifest && hasTxBlob)
@@ -143,7 +145,7 @@ doSubmit(RPC::JsonContext& context)
try
{
man = deserializeManifest(makeSlice(*ret), context.app.journal("Submit"));
man = deserializeManifest(makeSlice(*raw), context.app.journal("Submit"));
}
catch (std::exception& e)
{
@@ -174,17 +176,17 @@ doSubmit(RPC::JsonContext& context)
// forward compatible with a future manifest format change, even if that change is into a PQ opaque blob.
STTx tx = STTx(ttMANIFEST_SET, [&](STObject& obj) {
obj.setAccountID(sfAccount, calcAccountID(manifest->masterKey));
obj.setAccountID(sfAccount, calcAccountID(man->masterKey));
obj.setFieldU32(sfSequence, 0);
obj.setFieldU32(sfNetworkID, context.app.overlay().networkID());
obj.setFieldU32(sfNetworkID, context.app.config().NETWORK_ID);
obj.setFieldAmount(sfFee, XRPAmount{0});
obj.setFieldVL(sfSigningPubkey, std::vector<std::uint8_t>{});
obj.setFieldVL(sfSigningPubKey, std::vector<std::uint8_t>{});
obj.setFieldVL(sfTxnSignature, std::vector<std::uint8_t>{});
});
std::string const manifestHex =
+ "E05A" /* object marker for sfManfiest ... this goes at the end of the tx canonically */
+ strHex(raw) /* re-encode the original slice as fresh hex to match case etc */
+ strHex(*raw) /* re-encode the original slice as fresh hex to match case etc */
+ "E1"; /* object end marker for sfManifest */
std::string const txHex = serializeHex(tx) + manifestHex;