Skip to content

Commit

Permalink
Fix cardano-api
Browse files Browse the repository at this point in the history
  • Loading branch information
kderme committed Jan 19, 2021
1 parent e609e0a commit 08482ab
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 18 deletions.
9 changes: 5 additions & 4 deletions cardano-api/src/Cardano/Api/IPC.hs
Expand Up @@ -214,15 +214,16 @@ mkVersionedProtocols networkid ptcl
NodeToClientVersionData {
networkMagic = toNetworkMagic networkid
}
(\_connid _ctl -> protocols ptclBlockVersion))
(\_connid _ctl -> protocols ptclBlockVersion ptclVersion))
(Map.toList (Consensus.supportedNodeToClientVersions proxy))
where
proxy :: Proxy block
proxy = Proxy

protocols :: Consensus.BlockNodeToClientVersion block
-> Consensus.NodeToClientVersion
-> NodeToClientProtocols Net.InitiatorMode LBS.ByteString IO () Void
protocols ptclBlockVersion =
protocols ptclBlockVersion ptclVersion =
NodeToClientProtocols {
localChainSyncProtocol =
Net.InitiatorProtocolOnly $
Expand Down Expand Up @@ -255,7 +256,7 @@ mkVersionedProtocols networkid ptcl
Consensus.cChainSyncCodec,
Consensus.cTxSubmissionCodec,
Consensus.cStateQueryCodec
} = Consensus.clientCodecs codecConfig ptclBlockVersion
} = Consensus.clientCodecs codecConfig ptclBlockVersion ptclVersion

codecConfig :: Consensus.CodecConfig block
codecConfig = Consensus.pClientInfoCodecConfig
Expand Down Expand Up @@ -419,7 +420,7 @@ queryNodeLocalState connctInfo point query = do
(QueryInMode mode) IO ()
localStateQuerySingle resultVar =
LocalStateQueryClient $ pure $
Net.Query.SendMsgAcquire point $
Net.Query.SendMsgAcquire (Just point) $
Net.Query.ClientStAcquiring {
Net.Query.recvMsgAcquired =
Net.Query.SendMsgQuery query $
Expand Down
4 changes: 2 additions & 2 deletions cardano-api/src/Cardano/Api/Query.hs
Expand Up @@ -446,12 +446,12 @@ fromConsensusQueryResultShelleyBased _ QueryStakeAddresses{} q' r' =
fromShelleyDelegations delegs)
_ -> fromConsensusQueryResultMismatch

fromConsensusQueryResultShelleyBased QueryLedgerState{} q' r' =
fromConsensusQueryResultShelleyBased _ QueryLedgerState{} q' r' =
case q' of
Consensus.GetCBOR Consensus.DebugNewEpochState -> LedgerState r'
_ -> fromConsensusQueryResultMismatch

fromConsensusQueryResultShelleyBased QueryProtocolState q' r' =
fromConsensusQueryResultShelleyBased _ QueryProtocolState q' r' =
case q' of
Consensus.GetCBOR Consensus.DebugChainDepState -> ProtocolState r'
_ -> fromConsensusQueryResultMismatch
Expand Down
12 changes: 7 additions & 5 deletions cardano-api/src/Cardano/Api/Typed.hs
Expand Up @@ -538,7 +538,8 @@ import Ouroboros.Consensus.Ledger.Query (Query, ShowQuery)
import Ouroboros.Consensus.Ledger.SupportsMempool (ApplyTxErr, GenTx)
import Ouroboros.Consensus.Network.NodeToClient (Codecs' (..), clientCodecs)
import Ouroboros.Consensus.Node.NetworkProtocolVersion (BlockNodeToClientVersion,
SupportedNetworkProtocolVersion, supportedNodeToClientVersions)
NodeToClientVersion, SupportedNetworkProtocolVersion,
supportedNodeToClientVersions)
import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolClientInfo (..))
import Ouroboros.Consensus.Node.Run (SerialiseNodeToClientConstraints)
import Ouroboros.Consensus.Shelley.Node (emptyGenesisStaking)
Expand Down Expand Up @@ -738,7 +739,7 @@ connectToLocalNode LocalNodeConnectInfo {
NodeToClientVersionData {
networkMagic = toNetworkMagic network
}
(\_conn _runOrStop -> protocols ptcl blockVersion))
(\_conn _runOrStop -> protocols ptcl blockVersion version))
(Map.toList (supportedNodeToClientVersions proxy)))
path
where
Expand All @@ -748,14 +749,15 @@ connectToLocalNode LocalNodeConnectInfo {
protocols :: SerialiseNodeToClientConstraints block
=> ProtocolClient block (BlockProtocol block)
-> BlockNodeToClientVersion block
-> NodeToClientVersion
-> NodeToClientProtocols InitiatorMode LBS.ByteString IO () Void
protocols ptcl clientVersion =
protocols ptcl clientVersion nodeToClientVersion =
let Codecs {
cChainSyncCodec
, cTxSubmissionCodec
, cStateQueryCodec
} = clientCodecs (pClientInfoCodecConfig (protocolClientInfo ptcl))
clientVersion
clientVersion nodeToClientVersion

LocalNodeClientProtocols {
localChainSyncClient,
Expand Down Expand Up @@ -823,7 +825,7 @@ queryNodeLocalState connctInfo pointAndQuery = do
-> LocalStateQueryClient block (Point block) (Query block) IO ()
localStateQuerySingle resultVar (point, query) =
LocalStateQueryClient $ pure $
SendMsgAcquire point $
SendMsgAcquire (Just point) $
ClientStAcquiring {
recvMsgAcquired =
SendMsgQuery query $
Expand Down
5 changes: 1 addition & 4 deletions cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs
Expand Up @@ -56,7 +56,6 @@ import Ouroboros.Network.Block (Serialised (..), getTipPoint)

import qualified Cardano.Ledger.Core as Ledger
import qualified Cardano.Ledger.Era as Ledger
import qualified Cardano.Ledger.Shelley.Constraints as Ledger

import qualified Shelley.Spec.Ledger.Address as Ledger
import qualified Shelley.Spec.Ledger.API.Protocol as Ledger
Expand Down Expand Up @@ -637,7 +636,6 @@ queryLocalLedgerState
:: forall era ledgerera mode block.
ShelleyLedgerEra era ~ ledgerera
=> Consensus.ShelleyBasedEra ledgerera
=> Ledger.UsesTxOut ledgerera
=> ShelleyBasedEra era
-> LocalNodeConnectInfo mode block
-> ExceptT ShelleyQueryCmdLocalStateQueryError IO
Expand Down Expand Up @@ -677,8 +675,7 @@ queryLocalLedgerState era connectInfo@LocalNodeConnectInfo{localNodeConsensusMod
-- CBOR decode.
--UsesTxOut era
decodeLedgerState
:: FromCBOR (NewEpochState ledgerera)
=> Serialised (NewEpochState ledgerera)
:: Serialised (NewEpochState ledgerera)
-> Either LBS.ByteString (NewEpochState ledgerera)
decodeLedgerState (Serialised lbs) =
first (const lbs) (decodeFull lbs)
Expand Down
7 changes: 4 additions & 3 deletions cardano-node-chairman/app/Cardano/Chairman.hs
Expand Up @@ -455,7 +455,7 @@ localInitiatorNetworkApplication
versionedNodeToClientProtocols
version
versionData
(\_ _ -> protocols blockVersion))
(\_ _ -> protocols blockVersion version))
(Map.toList (supportedNodeToClientVersions proxy))
where
proxy :: Proxy blk
Expand All @@ -465,8 +465,9 @@ localInitiatorNetworkApplication

protocols
:: BlockNodeToClientVersion blk
-> NodeToClientVersion
-> NodeToClientProtocols InitiatorMode ByteString m () Void
protocols byronClientVersion =
protocols byronClientVersion version =
NodeToClientProtocols
{ localChainSyncProtocol =
InitiatorProtocolOnly $
Expand Down Expand Up @@ -495,4 +496,4 @@ localInitiatorNetworkApplication
, cTxSubmissionCodec
, cStateQueryCodec
} =
clientCodecs cfg byronClientVersion
clientCodecs cfg byronClientVersion version

0 comments on commit 08482ab

Please sign in to comment.