diff --git a/src/ripple/app/hook/Guard.h b/src/ripple/app/hook/Guard.h index 166d821db..0e4c13151 100644 --- a/src/ripple/app/hook/Guard.h +++ b/src/ripple/app/hook/Guard.h @@ -1034,7 +1034,8 @@ validateGuards( { // PASS, this is a version 1 api } - else if (rulesVersion & 0x04U && + else if ( + rulesVersion & 0x04U && hook_api::import_whitelist_2.find(import_name) != hook_api::import_whitelist_2.end()) { diff --git a/src/ripple/app/hook/applyHook.h b/src/ripple/app/hook/applyHook.h index 3c806fb7b..5f2513470 100644 --- a/src/ripple/app/hook/applyHook.h +++ b/src/ripple/app/hook/applyHook.h @@ -413,10 +413,7 @@ DECLARE_HOOK_FUNCTION( uint32_t write_len, uint32_t read_ptr, uint32_t read_len); -DECLARE_HOOK_FUNCTION( - int64_t, - xport_reserve, - uint32_t count); +DECLARE_HOOK_FUNCTION(int64_t, xport_reserve, uint32_t count); /* DECLARE_HOOK_FUNCTION(int64_t, str_find, uint32_t hread_ptr, uint32_t hread_len, uint32_t nread_ptr, uint32_t nread_len, uint32_t mode, @@ -496,8 +493,7 @@ struct HookResult std::queue> emittedTxn{}; // etx stored here until accept/rollback - std::queue> - exportedTxn{}; + std::queue> exportedTxn{}; HookStateMap& stateMap; uint16_t changedStateCount = 0; std::map< diff --git a/src/ripple/app/hook/impl/applyHook.cpp b/src/ripple/app/hook/impl/applyHook.cpp index 09fc872f3..ed4671667 100644 --- a/src/ripple/app/hook/impl/applyHook.cpp +++ b/src/ripple/app/hook/impl/applyHook.cpp @@ -1971,8 +1971,7 @@ hook::finalizeHookResult( // directory) if we are allowed to std::vector> emission_txnid; - std::vector - exported_txnid; + std::vector exported_txnid; if (doEmit) { @@ -2028,8 +2027,7 @@ hook::finalizeHookResult( } } } - - + DBG_PRINTF("exported txn count: %d\n", hookResult.exportedTxn.size()); for (; hookResult.exportedTxn.size() > 0; hookResult.exportedTxn.pop()) { @@ -2037,8 +2035,8 @@ hook::finalizeHookResult( auto& id = tpTrans->getID(); JLOG(j.trace()) << "HookExport[" << HR_ACC() << "]: " << id; - // exported txns must be marked bad by the hash router to ensure under - // no circumstances they will enter consensus on *this* chain. + // exported txns must be marked bad by the hash router to ensure + // under no circumstances they will enter consensus on *this* chain. applyCtx.app.getHashRouter().setFlags(id, SF_BAD); std::shared_ptr ptr = @@ -2074,8 +2072,7 @@ hook::finalizeHookResult( { JLOG(j.warn()) << "HookError[" << HR_ACC() << "]: " - << "Export Directory full when trying to insert " - << id; + << "Export Directory full when trying to insert " << id; return tecDIR_FULL; } } @@ -2108,9 +2105,7 @@ hook::finalizeHookResult( emission_txnid.size()); // this will never wrap, hard limit if (applyCtx.view().rules().enabled(featureExport)) { - meta.setFieldU16( - sfHookExportCount, - exported_txnid.size()); + meta.setFieldU16(sfHookExportCount, exported_txnid.size()); } meta.setFieldU16(sfHookExecutionIndex, exec_index); meta.setFieldU16(sfHookStateChangeCount, hookResult.changedStateCount); @@ -6284,10 +6279,11 @@ DEFINE_HOOK_FUNCTION( stpTrans->getAccountID(sfAccount) != hookCtx.result.account) { JLOG(j.trace()) << "HookExport[" << HC_ACC() - << "]: Attempted to export a txn that's not for this Hook's Account ID."; + << "]: Attempted to export a txn that's not for this " + "Hook's Account ID."; return EXPORT_FAILURE; } - + std::string reason; auto tpTrans = std::make_shared(stpTrans, reason, app); // RHTODO: is this needed or wise? VVV diff --git a/src/ripple/app/main/Application.cpp b/src/ripple/app/main/Application.cpp index bcb8ecc7e..5d952c376 100644 --- a/src/ripple/app/main/Application.cpp +++ b/src/ripple/app/main/Application.cpp @@ -605,7 +605,6 @@ public: return validatorKeys_; } - NetworkOPs& getOPs() override { diff --git a/src/ripple/app/misc/impl/TxQ.cpp b/src/ripple/app/misc/impl/TxQ.cpp index 31e009a40..77df92246 100644 --- a/src/ripple/app/misc/impl/TxQ.cpp +++ b/src/ripple/app/misc/impl/TxQ.cpp @@ -22,13 +22,13 @@ #include #include #include +#include #include #include #include +#include #include #include -#include -#include #include #include #include @@ -1621,9 +1621,9 @@ TxQ::accept(Application& app, OpenView& view) if (nodeType != ltEXPORTED_TXN) { - JLOG(j_.warn()) - << "ExportedTxn processing: emitted directory contained " - "non ltEMITTED_TXN type"; + JLOG(j_.warn()) << "ExportedTxn processing: emitted " + "directory contained " + "non ltEMITTED_TXN type"; // RH TODO: if this ever happens the entry should be // gracefully removed (somehow) continue; @@ -1647,19 +1647,21 @@ TxQ::accept(Application& app, OpenView& view) // this shouldn't happen, but do nothing continue; } - + if (exportedLgrSeq < seq - 1) { - // all old entries need to be turned into Export transactions so they can be removed - // from the directory + // all old entries need to be turned into Export + // transactions so they can be removed from the directory - // in the previous ledger all the ExportSign transactions were executed, and one-by-one - // added the validators' signatures to the ltEXPORTED_TXN's sfSigners array. - // now we need to collect these together and place them inside the ExportedTxn blob - // and publish the blob in the Export transaction type. + // in the previous ledger all the ExportSign transactions + // were executed, and one-by-one added the validators' + // signatures to the ltEXPORTED_TXN's sfSigners array. now + // we need to collect these together and place them inside + // the ExportedTxn blob and publish the blob in the Export + // transaction type. STArray signers = sleItem->getFieldArray(sfSigners); - + auto s = std::make_shared(); exported.add(*s); SerialIter sitTrans(s->slice()); @@ -1682,16 +1684,16 @@ TxQ::accept(Application& app, OpenView& view) stpTrans->setFieldArray(sfSigners, signers); - Blob const& blob = stpTrans->getSerializer().peekData(); + Blob const& blob = stpTrans->getSerializer().peekData(); - STTx exportTx(ttEXPORT, [&](auto& obj) { + STTx exportTx(ttEXPORT, [&](auto& obj) { obj.setFieldVL(sfExportedTxn, blob); obj.setFieldU32(sfLedgerSequence, seq); obj.setFieldH256(sfTransactionHash, txnHash); - obj.setFieldArray(sfSigners, signers); - }); - - // submit to the ledger + obj.setFieldArray(sfSigners, signers); + }); + + // submit to the ledger { uint256 txID = exportTx.getTransactionID(); auto s = std::make_shared(); @@ -1701,7 +1703,6 @@ TxQ::accept(Application& app, OpenView& view) view.rawTxInsert(txID, std::move(s), nullptr); ledgerChanged = true; } - } catch (std::exception& e) @@ -1710,13 +1711,12 @@ TxQ::accept(Application& app, OpenView& view) << "ExportedTxn Processing: Failure: " << e.what() << "\n"; } - continue; } - - // this ledger is the one after the exported txn was added to the directory - // so generate the export sign txns + + // this ledger is the one after the exported txn was added to + // the directory so generate the export sign txns auto s = std::make_shared(); exported.add(*s); @@ -1738,25 +1738,25 @@ TxQ::accept(Application& app, OpenView& view) auto seq = view.info().seq; auto txnHash = stpTrans->getTransactionID(); - - Serializer s = - buildMultiSigningData(*stpTrans, signingAcc); - auto multisig = ripple::sign(keys.publicKey, keys.secretKey, s.slice()); + Serializer s = buildMultiSigningData(*stpTrans, signingAcc); - STTx exportSignTx(ttEXPORT_SIGN, [&](auto& obj) { - obj.set(([&]() { - auto inner = std::make_unique(sfSigner); + auto multisig = + ripple::sign(keys.publicKey, keys.secretKey, s.slice()); + + STTx exportSignTx(ttEXPORT_SIGN, [&](auto& obj) { + obj.set(([&]() { + auto inner = std::make_unique(sfSigner); inner->setFieldVL(sfSigningPubKey, keys.publicKey); inner->setAccountID(sfAccount, signingAcc); - inner->setFieldVL(sfTxnSignature, multisig); - return inner; - })()); + inner->setFieldVL(sfTxnSignature, multisig); + return inner; + })()); obj.setFieldU32(sfLedgerSequence, seq); - obj.setFieldH256(sfTransactionHash, txnHash); - }); - - // submit to the ledger + obj.setFieldH256(sfTransactionHash, txnHash); + }); + + // submit to the ledger { uint256 txID = exportSignTx.getTransactionID(); auto s = std::make_shared(); @@ -1779,7 +1779,6 @@ TxQ::accept(Application& app, OpenView& view) view, exportedDirKeylet.key, sleDirNode, uDirEntry, dirEntry)); } while (0); - } // Inject emitted transactions if any diff --git a/src/ripple/app/tx/impl/Change.cpp b/src/ripple/app/tx/impl/Change.cpp index d1175ee3a..6f0a366e1 100644 --- a/src/ripple/app/tx/impl/Change.cpp +++ b/src/ripple/app/tx/impl/Change.cpp @@ -96,8 +96,9 @@ Change::preflight(PreflightContext const& ctx) } } - if ((ctx.tx.getTxnType() == ttEXPORT_SIGN || ctx.tx.getTxnType() == ttEXPORT) && - !ctx.rules.enabled(featureExport)) + if ((ctx.tx.getTxnType() == ttEXPORT_SIGN || + ctx.tx.getTxnType() == ttEXPORT) && + !ctx.rules.enabled(featureExport)) { JLOG(ctx.j.warn()) << "Change: Export not enabled"; return temDISABLED; @@ -1102,9 +1103,11 @@ Change::applyExport() if (!sle) { - // most likely explanation is that this was somehow a double-up, so just ignore + // most likely explanation is that this was somehow a double-up, so + // just ignore JLOG(j_.warn()) - << "HookError[" << txnID << "]: ttExport could not find exported txn in ledger"; + << "HookError[" << txnID + << "]: ttExport could not find exported txn in ledger"; break; } @@ -1139,16 +1142,18 @@ Change::applyExportSign() if (!sle) { - // most likely explanation is that this was somehow a double-up, so just ignore + // most likely explanation is that this was somehow a double-up, so + // just ignore JLOG(j_.warn()) - << "HookError[" << txnID << "]: ttExportSign could not find exported txn in ledger"; + << "HookError[" << txnID + << "]: ttExportSign could not find exported txn in ledger"; break; } // grab the signer object off the txn - STObject signerObj = const_cast(ctx_.tx) - .getField(sfSigner) - .downcast(); + STObject signerObj = const_cast(ctx_.tx) + .getField(sfSigner) + .downcast(); // append it to the signers field in the ledger object STArray signers = sle->getFieldArray(sfSigners); diff --git a/src/ripple/app/tx/impl/Import.cpp b/src/ripple/app/tx/impl/Import.cpp index 5ae7dfd2a..364e73b5c 100644 --- a/src/ripple/app/tx/impl/Import.cpp +++ b/src/ripple/app/tx/impl/Import.cpp @@ -17,6 +17,7 @@ */ //============================================================================== +#include #include #include #include @@ -37,11 +38,11 @@ #include #include #include -#include namespace ripple { -static const uint256 shadowTicketNamespace = uint256::fromVoid("RESERVED NAMESPACE SHADOW TICKET"); +static const uint256 shadowTicketNamespace = + uint256::fromVoid("RESERVED NAMESPACE SHADOW TICKET"); TxConsequences Import::makeTxConsequences(PreflightContext const& ctx) @@ -200,7 +201,8 @@ Import::preflight(PreflightContext const& ctx) if (!stpTrans || !meta) return temMALFORMED; - if (stpTrans->isFieldPresent(sfTicketSequence) && !ctx.rules.enabled(featureExport)) + if (stpTrans->isFieldPresent(sfTicketSequence) && + !ctx.rules.enabled(featureExport)) { JLOG(ctx.j.warn()) << "Import: cannot use TicketSequence XPOP."; return temMALFORMED; @@ -904,10 +906,14 @@ Import::preclaim(PreclaimContext const& ctx) // check if there is a shadow ticket, and if not we won't allow // the txn to pass into consensus - if (!ctx.view.exists(keylet::hookState(acc, seq, shadowTicketNamespace))) + if (!ctx.view.exists( + keylet::hookState(acc, seq, shadowTicketNamespace))) { - JLOG(ctx.j.warn()) << "Import: attempted to import a txn without shadow ticket."; - return telSHADOW_TICKET_REQUIRED; // tel code to avoid consensus/forward without SF_BAD + JLOG(ctx.j.warn()) + << "Import: attempted to import a txn without shadow ticket."; + return telSHADOW_TICKET_REQUIRED; // tel code to avoid + // consensus/forward without + // SF_BAD } } @@ -953,7 +959,6 @@ Import::preclaim(PreclaimContext const& ctx) if (!hasTicket) { - if (sle && sle->isFieldPresent(sfImportSequence)) { uint32_t sleImportSequence = sle->getFieldU32(sfImportSequence); @@ -1271,9 +1276,10 @@ Import::doApply() std::optional ticket; if (stpTrans->isFieldPresent(sfTicketSequence)) - ticket = uint256(stpTrans->getFieldU32(sfTicketSequence)); + ticket = uint256(stpTrans->getFieldU32(sfTicketSequence)); - if (sle && !ticket.has_value() && sle->getFieldU32(sfImportSequence) >= importSequence) + if (sle && !ticket.has_value() && + sle->getFieldU32(sfImportSequence) >= importSequence) { // make double sure import seq hasn't passed JLOG(ctx_.journal.warn()) << "Import: ImportSequence passed"; @@ -1370,21 +1376,22 @@ Import::doApply() sle->setFieldU32(sfImportSequence, importSequence); sle->setFieldAmount(sfBalance, finalBal); - + if (ticket.has_value()) { - auto sleTicket = view().peek(keylet::hookState(id, *ticket, shadowTicketNamespace)); + auto sleTicket = + view().peek(keylet::hookState(id, *ticket, shadowTicketNamespace)); if (!sleTicket) return tefINTERNAL; - TER result = hook::setHookState(ctx_, id, shadowTicketNamespace, *ticket, {}); + TER result = + hook::setHookState(ctx_, id, shadowTicketNamespace, *ticket, {}); if (result != tesSUCCESS) return result; // RHUPTO: ticketseq billing? } - if (create) { view().insert(sle); diff --git a/src/ripple/protocol/impl/Indexes.cpp b/src/ripple/protocol/impl/Indexes.cpp index 38048f614..4b9f1229c 100644 --- a/src/ripple/protocol/impl/Indexes.cpp +++ b/src/ripple/protocol/impl/Indexes.cpp @@ -66,8 +66,8 @@ enum class LedgerNameSpace : std::uint16_t { HOOK_DEFINITION = 'D', EMITTED_TXN = 'E', EMITTED_DIR = 'F', - EXPORTED_TXN = 0x4578, // Ex - EXPORTED_DIR = 0x4564, // Ed + EXPORTED_TXN = 0x4578, // Ex + EXPORTED_DIR = 0x4564, // Ed NFTOKEN_OFFER = 'q', NFTOKEN_BUY_OFFERS = 'h', NFTOKEN_SELL_OFFERS = 'i', diff --git a/src/ripple/protocol/impl/TxFormats.cpp b/src/ripple/protocol/impl/TxFormats.cpp index df7bc72cd..cb2a313ac 100644 --- a/src/ripple/protocol/impl/TxFormats.cpp +++ b/src/ripple/protocol/impl/TxFormats.cpp @@ -509,7 +509,6 @@ TxFormats::TxFormats() {sfLedgerSequence, soeREQUIRED}, }, commonFields); - } TxFormats const&