Skip to content

Commit

Permalink
Updated to use typed-protocols-0.3.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
coot authored and crocodile-dentist committed Nov 22, 2024
1 parent 4dde2e6 commit ccdff31
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 41 deletions.
15 changes: 13 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repository cardano-haskell-packages
-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
index-state:
, hackage.haskell.org 2024-10-10T08:11:33Z
, cardano-haskell-packages 2024-10-14T23:19:53Z
, hackage.haskell.org 2024-10-22T14:26:27Z
, cardano-haskell-packages 2024-10-23T20:55:17Z

packages:
cardano-api
Expand Down Expand Up @@ -52,3 +52,14 @@ write-ghc-environment-files: always
constraints:
Cabal < 3.14,
cardano-ledger-shelley ^>= 1.14.1

-- coot/typed-protocols-new-api
source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
tag: a94de8f4230c2012c850930d22185f011e0037a0
--sha256: sha256-kE17iKwCBNcRdEnCXjCSDHtvJtYji9wfx3zSEbe2/aQ=
subdir: ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-diffusion
ouroboros-consensus-protocol
6 changes: 3 additions & 3 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ library internal
ouroboros-consensus-diffusion ^>=0.18,
ouroboros-consensus-protocol ^>=0.9.0.2,
ouroboros-network,
ouroboros-network-api ^>=0.10,
ouroboros-network-api ^>=0.11,
ouroboros-network-framework,
ouroboros-network-protocols,
parsec,
Expand All @@ -225,7 +225,7 @@ library internal
time,
transformers,
transformers-except ^>=0.1.3,
typed-protocols ^>=0.1.1,
typed-protocols ^>=0.3,
vector,
yaml,

Expand Down Expand Up @@ -261,7 +261,7 @@ library
memory,
nothunks,
ouroboros-network-protocols,
typed-protocols ^>=0.1.1,
typed-protocols,

library gen
import: project-config
Expand Down
26 changes: 16 additions & 10 deletions cardano-api/internal/Cardano/Api/IPC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ import qualified Ouroboros.Network.Protocol.LocalTxSubmission.Client as Net.Tx

import Control.Concurrent.STM (TMVar, atomically, newEmptyTMVarIO, putTMVar, takeTMVar,
tryPutTMVar)
import Control.Exception (throwIO)
import Control.Monad (void)
import Control.Monad.IO.Class
import Control.Tracer (nullTracer)
Expand Down Expand Up @@ -202,15 +203,19 @@ connectToLocalNodeWithVersion
, localConsensusModeParams
}
clients =
liftIO $ Net.withIOManager $ \iomgr ->
Net.connectTo
(Net.localSnocket iomgr)
Net.NetworkConnectTracers
{ Net.nctMuxTracer = nullTracer
, Net.nctHandshakeTracer = nullTracer
}
versionedProtocls
(unFile localNodeSocketPath)
liftIO $ Net.withIOManager $ \iomgr -> do
r <-
Net.connectTo
(Net.localSnocket iomgr)
Net.NetworkConnectTracers
{ Net.nctMuxTracer = nullTracer
, Net.nctHandshakeTracer = nullTracer
}
versionedProtocls
(unFile localNodeSocketPath)
case r of
Left e -> throwIO e
Right _ -> pure ()
where
versionedProtocls =
-- First convert from the mode-parametrised view of things to the
Expand Down Expand Up @@ -302,10 +307,11 @@ mkVersionedProtocols networkid ptcl unversionedClients =
)
, localStateQueryProtocol =
Net.InitiatorProtocolOnly $
Net.mkMiniProtocolCbFromPeer $
Net.mkMiniProtocolCbFromPeerSt $
const
( nullTracer
, cStateQueryCodec
, Net.Query.StateIdle
, maybe
Net.localStateQueryPeerNull
Net.Query.localStateQueryClientPeer
Expand Down
38 changes: 19 additions & 19 deletions cardano-api/internal/Cardano/Api/LedgerState.hs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ import qualified Data.Yaml as Yaml
import Formatting.Buildable (build)
import GHC.Exts (IsList (..))
import Lens.Micro
import Network.TypedProtocol.Pipelined (Nat (..))
import Network.TypedProtocol.Core (Nat (..))
import System.FilePath

data InitialLedgerStateError
Expand Down Expand Up @@ -1097,45 +1097,45 @@ instance FromJSON NodeConfig where
<*> parseBabbageHardForkEpoch o
<*> parseConwayHardForkEpoch o

parseShelleyHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseShelleyHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseShelleyHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestShelleyHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 2 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestShelleyHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

parseAllegraHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseAllegraHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseAllegraHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestAllegraHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 3 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestAllegraHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

parseMaryHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseMaryHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseMaryHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestMaryHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 4 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestMaryHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

parseAlonzoHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseAlonzoHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseAlonzoHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestAlonzoHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 5 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestAlonzoHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]
parseBabbageHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseBabbageHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseBabbageHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestBabbageHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 7 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestBabbageHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

parseConwayHardForkEpoch :: Object -> Parser Consensus.TriggerHardFork
parseConwayHardForkEpoch :: Object -> Parser (Consensus.CardanoHardForkTrigger blk)
parseConwayHardForkEpoch o =
asum
[ Consensus.TriggerHardForkAtEpoch <$> o .: "TestConwayHardForkAtEpoch"
, pure $ Consensus.TriggerHardForkAtVersion 9 -- Mainnet default
[ Consensus.CardanoTriggerHardForkAtEpoch <$> o .: "TestConwayHardForkAtEpoch"
, pure Consensus.CardanoTriggerHardForkAtDefaultVersion
]

----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion cardano-api/src/Cardano/Api/ChainSync/ClientPipelined.hs
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,4 @@ where
import Ouroboros.Network.Protocol.ChainSync.ClientPipelined
import Ouroboros.Network.Protocol.ChainSync.PipelineDecision

import Network.TypedProtocol.Pipelined (N (..), Nat (..), natToInt)
import Network.TypedProtocol.Core (N (..), Nat (..), natToInt)
12 changes: 6 additions & 6 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ccdff31

Please sign in to comment.