diff --git a/ouroboros-consensus-cardano/changelog.d/20240627_125444_alexander.esgen_conway_mempool_refscript_limit.md b/ouroboros-consensus-cardano/changelog.d/20240627_125444_alexander.esgen_conway_mempool_refscript_limit.md new file mode 100644 index 0000000000..5ef5c65240 --- /dev/null +++ b/ouroboros-consensus-cardano/changelog.d/20240627_125444_alexander.esgen_conway_mempool_refscript_limit.md @@ -0,0 +1,4 @@ +### Non-Breaking + +- Also enabled total ref script size limit in the mempool in Conway (it + continues to be enabled in Babbage). diff --git a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs index bc204208da..bc3137ff54 100644 --- a/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs +++ b/ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Eras.hs @@ -211,6 +211,11 @@ defaultApplyShelleyBasedTx globals ledgerEnv mempoolState _wti tx = do refScriptPredicate = case getBabbageTxDict (Proxy @era) of Nothing -> pure () Just (BabbageTxDict mkError) + -- The ledger rules of Conway (and later eras) already handle ref + -- scripts appropriately, so we only need to perform the checks below + -- for Babbage. + | not $ isBeforeConway (Proxy @era) + -> pure () -- Reject it if it has more than 100 kibibytes of ref script. | refScriptsSize > totalRefScriptsSizeLimit -> throwError $ mkError @@ -299,7 +304,12 @@ instance (Praos.PraosCrypto c) => ShelleyBasedEra (ConwayEra c) where getConwayEraGovDict _ = Just ConwayEraGovDict - getBabbageTxDict _ = Nothing + getBabbageTxDict _ = Just $ BabbageTxDict $ \a b -> + SL.ApplyTxError + $ pure + $ Conway.ConwayUtxowFailure + $ Conway.UtxoFailure + $ Conway.MaxTxSizeUTxO a b applyAlonzoBasedTx :: forall era. ( ShelleyBasedEra era, diff --git a/ouroboros-consensus/changelog.d/20240820_160936_alexander.esgen_conway_mempool_refscript_limit.md b/ouroboros-consensus/changelog.d/20240820_160936_alexander.esgen_conway_mempool_refscript_limit.md new file mode 100644 index 0000000000..8d4ffc822c --- /dev/null +++ b/ouroboros-consensus/changelog.d/20240820_160936_alexander.esgen_conway_mempool_refscript_limit.md @@ -0,0 +1,4 @@ +### Non-Breaking + +- Mempool: also changed to use the more conservative value of Ledger's + `maxRefScriptSizePerBlock`, ie 1MiB, that was decided on for Conway. diff --git a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs index e41b3669f8..5950c7ee2b 100644 --- a/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs +++ b/ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Mempool/Update.hs @@ -185,10 +185,11 @@ pureTryAddTx cfg txSize wti tx is -- mempool, and... | let curSize = msNumBytes $ isMempoolSize is , curSize < getMempoolCapacityBytes (isCapacity is) - -- ... if the mempool has less than 2.5 mebibytes of ref scripts. - , let maxTotalRefScriptSize = 5 * 512 * 1024 -- 2.5 Mebibytes - curTotalRefScriptSize = isTotalRefScriptSize is - , curTotalRefScriptSize Prelude.< maxTotalRefScriptSize + -- ... if the mempool will have at most 1 mebibyte of ref scripts. + , let curTotalRefScriptSize = isTotalRefScriptSize is + newTxRefScriptSize = txRefScriptSize cfg (isLedgerState is) tx + maxTotalRefScriptSize = 1024 * 1024 -- 1MiB + , curTotalRefScriptSize + newTxRefScriptSize Prelude.<= maxTotalRefScriptSize = case eVtx of -- We only extended the ValidationResult with a single transaction