Skip to content

Commit 186ab52

Browse files
committed
Temp: wip make cardano-testnet compile
1 parent 7201cbd commit 186ab52

File tree

8 files changed

+35
-52
lines changed

8 files changed

+35
-52
lines changed

cardano-testnet/cardano-testnet.cabal

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ library
8989
, retry
9090
, safe-exceptions
9191
, scientific
92+
, stm
9293
, tasty ^>= 1.5
9394
, tasty-expected-failure
9495
, tasty-hedgehog

cardano-testnet/src/Parsers/Cardano.hs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -111,35 +111,6 @@ pAnyShelleyBasedEra envCli =
111111
AnyCardanoEra era <- envCliAnyCardanoEra envCli'
112112
forEraInEonMaybe era EraInEon
113113

114-
pAnyShelleyBasedEra :: EnvCli -> Parser (EraInEon ShelleyBasedEra)
115-
pAnyShelleyBasedEra envCli =
116-
asum $
117-
mconcat
118-
[
119-
[ OA.flag' (EraInEon ShelleyBasedEraShelley) $
120-
mconcat [OA.long "shelley-era", OA.help $ "Specify the Shelley era" <> deprecationText]
121-
, OA.flag' (EraInEon ShelleyBasedEraAllegra) $
122-
mconcat [OA.long "allegra-era", OA.help $ "Specify the Allegra era" <> deprecationText]
123-
, OA.flag' (EraInEon ShelleyBasedEraMary) $
124-
mconcat [OA.long "mary-era", OA.help $ "Specify the Mary era" <> deprecationText]
125-
, OA.flag' (EraInEon ShelleyBasedEraAlonzo) $
126-
mconcat [OA.long "alonzo-era", OA.help $ "Specify the Alonzo era" <> deprecationText]
127-
, OA.flag' (EraInEon ShelleyBasedEraBabbage) $
128-
mconcat [OA.long "babbage-era", OA.help $ "Specify the Babbage era (default)" <> deprecationText]
129-
, fmap (EraInEon . convert) $ pConwayEra envCli
130-
]
131-
, maybeToList $ pure <$> envCliAnyEon envCli
132-
, pure $ pure $ EraInEon ShelleyBasedEraConway
133-
]
134-
where
135-
deprecationText :: String
136-
deprecationText = " - DEPRECATED - will be removed in the future"
137-
138-
envCliAnyEon :: Typeable eon => Eon eon => EnvCli -> Maybe (EraInEon eon)
139-
envCliAnyEon envCli' = do
140-
AnyCardanoEra era <- envCliAnyCardanoEra envCli'
141-
forEraInEonMaybe era EraInEon
142-
143114
pTestnetNodeOptions :: Parser [NodeOption]
144115
pTestnetNodeOptions =
145116
-- If `--num-pool-nodes N` is present, return N nodes with option `SpoNodeOptions []`.

cardano-testnet/src/Testnet/Blockfrost.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import Cardano.Ledger.BaseTypes (EpochInterval, Nonce, NonNegativeInte
1414
UnitInterval, ProtVer(..), Version)
1515
import Cardano.Ledger.Coin (Coin)
1616
import Cardano.Ledger.Core (PParams(..))
17+
import Cardano.Ledger.Compactible (toCompactPartial)
1718
import Cardano.Ledger.Shelley.Genesis (ShelleyGenesis(..))
1819
import Cardano.Ledger.Shelley.PParams (ShelleyPParams(..))
1920
import Cardano.Ledger.Alonzo.Genesis (AlonzoGenesis(..))
@@ -248,7 +249,7 @@ blockfrostToGenesis (alonzoGenesis', conwayGenesis', shelleyGenesis') Blockfrost
248249
, sppMaxTxSize = bfgMaxTxSize
249250
, sppMaxBHSize = bfgMaxBlockHeaderSize
250251
, sppKeyDeposit = bfgKeyDeposit
251-
, sppPoolDeposit = bfgPoolDeposit
252+
, sppPoolDeposit = toCompactPartial bfgPoolDeposit
252253
, sppEMax = bfgEMax
253254
, sppNOpt = bfgNOpt
254255
, sppA0 = bfgA0

cardano-testnet/src/Testnet/Components/Configuration.hs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,9 @@ getDefaultShelleyGenesis asbe maxSupply opts = do
146146
getDefaultAlonzoGenesis :: ()
147147
=> HasCallStack
148148
=> MonadTest m
149-
=> ShelleyBasedEra era
150-
-> m AlonzoGenesis
151-
getDefaultAlonzoGenesis sbe =
152-
H.evalEither $ first prettyError (Defaults.defaultAlonzoGenesis sbe)
149+
=> m AlonzoGenesis
150+
getDefaultAlonzoGenesis =
151+
H.evalEither $ first prettyError Defaults.defaultAlonzoGenesis
153152

154153
numSeededUTxOKeys :: Int
155154
numSeededUTxOKeys = 3
@@ -181,7 +180,7 @@ createSPOGenesisAndFiles
181180
{ sgSecurityParam = unsafeNonZero 5
182181
, sgUpdateQuorum = 2
183182
}
184-
alonzoGenesis' <- getDefaultAlonzoGenesis sbe
183+
alonzoGenesis' <- getDefaultAlonzoGenesis
185184
let conwayGenesis' = Defaults.defaultConwayGenesis
186185

187186
(alonzoGenesis, conwayGenesis, shelleyGenesis) <- resolveOnChainParams onChainParams

cardano-testnet/src/Testnet/Components/Query.hs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ import qualified Cardano.Ledger.Conway.Governance as L
5454
import qualified Cardano.Ledger.Conway.PParams as L
5555
import qualified Cardano.Ledger.Shelley.LedgerState as L
5656
import qualified Cardano.Ledger.UMap as L
57+
import qualified Cardano.Ledger.Api.State.Query as SQ
58+
import qualified Data.Set as Set
5759

5860
import Prelude
5961

@@ -409,12 +411,9 @@ checkDRepState epochStateView@EpochStateView{nodeConfigPath, socketPath} sbe f =
409411
result <- H.evalIO . runExceptT $ foldEpochState nodeConfigPath socketPath QuickValidation terminationEpoch Nothing
410412
$ \(AnyNewEpochState actualEra newEpochState _) _slotNumber _blockNumber -> do
411413
Refl <- either error pure $ assertErasEqual sbe actualEra
412-
let dreps = shelleyBasedEraConstraints sbe newEpochState
413-
^. L.nesEsL
414-
. L.esLStateL
415-
. L.lsCertStateL
416-
. L.certVStateL
417-
. L.vsDRepsL
414+
let dreps =
415+
shelleyBasedEraConstraints sbe
416+
$ SQ.queryDRepState newEpochState Set.empty
418417
case f dreps of
419418
Nothing -> pure ConditionNotMet
420419
Just a -> do put $ Just a
@@ -602,7 +601,6 @@ getDelegationState epochStateView = do
602601
. L.esLStateL
603602
. L.lsCertStateL
604603
. L.certDStateL
605-
. L.dsUnifiedL
606604

607605
pure $ L.toStakeCredentials pools
608606

cardano-testnet/src/Testnet/Defaults.hs

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module Testnet.Defaults
4141
) where
4242

4343
import Cardano.Api (AnyShelleyBasedEra (..), CardanoEra (..), File (..),
44-
ShelleyBasedEra (..), pshow, toCardanoEra, unsafeBoundedRational)
44+
ShelleyBasedEra (..), pshow, unsafeBoundedRational)
4545
import qualified Cardano.Api as Api
4646

4747
import Cardano.Ledger.Alonzo.Core (PParams (..))
@@ -106,9 +106,9 @@ newtype AlonzoGenesisError
106106
= AlonzoGenErrTooMuchPrecision Rational
107107
deriving Show
108108

109-
defaultAlonzoGenesis :: ShelleyBasedEra era -> Either AlonzoGenesisError AlonzoGenesis
110-
defaultAlonzoGenesis sbe = do
111-
let genesis = Api.alonzoGenesisDefaults (toCardanoEra sbe)
109+
defaultAlonzoGenesis :: Either AlonzoGenesisError AlonzoGenesis
110+
defaultAlonzoGenesis = do
111+
let genesis = Api.alonzoGenesisDefaults
112112
prices = Ledger.agPrices genesis
113113

114114
-- double check that prices have correct values - they're set using unsafeBoundedRational in cardano-api
@@ -192,6 +192,7 @@ defaultYamlHardforkViaConfig sbe =
192192
ShelleyBasedEraAlonzo -> ("LastKnownBlockVersion-Major", Aeson.Number 5)
193193
ShelleyBasedEraBabbage -> ("LastKnownBlockVersion-Major", Aeson.Number 8)
194194
ShelleyBasedEraConway -> ("LastKnownBlockVersion-Major", Aeson.Number 9)
195+
ShelleyBasedEraDijkstra -> ("LastKnownBlockVersion-Major", Aeson.Number 10)
195196
, ("LastKnownBlockVersion-Minor", Aeson.Number 0)
196197
, ("LastKnownBlockVersion-Alt", Aeson.Number 0)
197198
]
@@ -236,7 +237,17 @@ defaultYamlHardforkViaConfig sbe =
236237
, ("TestAlonzoHardForkAtEpoch", Aeson.Number 0)
237238
, ("TestBabbageHardForkAtEpoch", Aeson.Number 0)
238239
, ("TestConwayHardForkAtEpoch", Aeson.Number 0)
239-
])
240+
]
241+
ShelleyBasedEraDijkstra ->
242+
[ ("TestShelleyHardForkAtEpoch", Aeson.Number 0)
243+
, ("TestAllegraHardForkAtEpoch", Aeson.Number 0)
244+
, ("TestMaryHardForkAtEpoch", Aeson.Number 0)
245+
, ("TestAlonzoHardForkAtEpoch", Aeson.Number 0)
246+
, ("TestBabbageHardForkAtEpoch", Aeson.Number 0)
247+
, ("TestConwayHardForkAtEpoch", Aeson.Number 0)
248+
, ("TestDijkstraHardForkAtEpoch", Aeson.Number 0)
249+
]
250+
)
240251
-- | Various tracers we can turn on or off
241252
tracers :: Aeson.KeyMap Aeson.Value
242253
tracers = Aeson.fromList $ map (bimap Aeson.fromText Aeson.Bool)
@@ -429,6 +440,8 @@ eraToProtocolVersion =
429440
AnyShelleyBasedEra ShelleyBasedEraBabbage -> mkProtVer (8, 0)
430441
-- By default start after bootstrap (which is PV9)
431442
AnyShelleyBasedEra ShelleyBasedEraConway -> mkProtVer (10, 0)
443+
-- TODO: is this correct?
444+
AnyShelleyBasedEra ShelleyBasedEraDijkstra -> mkProtVer (11, 0)
432445

433446
-- TODO: Expose from cardano-api
434447
mkProtVer :: (Natural, Natural) -> ProtVer
@@ -438,7 +451,7 @@ mkProtVer (majorProtVer, minorProtVer) =
438451
Nothing -> error "mkProtVer: invalid protocol version"
439452

440453
ppProtocolVersionL' :: Lens' (PParams Ledger.ShelleyEra) ProtVer
441-
ppProtocolVersionL' = Ledger.ppLens . Ledger.hkdProtocolVersionL @Ledger.ShelleyEra @Identity
454+
ppProtocolVersionL' = Ledger.ppLensHKD . Ledger.hkdProtocolVersionL @Ledger.ShelleyEra @Identity
442455

443456
defaultMainnetTopology :: Topology.NetworkTopology RemoteAddress
444457
defaultMainnetTopology =

cardano-testnet/src/Testnet/Ping.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ pingNode networkMagic sprocket = liftIO $ bracket
8080
Socket.connect sd (Socket.addrAddress peer)
8181
peerStr <- peerString
8282

83-
bearer <- getBearer makeSocketBearer sduTimeout nullTracer sd Nothing
83+
bearer <- getBearer makeSocketBearer sduTimeout sd Nothing
8484

8585
let versions = supportedNodeToClientVersions networkMagic
86-
!_ <- Mux.write bearer timeoutfn $ wrap handshakeNum InitiatorDir (handshakeReq versions doHandshakeQuery)
86+
!_ <- Mux.write bearer nullTracer timeoutfn $ wrap handshakeNum InitiatorDir (handshakeReq versions doHandshakeQuery)
8787
(msg, !_) <- nextMsg bearer timeoutfn handshakeNum
8888

8989
pure $ case CBOR.deserialiseFromBytes handshakeDec msg of
@@ -130,7 +130,7 @@ pingNode networkMagic sprocket = liftIO $ bracket
130130
-> MiniProtocolNum -- ^ handshake protocol number
131131
-> IO (LBS.ByteString, Time) -- ^ raw message and timestamp
132132
nextMsg bearer timeoutfn ptclNum = do
133-
(sdu, t_e) <- Mux.read bearer timeoutfn
133+
(sdu, t_e) <- Mux.read bearer nullTracer timeoutfn
134134
if mhNum (msHeader sdu) == ptclNum
135135
then pure (msBlob sdu, t_e)
136136
else nextMsg bearer timeoutfn ptclNum

cardano-testnet/src/Testnet/Types.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ getStartTime
209209
getStartTime tempRootPath TestnetRuntime{configurationFile} = withFrozenCallStack $ H.evalEither <=< H.evalIO . runExceptT $ do
210210
byronGenesisFile <-
211211
decodeNodeConfiguration configurationFile >>= \case
212-
NodeProtocolConfigurationCardano NodeByronProtocolConfiguration{npcByronGenesisFile} _ _ _ _ _ ->
212+
NodeProtocolConfigurationCardano NodeByronProtocolConfiguration{npcByronGenesisFile} _ _ _ _ _ _ ->
213213
pure $ unGenesisFile npcByronGenesisFile
214214
let byronGenesisFilePath = tempRootPath </> byronGenesisFile
215215
SystemStart . G.gdStartTime . G.configGenesisData <$> decodeGenesisFile byronGenesisFilePath

0 commit comments

Comments
 (0)