Skip to content

Commit eefcf30

Browse files
committed
WIP remove overrides from forging, replace mempool cap override with mult
1 parent b70b3cc commit eefcf30

File tree

41 files changed

+252
-428
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+252
-428
lines changed

ouroboros-consensus-cardano/ouroboros-consensus-cardano.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,7 @@ test-suite shelley-test
352352
constraints,
353353
containers,
354354
filepath,
355+
measures,
355356
microlens,
356357
ouroboros-consensus:{ouroboros-consensus, unstable-consensus-testlib},
357358
ouroboros-consensus-cardano,

ouroboros-consensus-cardano/src/byron/Ouroboros/Consensus/Byron/Ledger/Forge.hs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,11 @@ import Ouroboros.Consensus.Config
4040
import Ouroboros.Consensus.Ledger.Abstract
4141
import Ouroboros.Consensus.Ledger.SupportsMempool
4242
(LedgerSupportsMempool (..), txForgetValidated)
43-
import qualified Ouroboros.Consensus.Mempool as Mempool
4443
import Ouroboros.Consensus.Protocol.PBFT
4544

4645
forgeByronBlock ::
4746
HasCallStack
4847
=> TopLevelConfig ByronBlock
49-
-> Mempool.TxOverrides ByronBlock -- ^ How to override max tx capacity
50-
-- defined by ledger
5148
-> BlockNo -- ^ Current block number
5249
-> SlotNo -- ^ Current slot number
5350
-> TickedLedgerState ByronBlock -- ^ Current ledger
@@ -123,15 +120,13 @@ initBlockPayloads = BlockPayloads
123120
forgeRegularBlock ::
124121
HasCallStack
125122
=> BlockConfig ByronBlock
126-
-> Mempool.TxOverrides ByronBlock -- ^ How to override max tx capacity
127-
-- defined by ledger
128123
-> BlockNo -- ^ Current block number
129124
-> SlotNo -- ^ Current slot number
130125
-> TickedLedgerState ByronBlock -- ^ Current ledger
131126
-> [Validated (GenTx ByronBlock)] -- ^ Txs to consider adding in the block
132127
-> PBftIsLeader PBftByronCrypto -- ^ Leader proof ('IsLeader')
133128
-> ByronBlock
134-
forgeRegularBlock cfg maxTxCapacityOverrides bno sno st txs isLeader =
129+
forgeRegularBlock cfg bno sno st txs isLeader =
135130
forge $
136131
forgePBftFields
137132
(mkByronContextDSIGN cfg)
@@ -148,7 +143,7 @@ forgeRegularBlock cfg maxTxCapacityOverrides bno sno st txs isLeader =
148143
foldr
149144
extendBlockPayloads
150145
initBlockPayloads
151-
(takeLargestPrefixThatFits maxTxCapacityOverrides lcfg st txs)
146+
(takeLargestPrefixThatFits lcfg st txs)
152147

153148
txPayload :: CC.UTxO.TxPayload
154149
txPayload = CC.UTxO.mkTxPayload (bpTxs blockPayloads)

ouroboros-consensus-cardano/src/byron/Ouroboros/Consensus/Byron/Node.hs

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ import Ouroboros.Consensus.Config.SupportsNode
4949
import Ouroboros.Consensus.HeaderValidation
5050
import Ouroboros.Consensus.Ledger.Abstract
5151
import Ouroboros.Consensus.Ledger.Extended
52-
import qualified Ouroboros.Consensus.Mempool as Mempool
5352
import Ouroboros.Consensus.Node.InitStorage
5453
import Ouroboros.Consensus.Node.ProtocolInfo
5554
import Ouroboros.Consensus.Node.Run
@@ -128,10 +127,9 @@ type instance ForgeStateUpdateError ByronBlock = Void
128127

129128
byronBlockForging ::
130129
Monad m
131-
=> Mempool.TxOverrides ByronBlock
132-
-> ByronLeaderCredentials
130+
=> ByronLeaderCredentials
133131
-> BlockForging m ByronBlock
134-
byronBlockForging maxTxCapacityOverrides creds = BlockForging {
132+
byronBlockForging creds = BlockForging {
135133
forgeLabel = blcLabel creds
136134
, canBeLeader
137135
, updateForgeState = \_ _ _ -> return $ ForgeStateUpdated ()
@@ -141,7 +139,7 @@ byronBlockForging maxTxCapacityOverrides creds = BlockForging {
141139
canBeLeader
142140
slot
143141
tickedPBftState
144-
, forgeBlock = \cfg -> return ....: forgeByronBlock cfg maxTxCapacityOverrides
142+
, forgeBlock = \cfg -> return ....: forgeByronBlock cfg
145143
}
146144
where
147145
canBeLeader = mkPBftCanBeLeader creds
@@ -156,11 +154,8 @@ mkPBftCanBeLeader (ByronLeaderCredentials sk cert nid _) = PBftCanBeLeader {
156154
blockForgingByron :: Monad m
157155
=> ProtocolParams ByronBlock
158156
-> [BlockForging m ByronBlock]
159-
blockForgingByron ProtocolParamsByron { byronLeaderCredentials = mLeaderCreds
160-
, byronMaxTxCapacityOverrides = maxTxCapacityOverrides
161-
} =
162-
byronBlockForging maxTxCapacityOverrides
163-
<$> maybeToList mLeaderCreds
157+
blockForgingByron ProtocolParamsByron { byronLeaderCredentials } =
158+
byronBlockForging <$> maybeToList byronLeaderCredentials
164159

165160
{-------------------------------------------------------------------------------
166161
ProtocolInfo
@@ -178,7 +173,6 @@ data instance ProtocolParams ByronBlock = ProtocolParamsByron {
178173
, byronProtocolVersion :: Update.ProtocolVersion
179174
, byronSoftwareVersion :: Update.SoftwareVersion
180175
, byronLeaderCredentials :: Maybe ByronLeaderCredentials
181-
, byronMaxTxCapacityOverrides :: Mempool.TxOverrides ByronBlock
182176
}
183177

184178
protocolInfoByron :: ProtocolParams ByronBlock

ouroboros-consensus-cardano/src/ouroboros-consensus-cardano/Ouroboros/Consensus/Cardano/Node.hs

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ import Ouroboros.Consensus.HardFork.Combinator.Serialisation
100100
import qualified Ouroboros.Consensus.HardFork.History as History
101101
import Ouroboros.Consensus.HeaderValidation
102102
import Ouroboros.Consensus.Ledger.Extended
103-
import qualified Ouroboros.Consensus.Mempool as Mempool
104103
import Ouroboros.Consensus.Node.NetworkProtocolVersion
105104
import Ouroboros.Consensus.Node.ProtocolInfo
106105
import Ouroboros.Consensus.Node.Run
@@ -631,37 +630,30 @@ protocolInfoCardano paramsCardano
631630
genesisShelley = ledgerTransitionConfig ^. L.tcShelleyGenesisL
632631

633632
ProtocolParamsByron {
634-
byronGenesis = genesisByron
635-
, byronLeaderCredentials = mCredsByron
636-
, byronMaxTxCapacityOverrides = maxTxCapacityOverridesByron
633+
byronGenesis = genesisByron
634+
, byronLeaderCredentials = mCredsByron
637635
} = paramsByron
638636
ProtocolParamsShelleyBased {
639637
shelleyBasedInitialNonce = initialNonceShelley
640638
, shelleyBasedLeaderCredentials = credssShelleyBased
641639
} = paramsShelleyBased
642640
ProtocolParamsShelley {
643-
shelleyProtVer = protVerShelley
644-
, shelleyMaxTxCapacityOverrides = maxTxCapacityOverridesShelley
641+
shelleyProtVer = protVerShelley
645642
} = paramsShelley
646643
ProtocolParamsAllegra {
647-
allegraProtVer = protVerAllegra
648-
, allegraMaxTxCapacityOverrides = maxTxCapacityOverridesAllegra
644+
allegraProtVer = protVerAllegra
649645
} = paramsAllegra
650646
ProtocolParamsMary {
651-
maryProtVer = protVerMary
652-
, maryMaxTxCapacityOverrides = maxTxCapacityOverridesMary
647+
maryProtVer = protVerMary
653648
} = paramsMary
654649
ProtocolParamsAlonzo {
655-
alonzoProtVer = protVerAlonzo
656-
, alonzoMaxTxCapacityOverrides = maxTxCapacityOverridesAlonzo
650+
alonzoProtVer = protVerAlonzo
657651
} = paramsAlonzo
658652
ProtocolParamsBabbage {
659-
babbageProtVer = protVerBabbage
660-
, babbageMaxTxCapacityOverrides = maxTxCapacityOverridesBabbage
653+
babbageProtVer = protVerBabbage
661654
} = paramsBabbage
662655
ProtocolParamsConway {
663-
conwayProtVer = protVerConway
664-
, conwayMaxTxCapacityOverrides = maxTxCapacityOverridesConway
656+
conwayProtVer = protVerConway
665657
} = paramsConway
666658

667659
transitionConfigShelley = transitionConfigAllegra ^. L.tcPreviousEraConfigL
@@ -1033,7 +1025,7 @@ protocolInfoCardano paramsCardano
10331025
mBlockForgingByron :: Maybe (NonEmptyOptNP (BlockForging m) (CardanoEras c))
10341026
mBlockForgingByron = do
10351027
creds <- mCredsByron
1036-
return $ byronBlockForging maxTxCapacityOverridesByron creds `OptNP.at` IZ
1028+
return $ byronBlockForging creds `OptNP.at` IZ
10371029

10381030
blockForgingShelleyBased ::
10391031
ShelleyLeaderCredentials c
@@ -1059,27 +1051,25 @@ protocolInfoCardano paramsCardano
10591051

10601052
let tpraos :: forall era.
10611053
ShelleyEraWithCrypto c (TPraos c) era
1062-
=> Mempool.TxOverrides (ShelleyBlock (TPraos c) era)
1063-
-> BlockForging m (ShelleyBlock (TPraos c) era)
1064-
tpraos maxTxCapacityOverrides =
1065-
TPraos.shelleySharedBlockForging hotKey slotToPeriod credentials maxTxCapacityOverrides
1054+
=> BlockForging m (ShelleyBlock (TPraos c) era)
1055+
tpraos =
1056+
TPraos.shelleySharedBlockForging hotKey slotToPeriod credentials
10661057

10671058
let praos :: forall era.
10681059
ShelleyEraWithCrypto c (Praos c) era
1069-
=> Mempool.TxOverrides (ShelleyBlock (Praos c) era)
1070-
-> BlockForging m (ShelleyBlock (Praos c) era)
1071-
praos maxTxCapacityOverrides =
1072-
Praos.praosSharedBlockForging hotKey slotToPeriod credentials maxTxCapacityOverrides
1060+
=> BlockForging m (ShelleyBlock (Praos c) era)
1061+
praos =
1062+
Praos.praosSharedBlockForging hotKey slotToPeriod credentials
10731063

10741064
pure
10751065
$ OptSkip -- Byron
10761066
$ OptNP.fromNonEmptyNP $
1077-
tpraos maxTxCapacityOverridesShelley :*
1078-
tpraos maxTxCapacityOverridesAllegra :*
1079-
tpraos maxTxCapacityOverridesMary :*
1080-
tpraos maxTxCapacityOverridesAlonzo :*
1081-
praos maxTxCapacityOverridesBabbage :*
1082-
praos maxTxCapacityOverridesConway :*
1067+
tpraos :*
1068+
tpraos :*
1069+
tpraos :*
1070+
tpraos :*
1071+
praos :*
1072+
praos :*
10831073
Nil
10841074

10851075
protocolClientInfoCardano ::

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

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Ouroboros.Consensus.Block
2020
import Ouroboros.Consensus.Config
2121
import Ouroboros.Consensus.Ledger.Abstract
2222
import Ouroboros.Consensus.Ledger.SupportsMempool
23-
import qualified Ouroboros.Consensus.Mempool as Mempool
2423
import Ouroboros.Consensus.Protocol.Abstract (CanBeLeader, IsLeader)
2524
import Ouroboros.Consensus.Protocol.Ledger.HotKey (HotKey)
2625
import Ouroboros.Consensus.Shelley.Eras (EraCrypto)
@@ -47,8 +46,6 @@ forgeShelleyBlock ::
4746
=> HotKey (EraCrypto era) m
4847
-> CanBeLeader proto
4948
-> TopLevelConfig (ShelleyBlock proto era)
50-
-> Mempool.TxOverrides (ShelleyBlock proto era) -- ^ How to override max tx
51-
-- capacity defined by ledger
5249
-> BlockNo -- ^ Current block number
5350
-> SlotNo -- ^ Current slot number
5451
-> TickedLedgerState (ShelleyBlock proto era) -- ^ Current ledger
@@ -59,7 +56,6 @@ forgeShelleyBlock
5956
hotKey
6057
cbl
6158
cfg
62-
maxTxCapacityOverrides
6359
curNo
6460
curSlot
6561
tickedLedger
@@ -79,7 +75,6 @@ forgeShelleyBlock
7975
. Seq.fromList
8076
. fmap extractTx
8177
$ takeLargestPrefixThatFits
82-
maxTxCapacityOverrides
8378
(topLevelConfigLedger cfg)
8479
tickedLedger
8580
txs

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Node/Praos.hs

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ import qualified Data.Text as T
2828
import Ouroboros.Consensus.Block
2929
import Ouroboros.Consensus.Config (configConsensus)
3030
import Ouroboros.Consensus.Ledger.SupportsMempool (TxLimits)
31-
import qualified Ouroboros.Consensus.Mempool as Mempool
3231
import Ouroboros.Consensus.Node.ProtocolInfo
3332
import qualified Ouroboros.Consensus.Protocol.Ledger.HotKey as HotKey
3433
import Ouroboros.Consensus.Protocol.Praos (Praos, PraosParams (..),
@@ -57,12 +56,11 @@ praosBlockForging ::
5756
, IOLike m
5857
)
5958
=> PraosParams
60-
-> Mempool.TxOverrides (ShelleyBlock (Praos c) era)
6159
-> ShelleyLeaderCredentials (EraCrypto era)
6260
-> m (BlockForging m (ShelleyBlock (Praos c) era))
63-
praosBlockForging praosParams maxTxCapacityOverrides credentials = do
61+
praosBlockForging praosParams credentials = do
6462
hotKey <- HotKey.mkHotKey @m @c initSignKey startPeriod praosMaxKESEvo
65-
pure $ praosSharedBlockForging hotKey slotToPeriod credentials maxTxCapacityOverrides
63+
pure $ praosSharedBlockForging hotKey slotToPeriod credentials
6664
where
6765
PraosParams {praosMaxKESEvo, praosSlotsPerKESPeriod} = praosParams
6866

@@ -90,16 +88,14 @@ praosSharedBlockForging ::
9088
=> HotKey.HotKey c m
9189
-> (SlotNo -> Absolute.KESPeriod)
9290
-> ShelleyLeaderCredentials c
93-
-> Mempool.TxOverrides (ShelleyBlock (Praos c) era)
9491
-> BlockForging m (ShelleyBlock (Praos c) era)
9592
praosSharedBlockForging
9693
hotKey
9794
slotToPeriod
9895
ShelleyLeaderCredentials {
9996
shelleyLeaderCredentialsCanBeLeader = canBeLeader
10097
, shelleyLeaderCredentialsLabel = label
101-
}
102-
maxTxCapacityOverrides = do
98+
} = do
10399
BlockForging
104100
{ forgeLabel = label <> "_" <> T.pack (L.eraName @era),
105101
canBeLeader = canBeLeader,
@@ -115,21 +111,18 @@ praosSharedBlockForging
115111
hotKey
116112
canBeLeader
117113
cfg
118-
maxTxCapacityOverrides
119114
}
120115

121116
{-------------------------------------------------------------------------------
122117
ProtocolInfo
123118
-------------------------------------------------------------------------------}
124119

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

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

0 commit comments

Comments
 (0)