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 committed Oct 22, 2024
1 parent 07ca594 commit 66b8d9e
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 30 deletions.
12 changes: 11 additions & 1 deletion cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repository cardano-haskell-packages
-- 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
, cardano-haskell-packages 2024-10-21T06:28:35Z

packages:
cardano-api
Expand Down Expand Up @@ -52,3 +52,13 @@ 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: 254aa51558cc71baa5d23faa4bdb5b3ae1e7ba70
--sha256: sha256-Drnc35CQFB5QrYgHFYaqwn7Tnc8p11KJq3vp9DvpKoE=
subdir: ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-diffusion
6 changes: 3 additions & 3 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,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 @@ -222,7 +222,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 @@ -257,7 +257,7 @@ library
memory,
nothunks,
ouroboros-network-protocols,
typed-protocols ^>=0.1.1,
typed-protocols,

library gen
import: project-config
Expand Down
11 changes: 8 additions & 3 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 (SomeException, throwIO)
import Control.Monad (void)
import Control.Monad.IO.Class
import Control.Tracer (nullTracer)
Expand Down Expand Up @@ -202,15 +203,18 @@ connectToLocalNodeWithVersion
, localConsensusModeParams
}
clients =
liftIO $ Net.withIOManager $ \iomgr ->
Net.connectTo
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 +306,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)
6 changes: 3 additions & 3 deletions flake.lock

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

0 comments on commit 66b8d9e

Please sign in to comment.