@@ -30,6 +30,7 @@ module Ouroboros.Consensus.Shelley.Ledger.Mempool (
3030 , perTxOverhead
3131 -- * Exported for tests
3232 , AlonzoMeasure (.. )
33+ , ConwayMeasure (.. )
3334 , fromExUnits
3435 ) where
3536
@@ -361,14 +362,36 @@ instance ( ShelleyCompatible p (BabbageEra c)
361362
362363 txsBlockCapacity = txsBlockCapacityAlonzo
363364
365+ data ConwayMeasure = ConwayMeasure {
366+ alonzoMeasure :: ! AlonzoMeasure
367+ , refScriptsSize :: ! Mempool. ByteSize
368+ } deriving stock (Eq , Generic , Show )
369+ deriving (BoundedMeasure , Measure )
370+ via (InstantiatedAt Generic ConwayMeasure )
371+
364372instance ( ShelleyCompatible p (ConwayEra c )
365373 ) => Mempool. TxLimits (ShelleyBlock p (ConwayEra c )) where
366374
367- type TxMeasure (ShelleyBlock p (ConwayEra c )) = AlonzoMeasure
375+ type TxMeasure (ShelleyBlock p (ConwayEra c )) = ConwayMeasure
368376
369- txMeasure _st = txMeasureAlonzo
377+ txMeasure st genTx@ (ShelleyValidatedTx _txid vtx) =
378+ ConwayMeasure {
379+ alonzoMeasure = txMeasureAlonzo genTx
380+ , refScriptsSize = Mempool. ByteSize $ fromIntegral $
381+ SL. txNonDistinctRefScriptsSize utxo (SL. extractTx vtx)
382+ }
383+ where
384+ utxo = SL. getUTxO . tickedShelleyLedgerState $ st
370385
371- txsBlockCapacity = txsBlockCapacityAlonzo
386+
387+ txsBlockCapacity st =
388+ ConwayMeasure {
389+ alonzoMeasure = txsBlockCapacityAlonzo st
390+ , refScriptsSize =
391+ -- TODO use maxRefScriptSizePerBlock from
392+ -- https://github.com/IntersectMBO/cardano-ledger/pull/4450
393+ Mempool. ByteSize $ 2560 * 1024 -- 2.5 MB
394+ }
372395
373396{- ------------------------------------------------------------------------------
374397 WithTop
0 commit comments