From 99a357aee25ddd3458b77622a147e49b28a9f364 Mon Sep 17 00:00:00 2001 From: levonpetrosyan93 Date: Wed, 14 Dec 2022 05:03:19 +0400 Subject: [PATCH 1/2] Transaction rejected into mempool issue fixed --- src/wallet/wallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index ad848688e0..99cfff5029 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -4258,7 +4258,7 @@ bool CWallet::CreateTransaction(const std::vector& vecSend, CWalletT nBytes += GetSizeOfCompactSize(nExtraPayloadSize) + nExtraPayloadSize; } - if (nBytes > MAX_STANDARD_TX_SIZE) { + if (GetTransactionWeight(txNew) >= MAX_STANDARD_TX_WEIGHT) { // Do not create oversized transactions (bad-txns-oversize). strFailReason = _("Transaction too large"); return false; From 831e397fbb8095b630379bdf26a9ba5c524ae2f6 Mon Sep 17 00:00:00 2001 From: levonpetrosyan93 Date: Wed, 14 Dec 2022 05:17:35 +0400 Subject: [PATCH 2/2] Unifying tx weight number --- src/net_processing.cpp | 3 +-- src/policy/policy.cpp | 3 +-- src/policy/policy.h | 4 ++-- src/wallet/lelantusjoinsplitbuilder.cpp | 3 +-- 4 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/net_processing.cpp b/src/net_processing.cpp index 585bfc902d..b0d29aef8f 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -639,8 +639,7 @@ bool AddOrphanTx(const CTransactionRef& tx, NodeId peer) EXCLUSIVE_LOCKS_REQUIRE // 100 orphans, each of which is at most 99,999 bytes big is // at most 10 megabytes of orphans and somewhat more byprev index (in the worst case): unsigned int sz = GetTransactionWeight(*tx); - unsigned int szLimit = tx->IsLelantusJoinSplit() ? MAX_LELANTUS_TX_WEIGHT : MAX_STANDARD_TX_WEIGHT; - if (sz >= szLimit) + if (sz >= MAX_NEW_TX_WEIGHT) { LogPrint("mempool", "ignoring large orphan tx (size: %u, hash: %s)\n", sz, hash.ToString()); return false; diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index 572fe39761..5f13132cd1 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -68,8 +68,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes // computing signature hashes is O(ninputs*txsize). Limiting transactions // to MAX_STANDARD_TX_WEIGHT mitigates CPU exhaustion attacks. unsigned int sz = GetTransactionWeight(tx); - unsigned int szLimit = tx.IsLelantusJoinSplit() ? MAX_LELANTUS_TX_WEIGHT : MAX_STANDARD_TX_WEIGHT; - if (sz >= szLimit) { + if (sz >= MAX_NEW_TX_WEIGHT) { reason = "tx-size"; return false; } diff --git a/src/policy/policy.h b/src/policy/policy.h index 2a394fb4d3..4865201be3 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -24,8 +24,8 @@ static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = 3000000; static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000; /** The maximum weight for transactions we're willing to relay/mine */ static const unsigned int MAX_STANDARD_TX_WEIGHT = 400000; -/** The maximum weight for Lelantus joinsplit transactions we're willing to relay/mine */ -static const unsigned int MAX_LELANTUS_TX_WEIGHT = 520000; +/** The new maximum weight for transactions we're willing to relay/mine */ +static const unsigned int MAX_NEW_TX_WEIGHT = 520000; /** Maximum number of signature check operations in an IsStandard() P2SH script */ static const unsigned int MAX_P2SH_SIGOPS = 15; /** The maximum number of sigops we're willing to relay/mine in a single tx */ diff --git a/src/wallet/lelantusjoinsplitbuilder.cpp b/src/wallet/lelantusjoinsplitbuilder.cpp index b451f279e4..ebb0666ec5 100644 --- a/src/wallet/lelantusjoinsplitbuilder.cpp +++ b/src/wallet/lelantusjoinsplitbuilder.cpp @@ -316,8 +316,7 @@ CWalletTx LelantusJoinSplitBuilder::Build( // check fee result.SetTx(MakeTransactionRef(tx)); - unsigned int szLimit = (chainActive.Height() >= Params().GetConsensus().nLelantusV3PayloadStartBlock) ? MAX_LELANTUS_TX_WEIGHT : MAX_STANDARD_TX_WEIGHT; - if (GetTransactionWeight(tx) >= szLimit) { + if (GetTransactionWeight(tx) >= MAX_NEW_TX_WEIGHT) { throw std::runtime_error(_("Transaction too large")); }