From 992a85530ea1245f585754e15e865fac1e303518 Mon Sep 17 00:00:00 2001 From: Alexander Esgen Date: Tue, 7 Jan 2025 12:47:02 +0100 Subject: [PATCH] Shelley mempool per-tx size check: do not include `perTxOverhead` See the PR description for details --- ...107_124744_alexander.esgen_shelley_mempool_txsize_check.md | 4 ++++ .../src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) create mode 100644 ouroboros-consensus-cardano/changelog.d/20250107_124744_alexander.esgen_shelley_mempool_txsize_check.md diff --git a/ouroboros-consensus-cardano/changelog.d/20250107_124744_alexander.esgen_shelley_mempool_txsize_check.md b/ouroboros-consensus-cardano/changelog.d/20250107_124744_alexander.esgen_shelley_mempool_txsize_check.md new file mode 100644 index 0000000000..ecbfd60025 --- /dev/null +++ b/ouroboros-consensus-cardano/changelog.d/20250107_124744_alexander.esgen_shelley_mempool_txsize_check.md @@ -0,0 +1,4 @@ +### Patch + +- Fixed a bug where a valid tx with less than `4` bytes less than the max tx + size would be incorrectly rejected by the mempool. diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs index ad6f439ad0..b7ed4a3040 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs @@ -328,9 +328,9 @@ txInBlockSize :: txInBlockSize st (ShelleyTx _txid tx') = validateMaybe (maxTxSizeUTxO txsz limit) $ do guard $ txsz <= limit - Just $ IgnoringOverflow $ ByteSize32 $ fromIntegral txsz + Just $ IgnoringOverflow $ ByteSize32 $ fromIntegral txsz + perTxOverhead where - txsz = perTxOverhead + (tx' ^. sizeTxF) + txsz = tx' ^. sizeTxF pparams = getPParams $ tickedShelleyLedgerState st limit = fromIntegral (pparams ^. L.ppMaxTxSizeL) :: Integer