From 8d86c5e17d14b013ad9139e79743e6674e58744a Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Thu, 19 Oct 2023 19:00:49 +0200 Subject: [PATCH] fix: allow pseudo-transactions to omit NetworkID (#4737) The Network ID logic should not be applied to pseudo-transactions. This allows amendments to enable on a network with an ID > 1024. Context: - NetworkID: https://github.com/XRPLF/rippled/pull/4370 - Pseudo-transactions: https://xrpl.org/pseudo-transaction-types.html Fix #4736 --------- Co-authored-by: RichardAH --- src/ripple/app/tx/impl/Transactor.cpp | 37 +++++++++++++++------------ 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index 449392531b8..1affb6fcc56 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -40,25 +40,28 @@ namespace ripple { NotTEC preflight0(PreflightContext const& ctx) { - uint32_t const nodeNID = ctx.app.config().NETWORK_ID; - std::optional const txNID = ctx.tx[~sfNetworkID]; - - if (nodeNID <= 1024) + if (!isPseudoTx(ctx.tx) || ctx.tx.isFieldPresent(sfNetworkID)) { - // legacy networks have IDs 1024 and below. These networks cannot - // specify NetworkID in txn - if (txNID) - return telNETWORK_ID_MAKES_TX_NON_CANONICAL; - } - else - { - // new networks both require the field to be present and require it to - // match - if (!txNID) - return telREQUIRES_NETWORK_ID; + uint32_t nodeNID = ctx.app.config().NETWORK_ID; + std::optional txNID = ctx.tx[~sfNetworkID]; + + if (nodeNID <= 1024) + { + // legacy networks have ids less than 1024, these networks cannot + // specify NetworkID in txn + if (txNID) + return telNETWORK_ID_MAKES_TX_NON_CANONICAL; + } + else + { + // new networks both require the field to be present and require it + // to match + if (!txNID) + return telREQUIRES_NETWORK_ID; - if (*txNID != nodeNID) - return telWRONG_NETWORK; + if (*txNID != nodeNID) + return telWRONG_NETWORK; + } } auto const txID = ctx.tx.getTransactionID();