Skip to content

Commit e6e0e81

Browse files
committed
Make bench/tx-generator compile; NEEDS CAREFUL REVIEW
1 parent fea055c commit e6e0e81

File tree

10 files changed

+44
-35
lines changed

10 files changed

+44
-35
lines changed

bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/NodeToNode.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ benchmarkConnectTxSubmit EnvConsts { .. } handshakeTracer submissionTracer codec
8989
done <- NtN.connectTo
9090
(socketSnocket envIOManager)
9191
NetworkConnectTracers {
92-
nctMuxTracer = mempty,
92+
nctMuxTracers = Mux.nullTracers,
9393
nctHandshakeTracer = handshakeTracer
9494
}
9595
peerMultiplex

bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SizedMetadata.hs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ assumeMapCosts _proxy = stepFunction [
6969
ShelleyBasedEraAlonzo -> 42
7070
ShelleyBasedEraBabbage -> 42
7171
ShelleyBasedEraConway -> 42
72+
-- TODO: check if this is correct!
73+
ShelleyBasedEraDijkstra -> 42
7274

7375
-- Bytestring costs are not LINEAR !!
7476
-- Costs are piecewise linear for payload sizes [0..23] and [24..64].
@@ -141,12 +143,13 @@ mkMetadata size
141143
else Right $ metadataInEra $ Just metadata
142144
where
143145
minSize = case shelleyBasedEra @era of
144-
ShelleyBasedEraShelley -> 37
145-
ShelleyBasedEraAllegra -> 39
146-
ShelleyBasedEraMary -> 39
147-
ShelleyBasedEraAlonzo -> 39 -- TODO: check minSize for Alonzo
148-
ShelleyBasedEraBabbage -> 39 -- TODO: check minSize for Babbage
149-
ShelleyBasedEraConway -> 39 -- TODO: check minSize for Conway
146+
ShelleyBasedEraShelley -> 37
147+
ShelleyBasedEraAllegra -> 39
148+
ShelleyBasedEraMary -> 39
149+
ShelleyBasedEraAlonzo -> 39 -- TODO: check minSize for Alonzo
150+
ShelleyBasedEraBabbage -> 39 -- TODO: check minSize for Babbage
151+
ShelleyBasedEraConway -> 39 -- TODO: check minSize for Conway
152+
ShelleyBasedEraDijkstra -> 39 -- TODO: check minSize for Dijkstra
150153
nettoSize = size - minSize
151154

152155
-- At 24 the CBOR representation changes.

bench/tx-generator/src/Cardano/Benchmarking/GeneratorTx/SubmissionClient.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ txSubmissionClient tr bmtr initialTxSource endOfProtocolCallback =
181181
where
182182
getTxSize :: Tx era -> Integer
183183
getTxSize (ShelleyTx sbe tx) =
184-
shelleyBasedEraConstraints sbe $ tx ^. Ledger.sizeTxF
184+
shelleyBasedEraConstraints sbe $ toInteger (tx ^. Ledger.sizeTxF)
185185

186186
toGenTx :: Tx era -> GenTx CardanoBlock
187187
toGenTx tx = toConsensusGenTx $ TxInMode shelleyBasedEra tx

bench/tx-generator/src/Cardano/Benchmarking/OuroborosImports.hs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module Cardano.Benchmarking.OuroborosImports
1212
, ShelleyGenesis
1313
, SigningKey
1414
, SigningKeyFile
15-
, StandardShelley
1615
, NetworkId
1716
-- , getGenesis
1817
, makeLocalConnectInfo
@@ -35,7 +34,7 @@ import qualified Ouroboros.Consensus.Cardano as Consensus
3534
import Ouroboros.Consensus.Config (TopLevelConfig, configBlock, configCodec)
3635
import Ouroboros.Consensus.Config.SupportsNode (ConfigSupportsNode (..), getNetworkMagic)
3736
import Ouroboros.Consensus.Node (ProtocolInfo (..))
38-
import Ouroboros.Consensus.Shelley.Eras (StandardCrypto, StandardShelley)
37+
import Ouroboros.Consensus.Shelley.Eras (StandardCrypto)
3938
import Ouroboros.Network.Protocol.LocalTxSubmission.Type (SubmitResult (..))
4039

4140
import Prelude

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

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,15 @@ liftCoreWithEra era coreCall = withEra era ( liftIO . runExceptT . coreCall)
7070
withEra :: AnyCardanoEra -> (forall era. IsShelleyBasedEra era => AsType era -> ActionM x) -> ActionM x
7171
withEra era action = do
7272
case era of
73-
AnyCardanoEra ConwayEra -> action AsConwayEra
74-
AnyCardanoEra BabbageEra -> action AsBabbageEra
75-
AnyCardanoEra AlonzoEra -> action AsAlonzoEra
76-
AnyCardanoEra MaryEra -> action AsMaryEra
77-
AnyCardanoEra AllegraEra -> action AsAllegraEra
78-
AnyCardanoEra ShelleyEra -> action AsShelleyEra
79-
AnyCardanoEra ByronEra -> error "byron not supported"
73+
AnyCardanoEra ConwayEra -> action AsConwayEra
74+
AnyCardanoEra BabbageEra -> action AsBabbageEra
75+
AnyCardanoEra AlonzoEra -> action AsAlonzoEra
76+
AnyCardanoEra MaryEra -> action AsMaryEra
77+
AnyCardanoEra AllegraEra -> action AsAllegraEra
78+
AnyCardanoEra ShelleyEra -> action AsShelleyEra
79+
AnyCardanoEra ByronEra -> error "byron not supported"
80+
-- TODO: is this correct?
81+
AnyCardanoEra DijkstraEra -> error "Dijkstra not supported"
8082

8183
setProtocolParameters :: ProtocolParametersSource -> ActionM ()
8284
setProtocolParameters s = case s of

bench/tx-generator/src/Cardano/TxGenerator/ProtocolParameters.hs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
{-# LANGUAGE NamedFieldPuns #-}
33
{-# LANGUAGE RecordWildCards #-}
44
{-# LANGUAGE TypeFamilies #-}
5+
{-# LANGUAGE DataKinds #-}
56

67
{--
78
Due to the changes to "cardano-api" listed below it was decided to move
@@ -32,9 +33,9 @@ where
3233

3334
import Cardano.Api (AnyPlutusScriptVersion (..), CostModel, ExecutionUnitPrices (..),
3435
ExecutionUnits, LedgerProtocolParameters (..),
35-
PlutusScriptVersion (PlutusScriptV1, PlutusScriptV2, PlutusScriptV3), PraosNonce,
36+
PlutusScriptVersion (PlutusScriptV1, PlutusScriptV2, PlutusScriptV3, PlutusScriptV4), PraosNonce,
3637
ProtocolParametersConversionError (..),
37-
ShelleyBasedEra (ShelleyBasedEraAllegra, ShelleyBasedEraAlonzo, ShelleyBasedEraBabbage, ShelleyBasedEraConway, ShelleyBasedEraMary, ShelleyBasedEraShelley),
38+
ShelleyBasedEra (ShelleyBasedEraAllegra, ShelleyBasedEraAlonzo, ShelleyBasedEraBabbage, ShelleyBasedEraConway, ShelleyBasedEraMary, ShelleyBasedEraShelley, ShelleyBasedEraDijkstra),
3839
ShelleyLedgerEra, fromAlonzoCostModels, fromAlonzoExUnits, fromAlonzoPrices,
3940
makePraosNonce, toAlonzoCostModels, toAlonzoExUnits, toAlonzoPrices,
4041
toLedgerNonce)
@@ -242,6 +243,7 @@ fromPlutusLanguageName :: Plutus.Language -> AnyPlutusScriptVersion
242243
fromPlutusLanguageName Plutus.PlutusV1 = AnyPlutusScriptVersion PlutusScriptV1
243244
fromPlutusLanguageName Plutus.PlutusV2 = AnyPlutusScriptVersion PlutusScriptV2
244245
fromPlutusLanguageName Plutus.PlutusV3 = AnyPlutusScriptVersion PlutusScriptV3
246+
fromPlutusLanguageName Plutus.PlutusV4 = AnyPlutusScriptVersion PlutusScriptV4
245247

246248
instance Aeson.ToJSON ProtocolParameters where
247249
toJSON ProtocolParameters{..} =
@@ -296,6 +298,7 @@ toPlutusLanguageName :: AnyPlutusScriptVersion -> Plutus.Language
296298
toPlutusLanguageName (AnyPlutusScriptVersion PlutusScriptV1) = Plutus.PlutusV1
297299
toPlutusLanguageName (AnyPlutusScriptVersion PlutusScriptV2) = Plutus.PlutusV2
298300
toPlutusLanguageName (AnyPlutusScriptVersion PlutusScriptV3) = Plutus.PlutusV3
301+
toPlutusLanguageName (AnyPlutusScriptVersion PlutusScriptV4) = Plutus.PlutusV4
299302

300303
-- Praos nonce.
301304
--------------------------------------------------------------------------------
@@ -348,6 +351,7 @@ toLedgerPParams ShelleyBasedEraMary = toShelleyPParams
348351
toLedgerPParams ShelleyBasedEraAlonzo = toAlonzoPParams
349352
toLedgerPParams ShelleyBasedEraBabbage = toBabbagePParams
350353
toLedgerPParams ShelleyBasedEraConway = toConwayPParams
354+
toLedgerPParams ShelleyBasedEraDijkstra = toConwayPParams
351355

352356
-- Was removed in "cardano-api" module "Cardano.Api.Internal.ProtocolParameters"
353357
toShelleyCommonPParams
@@ -396,8 +400,8 @@ toShelleyCommonPParams
396400
-- Was removed in "cardano-api" module "Cardano.Api.Internal.ProtocolParameters"
397401
toShelleyPParams
398402
:: ( EraPParams ledgerera
399-
, Ledger.AtMostEra Ledger.MaryEra ledgerera
400-
, Ledger.AtMostEra Ledger.AlonzoEra ledgerera
403+
, Ledger.AtMostEra "Mary" ledgerera
404+
, Ledger.AtMostEra "Alonzo" ledgerera
401405
)
402406
=> ProtocolParameters
403407
-> Either ProtocolParametersConversionError (PParams ledgerera)
@@ -517,6 +521,7 @@ fromLedgerPParams ShelleyBasedEraMary = fromShelleyPParams
517521
fromLedgerPParams ShelleyBasedEraAlonzo = fromExactlyAlonzoPParams
518522
fromLedgerPParams ShelleyBasedEraBabbage = fromBabbagePParams
519523
fromLedgerPParams ShelleyBasedEraConway = fromConwayPParams
524+
fromLedgerPParams ShelleyBasedEraDijkstra = fromConwayPParams
520525

521526
-- TODO: Use the ledger's PParams (from module Cardano.Api.Ledger) type instead.
522527
fromShelleyCommonPParams
@@ -556,8 +561,8 @@ fromShelleyCommonPParams pp =
556561
-- TODO: Use the ledger's PParams (from module Cardano.Api.Ledger) type instead.
557562
fromShelleyPParams
558563
:: ( EraPParams ledgerera
559-
, Ledger.AtMostEra Ledger.MaryEra ledgerera
560-
, Ledger.AtMostEra Ledger.AlonzoEra ledgerera
564+
, Ledger.AtMostEra "Mary" ledgerera
565+
, Ledger.AtMostEra "Alonzo" ledgerera
561566
)
562567
=> PParams ledgerera
563568
-> ProtocolParameters

bench/tx-generator/src/Cardano/TxGenerator/Setup/NodeConfig.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ getGenesis (SomeConsensusProtocol CardanoBlockType proto)
4242
getGenesisPath :: NodeConfiguration -> Maybe GenesisFile
4343
getGenesisPath nodeConfig =
4444
case ncProtocolConfig nodeConfig of
45-
NodeProtocolConfigurationCardano _ shelleyConfig _ _ _ _ ->
45+
NodeProtocolConfigurationCardano _ shelleyConfig _ _ _ _ _ ->
4646
Just $ npcShelleyGenesisFile shelleyConfig
4747

4848
mkConsensusProtocol :: NodeConfiguration -> IO (Either TxGenError SomeConsensusProtocol)
4949
mkConsensusProtocol nodeConfig =
5050
case ncProtocolConfig nodeConfig of
51-
NodeProtocolConfigurationCardano byronConfig shelleyConfig alonzoConfig conwayConfig hardforkConfig checkpointsConfig ->
51+
NodeProtocolConfigurationCardano byronConfig shelleyConfig alonzoConfig conwayConfig dijkstraConfig hardforkConfig checkpointsConfig ->
5252
first ProtocolError
53-
<$> runExceptT (mkSomeConsensusProtocolCardano byronConfig shelleyConfig alonzoConfig conwayConfig hardforkConfig checkpointsConfig Nothing)
53+
<$> runExceptT (mkSomeConsensusProtocolCardano byronConfig shelleyConfig alonzoConfig conwayConfig dijkstraConfig hardforkConfig checkpointsConfig Nothing)
5454

5555
-- | Creates a NodeConfiguration from a config file;
5656
-- the result is devoid of any keys/credentials

bench/tx-generator/src/Cardano/TxGenerator/Setup/Plutus.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ import Data.ByteString.Short (ShortByteString)
2020
import Data.Int (Int64)
2121
import Data.Map.Strict as Map (lookup)
2222

23-
import Control.Exception (displayException)
2423
import Control.Monad.Trans.Except
2524
import Control.Monad.Trans.Except.Extra
2625
import Control.Monad.Writer (runWriter)

bench/tx-generator/src/Cardano/TxGenerator/Utils.hs

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,14 @@ import GHC.Stack
2626
-- regardless of which particular era.
2727
liftAnyEra :: ( forall era. IsCardanoEra era => f1 era -> f2 era ) -> InAnyCardanoEra f1 -> InAnyCardanoEra f2
2828
liftAnyEra f x = case x of
29-
InAnyCardanoEra ByronEra a -> InAnyCardanoEra ByronEra $ f a
30-
InAnyCardanoEra ShelleyEra a -> InAnyCardanoEra ShelleyEra $ f a
31-
InAnyCardanoEra AllegraEra a -> InAnyCardanoEra AllegraEra $ f a
32-
InAnyCardanoEra MaryEra a -> InAnyCardanoEra MaryEra $ f a
33-
InAnyCardanoEra AlonzoEra a -> InAnyCardanoEra AlonzoEra $ f a
34-
InAnyCardanoEra BabbageEra a -> InAnyCardanoEra BabbageEra $ f a
35-
InAnyCardanoEra ConwayEra a -> InAnyCardanoEra ConwayEra $ f a
29+
InAnyCardanoEra ByronEra a -> InAnyCardanoEra ByronEra $ f a
30+
InAnyCardanoEra ShelleyEra a -> InAnyCardanoEra ShelleyEra $ f a
31+
InAnyCardanoEra AllegraEra a -> InAnyCardanoEra AllegraEra $ f a
32+
InAnyCardanoEra MaryEra a -> InAnyCardanoEra MaryEra $ f a
33+
InAnyCardanoEra AlonzoEra a -> InAnyCardanoEra AlonzoEra $ f a
34+
InAnyCardanoEra BabbageEra a -> InAnyCardanoEra BabbageEra $ f a
35+
InAnyCardanoEra ConwayEra a -> InAnyCardanoEra ConwayEra $ f a
36+
InAnyCardanoEra DijkstraEra a -> InAnyCardanoEra DijkstraEra $ f a
3637

3738
-- | `keyAddress` determines an address for the relevant era.
3839
keyAddress :: forall era. IsShelleyBasedEra era => NetworkId -> SigningKey PaymentKey -> AddressInEra era

bench/tx-generator/tx-generator.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ library
136136
, formatting
137137
, generic-monoid
138138
, ghc-prim
139-
, io-classes
139+
, io-classes:{io-classes, strict-stm}
140140
, microlens
141141
, mtl
142142
, network

0 commit comments

Comments
 (0)