Skip to content

Commit 501d885

Browse files
committed
Mempool: reject txs that don't fit in an empty mempool
1 parent 6a8def9 commit 501d885

File tree

1 file changed

+11
-1
lines changed
  • ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool

1 file changed

+11
-1
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,17 @@ pureTryAddTx cfg txSize wti tx is
189189
, let curTotalRefScriptSize = isTotalRefScriptSize is
190190
newTxRefScriptSize = txRefScriptSize cfg (isLedgerState is) tx
191191
maxTotalRefScriptSize = 1024 * 1024 -- 1MiB
192-
, curTotalRefScriptSize + newTxRefScriptSize Prelude.<= maxTotalRefScriptSize
192+
mempoolStaysBelowCapacity =
193+
curTotalRefScriptSize + newTxRefScriptSize Prelude.<= maxTotalRefScriptSize
194+
-- In case the tx exceeds the per-tx limit, let it be rejected by tx
195+
-- validation (such that we are not blocked here forever/for a long
196+
-- time).
197+
--
198+
-- For Babbage, this is 100KiB (see @totalRefScriptsSizeLimit@ in
199+
-- "Ouroboros.Consensus.Shelley.Eras"), and for Conway, this is 200KiB
200+
-- (see @maxRefScriptSizePerTx@ in "Cardano.Ledger.Conway.Rules.Ledger").
201+
txRefScriptSizeTooLarge = newTxRefScriptSize Prelude.> 200 * 1024
202+
, mempoolStaysBelowCapacity || txRefScriptSizeTooLarge
193203
=
194204
case eVtx of
195205
-- We only extended the ValidationResult with a single transaction

0 commit comments

Comments
 (0)