Skip to content

Commit 1ddee1c

Browse files
committed
Conway: add ref scripts size to TxMeasure
1 parent 4a2b2c2 commit 1ddee1c

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Breaking
2+
3+
- Introduced `ConwayMeasure`, a Conway-specific `TxMeasure` adding the total
4+
reference scripts size as a new dimension on top of `AlonzoMeasure`.

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

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
364372
instance ( 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

Comments
 (0)