Skip to content

Commit 0377bcd

Browse files
authored
Enforce -Wmissing-local-signatures (#2130)
Resolves #1748
1 parent 6c90f0b commit 0377bcd

File tree

91 files changed

+444
-119
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

91 files changed

+444
-119
lines changed

hydra-cardano-api/hydra-cardano-api.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ common project-config
3333
ghc-options:
3434
-Wall -Wcompat -Widentities -Wincomplete-record-updates
3535
-Wincomplete-uni-patterns -Wredundant-constraints -Wunused-packages
36-
-Wmissing-deriving-strategies -fprint-potential-instances
36+
-fprint-potential-instances -Wmissing-local-signatures
3737

3838
library
3939
import: project-config

hydra-cardano-api/src/Hydra/Cardano/Api/AddressInEra.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ fromPlutusAddress network plutusAddress =
8787
(cred, Nothing) ->
8888
Ledger.Addr network (unsafeCredential cred) Ledger.StakeRefNull
8989
where
90+
unsafeCredential :: Plutus.Credential -> Ledger.Credential keyRole
9091
unsafeCredential = \case
9192
PubKeyCredential (Plutus.PubKeyHash h) ->
9293
Ledger.KeyHashObj . Ledger.KeyHash . unsafeHashFromBytes $ fromBuiltin h

hydra-cardano-api/src/Hydra/Cardano/Api/BlockHeader.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ genBlockHeaderHash :: Gen (Hash BlockHeader)
2828
genBlockHeaderHash =
2929
unsafeBlockHeaderHashFromBytes . BS.pack <$> vectorOf 32 arbitrary
3030
where
31+
unsafeBlockHeaderHashFromBytes :: ByteString -> Hash BlockHeader
3132
unsafeBlockHeaderHashFromBytes bytes =
3233
case deserialiseFromRawBytes (proxyToAsType Proxy) bytes of
3334
Left e ->

hydra-cardano-api/src/Hydra/Cardano/Api/Pretty.hs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Cardano.Binary (serialize)
99
import Cardano.Ledger.Alonzo.Scripts qualified as Ledger
1010
import Cardano.Ledger.Alonzo.TxWits qualified as Ledger
1111
import Cardano.Ledger.Core qualified as Ledger
12+
import Cardano.Ledger.Plutus.Data qualified as Ledger
1213
import Data.Aeson qualified as Aeson
1314
import Data.ByteString.Lazy qualified as BL
1415
import Data.Function (on)
@@ -137,6 +138,7 @@ renderTxWithUTxO utxo (Tx body _wits) =
137138
where
138139
indent = "\n " <> T.replicate n " "
139140

141+
prettyDatumUtxo :: Api.TxOutDatum ctx -> String
140142
prettyDatumUtxo = \case
141143
TxOutDatumNone ->
142144
"TxOutDatumNone"
@@ -170,6 +172,7 @@ renderTxWithUTxO utxo (Tx body _wits) =
170172

171173
totalScriptSize = sum $ BL.length . serialize <$> scripts
172174

175+
prettyScript :: Ledger.Script LedgerEra -> String
173176
prettyScript script =
174177
"Script (" <> show (Ledger.hashScript script) <> ")"
175178

@@ -179,6 +182,7 @@ renderTxWithUTxO utxo (Tx body _wits) =
179182
"== DATUMS (" <> show (length dats) <> ")"
180183
: (("- " <>) . showDatumAndHash <$> Map.toList dats)
181184

185+
showDatumAndHash :: (Ledger.SafeHash i, Ledger.Data era) -> String
182186
showDatumAndHash (k, v) =
183187
mconcat
184188
[ show (Ledger.extractHash k)
@@ -196,6 +200,7 @@ renderTxWithUTxO utxo (Tx body _wits) =
196200
in "== REDEEMERS (" <> show (length rdmrs) <> ")"
197201
: (("- " <>) . prettyRedeemer <$> rdmrs)
198202

203+
prettyRedeemer :: forall p era. Show p => (p, (Ledger.Data era, Ledger.ExUnits)) -> String
199204
prettyRedeemer (purpose, (redeemerData, redeemerBudget)) =
200205
unwords
201206
[ show purpose

hydra-cardano-api/src/Hydra/Cardano/Api/TxOut.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ toPlutusTxOut =
187187
-- a 'Left', which we expect to throw away anyway on 'eitherToMaybe'.
188188
eitherToMaybe . Ledger.transTxOutV2 (error "TxOutSource used unexpectedly") . toLedgerTxOut
189189
where
190+
eitherToMaybe :: Either a b -> Maybe b
190191
eitherToMaybe = \case
191192
Left _ -> Nothing
192193
Right x -> Just x

hydra-cardano-api/src/Hydra/Cardano/Api/Value.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ containsValue :: Value -> Value -> Bool
1919
containsValue a b =
2020
all positive . toList $ a <> negateValue b
2121
where
22+
positive :: (a, Quantity) -> Bool
2223
positive (_, q) = q >= 0
2324

2425
-- | Calculate minimum ada as 'Value' for a 'TxOut'.
@@ -81,6 +82,7 @@ fromPlutusValue :: Plutus.Value -> Maybe Value
8182
fromPlutusValue plutusValue = do
8283
fmap fromList . mapM convertAsset $ flattenValue plutusValue
8384
where
85+
convertAsset :: (Plutus.CurrencySymbol, Plutus.TokenName, Integer) -> Maybe (AssetId, Quantity)
8486
convertAsset (cs, tk, i)
8587
| cs == adaSymbol && tk == adaToken =
8688
pure (AdaAssetId, Quantity i)

hydra-chain-observer/hydra-chain-observer.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ common project-config
3434
ghc-options:
3535
-Wall -Wcompat -Widentities -Wincomplete-record-updates
3636
-Wincomplete-uni-patterns -Wredundant-constraints -Wunused-packages
37-
-fprint-potential-instances
37+
-fprint-potential-instances -Wmissing-local-signatures
3838

3939
library
4040
import: project-config

hydra-chain-observer/src/Hydra/Blockfrost/ChainObserver.hs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import Control.Concurrent.Class.MonadSTM (
1414
newTVarIO,
1515
writeTVar,
1616
)
17-
import Control.Retry (constantDelay, retrying)
17+
import Control.Retry (RetryPolicyM, RetryStatus, constantDelay, retrying)
1818
import Data.ByteString.Base16 qualified as Base16
1919
import Hydra.Cardano.Api (
2020
ChainPoint (..),
@@ -104,10 +104,12 @@ blockfrostClient tracer projectPath blockConfirmations = do
104104
pure $ Left ex
105105
}
106106
where
107+
shouldRetry :: MonadIO m => RetryStatus -> Either APIBlockfrostError b -> m Bool
107108
shouldRetry _ = \case
108109
Right{} -> pure False
109110
Left err -> pure $ isRetryable err
110111

112+
retryPolicy :: DiffTime -> RetryPolicyM IO
111113
retryPolicy blockTime = constantDelay (truncate blockTime * 1000 * 1000)
112114

113115
-- | Iterative process that follows the chain using a naive roll-forward approach,

hydra-chain-observer/src/Hydra/ChainObserver/Options.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ hydraChainObserverOptions =
9494
<> header "hydra-chain-observer"
9595
)
9696
where
97+
versionInfo :: Parser (a -> a)
9798
versionInfo =
9899
infoOption
99100
(showVersion hydraNodeVersion)

hydra-cluster/bench/Bench/EndToEnd.hs

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import Control.Lens (to, (^..), (^?))
2222
import Control.Monad.Class.MonadAsync (mapConcurrently)
2323
import Data.Aeson (Result (Error, Success), Value, encode, fromJSON, (.=))
2424
import Data.Aeson.Lens (key, values, _JSON, _Number, _String)
25+
import Data.ByteString.Lazy qualified as LBS
2526
import Data.List qualified as List
2627
import Data.Map qualified as Map
2728
import Data.Scientific (Scientific)
@@ -130,6 +131,12 @@ benchDemo networkId nodeSocket timeoutSeconds hydraClients workDir dataset@Datas
130131
(leader : followers) ->
131132
(,[]) <$> scenario hydraTracer backend workDir dataset (leader :| followers)
132133
where
134+
withHydraClientConnections ::
135+
Tracer IO HydraNodeLog ->
136+
[(Host, Int)] ->
137+
[HydraClient] ->
138+
([HydraClient] -> IO a) ->
139+
IO a
133140
withHydraClientConnections tracer apiHosts connections action = do
134141
case apiHosts of
135142
[] -> action connections
@@ -309,10 +316,14 @@ movingAverage confirmations =
309316
timeSlice t@UTCTime{utctDayTime} =
310317
t{utctDayTime = fromIntegral (floor (utctDayTime / window) * window :: Integer)}
311318

319+
fiveSecSlice :: (UTCTime, NominalDiffTime, NominalDiffTime) -> (UTCTime, NominalDiffTime, NominalDiffTime) -> Bool
312320
fiveSecSlice (timeSlice -> t1, _, _) (timeSlice -> t2, _, _) = t1 == t2
313321

322+
fst3 :: (a, b, c) -> a
314323
fst3 (a, _, _) = a
324+
snd3 :: (a, b, c) -> b
315325
snd3 (_, a, _) = a
326+
thd3 :: (a, b, c) -> c
316327
thd3 (_, _, a) = a
317328

318329
average = \case
@@ -481,21 +492,29 @@ waitForAllConfirmations n1 Registry{processedTxs} allIds = do
481492
waitForSnapshotConfirmation = waitMatch 20 n1 $ \v ->
482493
maybeTxValid v <|> maybeTxInvalid v <|> maybeSnapshotConfirmed v
483494

495+
maybeTxValid :: Value -> Maybe WaitResult
484496
maybeTxValid v = do
485497
guard (v ^? key "tag" == Just "TxValid")
486498
v
487-
^? key "transactionId" . to fromJSON >>= \case
488-
Error _ -> Nothing
489-
Success txid -> pure $ TxValid txid
499+
^? key "transactionId"
500+
. to fromJSON
501+
>>= \case
502+
Error _ -> Nothing
503+
Success txid -> pure $ TxValid txid
490504

505+
maybeTxInvalid :: Value -> Maybe WaitResult
491506
maybeTxInvalid v = do
492507
guard (v ^? key "tag" == Just "TxInvalid")
493508
v
494-
^? key "transaction" . key "txId" . to fromJSON >>= \case
495-
Error _ -> Nothing
496-
Success tx ->
497-
TxInvalid tx <$> v ^? key "validationError" . key "reason" . _String
498-
509+
^? key "transaction"
510+
. key "txId"
511+
. to fromJSON
512+
>>= \case
513+
Error _ -> Nothing
514+
Success tx ->
515+
TxInvalid tx <$> v ^? key "validationError" . key "reason" . _String
516+
517+
maybeSnapshotConfirmed :: Value -> Maybe WaitResult
499518
maybeSnapshotConfirmed v = do
500519
guard (v ^? key "tag" == Just "SnapshotConfirmed")
501520
snapshot <- v ^? key "snapshot"
@@ -553,4 +572,5 @@ writeResultsCsv fp res = do
553572
where
554573
headers = "txId,confirmationTime"
555574

575+
toCsv :: (UTCTime, NominalDiffTime, NominalDiffTime, Int) -> LBS.ByteString
556576
toCsv (a, b, c, d) = show a <> "," <> encode b <> "," <> encode c <> "," <> encode d <> "\n"

0 commit comments

Comments
 (0)