Skip to content

Commit

Permalink
Shelley mempool per-tx size check: do not include perTxOverhead (#1352
Browse files Browse the repository at this point in the history
)

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.
  • Loading branch information
amesgen authored Jan 8, 2025
2 parents 911cfb0 + 992a855 commit 4fddb31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4fddb31

Please sign in to comment.