Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<!--
A new scriv changelog fragment.

Uncomment the section that is right (remove the HTML comment wrapper).
-->

<!--
### Patch

- A bullet item for the Patch category.

-->
<!--
### Non-Breaking

- A bullet item for the Non-Breaking category.

-->

### Breaking

- Remove the capacity override from forging functions.
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ test-suite shelley-test
constraints,
containers,
filepath,
measures,
microlens,
ouroboros-consensus:{ouroboros-consensus, unstable-consensus-testlib},
ouroboros-consensus-cardano,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,11 @@ import Ouroboros.Consensus.Config
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.SupportsMempool
(LedgerSupportsMempool (..), txForgetValidated)
import qualified Ouroboros.Consensus.Mempool as Mempool
import Ouroboros.Consensus.Protocol.PBFT

forgeByronBlock ::
HasCallStack
=> TopLevelConfig ByronBlock
-> Mempool.TxOverrides ByronBlock -- ^ How to override max tx capacity
-- defined by ledger
-> BlockNo -- ^ Current block number
-> SlotNo -- ^ Current slot number
-> TickedLedgerState ByronBlock -- ^ Current ledger
Expand Down Expand Up @@ -123,15 +120,13 @@ initBlockPayloads = BlockPayloads
forgeRegularBlock ::
HasCallStack
=> BlockConfig ByronBlock
-> Mempool.TxOverrides ByronBlock -- ^ How to override max tx capacity
-- defined by ledger
-> BlockNo -- ^ Current block number
-> SlotNo -- ^ Current slot number
-> TickedLedgerState ByronBlock -- ^ Current ledger
-> [Validated (GenTx ByronBlock)] -- ^ Txs to consider adding in the block
-> PBftIsLeader PBftByronCrypto -- ^ Leader proof ('IsLeader')
-> ByronBlock
forgeRegularBlock cfg maxTxCapacityOverrides bno sno st txs isLeader =
forgeRegularBlock cfg bno sno st txs isLeader =
forge $
forgePBftFields
(mkByronContextDSIGN cfg)
Expand All @@ -146,7 +141,7 @@ forgeRegularBlock cfg maxTxCapacityOverrides bno sno st txs isLeader =
foldr
extendBlockPayloads
initBlockPayloads
(takeLargestPrefixThatFits maxTxCapacityOverrides st txs)
(takeLargestPrefixThatFits st txs)

txPayload :: CC.UTxO.TxPayload
txPayload = CC.UTxO.mkTxPayload (bpTxs blockPayloads)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ import Ouroboros.Consensus.Config.SupportsNode
import Ouroboros.Consensus.HeaderValidation
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.Extended
import qualified Ouroboros.Consensus.Mempool as Mempool
import Ouroboros.Consensus.Node.InitStorage
import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.Node.Run
Expand Down Expand Up @@ -128,10 +127,9 @@ type instance ForgeStateUpdateError ByronBlock = Void

byronBlockForging ::
Monad m
=> Mempool.TxOverrides ByronBlock
-> ByronLeaderCredentials
=> ByronLeaderCredentials
-> BlockForging m ByronBlock
byronBlockForging maxTxCapacityOverrides creds = BlockForging {
byronBlockForging creds = BlockForging {
forgeLabel = blcLabel creds
, canBeLeader
, updateForgeState = \_ _ _ -> return $ ForgeStateUpdated ()
Expand All @@ -141,7 +139,7 @@ byronBlockForging maxTxCapacityOverrides creds = BlockForging {
canBeLeader
slot
tickedPBftState
, forgeBlock = \cfg -> return ....: forgeByronBlock cfg maxTxCapacityOverrides
, forgeBlock = \cfg -> return ....: forgeByronBlock cfg
}
where
canBeLeader = mkPBftCanBeLeader creds
Expand All @@ -156,10 +154,9 @@ mkPBftCanBeLeader (ByronLeaderCredentials sk cert nid _) = PBftCanBeLeader {
blockForgingByron :: Monad m
=> ProtocolParams ByronBlock
-> [BlockForging m ByronBlock]
blockForgingByron ProtocolParamsByron { byronLeaderCredentials = mLeaderCreds
, byronMaxTxCapacityOverrides = maxTxCapacityOverrides
blockForgingByron ProtocolParamsByron { byronLeaderCredentials = mLeaderCreds
} =
byronBlockForging maxTxCapacityOverrides
byronBlockForging
<$> maybeToList mLeaderCreds

{-------------------------------------------------------------------------------
Expand All @@ -178,7 +175,6 @@ data instance ProtocolParams ByronBlock = ProtocolParamsByron {
, byronProtocolVersion :: Update.ProtocolVersion
, byronSoftwareVersion :: Update.SoftwareVersion
, byronLeaderCredentials :: Maybe ByronLeaderCredentials
, byronMaxTxCapacityOverrides :: Mempool.TxOverrides ByronBlock
}

protocolInfoByron :: ProtocolParams ByronBlock
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,6 @@ import Ouroboros.Consensus.HardFork.Combinator.Serialisation
import qualified Ouroboros.Consensus.HardFork.History as History
import Ouroboros.Consensus.HeaderValidation
import Ouroboros.Consensus.Ledger.Extended
import qualified Ouroboros.Consensus.Mempool as Mempool
import Ouroboros.Consensus.Node.NetworkProtocolVersion
import Ouroboros.Consensus.Node.ProtocolInfo
import Ouroboros.Consensus.Node.Run
Expand Down Expand Up @@ -631,37 +630,30 @@ protocolInfoCardano paramsCardano
genesisShelley = ledgerTransitionConfig ^. L.tcShelleyGenesisL

ProtocolParamsByron {
byronGenesis = genesisByron
, byronLeaderCredentials = mCredsByron
, byronMaxTxCapacityOverrides = maxTxCapacityOverridesByron
byronGenesis = genesisByron
, byronLeaderCredentials = mCredsByron
} = paramsByron
ProtocolParamsShelleyBased {
shelleyBasedInitialNonce = initialNonceShelley
, shelleyBasedLeaderCredentials = credssShelleyBased
} = paramsShelleyBased
ProtocolParamsShelley {
shelleyProtVer = protVerShelley
, shelleyMaxTxCapacityOverrides = maxTxCapacityOverridesShelley
shelleyProtVer = protVerShelley
} = paramsShelley
ProtocolParamsAllegra {
allegraProtVer = protVerAllegra
, allegraMaxTxCapacityOverrides = maxTxCapacityOverridesAllegra
allegraProtVer = protVerAllegra
} = paramsAllegra
ProtocolParamsMary {
maryProtVer = protVerMary
, maryMaxTxCapacityOverrides = maxTxCapacityOverridesMary
maryProtVer = protVerMary
} = paramsMary
ProtocolParamsAlonzo {
alonzoProtVer = protVerAlonzo
, alonzoMaxTxCapacityOverrides = maxTxCapacityOverridesAlonzo
alonzoProtVer = protVerAlonzo
} = paramsAlonzo
ProtocolParamsBabbage {
babbageProtVer = protVerBabbage
, babbageMaxTxCapacityOverrides = maxTxCapacityOverridesBabbage
babbageProtVer = protVerBabbage
} = paramsBabbage
ProtocolParamsConway {
conwayProtVer = protVerConway
, conwayMaxTxCapacityOverrides = maxTxCapacityOverridesConway
conwayProtVer = protVerConway
} = paramsConway

transitionConfigShelley = transitionConfigAllegra ^. L.tcPreviousEraConfigL
Expand Down Expand Up @@ -1033,7 +1025,7 @@ protocolInfoCardano paramsCardano
mBlockForgingByron :: Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
mBlockForgingByron = do
creds <- mCredsByron
return $ byronBlockForging maxTxCapacityOverridesByron creds `OptNP.at` IZ
return $ byronBlockForging creds `OptNP.at` IZ

blockForgingShelleyBased ::
ShelleyLeaderCredentials c
Expand All @@ -1058,28 +1050,26 @@ protocolInfoCardano paramsCardano
Absolute.KESPeriod $ fromIntegral $ slot `div` praosSlotsPerKESPeriod

let tpraos :: forall era.
ShelleyEraWithCrypto c (TPraos c) era
=> Mempool.TxOverrides (ShelleyBlock (TPraos c) era)
-> BlockForging m (ShelleyBlock (TPraos c) era)
tpraos maxTxCapacityOverrides =
TPraos.shelleySharedBlockForging hotKey slotToPeriod credentials maxTxCapacityOverrides
ShelleyEraWithCrypto c (TPraos c) era
=> BlockForging m (ShelleyBlock (TPraos c) era)
tpraos =
TPraos.shelleySharedBlockForging hotKey slotToPeriod credentials

let praos :: forall era.
ShelleyEraWithCrypto c (Praos c) era
=> Mempool.TxOverrides (ShelleyBlock (Praos c) era)
-> BlockForging m (ShelleyBlock (Praos c) era)
praos maxTxCapacityOverrides =
Praos.praosSharedBlockForging hotKey slotToPeriod credentials maxTxCapacityOverrides
ShelleyEraWithCrypto c (Praos c) era
=> BlockForging m (ShelleyBlock (Praos c) era)
praos =
Praos.praosSharedBlockForging hotKey slotToPeriod credentials

pure
$ OptSkip -- Byron
$ OptNP.fromNonEmptyNP $
tpraos maxTxCapacityOverridesShelley :*
tpraos maxTxCapacityOverridesAllegra :*
tpraos maxTxCapacityOverridesMary :*
tpraos maxTxCapacityOverridesAlonzo :*
praos maxTxCapacityOverridesBabbage :*
praos maxTxCapacityOverridesConway :*
tpraos :*
tpraos :*
tpraos :*
tpraos :*
praos :*
praos :*
Nil

protocolClientInfoCardano ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import Ouroboros.Consensus.Config
import Ouroboros.Consensus.Ledger.Abstract
import Ouroboros.Consensus.Ledger.SupportsMempool
import Ouroboros.Consensus.Mempool (TxLimits)
import qualified Ouroboros.Consensus.Mempool as Mempool
import Ouroboros.Consensus.Protocol.Abstract (CanBeLeader, IsLeader)
import Ouroboros.Consensus.Protocol.Ledger.HotKey (HotKey)
import Ouroboros.Consensus.Shelley.Eras (EraCrypto)
Expand All @@ -45,8 +44,6 @@ forgeShelleyBlock ::
=> HotKey (EraCrypto era) m
-> CanBeLeader proto
-> TopLevelConfig (ShelleyBlock proto era)
-> Mempool.TxOverrides (ShelleyBlock proto era) -- ^ How to override max tx
-- capacity defined by ledger
-> BlockNo -- ^ Current block number
-> SlotNo -- ^ Current slot number
-> TickedLedgerState (ShelleyBlock proto era) -- ^ Current ledger
Expand All @@ -57,7 +54,6 @@ forgeShelleyBlock
hotKey
cbl
cfg
maxTxCapacityOverrides
curNo
curSlot
tickedLedger
Expand All @@ -76,7 +72,7 @@ forgeShelleyBlock
SL.toTxSeq @era
. Seq.fromList
. fmap extractTx
$ takeLargestPrefixThatFits maxTxCapacityOverrides tickedLedger txs
$ takeLargestPrefixThatFits tickedLedger txs

extractTx :: Validated (GenTx (ShelleyBlock proto era)) -> Core.Tx era
extractTx (ShelleyValidatedTx _txid vtx) = SL.extractTx vtx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,11 @@ praosBlockForging ::
, IOLike m
)
=> PraosParams
-> Mempool.TxOverrides (ShelleyBlock (Praos c) era)
-> ShelleyLeaderCredentials (EraCrypto era)
-> m (BlockForging m (ShelleyBlock (Praos c) era))
praosBlockForging praosParams maxTxCapacityOverrides credentials = do
praosBlockForging praosParams credentials = do
hotKey <- HotKey.mkHotKey @m @c initSignKey startPeriod praosMaxKESEvo
pure $ praosSharedBlockForging hotKey slotToPeriod credentials maxTxCapacityOverrides
pure $ praosSharedBlockForging hotKey slotToPeriod credentials
where
PraosParams {praosMaxKESEvo, praosSlotsPerKESPeriod} = praosParams

Expand Down Expand Up @@ -89,16 +88,14 @@ praosSharedBlockForging ::
=> HotKey.HotKey c m
-> (SlotNo -> Absolute.KESPeriod)
-> ShelleyLeaderCredentials c
-> Mempool.TxOverrides (ShelleyBlock (Praos c) era)
-> BlockForging m (ShelleyBlock (Praos c) era)
-> BlockForging m (ShelleyBlock (Praos c) era)
praosSharedBlockForging
hotKey
slotToPeriod
ShelleyLeaderCredentials {
shelleyLeaderCredentialsCanBeLeader = canBeLeader
, shelleyLeaderCredentialsLabel = label
}
maxTxCapacityOverrides = do
} = do
BlockForging
{ forgeLabel = label <> "_" <> T.pack (L.eraName @era),
canBeLeader = canBeLeader,
Expand All @@ -114,21 +111,18 @@ praosSharedBlockForging
hotKey
canBeLeader
cfg
maxTxCapacityOverrides
}

{-------------------------------------------------------------------------------
ProtocolInfo
-------------------------------------------------------------------------------}

data instance ProtocolParams (ShelleyBlock (Praos c) (BabbageEra c)) = ProtocolParamsBabbage {
babbageProtVer :: SL.ProtVer
babbageProtVer :: SL.ProtVer
-- ^ see 'Ouroboros.Consensus.Shelley.Node.TPraos.shelleyProtVer', mutatis mutandi
, babbageMaxTxCapacityOverrides :: Mempool.TxOverrides (ShelleyBlock (Praos c) (BabbageEra c))
}

data instance ProtocolParams (ShelleyBlock (Praos c) (ConwayEra c)) = ProtocolParamsConway {
conwayProtVer :: SL.ProtVer
conwayProtVer :: SL.ProtVer
-- ^ see 'Ouroboros.Consensus.Shelley.Node.TPraos.shelleyProtVer', mutatis mutandi
, conwayMaxTxCapacityOverrides :: Mempool.TxOverrides (ShelleyBlock (Praos c) (ConwayEra c))
}
Loading