From 17255f777080468b7cb795b04cf1055cc8b3be17 Mon Sep 17 00:00:00 2001 From: RichardAH Date: Tue, 30 May 2023 14:39:22 +0200 Subject: [PATCH 1/4] Network ID logic should not be applied to pseudos --- src/ripple/app/tx/impl/Transactor.cpp | 35 ++++++++++++++++----------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index 449392531b8..b554b27a357 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -40,25 +40,32 @@ 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)) { - // legacy networks have IDs 1024 and below. These networks cannot - // specify NetworkID in txn - if (txNID) - return telNETWORK_ID_MAKES_TX_NON_CANONICAL; + // all emitted and pseudo transactions are free to pass, do not need network id } 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 (*txNID != nodeNID) - return telWRONG_NETWORK; + 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; + } } auto const txID = ctx.tx.getTransactionID(); From 615c7b326ad7886442c530a894ee2494a00dd277 Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Mon, 2 Oct 2023 19:06:55 +0200 Subject: [PATCH 2/4] clang-format --- src/ripple/app/tx/impl/Transactor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index b554b27a357..280c59ac6d8 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -42,7 +42,8 @@ preflight0(PreflightContext const& ctx) { if (isPseudoTx(ctx.tx)) { - // all emitted and pseudo transactions are free to pass, do not need network id + // all emitted and pseudo transactions are free to pass, do not need + // network id } else { @@ -58,8 +59,8 @@ preflight0(PreflightContext const& ctx) } else { - // new networks both require the field to be present and require it to - // match + // new networks both require the field to be present and require it + // to match if (!txNID) return telREQUIRES_NETWORK_ID; From 1ef59e81137c84b4f49019312bcfbea9df6eaf2d Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Tue, 17 Oct 2023 17:06:31 +0200 Subject: [PATCH 3/4] Update Transactor.cpp --- src/ripple/app/tx/impl/Transactor.cpp | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index 280c59ac6d8..a118ff04b3f 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -40,12 +40,7 @@ namespace ripple { NotTEC preflight0(PreflightContext const& ctx) { - if (isPseudoTx(ctx.tx)) - { - // all emitted and pseudo transactions are free to pass, do not need - // network id - } - else + if (ctx.tx.isFieldPresent(sfNetworkID)) { uint32_t nodeNID = ctx.app.config().NETWORK_ID; std::optional txNID = ctx.tx[~sfNetworkID]; From d8b2ba42a6b2ba1a327ecb7f8021bdff662f3e75 Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Wed, 18 Oct 2023 08:33:15 +0200 Subject: [PATCH 4/4] Update Transactor.cpp --- src/ripple/app/tx/impl/Transactor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ripple/app/tx/impl/Transactor.cpp b/src/ripple/app/tx/impl/Transactor.cpp index a118ff04b3f..1affb6fcc56 100644 --- a/src/ripple/app/tx/impl/Transactor.cpp +++ b/src/ripple/app/tx/impl/Transactor.cpp @@ -40,7 +40,7 @@ namespace ripple { NotTEC preflight0(PreflightContext const& ctx) { - if (ctx.tx.isFieldPresent(sfNetworkID)) + if (!isPseudoTx(ctx.tx) || ctx.tx.isFieldPresent(sfNetworkID)) { uint32_t nodeNID = ctx.app.config().NETWORK_ID; std::optional txNID = ctx.tx[~sfNetworkID];