From 92ec07a1bebfe50801b86bc2beafd74af95408ee Mon Sep 17 00:00:00 2001 From: Nicholas Dudfield Date: Fri, 10 Apr 2026 10:36:50 +0700 Subject: [PATCH] chore: regenerate hook/sfcodes.h + format fix Regenerate sfcodes.h to include the new sfSidecarType field (UINT8, code 20). Also apply clang-format to ConsensusExtensions.cpp. --- hook/sfcodes.h | 1 + .../app/consensus/ConsensusExtensions.cpp | 164 +++++++++--------- 2 files changed, 79 insertions(+), 86 deletions(-) diff --git a/hook/sfcodes.h b/hook/sfcodes.h index f8e25b7f0..bd0cb773a 100644 --- a/hook/sfcodes.h +++ b/hook/sfcodes.h @@ -9,6 +9,7 @@ #define sfUNLModifyDisabling ((16U << 16U) + 17U) #define sfHookResult ((16U << 16U) + 18U) #define sfWasLockingChainSend ((16U << 16U) + 19U) +#define sfSidecarType ((16U << 16U) + 20U) #define sfLedgerEntryType ((1U << 16U) + 1U) #define sfTransactionType ((1U << 16U) + 2U) #define sfSignerWeight ((1U << 16U) + 3U) diff --git a/src/xrpld/app/consensus/ConsensusExtensions.cpp b/src/xrpld/app/consensus/ConsensusExtensions.cpp index 55ff786c8..aab2aa539 100644 --- a/src/xrpld/app/consensus/ConsensusExtensions.cpp +++ b/src/xrpld/app/consensus/ConsensusExtensions.cpp @@ -669,96 +669,88 @@ ConsensusExtensions::onAcquiredSidecarSet(std::shared_ptr const& map) } std::size_t merged = 0; - map->visitLeaves( - [&](boost::intrusive_ptr const& item) { - try + map->visitLeaves([&](boost::intrusive_ptr const& + item) { + try + { + SerialIter sit(item->slice()); + STObject sidecar(sit, sfGeneric); + + // Enforce the self-describing type tag. + if (!sidecar.isFieldPresent(sfSidecarType) || + sidecar.getFieldU8(sfSidecarType) != sidecarExportSig) + return; + + if (!sidecar.isFieldPresent(sfTransactionHash) || + !sidecar.isFieldPresent(sfSigningPubKey)) + return; + + auto const txHash = sidecar.getFieldH256(sfTransactionHash); + auto const pk = sidecar.getFieldVL(sfSigningPubKey); + if (!publicKeyType(makeSlice(pk))) + return; + + PublicKey const valPK{makeSlice(pk)}; + if (!app_.validators().trusted(valPK)) + return; + + // Require a real signature (not pubkey-only). + if (!sidecar.isFieldPresent(sfTxnSignature)) + return; + + // Skip if we already have a verified sig for this + // validator (e.g. from the proposal ingestion path). + if (exportSigCollector_.hasVerifiedSignature(txHash, valPK)) + return; + + auto const sigVL = sidecar.getFieldVL(sfTxnSignature); + auto const sigSlice = makeSlice(sigVL); + + // Verify the multisign signature against the inner + // tx. + auto const txIt = exportTxns.find(txHash); + if (txIt == exportTxns.end() || + !txIt->second->isFieldPresent(sfExportedTxn)) { - SerialIter sit(item->slice()); - STObject sidecar(sit, sfGeneric); - - // Enforce the self-describing type tag. - if (!sidecar.isFieldPresent(sfSidecarType) || - sidecar.getFieldU8(sfSidecarType) != - sidecarExportSig) - return; - - if (!sidecar.isFieldPresent(sfTransactionHash) || - !sidecar.isFieldPresent(sfSigningPubKey)) - return; - - auto const txHash = - sidecar.getFieldH256(sfTransactionHash); - auto const pk = sidecar.getFieldVL(sfSigningPubKey); - if (!publicKeyType(makeSlice(pk))) - return; - - PublicKey const valPK{makeSlice(pk)}; - if (!app_.validators().trusted(valPK)) - return; - - // Require a real signature (not pubkey-only). - if (!sidecar.isFieldPresent(sfTxnSignature)) - return; - - // Skip if we already have a verified sig for this - // validator (e.g. from the proposal ingestion path). - if (exportSigCollector_.hasVerifiedSignature( - txHash, valPK)) - return; - - auto const sigVL = - sidecar.getFieldVL(sfTxnSignature); - auto const sigSlice = makeSlice(sigVL); - - // Verify the multisign signature against the inner - // tx. - auto const txIt = exportTxns.find(txHash); - if (txIt == exportTxns.end() || - !txIt->second->isFieldPresent(sfExportedTxn)) - { - JLOG(j_.debug()) - << "Export: SHAMap merge — cannot verify " - "sig for tx " - << txHash - << " (not in open ledger) — skipped"; - return; - } - - auto const& exportedObj = - const_cast(*txIt->second) - .peekAtField(sfExportedTxn) - .downcast(); - - Serializer innerSer; - exportedObj.add(innerSer); - SerialIter sit2(innerSer.slice()); - STTx innerTx(std::ref(sit2)); - - auto const signerAcctID = calcAccountID(valPK); - auto const sigData = - buildMultiSigningData(innerTx, signerAcctID); - if (!verify(valPK, sigData.slice(), sigSlice)) - { - JLOG(j_.warn()) - << "Export: SHAMap merge — invalid sig " - "for tx " - << txHash << " — rejected"; - return; - } - - Buffer sigBuf(sigSlice.data(), sigSlice.size()); - exportSigCollector_.addVerifiedSignature( - txHash, valPK, sigBuf); - ++merged; + JLOG(j_.debug()) + << "Export: SHAMap merge — cannot verify " + "sig for tx " + << txHash << " (not in open ledger) — skipped"; + return; } - catch (std::exception const& e) + + auto const& exportedObj = const_cast(*txIt->second) + .peekAtField(sfExportedTxn) + .downcast(); + + Serializer innerSer; + exportedObj.add(innerSer); + SerialIter sit2(innerSer.slice()); + STTx innerTx(std::ref(sit2)); + + auto const signerAcctID = calcAccountID(valPK); + auto const sigData = + buildMultiSigningData(innerTx, signerAcctID); + if (!verify(valPK, sigData.slice(), sigSlice)) { - JLOG(j_.warn()) - << "Export: SHAMap merge — failed to parse " - "entry: " - << e.what(); + JLOG(j_.warn()) << "Export: SHAMap merge — invalid sig " + "for tx " + << txHash << " — rejected"; + return; } - }); + + Buffer sigBuf(sigSlice.data(), sigSlice.size()); + exportSigCollector_.addVerifiedSignature( + txHash, valPK, sigBuf); + ++merged; + } + catch (std::exception const& e) + { + JLOG(j_.warn()) << "Export: SHAMap merge — failed to parse " + "entry: " + << e.what(); + } + }); JLOG(j_.info()) << "Export: merged " << merged << " verified entries from peer exportSigSet " "hash="