Skip to content

Commit 4fddb31

Browse files
authored
Shelley mempool per-tx size check: do not include perTxOverhead (#1352)
With the previous logic, a tx that has less than `perTxOverhead = 4` bytes less than the max tx size will be rejected by the mempool even though it is perfectly valid. This bug was introduced in #1175. This behavior could be rather surprising for users who create a big (but not too big) tx and then can't submit it to any node. The fix is to use the "raw" size (without adding `perTxOverhead`) for the check, but to still add `perTxOverhead` when returning the `TxMeasure`. Related: This code shouldn't live in Consensus (also see the module header), cf IntersectMBO/cardano-ledger#4820.
2 parents 911cfb0 + 992a855 commit 4fddb31

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Patch
2+
3+
- Fixed a bug where a valid tx with less than `4` bytes less than the max tx
4+
size would be incorrectly rejected by the mempool.

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Mempool.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,9 +328,9 @@ txInBlockSize ::
328328
txInBlockSize st (ShelleyTx _txid tx') =
329329
validateMaybe (maxTxSizeUTxO txsz limit) $ do
330330
guard $ txsz <= limit
331-
Just $ IgnoringOverflow $ ByteSize32 $ fromIntegral txsz
331+
Just $ IgnoringOverflow $ ByteSize32 $ fromIntegral txsz + perTxOverhead
332332
where
333-
txsz = perTxOverhead + (tx' ^. sizeTxF)
333+
txsz = tx' ^. sizeTxF
334334

335335
pparams = getPParams $ tickedShelleyLedgerState st
336336
limit = fromIntegral (pparams ^. L.ppMaxTxSizeL) :: Integer

0 commit comments

Comments
 (0)