Skip to content

Commit

Permalink
Conway: add ref scripts size to TxMeasure
Browse files Browse the repository at this point in the history
  • Loading branch information
amesgen committed Jul 1, 2024
1 parent b07cf3f commit 3be53f2
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Breaking

- Introduced `ConwayMeasure`, a Conway-specific `TxMeasure` adding the total
reference scripts size as a new dimension on top of `AlonzoMeasure`.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ module Ouroboros.Consensus.Shelley.Ledger.Mempool (
, perTxOverhead
-- * Exported for tests
, AlonzoMeasure (..)
, ConwayMeasure (..)
, fromExUnits
) where

Expand Down Expand Up @@ -361,14 +362,36 @@ instance ( ShelleyCompatible p (BabbageEra c)

txsBlockCapacity = txsBlockCapacityAlonzo

data ConwayMeasure = ConwayMeasure {
alonzoMeasure :: !AlonzoMeasure
, refScriptsSize :: !Mempool.ByteSize
} deriving stock (Eq, Generic, Show)
deriving (BoundedMeasure, Measure)
via (InstantiatedAt Generic ConwayMeasure)

instance ( ShelleyCompatible p (ConwayEra c)
) => Mempool.TxLimits (ShelleyBlock p (ConwayEra c)) where

type TxMeasure (ShelleyBlock p (ConwayEra c)) = AlonzoMeasure
type TxMeasure (ShelleyBlock p (ConwayEra c)) = ConwayMeasure

txMeasure _st = txMeasureAlonzo
txMeasure st genTx@(ShelleyValidatedTx _txid vtx) =
ConwayMeasure {
alonzoMeasure = txMeasureAlonzo genTx
, refScriptsSize = Mempool.ByteSize $ fromIntegral $
SL.txNonDistinctRefScriptsSize utxo (SL.extractTx vtx)
}
where
utxo = SL.getUTxO . tickedShelleyLedgerState $ st

txsBlockCapacity = txsBlockCapacityAlonzo

txsBlockCapacity st =
ConwayMeasure {
alonzoMeasure = txsBlockCapacityAlonzo st
, refScriptsSize =
-- TODO use maxRefScriptSizePerBlock from
-- https://github.com/IntersectMBO/cardano-ledger/pull/4450
Mempool.ByteSize $ 2560 * 1024 -- 2.5 MB
}

{-------------------------------------------------------------------------------
WithTop
Expand Down

0 comments on commit 3be53f2

Please sign in to comment.