From 215e587726cd4f5b9c88a79e992801a0c55b83a9 Mon Sep 17 00:00:00 2001 From: Ziyang Liu Date: Tue, 30 Jan 2024 10:50:59 -0800 Subject: [PATCH] Misc --- cabal.project | 17 ++--------------- cardano-api/cardano-api.cabal | 8 ++++---- .../internal/Cardano/Api/Convenience/Query.hs | 5 +++-- cardano-api/internal/Cardano/Api/IPC.hs | 4 ++-- cardano-api/internal/Cardano/Api/IPC/Monad.hs | 5 +++-- cardano-api/internal/Cardano/Api/LedgerState.hs | 5 ++--- 6 files changed, 16 insertions(+), 28 deletions(-) diff --git a/cabal.project b/cabal.project index 3c08b8b67d..3faf1933f2 100644 --- a/cabal.project +++ b/cabal.project @@ -20,8 +20,8 @@ packages: cardano-api cardano-api-gen --- package cardano-api --- ghc-options: -Werror +package cardano-api + ghc-options: -Werror package cardano-api-gen ghc-options: -Werror @@ -41,16 +41,3 @@ write-ghc-environment-files: always -- IMPORTANT -- Do NOT add more source-repository-package stanzas here unless they are strictly -- temporary! Please read the section in CONTRIBUTING about updating dependencies. - -source-repository-package - type: git - location: https://github.com/IntersectMBO/ouroboros-consensus.git - tag: cb4141a67d686e95d441ad17e758fb63480a0111 - subdir: - ouroboros-consensus - ouroboros-consensus-cardano - ouroboros-consensus-protocol - ouroboros-consensus-diffusion - sop-extras - strict-sop-core - --sha256: sha256-HnbevSn4lfaGr8gAIDnLm9OLnyxcHhcQYZoB+x+SItc= diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index ec2941de10..25199eb9fe 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -191,10 +191,10 @@ library internal , mtl , network , optparse-applicative-fork - , ouroboros-consensus ^>= 0.14 - , ouroboros-consensus-cardano ^>= 0.12 - , ouroboros-consensus-diffusion ^>= 0.9 - , ouroboros-consensus-protocol ^>= 0.6 + , ouroboros-consensus ^>= 0.15 + , ouroboros-consensus-cardano ^>= 0.13 + , ouroboros-consensus-diffusion ^>= 0.10 + , ouroboros-consensus-protocol ^>= 0.7 , ouroboros-network , ouroboros-network-api ^>= 0.6.2 , ouroboros-network-framework diff --git a/cardano-api/internal/Cardano/Api/Convenience/Query.hs b/cardano-api/internal/Cardano/Api/Convenience/Query.hs index 0bb04b3af6..bfd6619cab 100644 --- a/cardano-api/internal/Cardano/Api/Convenience/Query.hs +++ b/cardano-api/internal/Cardano/Api/Convenience/Query.hs @@ -35,6 +35,7 @@ import Cardano.Ledger.CertState (DRepState (..)) import qualified Cardano.Ledger.Credential as L import qualified Cardano.Ledger.Keys as L import Ouroboros.Consensus.HardFork.Combinator.AcrossEras (EraMismatch (..)) +import Ouroboros.Network.Protocol.LocalStateQuery.Type (Target (..)) import Control.Monad.Trans (MonadTrans (..)) import Control.Monad.Trans.Except (ExceptT (..), runExceptT) @@ -130,7 +131,7 @@ determineEra :: () => LocalNodeConnectInfo -> IO (Either AcquiringFailure AnyCardanoEra) determineEra localNodeConnInfo = - queryNodeLocalState localNodeConnInfo Nothing QueryCurrentEra + queryNodeLocalState localNodeConnInfo VolatileTip QueryCurrentEra -- | Execute a query against the local node. The local -- node must be in CardanoMode. @@ -155,6 +156,6 @@ executeQueryAnyMode :: forall result. () -> QueryInMode (Either EraMismatch result) -> IO (Either QueryConvenienceError result) executeQueryAnyMode localNodeConnInfo q = runExceptT $ do - lift (queryNodeLocalState localNodeConnInfo Nothing q) + lift (queryNodeLocalState localNodeConnInfo VolatileTip q) & onLeft (left . AcqFailure) & onLeft (left . QueryEraMismatch) diff --git a/cardano-api/internal/Cardano/Api/IPC.hs b/cardano-api/internal/Cardano/Api/IPC.hs index 7c0b0bd586..1d32f2e58c 100644 --- a/cardano-api/internal/Cardano/Api/IPC.hs +++ b/cardano-api/internal/Cardano/Api/IPC.hs @@ -533,7 +533,7 @@ toAcquiringFailure AcquireFailurePointNotOnChain = AFPointNotOnChain queryNodeLocalState :: forall result. () => LocalNodeConnectInfo - -> Maybe ChainPoint + -> Net.Query.Target ChainPoint -> QueryInMode result -> IO (Either AcquiringFailure result) queryNodeLocalState connctInfo mpoint query = do @@ -549,7 +549,7 @@ queryNodeLocalState connctInfo mpoint query = do atomically (takeTMVar resultVar) where singleQuery - :: Maybe ChainPoint + :: Net.Query.Target ChainPoint -> TMVar (Either AcquiringFailure result) -> Net.Query.LocalStateQueryClient BlockInMode ChainPoint QueryInMode IO () singleQuery mPointVar' resultVar' = diff --git a/cardano-api/internal/Cardano/Api/IPC/Monad.hs b/cardano-api/internal/Cardano/Api/IPC/Monad.hs index fe55232ddd..9318478bb1 100644 --- a/cardano-api/internal/Cardano/Api/IPC/Monad.hs +++ b/cardano-api/internal/Cardano/Api/IPC/Monad.hs @@ -14,6 +14,7 @@ import Cardano.Api.IPC.Version import Cardano.Ledger.Shelley.Scripts () import qualified Ouroboros.Network.Protocol.LocalStateQuery.Client as Net.Query +import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as Net.Query import Control.Concurrent.STM import Control.Monad @@ -42,7 +43,7 @@ newtype LocalStateQueryExpr block point query r m a = LocalStateQueryExpr -- | Execute a local state query expression. executeLocalStateQueryExpr :: () => LocalNodeConnectInfo - -> Maybe ChainPoint + -> Net.Query.Target ChainPoint -> LocalStateQueryExpr BlockInMode ChainPoint QueryInMode () IO a -> IO (Either AcquiringFailure a) executeLocalStateQueryExpr connectInfo target f = do @@ -68,7 +69,7 @@ setupLocalStateQueryExpr :: -- ^ An STM expression that only returns when all protocols are complete. -- Protocols must wait until 'waitDone' returns because premature exit will -- cause other incomplete protocols to abort which may lead to deadlock. - -> Maybe ChainPoint + -> Net.Query.Target ChainPoint -> TMVar (Either AcquiringFailure a) -> NodeToClientVersion -> LocalStateQueryExpr BlockInMode ChainPoint QueryInMode () IO a diff --git a/cardano-api/internal/Cardano/Api/LedgerState.hs b/cardano-api/internal/Cardano/Api/LedgerState.hs index a2e48dc453..72e929bcf4 100644 --- a/cardano-api/internal/Cardano/Api/LedgerState.hs +++ b/cardano-api/internal/Cardano/Api/LedgerState.hs @@ -484,7 +484,7 @@ foldBlocks nodeConfigFilePath socketPath validationMode state0 accumulate = hand } -- | Defines the client side of the chain sync protocol. - chainSyncClient :: Word32 + chainSyncClient :: Word16 -- ^ The maximum number of concurrent requests. -> IORef a -- ^ State accumulator. Written to on every block. @@ -1950,7 +1950,7 @@ checkLedgerStateCondition nodeConfigFilePath socketPath validationMode terminati } -- | Defines the client side of the chain sync protocol. - chainSyncClient :: Word32 + chainSyncClient :: Word16 -- ^ The maximum number of concurrent requests. -> IORef (LedgerStateCondition, s) -- ^ State accumulator. Written to on every block. @@ -2078,4 +2078,3 @@ atTerminationEpoch terminationEpoch events = handleIOExceptions :: MonadIOTransError FoldBlocksError t m => ExceptT FoldBlocksError IO a -> t m a handleIOExceptions = liftEither <=< liftIO . fmap (join . first FoldBlocksIOException) . try . runExceptT -