Skip to content

Commit

Permalink
Merge #1765 #1767
Browse files Browse the repository at this point in the history
1765: Add script to show cardano-node and cardano-cli versions r=rvl a=rvl

Run this script if you would like to know which version of `cardano-node` will be in the `nix-shell` (i.e. CI).

This PR IntersectMBO/cardano-node#1283 fixes the CLI version strings.


1767: Better tracing of shelley network local state query r=rvl a=rvl

### Issue Number

ADP-302 / #1750

### Overview

More detail in the logs.


Co-authored-by: Rodney Lorrimar <[email protected]>
  • Loading branch information
iohk-bors[bot] and rvl authored Jun 16, 2020
3 parents 76398e7 + 235a5a9 + e295b32 commit cae1c25
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 12 deletions.
35 changes: 23 additions & 12 deletions lib/shelley/src/Cardano/Wallet/Shelley/Network.hs
Original file line number Diff line number Diff line change
Expand Up @@ -323,12 +323,16 @@ withNetworkLayer tr np addrInfo versionData action = do
case Map.elems rewardAccounts of
[SL.Coin amt] -> pure (Quantity (fromIntegral amt))
_ -> throwE $ ErrGetAccountBalanceAccountNotFound acct
Left acqFail ->
Left acqFail -> do
traceWith tr $
MsgLocalStateQueryError DelegationRewardsClient $
show acqFail
-- NOTE: this could possibly happen in rare circumstances when
-- the chain is switched and the local state query is made
-- before the node tip variable is updated.
throwE $ ErrGetAccountBalanceNetworkUnreachable $
ErrNetworkUnreachable $ T.pack $ "Unexpected " ++ show acqFail
ErrNetworkUnreachable $
T.pack $ "Unexpected " ++ show acqFail

_currentNodeTip nodeTipVar =
fromTip getGenesisBlockHash getEpochLength <$>
Expand Down Expand Up @@ -444,7 +448,7 @@ mkDelegationRewardsClient tr queryRewardQ =
})
NodeToClientV_2
where
tr' = contramap MsgLocalStateQuery tr
tr' = contramap (MsgLocalStateQuery DelegationRewardsClient) tr
codec = cStateQueryCodec serialisedCodecs

codecs :: MonadST m => ClientCodecs ShelleyBlock m
Expand Down Expand Up @@ -500,7 +504,7 @@ mkTipSyncClient tr np localTxSubmissionQ onTipUpdate onPParamsUpdate = do
-> m ()
handleLocalState = \case
Left (e :: AcquireFailure) ->
traceWith tr $ MsgLocalStateQueryError $ show e
traceWith tr $ MsgLocalStateQueryError TipSyncClient $ show e
Right ls ->
onPParamsUpdate' $ fromPParams ls

Expand Down Expand Up @@ -538,7 +542,7 @@ mkTipSyncClient tr np localTxSubmissionQ onTipUpdate onPParamsUpdate = do

, localStateQueryProtocol =
let
tr' = contramap MsgLocalStateQuery tr
tr' = contramap (MsgLocalStateQuery TipSyncClient) tr
codec = cStateQueryCodec serialisedCodecs
in
InitiatorProtocolOnly $ MuxPeerRaw
Expand Down Expand Up @@ -670,7 +674,7 @@ data NetworkLayerLog
(LocalTxSubmission
(GenTx ShelleyBlock)
(OC.ApplyTxError TPraosStandardCrypto)))
| MsgLocalStateQuery
| MsgLocalStateQuery QueryClientName
(TraceSendRecv
(LocalStateQuery ShelleyBlock (Query ShelleyBlock)))
| MsgHandshakeTracer
Expand All @@ -681,11 +685,16 @@ data NetworkLayerLog
| MsgPostSealedTx W.SealedTx
| MsgNodeTip W.BlockHeader
| MsgProtocolParameters W.ProtocolParameters
| MsgLocalStateQueryError String
| MsgLocalStateQueryError QueryClientName String
| MsgGetRewardAccountBalance W.BlockHeader W.ChimericAccount
| MsgAccountDelegationAndRewards W.ChimericAccount
Delegations RewardAccounts

data QueryClientName
= TipSyncClient
| DelegationRewardsClient
deriving (Show, Eq)

type HandshakeTrace = TraceSendRecv (Handshake NodeToClientVersion CBOR.Term)

instance ToText NetworkLayerLog where
Expand Down Expand Up @@ -716,8 +725,8 @@ instance ToText NetworkLayerLog where
[ "Posting transaction, serialized as:"
, T.decodeUtf8 $ convertToBase Base16 bytes
]
MsgLocalStateQuery msg ->
T.pack (show msg)
MsgLocalStateQuery client msg ->
T.pack (show client <> " " <> show msg)
MsgNodeTip bh -> T.unwords
[ "Network node tip is"
, pretty bh
Expand All @@ -726,9 +735,11 @@ instance ToText NetworkLayerLog where
[ "Protocol parameters for tip are:"
, pretty params
]
MsgLocalStateQueryError e -> T.unwords
[ "Error when querying local state parameters:"
, T.pack e
MsgLocalStateQueryError client e -> T.pack $ mconcat
[ "Error when querying local state parameters for "
, show client
, ": "
, e
]
MsgGetRewardAccountBalance bh acct -> T.unwords
[ "Querying the reward account balance for"
Expand Down
20 changes: 20 additions & 0 deletions scripts/cardano-node-rev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/usr/bin/env bash

# Run this script if you would like to know which version of
# cardano-node will be in the nix-shell (i.e. CI).
#
# Instructions for updating the version are here:
# https://github.com/input-output-hk/cardano-wallet/wiki/Updating-Dependencies

set -euo pipefail

echo "Reading cardano-node branch/tag and revision from nix/sources.json"
jq -r '.["cardano-node"] | .branch, .rev' < `dirname $0`/../nix/sources.json

echo
echo "Your cardano-node is `type -p cardano-node`"
cardano-node version

echo
echo "Your cardano-cli is `type -p cardano-cli`"
cardano-cli version

0 comments on commit cae1c25

Please sign in to comment.