Skip to content

Commit e3e74b0

Browse files
authored
Merge pull request #6085 from IntersectMBO/smelc/tx-generator-simplifications
tx-generator: Core.hs: simplifications + better non-Byron support
2 parents 9017d91 + edebc27 commit e3e74b0

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,23 @@ cancelBenchmark = do
162162
getLocalConnectInfo :: ActionM LocalNodeConnectInfo
163163
getLocalConnectInfo = makeLocalConnectInfo <$> getEnvNetworkId <*> getEnvSocketPath
164164

165-
queryEra :: ActionM AnyCardanoEra
165+
queryEra :: ActionM AnyShelleyBasedEra
166166
queryEra = do
167167
localNodeConnectInfo <- getLocalConnectInfo
168168
chainTip <- getLocalChainTip localNodeConnectInfo
169-
mapExceptT liftIO .
169+
AnyCardanoEra era <- mapExceptT liftIO .
170170
modifyError (Env.TxGenError . TxGenError . show) $
171171
queryNodeLocalState localNodeConnectInfo (SpecificPoint $ chainTipToChainPoint chainTip) QueryCurrentEra
172+
caseByronOrShelleyBasedEra
173+
(liftTxGenError $ TxGenError "queryEra Byron not supported")
174+
(return . AnyShelleyBasedEra)
175+
era
172176

173177
queryRemoteProtocolParameters :: ActionM ProtocolParameters
174178
queryRemoteProtocolParameters = do
175179
localNodeConnectInfo <- getLocalConnectInfo
176180
chainTip <- liftIO $ getLocalChainTip localNodeConnectInfo
177-
era <- queryEra
181+
AnyShelleyBasedEra sbe <- queryEra
178182
let
179183
callQuery :: forall era.
180184
QueryInEra era (Ledger.PParams (ShelleyLedgerEra era))
@@ -187,22 +191,15 @@ queryRemoteProtocolParameters = do
187191
liftIO $ BSL.writeFile pparamsFile $ prettyPrintOrdered pp'
188192
traceDebug $ "queryRemoteProtocolParameters : query result saved in: " ++ pparamsFile
189193
return pp'
190-
case era of
191-
AnyCardanoEra ByronEra -> liftTxGenError $ TxGenError "queryRemoteProtocolParameters Byron not supported"
192-
AnyCardanoEra ShelleyEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraShelley QueryProtocolParameters
193-
AnyCardanoEra AllegraEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraAllegra QueryProtocolParameters
194-
AnyCardanoEra MaryEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraMary QueryProtocolParameters
195-
AnyCardanoEra AlonzoEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraAlonzo QueryProtocolParameters
196-
AnyCardanoEra BabbageEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraBabbage QueryProtocolParameters
197-
AnyCardanoEra ConwayEra -> callQuery $ QueryInShelleyBasedEra ShelleyBasedEraConway QueryProtocolParameters
194+
callQuery $ QueryInShelleyBasedEra sbe QueryProtocolParameters
198195

199196
getProtocolParameters :: ActionM ProtocolParameters
200197
getProtocolParameters = do
201198
getProtoParamMode >>= \case
202199
ProtocolParameterQuery -> queryRemoteProtocolParameters
203200
ProtocolParameterLocal parameters -> return parameters
204201

205-
waitForEra :: AnyCardanoEra -> ActionM ()
202+
waitForEra :: AnyShelleyBasedEra -> ActionM ()
206203
waitForEra era = do
207204
currentEra <- queryEra
208205
if currentEra == era

bench/tx-generator/src/Cardano/Benchmarking/Script/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ data Action where
117117
-- with testing and quick fixes.
118118
Reserved :: [String] -> Action
119119
-- 'WaitForEra' loops doing delays/sleeps until the current era matches.
120-
WaitForEra :: !AnyCardanoEra -> Action
120+
WaitForEra :: !AnyShelleyBasedEra -> Action
121121
-- | 'SetProtocolParameters' has one option to read from a file and
122122
-- another to pass directly and just sets a state variable for
123123
-- the @protoParams@ field of 'Cardano.Benchmarking.Script.Env.Env'.

0 commit comments

Comments
 (0)