From 169bc54b5dd10433e16505b1decdd2d7a445213c Mon Sep 17 00:00:00 2001 From: John Ky Date: Sat, 28 Jan 2023 23:50:17 -0800 Subject: [PATCH 1/7] Remove dependency on cardano-prelude from cardano-api --- cardano-api/cardano-api.cabal | 2 -- cardano-api/gen/Test/Gen/Cardano/Api.hs | 5 +---- cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs | 7 ++----- cardano-api/src/Cardano/Api/Keys/Byron.hs | 6 ++---- cardano-api/src/Cardano/Api/Tx.hs | 3 ++- 5 files changed, 7 insertions(+), 16 deletions(-) diff --git a/cardano-api/cardano-api.cabal b/cardano-api/cardano-api.cabal index cd720b65bc2..35246236533 100644 --- a/cardano-api/cardano-api.cabal +++ b/cardano-api/cardano-api.cabal @@ -124,7 +124,6 @@ library , cardano-ledger-byron ^>= 0.1 , cardano-ledger-core ^>= 0.1 , cardano-ledger-shelley-ma ^>= 0.1 - , cardano-prelude , cardano-protocol-tpraos >= 0.1 , cardano-slotting >= 0.1 , cborg @@ -197,7 +196,6 @@ library gen , cardano-ledger-alonzo-test , cardano-ledger-byron-test ^>= 1.4 , cardano-ledger-core ^>= 0.1 - , cardano-prelude , containers , hedgehog , cardano-ledger-shelley ^>= 0.1 diff --git a/cardano-api/gen/Test/Gen/Cardano/Api.hs b/cardano-api/gen/Test/Gen/Cardano/Api.hs index 43ca2735e81..a018368de2a 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api.hs @@ -8,12 +8,9 @@ module Test.Gen.Cardano.Api , genAlonzoGenesis ) where -import Cardano.Prelude (panic) - import Cardano.Api.Shelley as Api import qualified Data.Map.Strict as Map -import qualified Data.Text as Text import Data.Word (Word64) --TODO: why do we have this odd split? We can get rid of the old name "typed" @@ -92,7 +89,7 @@ genCostModels = do CostModel cModel <- genCostModel lang <- genLanguage case Alonzo.mkCostModel lang cModel of - Left err -> panic . Text.pack $ "genCostModels: " <> show err + Left err -> error $ "genCostModels: " <> show err Right alonzoCostModel -> Alonzo.CostModels . conv <$> Gen.list (Range.linear 1 3) (return alonzoCostModel) where diff --git a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs index b838e37beda..271ec9fba98 100644 --- a/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs +++ b/cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs @@ -105,8 +105,6 @@ module Test.Gen.Cardano.Api.Typed , genRational ) where -import Cardano.Prelude (panic) - import Cardano.Api hiding (txIns) import qualified Cardano.Api as Api import Cardano.Api.Byron (KeyWitness (ByronKeyWitness), @@ -127,7 +125,6 @@ import Data.Map.Strict (Map) import Data.Maybe (maybeToList) import Data.Ratio (Ratio, (%)) import Data.String -import qualified Data.Text as Text import Data.Word (Word64) import Numeric.Natural (Natural) @@ -498,7 +495,7 @@ genTxValidityUpperBound era = pure (TxValidityNoUpperBound supported) (Nothing, Nothing) -> - panic "genTxValidityUpperBound: unexpected era support combination" + error "genTxValidityUpperBound: unexpected era support combination" genTxValidityRange :: CardanoEra era @@ -863,7 +860,7 @@ genCostModel = do eCostModel <- Alonzo.mkCostModel <$> genPlutusLanguage <*> mapM (const $ Gen.integral (Range.linear 0 5000)) costModelParams case eCostModel of - Left err -> panic $ Text.pack $ "genCostModel: " <> show err + Left err -> error $ "genCostModel: " <> show err Right cModel -> return . CostModel $ Alonzo.getCostModelParams cModel genPlutusLanguage :: Gen Language diff --git a/cardano-api/src/Cardano/Api/Keys/Byron.hs b/cardano-api/src/Cardano/Api/Keys/Byron.hs index 2f8b6a312be..72c9584988f 100644 --- a/cardano-api/src/Cardano/Api/Keys/Byron.hs +++ b/cardano-api/src/Cardano/Api/Keys/Byron.hs @@ -30,8 +30,6 @@ module Cardano.Api.Keys.Byron ( toByronSigningKey ) where -import qualified Cardano.Prelude as CBOR (toCborError) - import qualified Codec.CBOR.Decoding as CBOR import qualified Codec.CBOR.Read as CBOR import Control.Monad @@ -42,6 +40,7 @@ import Data.Either.Combinators import Data.String (IsString) import Data.Text (Text) import qualified Data.Text as Text +import Formatting (build, formatToString) import qualified Cardano.Crypto.DSIGN.Class as Crypto import qualified Cardano.Crypto.Seed as Crypto @@ -272,8 +271,7 @@ instance SerialiseAsRawBytes (SigningKey ByronKeyLegacy) where ) decodeXPrv :: CBOR.Decoder s Wallet.XPrv - decodeXPrv = CBOR.decodeBytesCanonical >>= CBOR.toCborError . Wallet.xprv - + decodeXPrv = CBOR.decodeBytesCanonical >>= either (fail . formatToString build) pure . Wallet.xprv -- | Decoder for a Byron/Classic signing key. -- Lifted from cardano-sl legacy codebase. diff --git a/cardano-api/src/Cardano/Api/Tx.hs b/cardano-api/src/Cardano/Api/Tx.hs index 55373a57416..62479b587eb 100644 --- a/cardano-api/src/Cardano/Api/Tx.hs +++ b/cardano-api/src/Cardano/Api/Tx.hs @@ -58,6 +58,7 @@ import qualified Data.Map.Strict as Map import qualified Data.Set as Set import Data.Type.Equality (TestEquality (..), (:~:) (Refl)) import qualified Data.Vector as Vector +import Formatting (build, formatToString) -- -- Common types, consensus, network @@ -431,7 +432,7 @@ decodeShelleyBasedWitness era = case t of 0 -> fmap (fmap (ShelleyKeyWitness era)) fromCBOR 1 -> fmap (fmap (ShelleyBootstrapWitness era)) fromCBOR - _ -> CBOR.cborError $ CBOR.DecoderErrorUnknownTag + _ -> fail . formatToString build $ CBOR.DecoderErrorUnknownTag "Shelley Witness" (fromIntegral t) From 61904601a293c6feaa897483f41c4674d356bc28 Mon Sep 17 00:00:00 2001 From: John Ky Date: Sun, 29 Jan 2023 10:54:56 -0800 Subject: [PATCH 2/7] Remove NoImplicitPrelude from cardano-submit-api --- cardano-submit-api/app/Main.hs | 2 -- cardano-submit-api/cardano-submit-api.cabal | 4 ---- cardano-submit-api/src/Cardano/TxSubmit.hs | 5 ----- cardano-submit-api/src/Cardano/TxSubmit/CLI/Parsers.hs | 7 +------ cardano-submit-api/src/Cardano/TxSubmit/CLI/Types.hs | 2 -- cardano-submit-api/src/Cardano/TxSubmit/Config.hs | 9 --------- cardano-submit-api/src/Cardano/TxSubmit/ErrorRender.hs | 1 - cardano-submit-api/src/Cardano/TxSubmit/Metrics.hs | 6 ------ cardano-submit-api/src/Cardano/TxSubmit/Rest/Parsers.hs | 3 --- cardano-submit-api/src/Cardano/TxSubmit/Rest/Types.hs | 2 -- cardano-submit-api/src/Cardano/TxSubmit/Rest/Web.hs | 4 ---- .../src/Cardano/TxSubmit/Tracing/ToObjectOrphans.hs | 4 ---- cardano-submit-api/src/Cardano/TxSubmit/Types.hs | 7 ------- cardano-submit-api/src/Cardano/TxSubmit/Util.hs | 2 -- cardano-submit-api/test/test.hs | 3 --- 15 files changed, 1 insertion(+), 60 deletions(-) diff --git a/cardano-submit-api/app/Main.hs b/cardano-submit-api/app/Main.hs index 14da90564d2..dba33e8bc52 100644 --- a/cardano-submit-api/app/Main.hs +++ b/cardano-submit-api/app/Main.hs @@ -1,8 +1,6 @@ module Main where import Cardano.TxSubmit (opts, runTxSubmitWebapi) -import Control.Monad ((=<<)) -import System.IO (IO) import qualified Options.Applicative as Opt diff --git a/cardano-submit-api/cardano-submit-api.cabal b/cardano-submit-api/cardano-submit-api.cabal index 72fa832c00a..3c81f50cec8 100644 --- a/cardano-submit-api/cardano-submit-api.cabal +++ b/cardano-submit-api/cardano-submit-api.cabal @@ -19,14 +19,12 @@ extra-source-files: CHANGELOG.md common project-config default-language: Haskell2010 build-depends: base >= 4.14 && < 4.17 - default-extensions: NoImplicitPrelude ghc-options: -Wall -Wcompat -Wincomplete-record-updates -Wincomplete-uni-patterns -Wno-all-missed-specialisations - -Wno-implicit-prelude -Wno-missing-import-lists -Wno-safe -Wno-unsafe @@ -34,8 +32,6 @@ common project-config -fwarn-incomplete-patterns -fwarn-redundant-constraints - default-extensions: NoImplicitPrelude - library import: project-config build-depends: base >= 4.14 && < 4.17 diff --git a/cardano-submit-api/src/Cardano/TxSubmit.hs b/cardano-submit-api/src/Cardano/TxSubmit.hs index 039828ef93a..066c0bca8ad 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit.hs @@ -1,5 +1,4 @@ {-# LANGUAGE NamedFieldPuns #-} -{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} module Cardano.TxSubmit @@ -14,13 +13,9 @@ import Cardano.TxSubmit.Config (GenTxSubmitNodeConfig (..), ToggleLogg TxSubmitNodeConfig, readTxSubmitNodeConfig) import Cardano.TxSubmit.Metrics (registerMetricsServer) import Cardano.TxSubmit.Web (runTxSubmitServer) -import Control.Applicative (Applicative (..)) import Control.Monad (void) import Control.Monad.IO.Class (MonadIO (liftIO)) -import Data.Either (Either (..)) -import Data.Function (($)) import Data.Text (Text) -import System.IO (IO) import qualified Cardano.BM.Setup as Logging import qualified Cardano.BM.Trace as Logging diff --git a/cardano-submit-api/src/Cardano/TxSubmit/CLI/Parsers.hs b/cardano-submit-api/src/Cardano/TxSubmit/CLI/Parsers.hs index 9a5ffb0e322..b32db5920db 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/CLI/Parsers.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/CLI/Parsers.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} module Cardano.TxSubmit.CLI.Parsers @@ -14,11 +13,7 @@ import Cardano.Api (AnyConsensusModeParams (..), ConsensusModeParams ( EpochSlots (..), NetworkId (..), NetworkMagic (..), SocketPath (..)) import Cardano.TxSubmit.CLI.Types (ConfigFile (..), TxSubmitNodeParams (..)) import Cardano.TxSubmit.Rest.Parsers (pWebserverConfig) -import Control.Applicative (Alternative (..), Applicative (..), (<**>)) -import Data.Function ((.)) -import Data.Functor (Functor (fmap), (<$>)) -import Data.Int -import Data.Semigroup (Semigroup ((<>))) +import Control.Applicative (Alternative (..), (<**>)) import Data.Word (Word64) import Options.Applicative (Parser, ParserInfo) diff --git a/cardano-submit-api/src/Cardano/TxSubmit/CLI/Types.hs b/cardano-submit-api/src/Cardano/TxSubmit/CLI/Types.hs index e5e90ef40f1..cf1f58cec29 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/CLI/Types.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/CLI/Types.hs @@ -6,8 +6,6 @@ module Cardano.TxSubmit.CLI.Types import Cardano.Api (AnyConsensusModeParams, NetworkId (..), SocketPath) import Cardano.TxSubmit.Rest.Types (WebserverConfig) -import Data.Int -import System.IO (FilePath) -- | The product type of all command line arguments data TxSubmitNodeParams = TxSubmitNodeParams diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Config.hs b/cardano-submit-api/src/Cardano/TxSubmit/Config.hs index b52ed12e17b..ce356305e1c 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Config.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Config.hs @@ -1,5 +1,4 @@ {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -14,20 +13,12 @@ module Cardano.TxSubmit.Config import Cardano.Api -import Control.Applicative (Applicative (pure, (<*>))) import Control.Exception (IOException, catch) import Data.Aeson (FromJSON (..), Object, Value (..), (.:)) import Data.Aeson.Types (Parser) import Data.Bool (bool) import Data.ByteString (ByteString) -import Data.Either (Either (Left, Right)) -import Data.Eq (Eq) -import Data.Function (($)) -import Data.Functor (Functor (..), (<$>)) -import Data.Semigroup (Semigroup ((<>))) import Protolude.Panic (panic) -import System.IO (FilePath, IO) -import Text.Show (Show) import qualified Cardano.BM.Configuration as Logging import qualified Cardano.BM.Configuration.Model as Logging diff --git a/cardano-submit-api/src/Cardano/TxSubmit/ErrorRender.hs b/cardano-submit-api/src/Cardano/TxSubmit/ErrorRender.hs index d025d15801c..0fa109cf298 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/ErrorRender.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/ErrorRender.hs @@ -16,7 +16,6 @@ import Cardano.Api import Cardano.Chain.Byron.API (ApplyMempoolPayloadErr (..)) import Cardano.Chain.UTxO.UTxO (UTxOError (..)) import Cardano.Chain.UTxO.Validation (TxValidationError (..), UTxOValidationError (..)) -import Data.Monoid (Monoid (mconcat), (<>)) import Data.Text (Text) import Formatting (build, sformat, stext, (%)) import Ouroboros.Consensus.Cardano.Block (EraMismatch (..)) diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Metrics.hs b/cardano-submit-api/src/Cardano/TxSubmit/Metrics.hs index 6a5556a36af..6048b694623 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Metrics.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Metrics.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} module Cardano.TxSubmit.Metrics @@ -7,13 +6,8 @@ module Cardano.TxSubmit.Metrics , registerMetricsServer ) where -import Control.Applicative (Applicative (pure), (<$>), (<*>)) import Control.Concurrent.Async (Async, async) import Control.Monad.Reader (MonadIO (liftIO), MonadReader (ask), ReaderT (runReaderT)) -import Data.Function (($), (.)) -import Data.Int -import Data.Monoid (Monoid (mempty)) -import System.IO (IO) import System.Metrics.Prometheus.Concurrent.RegistryT (RegistryT (..), registerGauge, runRegistryT, unRegistryT) import System.Metrics.Prometheus.Http.Scrape (serveMetricsT) diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Rest/Parsers.hs b/cardano-submit-api/src/Cardano/TxSubmit/Rest/Parsers.hs index 94fc701638c..f5ca11ce322 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Rest/Parsers.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Rest/Parsers.hs @@ -7,9 +7,6 @@ module Cardano.TxSubmit.Rest.Parsers ) where import Cardano.TxSubmit.Rest.Types (WebserverConfig (..)) -import Control.Applicative (Applicative (pure), (<$>)) -import Data.Function (($)) -import Data.Semigroup ((<>)) import Data.String (fromString) import Network.Wai.Handler.Warp (HostPreference, Port) import Options.Applicative (Parser, auto, help, long, metavar, option, showDefault, diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Rest/Types.hs b/cardano-submit-api/src/Cardano/TxSubmit/Rest/Types.hs index 43004d3f5ac..0c25c5eefb1 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Rest/Types.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Rest/Types.hs @@ -7,8 +7,6 @@ module Cardano.TxSubmit.Rest.Types ) where import Data.Function ((&)) -import Data.Semigroup ((<>)) -import Text.Show (Show (..)) import qualified Network.Wai.Handler.Warp as Warp diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Rest/Web.hs b/cardano-submit-api/src/Cardano/TxSubmit/Rest/Web.hs index 4d89c8d2677..fadc3f2c161 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Rest/Web.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Rest/Web.hs @@ -6,15 +6,11 @@ module Cardano.TxSubmit.Rest.Web import Cardano.BM.Trace (Trace, logInfo) import Control.Exception (bracket) -import Data.Function (($)) -import Data.Semigroup ((<>)) import Data.Streaming.Network (bindPortTCP) import Data.Text (Text) import Network.Socket (close, getSocketName, withSocketsDo) import Network.Wai.Handler.Warp (Settings, getHost, getPort, runSettingsSocket) import Servant (Application) -import System.IO (IO) -import Text.Show (Show (..)) import qualified Data.Text as T diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Tracing/ToObjectOrphans.hs b/cardano-submit-api/src/Cardano/TxSubmit/Tracing/ToObjectOrphans.hs index e2a05f72444..7c234ddcc4d 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Tracing/ToObjectOrphans.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Tracing/ToObjectOrphans.hs @@ -10,13 +10,9 @@ import Cardano.BM.Data.Severity (Severity (Debug, Error, Notice, Warni import Cardano.BM.Data.Tracer (HasPrivacyAnnotation, HasSeverityAnnotation (..), HasTextFormatter, ToObject (toObject), Transformable (..), trStructured) import Data.Aeson ((.=)) -import Data.String (String) import Data.Text (Text) import Ouroboros.Network.NodeToClient (ErrorPolicyTrace (..), WithAddr (..)) -import System.IO (IO) -import Text.Show (Show (..)) -import Data.Monoid (mconcat) import qualified Network.Socket as Socket instance HasPrivacyAnnotation (WithAddr Socket.SockAddr ErrorPolicyTrace) diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Types.hs b/cardano-submit-api/src/Cardano/TxSubmit/Types.hs index f9f6f45549f..dabd3d32efe 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Types.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Types.hs @@ -19,12 +19,6 @@ import Cardano.Api (AnyCardanoEra, AnyConsensusMode (..), Error (..), import Cardano.Binary (DecoderError) import Data.Aeson (ToJSON (..), Value (..)) import Data.ByteString.Char8 (ByteString) -import Data.Either (Either (Right)) -import Data.Eq (Eq (..)) -import Data.Function (id, (.)) -import Data.Functor (Functor (fmap)) -import Data.Int (Int) -import Data.Monoid (Monoid (mconcat), (<>)) import Data.Text (Text) import Formatting (build, sformat) import GHC.Generics (Generic) @@ -33,7 +27,6 @@ import Ouroboros.Consensus.Cardano.Block (EraMismatch (..)) import Servant (Accept (..), JSON, MimeRender (..), MimeUnrender (..), PostAccepted, ReqBody, (:>)) import Servant.API.Generic (ToServantApi, (:-)) -import Text.Show (Show (..)) import qualified Data.ByteString.Lazy.Char8 as LBS import qualified Data.List as L diff --git a/cardano-submit-api/src/Cardano/TxSubmit/Util.hs b/cardano-submit-api/src/Cardano/TxSubmit/Util.hs index 850321c045c..4da9d8d8a03 100644 --- a/cardano-submit-api/src/Cardano/TxSubmit/Util.hs +++ b/cardano-submit-api/src/Cardano/TxSubmit/Util.hs @@ -1,5 +1,3 @@ -{-# LANGUAGE NoImplicitPrelude #-} - module Cardano.TxSubmit.Util ( logException ) where diff --git a/cardano-submit-api/test/test.hs b/cardano-submit-api/test/test.hs index 723a769201f..c3a0883379a 100644 --- a/cardano-submit-api/test/test.hs +++ b/cardano-submit-api/test/test.hs @@ -1,6 +1,3 @@ - -import System.IO (IO) - import qualified System.IO as IO main :: IO () From a604d52cccd0a11154e54ef2dda955dae6fd94f4 Mon Sep 17 00:00:00 2001 From: John Ky Date: Sun, 29 Jan 2023 22:27:43 -0800 Subject: [PATCH 3/7] Remove NoImplicitPrelude from cardano-cli --- cardano-cli/app/cardano-cli.hs | 2 -- cardano-cli/cardano-cli.cabal | 6 +++--- .../src/Cardano/CLI/Byron/Delegation.hs | 9 ++++++++- cardano-cli/src/Cardano/CLI/Byron/Legacy.hs | 13 +++++++++---- cardano-cli/src/Cardano/CLI/Byron/Query.hs | 7 +++++-- cardano-cli/src/Cardano/CLI/Byron/Run.hs | 17 ++++++++++------- .../src/Cardano/CLI/Byron/UpdateProposal.hs | 6 +++++- cardano-cli/src/Cardano/CLI/Byron/Vote.hs | 7 ++++--- cardano-cli/src/Cardano/CLI/IO/Lazy.hs | 8 ++------ cardano-cli/src/Cardano/CLI/Run.hs | 16 ++++++++-------- cardano-cli/src/Cardano/CLI/Run/Friendly.hs | 12 +++++++++--- cardano-cli/src/Cardano/CLI/Shelley/Orphans.hs | 3 +-- cardano-cli/src/Cardano/CLI/Shelley/Run.hs | 4 ++-- .../src/Cardano/CLI/Shelley/Run/Address.hs | 6 +++--- .../Cardano/CLI/Shelley/Run/Address/Info.hs | 7 +++++-- .../src/Cardano/CLI/Shelley/Run/Governance.hs | 12 ++++++------ cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs | 18 ++++++++++++------ .../src/Cardano/CLI/Shelley/Run/Pool.hs | 11 +++++------ .../Cardano/CLI/Shelley/Run/StakeAddress.hs | 8 ++++---- cardano-cli/src/Cardano/CLI/Types.hs | 7 +++---- cardano-cli/test/Test/Cli/FilePermissions.hs | 7 ++++--- cardano-cli/test/Test/Cli/ITN.hs | 14 +++++++++----- cardano-cli/test/Test/Cli/MultiAssetParsing.hs | 8 +++----- .../test/Test/Cli/Pioneers/Exercise1.hs | 2 +- .../test/Test/Cli/Pioneers/Exercise2.hs | 2 +- .../test/Test/Cli/Pioneers/Exercise3.hs | 2 +- .../test/Test/Cli/Pioneers/Exercise4.hs | 2 +- .../test/Test/Cli/Pioneers/Exercise5.hs | 2 +- .../test/Test/Cli/Pioneers/Exercise6.hs | 2 +- cardano-cli/test/Test/Cli/Shelley/Run/Query.hs | 8 ++------ cardano-cli/test/Test/Config/Mainnet.hs | 7 ------- .../test/Test/Golden/Byron/SigningKeys.hs | 5 +++-- cardano-cli/test/Test/Golden/Byron/Tx.hs | 10 ++++++---- .../test/Test/Golden/Byron/UpdateProposal.hs | 4 +++- cardano-cli/test/Test/Golden/Byron/Vote.hs | 8 +++++--- cardano-cli/test/Test/Golden/Shelley.hs | 2 -- .../test/Test/Golden/Shelley/Address/Build.hs | 2 +- .../test/Test/Golden/Shelley/Address/KeyGen.hs | 2 +- .../Test/Golden/Shelley/Genesis/InitialTxIn.hs | 1 - .../Golden/Shelley/Genesis/KeyGenDelegate.hs | 2 +- .../Golden/Shelley/Genesis/KeyGenGenesis.hs | 2 +- .../Test/Golden/Shelley/Genesis/KeyGenUtxo.hs | 2 +- .../Test/Golden/Shelley/Genesis/KeyHash.hs | 1 - .../Shelley/Key/ConvertCardanoAddressKey.hs | 3 ++- .../Shelley/Metadata/StakePoolMetadata.hs | 7 +++++-- .../Test/Golden/Shelley/MultiSig/Address.hs | 1 - .../Test/Golden/Shelley/Node/IssueOpCert.hs | 3 ++- .../test/Test/Golden/Shelley/Node/KeyGen.hs | 2 +- .../test/Test/Golden/Shelley/Node/KeyGenKes.hs | 2 +- .../test/Test/Golden/Shelley/Node/KeyGenVrf.hs | 2 +- .../Test/Golden/Shelley/StakeAddress/Build.hs | 1 - .../StakeAddress/DeregistrationCertificate.hs | 2 +- .../Test/Golden/Shelley/StakeAddress/KeyGen.hs | 2 +- .../StakeAddress/RegistrationCertificate.hs | 2 +- .../StakePool/RegistrationCertificate.hs | 2 +- .../GenesisKeyDelegationCertificate.hs | 2 +- .../Certificates/MIRCertificate.hs | 2 +- .../Certificates/OperationalCertificate.hs | 2 +- .../Certificates/StakeAddressCertificates.hs | 2 +- .../Certificates/StakePoolCertificates.hs | 2 +- .../TextEnvelope/Keys/ExtendedPaymentKeys.hs | 2 +- .../TextEnvelope/Keys/GenesisDelegateKeys.hs | 2 +- .../Shelley/TextEnvelope/Keys/GenesisKeys.hs | 2 +- .../TextEnvelope/Keys/GenesisUTxOKeys.hs | 2 +- .../Shelley/TextEnvelope/Keys/KESKeys.hs | 2 +- .../Shelley/TextEnvelope/Keys/PaymentKeys.hs | 2 +- .../Shelley/TextEnvelope/Keys/StakeKeys.hs | 2 +- .../Shelley/TextEnvelope/Keys/VRFKeys.hs | 2 +- .../Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs | 3 +-- .../Golden/Shelley/TextEnvelope/Tx/TxBody.hs | 3 +-- .../Test/Golden/Shelley/TextView/DecodeCbor.hs | 1 - .../Shelley/Transaction/CalculateMinFee.hs | 1 - cardano-cli/test/cardano-cli-golden.hs | 2 -- cardano-cli/test/cardano-cli-test.hs | 1 - 74 files changed, 181 insertions(+), 161 deletions(-) diff --git a/cardano-cli/app/cardano-cli.hs b/cardano-cli/app/cardano-cli.hs index f613c310ccc..dc6454abac0 100644 --- a/cardano-cli/app/cardano-cli.hs +++ b/cardano-cli/app/cardano-cli.hs @@ -5,8 +5,6 @@ #define UNIX #endif -import Cardano.Prelude - import Control.Monad.Trans.Except.Exit (orDie) import qualified Options.Applicative as Opt diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 26a763a9aa0..7b5b1e94bbb 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -22,8 +22,7 @@ Flag unexpected_thunks common project-config default-language: Haskell2010 - default-extensions: NoImplicitPrelude - OverloadedStrings + default-extensions: OverloadedStrings build-depends: base >= 4.14 && < 4.17 ghc-options: -Wall @@ -157,7 +156,6 @@ executable cardano-cli build-depends: cardano-cli , cardano-crypto-class ^>= 2.0 - , cardano-prelude , optparse-applicative-fork , transformers-except @@ -171,6 +169,7 @@ test-suite cardano-cli-test build-depends: aeson , bech32 >= 1.1.0 , base16-bytestring + , bytestring , cardano-api , cardano-api:gen , cardano-cli @@ -231,6 +230,7 @@ test-suite cardano-cli-golden , hedgehog-extras , text , time + , transformers , unordered-containers build-tool-depends: cardano-cli:cardano-cli diff --git a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs index 7d812c096d6..a2c14d83910 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Delegation.hs @@ -12,8 +12,9 @@ module Cardano.CLI.Byron.Delegation ) where -import Cardano.Prelude hiding (show, trace) +import Prelude hiding ((.)) +import Control.Category import Control.Monad.Trans.Except.Extra (left) import qualified Data.ByteString.Lazy as LB import Formatting (Format, sformat) @@ -28,6 +29,12 @@ import qualified Cardano.Crypto as Crypto import Cardano.CLI.Byron.Key (ByronKeyFailure, renderByronKeyFailure) import Cardano.CLI.Types (CertificateFile (..)) +import Cardano.Prelude (canonicalDecodePretty, canonicalEncodePretty) +import Control.Monad (unless) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) +import Data.ByteString (ByteString) +import Data.Text (Text) data ByronDelegationError = CertificateValidationErrors !FilePath ![Text] diff --git a/cardano-cli/src/Cardano/CLI/Byron/Legacy.hs b/cardano-cli/src/Cardano/CLI/Byron/Legacy.hs index 9102fec0973..bd44c0ada63 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Legacy.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Legacy.hs @@ -1,6 +1,5 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE GADTs #-} -{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -10,13 +9,19 @@ module Cardano.CLI.Byron.Legacy ( , decodeLegacyDelegateKey ) where -import Cardano.Prelude +import Cardano.Prelude (cborError) + +import Control.Monad (when) +import Formatting (build, formatToString) import qualified Codec.CBOR.Decoding as D import qualified Codec.CBOR.Encoding as E +import Cardano.Api (textShow) import Cardano.Crypto.Signing (SigningKey (..)) import qualified Cardano.Crypto.Wallet as Wallet +import Data.Text (Text) + -- | LegacyDelegateKey is a subset of the UserSecret's from the legacy codebase: -- 1. the VSS keypair must be present @@ -31,7 +36,7 @@ encodeXPrv a = E.encodeBytes $ Wallet.unXPrv a decodeXPrv :: D.Decoder s Wallet.XPrv decodeXPrv = - toCborError . Wallet.xprv =<< D.decodeBytesCanonical + either (fail . formatToString build) pure . Wallet.xprv =<< D.decodeBytesCanonical -- Stolen from: cardano-sl/binary/src/Pos/Binary/Class/Core.hs -- | Enforces that the input size is the same as the decoded one, failing in @@ -44,7 +49,7 @@ enforceSize lbl requestedSize = D.decodeListLenCanonical >>= matchSize requested matchSize :: Int -> Text -> Int -> D.Decoder s () matchSize requestedSize lbl actualSize = when (actualSize /= requestedSize) $ - cborError (lbl <> " failed the size check. Expected " <> show requestedSize <> ", found " <> show actualSize) + cborError (lbl <> " failed the size check. Expected " <> textShow requestedSize <> ", found " <> textShow actualSize) -- | Encoder for a Byron/Classic signing key. -- Lifted from cardano-sl legacy codebase. diff --git a/cardano-cli/src/Cardano/CLI/Byron/Query.hs b/cardano-cli/src/Cardano/CLI/Byron/Query.hs index e0f378a9a2b..dabf2a95848 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Query.hs @@ -10,12 +10,15 @@ module Cardano.CLI.Byron.Query ) where import Cardano.Api -import Cardano.Prelude +import Control.Monad.IO.Unlift (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, newExceptT) import Data.Aeson.Encode.Pretty (encodePretty) import qualified Data.ByteString.Lazy as LB +import Data.Text (Text) import qualified Data.Text.Encoding as Text +import qualified Data.Text.IO as Text {- HLINT ignore "Reduce duplication" -} @@ -44,6 +47,6 @@ runGetLocalNodeTip networkId = do } tip <- liftIO $ getLocalChainTip connctInfo - liftIO . putTextLn . Text.decodeUtf8 . LB.toStrict $ encodePretty tip + liftIO . Text.putStrLn . Text.decodeUtf8 . LB.toStrict $ encodePretty tip diff --git a/cardano-cli/src/Cardano/CLI/Byron/Run.hs b/cardano-cli/src/Cardano/CLI/Byron/Run.hs index a96846e02a3..f877b2487af 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Run.hs @@ -6,11 +6,14 @@ module Cardano.CLI.Byron.Run , runByronClientCommand ) where -import Cardano.Prelude - +import Control.Monad.IO.Class (MonadIO (liftIO)) +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, hoistEither, left) +import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString.Char8 as BS +import Data.Text (Text) import qualified Data.Text as Text +import qualified Data.Text.IO as Text import qualified Data.Text.Lazy.Builder as Builder import qualified Data.Text.Lazy.IO as TL import qualified Formatting as F @@ -20,7 +23,7 @@ import qualified Cardano.Chain.Genesis as Genesis import qualified Cardano.Crypto.Hashing as Crypto import qualified Cardano.Crypto.Signing as Crypto -import Cardano.Api hiding (UpdateProposal, GenesisParameters) +import Cardano.Api hiding (GenesisParameters, UpdateProposal) import Cardano.Api.Byron (SomeByronSigningKey (..), Tx (..)) import Ouroboros.Consensus.Byron.Ledger (ByronBlock) @@ -113,7 +116,7 @@ runValidateCBOR :: CBORObject -> FilePath -> ExceptT ByronClientCmdError IO () runValidateCBOR cborObject fp = do bs <- firstExceptT ByronCmdHelpersError $ readCBOR fp res <- hoistEither . first ByronCmdHelpersError $ validateCBOR cborObject bs - liftIO $ putTextLn res + liftIO $ Text.putStrLn res runPrettyPrintCBOR :: FilePath -> ExceptT ByronClientCmdError IO () runPrettyPrintCBOR fp = do @@ -123,7 +126,7 @@ runPrettyPrintCBOR fp = do runPrettySigningKeyPublic :: ByronKeyFormat -> SigningKeyFile -> ExceptT ByronClientCmdError IO () runPrettySigningKeyPublic bKeyFormat skF = do sK <- firstExceptT ByronCmdKeyFailure $ readByronSigningKey bKeyFormat skF - liftIO . putTextLn . prettyPublicKey $ byronWitnessToVerKey sK + liftIO . Text.putStrLn . prettyPublicKey $ byronWitnessToVerKey sK runMigrateDelegateKeyFrom :: SigningKeyFile @@ -143,7 +146,7 @@ runPrintGenesisHash :: GenesisFile -> ExceptT ByronClientCmdError IO () runPrintGenesisHash genFp = do genesis <- firstExceptT ByronCmdGenesisError $ readGenesis genFp dummyNetwork - liftIO . putTextLn $ formatter genesis + liftIO . Text.putStrLn $ formatter genesis where -- For this purpose of getting the hash, it does not matter what network -- value we use here. @@ -163,7 +166,7 @@ runPrintSigningKeyAddress runPrintSigningKeyAddress bKeyFormat networkid skF = do sK <- firstExceptT ByronCmdKeyFailure $ readByronSigningKey bKeyFormat skF let sKeyAddr = prettyAddress . makeByronAddress networkid $ byronWitnessToVerKey sK - liftIO $ putTextLn sKeyAddr + liftIO $ Text.putStrLn sKeyAddr runKeygen :: NewSigningKeyFile -> ExceptT ByronClientCmdError IO () runKeygen (NewSigningKeyFile skF) = do diff --git a/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs b/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs index ac29597bd95..aea82c001e2 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs @@ -8,11 +8,15 @@ module Cardano.CLI.Byron.UpdateProposal , submitByronUpdateProposal ) where -import Cardano.Prelude +import Cardano.Prelude (ConvertText (..)) +import Control.Exception (Exception (..)) +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT, hoistEither) import Control.Tracer (stdoutTracer, traceWith) +import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString as BS +import Data.Text (Text) import Cardano.Chain.Update (InstallerHash (..), ProtocolVersion (..), SoftwareVersion (..), SystemTag (..)) diff --git a/cardano-cli/src/Cardano/CLI/Byron/Vote.hs b/cardano-cli/src/Cardano/CLI/Byron/Vote.hs index 0899762dc4d..312371d0a45 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Vote.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Vote.hs @@ -8,14 +8,13 @@ module Cardano.CLI.Byron.Vote , submitByronVote ) where -import Cardano.Prelude - +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, hoistEither) import Control.Tracer (stdoutTracer, traceWith) import qualified Data.ByteString as BS +import Data.Text (Text) import qualified Data.Text as Text - import qualified Cardano.Binary as Binary import Cardano.CLI.Byron.UpdateProposal (ByronUpdateProposalError, readByronUpdateProposal) @@ -30,6 +29,8 @@ import Cardano.CLI.Byron.Tx (ByronTxError, nodeSubmitTx) import Cardano.CLI.Helpers (HelpersError, ensureNewFileLBS) import Cardano.CLI.Shelley.Commands (ByronKeyFormat (..)) import Cardano.CLI.Types +import Control.Monad.IO.Class (MonadIO (..)) +import Data.Bifunctor (first) data ByronVoteError diff --git a/cardano-cli/src/Cardano/CLI/IO/Lazy.hs b/cardano-cli/src/Cardano/CLI/IO/Lazy.hs index d4fe2d5b6ca..16f50c63307 100644 --- a/cardano-cli/src/Cardano/CLI/IO/Lazy.hs +++ b/cardano-cli/src/Cardano/CLI/IO/Lazy.hs @@ -10,12 +10,8 @@ module Cardano.CLI.IO.Lazy , forStateM ) where -import Control.Applicative (Applicative((<*>), pure), (<$>)) -import Control.Monad (Monad(..)) -import Control.Monad.IO.Unlift (MonadIO(liftIO), MonadUnliftIO, askUnliftIO, UnliftIO(unliftIO)) -import Data.Function (($), (.), flip) -import Data.Int (Int) -import System.IO (IO) +import Control.Monad.IO.Unlift (MonadIO (liftIO), MonadUnliftIO, UnliftIO (unliftIO), + askUnliftIO) import qualified Data.List as L import qualified System.IO.Unsafe as IO diff --git a/cardano-cli/src/Cardano/CLI/Run.hs b/cardano-cli/src/Cardano/CLI/Run.hs index c8be9b9d62b..e50441b46da 100644 --- a/cardano-cli/src/Cardano/CLI/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Run.hs @@ -8,12 +8,15 @@ module Cardano.CLI.Run , runClientCommand ) where -import Cardano.Prelude - +import Control.Monad (forM_) +import Control.Monad.IO.Unlift (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT) -import Data.String +import qualified Data.List as L +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.IO as Text +import qualified System.IO as IO import Cardano.CLI.Byron.Commands (ByronCommand) import Cardano.CLI.Byron.Run (ByronClientCmdError, renderByronClientCmdError, @@ -32,9 +35,6 @@ import Options.Applicative.Types (OptReader (..), Option (..), Parser import Paths_cardano_cli (version) import System.Info (arch, compilerName, compilerVersion, os) -import qualified Data.List as L -import qualified System.IO as IO - -- | Sub-commands of 'cardano-cli'. data ClientCommand = @@ -75,7 +75,7 @@ renderClientCommandError (ShelleyClientError cmd err) = -- the provided 'ExceptT'. ioExceptTWithWarning :: MonadIO m => Text -> ExceptT e m () -> ExceptT e m () ioExceptTWithWarning warningMsg e = - liftIO (Text.hPutStrLn stderr warningMsg) >> e + liftIO (Text.hPutStrLn IO.stderr warningMsg) >> e -- | Used in the event that Shelley-related commands are run using the -- now-deprecated \"shelley\" subcommand. @@ -93,7 +93,7 @@ runShelleyClientCommandWithDeprecationWarning = runDisplayVersion :: ExceptT ClientCommandErrors IO () runDisplayVersion = do - liftIO . putTextLn $ mconcat + liftIO . Text.putStrLn $ mconcat [ "cardano-cli ", renderVersion version , " - ", Text.pack os, "-", Text.pack arch , " - ", Text.pack compilerName, "-", renderVersion compilerVersion diff --git a/cardano-cli/src/Cardano/CLI/Run/Friendly.hs b/cardano-cli/src/Cardano/CLI/Run/Friendly.hs index 4f16f93a76f..d2b36e88b08 100644 --- a/cardano-cli/src/Cardano/CLI/Run/Friendly.hs +++ b/cardano-cli/src/Cardano/CLI/Run/Friendly.hs @@ -10,18 +10,24 @@ -- | User-friendly pretty-printing for textual user interfaces (TUI) module Cardano.CLI.Run.Friendly (friendlyTxBS, friendlyTxBodyBS) where -import Cardano.Prelude - import Data.Aeson (Value (..), object, toJSON, (.=)) import qualified Data.Aeson as Aeson import qualified Data.Aeson.Key as Aeson import qualified Data.Aeson.Types as Aeson +import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as BSC +import Data.Char (isAscii) +import Data.Function ((&)) +import Data.Functor ((<&>)) import qualified Data.Map.Strict as Map +import Data.Maybe (catMaybes, isJust) +import Data.Ratio (numerator) import qualified Data.Text as Text import Data.Yaml (array) import Data.Yaml.Pretty (setConfCompare) import qualified Data.Yaml.Pretty as Yaml +import GHC.Real (denominator) +import GHC.Unicode (isAlphaNum) import Cardano.Api as Api import Cardano.Api.Byron (KeyWitness (ByronKeyWitness)) @@ -200,7 +206,7 @@ friendlyTxOut (TxOut addr amount mdatum script) = friendlyStakeReference :: StakeAddressReference -> Aeson.Value friendlyStakeReference = \case NoStakeAddress -> Null - StakeAddressByPointer ptr -> String (show ptr) + StakeAddressByPointer ptr -> String (textShow ptr) StakeAddressByValue cred -> object [friendlyStakeCredential cred] friendlyUpdateProposal :: TxUpdateProposal era -> Aeson.Value diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Orphans.hs b/cardano-cli/src/Cardano/CLI/Shelley/Orphans.hs index 85991da74a2..bc6463238b5 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Orphans.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Orphans.hs @@ -23,14 +23,13 @@ import qualified Cardano.Ledger.PoolDistr as Ledger import qualified Cardano.Ledger.Shelley.EpochBoundary as Ledger import qualified Cardano.Ledger.Shelley.PoolRank as Ledger import Cardano.Ledger.TxIn (TxId (..)) -import Cardano.Prelude (Bool(True), Category((.))) import qualified Cardano.Protocol.TPraos.API as Ledger import Cardano.Protocol.TPraos.BHeader (HashHeader (..)) import qualified Cardano.Protocol.TPraos.Rules.Prtcl as Ledger import qualified Cardano.Protocol.TPraos.Rules.Tickn as Ledger import qualified Cardano.Slotting.Slot as Cardano import qualified Control.SetAlgebra as SetAlgebra (BiMap, forwards) -import Data.Aeson (FromJSON(..), KeyValue((.=)), ToJSON(..), ToJSONKey) +import Data.Aeson (FromJSON (..), KeyValue ((.=)), ToJSON (..), ToJSONKey) import qualified Data.Aeson as Aeson import qualified Data.ByteString.Base16 as Base16 import qualified Data.ByteString.Short as SBS diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run.hs index a095d8dd6d8..1af3a805893 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run.hs @@ -4,8 +4,6 @@ module Cardano.CLI.Shelley.Run , runShelleyClientCommand ) where -import Cardano.Prelude - import Cardano.Api import Control.Monad.Trans.Except.Extra (firstExceptT) @@ -24,6 +22,8 @@ import Cardano.CLI.Shelley.Run.Transaction -- Block, System, DevOps import Cardano.CLI.Shelley.Run.Genesis import Cardano.CLI.Shelley.Run.TextView +import Cardano.Prelude (ExceptT) +import Data.Text (Text) data ShelleyClientCmdError = ShelleyCmdAddressError !ShelleyAddressCmdError diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs index ff351f69940..6e2b891cc85 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs @@ -11,9 +11,6 @@ module Cardano.CLI.Shelley.Run.Address , makeStakeAddressRef ) where -import Cardano.Prelude hiding (putStrLn) - - import Control.Monad.Trans.Except.Extra (firstExceptT, left, newExceptT) import qualified Data.ByteString.Char8 as BS import qualified Data.Text as Text @@ -30,6 +27,9 @@ import Cardano.CLI.Shelley.Parsers (AddressCmd (..), AddressKeyType (. import Cardano.CLI.Shelley.Run.Address.Info (ShelleyAddressInfoError, runAddressInfo) import Cardano.CLI.Shelley.Run.Read import Cardano.CLI.Types +import Cardano.Prelude (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) +import Data.Text (Text) data ShelleyAddressCmdError = ShelleyAddressCmdAddressInfoError !ShelleyAddressInfoError diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Address/Info.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Address/Info.hs index 9c06b2a2eb0..6d1f16ed934 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Address/Info.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Address/Info.hs @@ -6,12 +6,15 @@ module Cardano.CLI.Shelley.Run.Address.Info import Cardano.Api import Cardano.CLI.Shelley.Parsers (OutputFile (..)) -import Cardano.Prelude + +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (left) import Data.Aeson (ToJSON (..), object, (.=)) import Data.Aeson.Encode.Pretty (encodePretty) - import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Text (Text) +import Options.Applicative (Alternative (..)) newtype ShelleyAddressInfoError = ShelleyAddressInvalid Text deriving Show diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Governance.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Governance.hs index 975c4f64fb2..a5db5cd67fa 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Governance.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Governance.hs @@ -4,14 +4,14 @@ module Cardano.CLI.Shelley.Run.Governance , runGovernanceCmd ) where -import Cardano.Prelude - -import Data.Aeson +import Control.Monad (unless, when) +import Control.Monad.Trans.Except (ExceptT) +import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT, left, newExceptT) +import Data.Aeson (eitherDecode) import qualified Data.ByteString.Lazy as LB +import Data.Text (Text) import qualified Data.Text as Text -import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT, left, newExceptT) - import Cardano.Api import Cardano.Api.Shelley @@ -170,7 +170,7 @@ runGovernanceUpdateProposal (OutputFile upFile) eNo genVerKeyFiles upPprams mCos (AsVerificationKey AsGenesisKey) vkeyFile | VerificationKeyFile vkeyFile <- genVerKeyFiles ] - let genKeyHashes = map verificationKeyHash genVKeys + let genKeyHashes = fmap verificationKeyHash genVKeys upProp = makeShelleyUpdateProposal finalUpPprams genKeyHashes eNo firstExceptT ShelleyGovernanceCmdTextEnvWriteError . newExceptT $ writeFileTextEnvelope upFile Nothing upProp diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs index 7aaa1ea9570..10a235e2963 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs @@ -12,8 +12,6 @@ module Cardano.CLI.Shelley.Run.Key , decodeBech32 ) where -import Cardano.Prelude - import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BSC import qualified Data.Text as Text @@ -41,6 +39,14 @@ import Cardano.CLI.Shelley.Key (VerificationKeyTextOrFile (..), VerificationKeyTextOrFileError, readVerificationKeyTextOrFileAnyOf, renderVerificationKeyTextOrFileError) import Cardano.CLI.Types (SigningKeyFile (..), VerificationKeyFile (..)) +import Cardano.Prelude (MonadIO (..)) +import Control.Exception (Exception (..), IOException) +import Control.Monad.Trans.Except (ExceptT) +import Data.Bifunctor (Bifunctor (..)) +import Data.ByteString (ByteString) +import Data.Text (Text) +import qualified Data.Text.Encoding as Text +import System.Exit (exitFailure) data ShelleyKeyCmdError @@ -349,7 +355,7 @@ convertByronSigningKey mPwd byronFormat convert case mPwd of -- Change password to empty string Just pwd -> return . Crypto.SigningKey - $ Crypto.xPrvChangePass (encodeUtf8 pwd) (encodeUtf8 "") xprv + $ Crypto.xPrvChangePass (Text.encodeUtf8 pwd) (Text.encodeUtf8 "") xprv Nothing -> return sk ByronApi.AByronSigningKey (ByronSigningKey sk) -> return sk @@ -388,7 +394,7 @@ runConvertByronGenesisVerificationKey runConvertByronGenesisVerificationKey (VerificationKeyBase64 b64ByronVKey) (OutputFile vkeyPathNew) = do - vk <- firstExceptT (ShelleyKeyCmdByronKeyParseError . show) + vk <- firstExceptT (ShelleyKeyCmdByronKeyParseError . textShow) . hoistEither . Byron.Crypto.parseFullVerificationKey . Text.pack @@ -515,7 +521,7 @@ readFileITNKey fp = do eStr <- Exception.try $ readFile fp case eStr of Left e -> return . Left $ ItnReadBech32FileError fp e - Right str -> return . Right . Text.concat $ Text.words str + Right str -> return . Right . Text.concat $ Text.words $ Text.pack str -------------------------------------------------------------------------------- -- `cardano-address` extended signing key conversions @@ -602,7 +608,7 @@ readBech32Bip32SigningKeyFile (SigningKeyFile fp) = do case eStr of Left e -> pure . Left $ FileIOError fp e Right str -> - case decodeBech32 (Text.concat $ Text.words str) of + case decodeBech32 (Text.concat $ Text.words $ Text.pack str) of Left err -> pure $ Left $ FileError fp (CardanoAddressSigningKeyBech32DecodeError err) diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Pool.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Pool.hs index d3874343813..04793003a25 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Pool.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Pool.hs @@ -4,15 +4,11 @@ module Cardano.CLI.Shelley.Run.Pool , runPoolCmd ) where -import Cardano.Prelude - -import qualified Data.Text as Text -import qualified Data.Text.IO as Text - import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT, hoistEither, newExceptT) - import qualified Data.ByteString.Char8 as BS +import qualified Data.Text as Text +import qualified Data.Text.IO as Text import Cardano.Api import Cardano.Api.Shelley @@ -21,6 +17,9 @@ import Cardano.CLI.Shelley.Key (VerificationKeyOrFile, readVerificatio import Cardano.CLI.Types (OutputFormat (..)) import qualified Cardano.Ledger.Slot as Shelley +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) +import Data.Text (Text) data ShelleyPoolCmdError = ShelleyPoolCmdReadFileError !(FileError TextEnvelopeError) diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/StakeAddress.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/StakeAddress.hs index cba00e4d5d2..3972f196913 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/StakeAddress.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/StakeAddress.hs @@ -5,14 +5,14 @@ module Cardano.CLI.Shelley.Run.StakeAddress , runStakeAddressKeyGenToFile ) where -import Cardano.Prelude - +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) +import Control.Monad.Trans.Except.Extra (firstExceptT, newExceptT) import qualified Data.ByteString.Char8 as BS +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.IO as Text -import Control.Monad.Trans.Except.Extra (firstExceptT, newExceptT) - import Cardano.Api import Cardano.Api.Shelley diff --git a/cardano-cli/src/Cardano/CLI/Types.hs b/cardano-cli/src/Cardano/CLI/Types.hs index 47765d8685c..0ad3f7830c3 100644 --- a/cardano-cli/src/Cardano/CLI/Types.hs +++ b/cardano-cli/src/Cardano/CLI/Types.hs @@ -41,10 +41,9 @@ module Cardano.CLI.Types , AllOrOnly(..) ) where -import Cardano.Prelude hiding (Word64) - import Data.Aeson (FromJSON (..), ToJSON (..), object, pairs, (.=)) import qualified Data.Aeson as Aeson +import Data.String (IsString) import qualified Data.Text as Text import Data.Word (Word64) @@ -173,8 +172,8 @@ data OpCertIntervalInformation instance FromJSON GenesisFile where parseJSON (Aeson.String genFp) = pure . GenesisFile $ Text.unpack genFp - parseJSON invalid = panic $ "Parsing of GenesisFile failed due to type mismatch. " - <> "Encountered: " <> Text.pack (show invalid) + parseJSON invalid = error $ "Parsing of GenesisFile failed due to type mismatch. " + <> "Encountered: " <> show invalid -- | The desired output format. data OutputFormat diff --git a/cardano-cli/test/Test/Cli/FilePermissions.hs b/cardano-cli/test/Test/Cli/FilePermissions.hs index 0c0c0901cce..b5922fc46b4 100644 --- a/cardano-cli/test/Test/Cli/FilePermissions.hs +++ b/cardano-cli/test/Test/Cli/FilePermissions.hs @@ -5,15 +5,16 @@ module Test.Cli.FilePermissions ( tests ) where -import Cardano.Prelude - - import Cardano.Node.Run (checkVRFFilePermissions) + import Hedgehog (Property, discover, success) import qualified Hedgehog import qualified Hedgehog.Extras.Test.Base as H import Hedgehog.Internal.Property (failWith) +import Control.Monad (void) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (runExceptT) import Test.OptParse (execCardanoCLI) -- | This property ensures that the VRF signing key file is created only with owner permissions diff --git a/cardano-cli/test/Test/Cli/ITN.hs b/cardano-cli/test/Test/Cli/ITN.hs index d140bc443c2..7798bd144c8 100644 --- a/cardano-cli/test/Test/Cli/ITN.hs +++ b/cardano-cli/test/Test/Cli/ITN.hs @@ -5,15 +5,19 @@ module Test.Cli.ITN ) where import Cardano.CLI.Shelley.Run.Key (decodeBech32) -import Cardano.Prelude -import Hedgehog (Property, (===)) -import Test.OptParse import qualified Codec.Binary.Bech32 as Bech32 +import Control.Monad (void) +import Control.Monad.IO.Class (MonadIO (..)) +import Data.ByteString (ByteString) import qualified Data.ByteString.Base16 as Base16 +import Data.Text (Text) +import qualified Data.Text.IO as Text +import Hedgehog (Property, (===)) import qualified Hedgehog as H import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H +import Test.OptParse {- HLINT ignore "Reduce duplication" -} @@ -38,8 +42,8 @@ prop_convertITNKeys = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir -> do outputHaskellSignKeyFp <- noteTempFile tempDir "haskell-signing-key.key" -- Write ITN keys to disk - liftIO $ writeFile itnVerKeyFp itnVerKey - liftIO $ writeFile itnSignKeyFp itnSignKey + liftIO $ Text.writeFile itnVerKeyFp itnVerKey + liftIO $ Text.writeFile itnSignKeyFp itnSignKey H.assertFilesExist [itnVerKeyFp, itnSignKeyFp] -- Generate haskell stake verification key diff --git a/cardano-cli/test/Test/Cli/MultiAssetParsing.hs b/cardano-cli/test/Test/Cli/MultiAssetParsing.hs index 4bf4fcc96a9..d3d842c9c32 100644 --- a/cardano-cli/test/Test/Cli/MultiAssetParsing.hs +++ b/cardano-cli/test/Test/Cli/MultiAssetParsing.hs @@ -3,13 +3,11 @@ module Test.Cli.MultiAssetParsing where -import Cardano.Prelude hiding (filter) - import qualified Data.Text as Text import qualified Text.Parsec as Parsec (parse) import Hedgehog (Property, checkSequential, discover, forAll, property, tripping) -import Hedgehog.Gen (filter) +import qualified Hedgehog.Gen as Gen import Cardano.Api (parseValue, renderValue, renderValuePretty, valueToList) @@ -18,7 +16,7 @@ import Test.Gen.Cardano.Api.Typed (genValueDefault) prop_roundtrip_Value_parse_render :: Property prop_roundtrip_Value_parse_render = property $ do - value <- forAll $ filter (not . null . valueToList) genValueDefault + value <- forAll $ Gen.filter (not . null . valueToList) genValueDefault tripping value renderValue @@ -27,7 +25,7 @@ prop_roundtrip_Value_parse_render = prop_roundtrip_Value_parse_renderPretty :: Property prop_roundtrip_Value_parse_renderPretty = property $ do - value <- forAll $ filter (not . null . valueToList) genValueDefault + value <- forAll $ Gen.filter (not . null . valueToList) genValueDefault tripping value renderValuePretty diff --git a/cardano-cli/test/Test/Cli/Pioneers/Exercise1.hs b/cardano-cli/test/Test/Cli/Pioneers/Exercise1.hs index 95ae944e024..f2244bd26b0 100644 --- a/cardano-cli/test/Test/Cli/Pioneers/Exercise1.hs +++ b/cardano-cli/test/Test/Cli/Pioneers/Exercise1.hs @@ -4,7 +4,7 @@ module Test.Cli.Pioneers.Exercise1 ( tests ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Cli/Pioneers/Exercise2.hs b/cardano-cli/test/Test/Cli/Pioneers/Exercise2.hs index 2e6e7e08f03..bcc89a9d890 100644 --- a/cardano-cli/test/Test/Cli/Pioneers/Exercise2.hs +++ b/cardano-cli/test/Test/Cli/Pioneers/Exercise2.hs @@ -4,7 +4,7 @@ module Test.Cli.Pioneers.Exercise2 ( tests ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Cli/Pioneers/Exercise3.hs b/cardano-cli/test/Test/Cli/Pioneers/Exercise3.hs index 9079ce15927..4067dee48ea 100644 --- a/cardano-cli/test/Test/Cli/Pioneers/Exercise3.hs +++ b/cardano-cli/test/Test/Cli/Pioneers/Exercise3.hs @@ -4,7 +4,7 @@ module Test.Cli.Pioneers.Exercise3 ( tests ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Cli/Pioneers/Exercise4.hs b/cardano-cli/test/Test/Cli/Pioneers/Exercise4.hs index c73d6baaad3..4d4118b83fb 100644 --- a/cardano-cli/test/Test/Cli/Pioneers/Exercise4.hs +++ b/cardano-cli/test/Test/Cli/Pioneers/Exercise4.hs @@ -4,7 +4,7 @@ module Test.Cli.Pioneers.Exercise4 ( tests ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Cli/Pioneers/Exercise5.hs b/cardano-cli/test/Test/Cli/Pioneers/Exercise5.hs index 621b253f100..c2e3cf4fc7b 100644 --- a/cardano-cli/test/Test/Cli/Pioneers/Exercise5.hs +++ b/cardano-cli/test/Test/Cli/Pioneers/Exercise5.hs @@ -4,7 +4,7 @@ module Test.Cli.Pioneers.Exercise5 ( tests ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Cli/Pioneers/Exercise6.hs b/cardano-cli/test/Test/Cli/Pioneers/Exercise6.hs index 52ec7f01527..054b24a2d87 100644 --- a/cardano-cli/test/Test/Cli/Pioneers/Exercise6.hs +++ b/cardano-cli/test/Test/Cli/Pioneers/Exercise6.hs @@ -4,7 +4,7 @@ module Test.Cli.Pioneers.Exercise6 ( tests ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Cli/Shelley/Run/Query.hs b/cardano-cli/test/Test/Cli/Shelley/Run/Query.hs index 392586da5e8..79ef4fff934 100644 --- a/cardano-cli/test/Test/Cli/Shelley/Run/Query.hs +++ b/cardano-cli/test/Test/Cli/Shelley/Run/Query.hs @@ -2,15 +2,11 @@ module Test.Cli.Shelley.Run.Query ( tests ) where -import Cardano.Slotting.Time (RelativeTime(..)) -import Control.Monad (return) -import Data.Bool -import Data.Function +import Cardano.Slotting.Time (RelativeTime (..)) import Hedgehog (Property, (===)) -import System.IO as IO import qualified Cardano.CLI.Shelley.Run.Query as Q -import qualified Hedgehog as H +import qualified Hedgehog as H import qualified Hedgehog.Extras.Test.Base as H unit_percentage :: Property diff --git a/cardano-cli/test/Test/Config/Mainnet.hs b/cardano-cli/test/Test/Config/Mainnet.hs index 465ad61494c..3801ebc831c 100644 --- a/cardano-cli/test/Test/Config/Mainnet.hs +++ b/cardano-cli/test/Test/Config/Mainnet.hs @@ -7,16 +7,9 @@ module Test.Config.Mainnet ) where import Cardano.Api (initialLedgerState, renderInitialLedgerStateError) -import Control.Monad import Control.Monad.Trans.Except -import Data.Bool (Bool(..)) -import Data.Either (Either(..)) -import Data.Function -import Data.Maybe import Hedgehog (Property, (===)) import System.FilePath (()) -import System.IO (IO) -import Text.Show import qualified Data.Aeson as J import qualified Data.Text as T diff --git a/cardano-cli/test/Test/Golden/Byron/SigningKeys.hs b/cardano-cli/test/Test/Golden/Byron/SigningKeys.hs index af92e8967cd..ddca16ee1e2 100644 --- a/cardano-cli/test/Test/Golden/Byron/SigningKeys.hs +++ b/cardano-cli/test/Test/Golden/Byron/SigningKeys.hs @@ -4,9 +4,10 @@ module Test.Golden.Byron.SigningKeys ( tests ) where -import Cardano.Prelude - import Codec.CBOR.Read (deserialiseFromBytes) +import Control.Monad (void) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (runExceptT) import qualified Data.ByteString.Lazy as LB import qualified Cardano.Crypto.Signing as Crypto diff --git a/cardano-cli/test/Test/Golden/Byron/Tx.hs b/cardano-cli/test/Test/Golden/Byron/Tx.hs index ff52193cf2e..4ddceb840ce 100644 --- a/cardano-cli/test/Test/Golden/Byron/Tx.hs +++ b/cardano-cli/test/Test/Golden/Byron/Tx.hs @@ -4,12 +4,14 @@ module Test.Golden.Byron.Tx ( txTests ) where -import Cardano.CLI.Byron.Tx -import Cardano.Prelude -import qualified Data.Text as Text - import Cardano.Chain.UTxO (ATxAux) +import Cardano.CLI.Byron.Tx +import Control.Monad (void) +import Control.Monad.IO.Class (liftIO) +import Control.Monad.Trans.Except (runExceptT) +import Data.ByteString (ByteString) +import qualified Data.Text as Text import Hedgehog (Property, (===)) import qualified Hedgehog as H diff --git a/cardano-cli/test/Test/Golden/Byron/UpdateProposal.hs b/cardano-cli/test/Test/Golden/Byron/UpdateProposal.hs index dfe62fc8e31..1e1967cb094 100644 --- a/cardano-cli/test/Test/Golden/Byron/UpdateProposal.hs +++ b/cardano-cli/test/Test/Golden/Byron/UpdateProposal.hs @@ -4,7 +4,9 @@ module Test.Golden.Byron.UpdateProposal ( updateProposalTest ) where -import Cardano.Prelude +import Control.Monad (void) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (runExceptT) import qualified Data.Text as Text import Cardano.CLI.Byron.UpdateProposal diff --git a/cardano-cli/test/Test/Golden/Byron/Vote.hs b/cardano-cli/test/Test/Golden/Byron/Vote.hs index 51e5c60b20c..b22f4d13822 100644 --- a/cardano-cli/test/Test/Golden/Byron/Vote.hs +++ b/cardano-cli/test/Test/Golden/Byron/Vote.hs @@ -5,16 +5,18 @@ module Test.Golden.Byron.Vote ) where import Cardano.CLI.Byron.Vote -import Cardano.Prelude + +import Control.Monad (void) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (runExceptT) import qualified Data.Text as Text +import qualified Hedgehog.Extras.Test.Base as H import Hedgehog (Property, (===)) import qualified Hedgehog as H import Hedgehog.Internal.Property (failWith) import Test.OptParse -import qualified Hedgehog.Extras.Test.Base as H - {- HLINT ignore "Use camelCase" -} golden_byron_yes_vote :: Property diff --git a/cardano-cli/test/Test/Golden/Shelley.hs b/cardano-cli/test/Test/Golden/Shelley.hs index be9bb71a85c..65497b13689 100644 --- a/cardano-cli/test/Test/Golden/Shelley.hs +++ b/cardano-cli/test/Test/Golden/Shelley.hs @@ -9,8 +9,6 @@ module Test.Golden.Shelley , txTests ) where -import Cardano.Prelude - import Test.Golden.Shelley.Address.Build (golden_shelleyAddressBuild) import Test.Golden.Shelley.Address.Info (golden_shelleyAddressInfo) import Test.Golden.Shelley.Address.KeyGen (golden_shelleyAddressKeyGen) diff --git a/cardano-cli/test/Test/Golden/Shelley/Address/Build.hs b/cardano-cli/test/Test/Golden/Shelley/Address/Build.hs index 80f993d2344..5758feb2129 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Address/Build.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Address/Build.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.Address.Build ( golden_shelleyAddressBuild ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse as OP diff --git a/cardano-cli/test/Test/Golden/Shelley/Address/KeyGen.hs b/cardano-cli/test/Test/Golden/Shelley/Address/KeyGen.hs index 2e124bc91ac..98a86ec8bb4 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Address/KeyGen.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Address/KeyGen.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.Address.KeyGen ( golden_shelleyAddressKeyGen ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Genesis/InitialTxIn.hs b/cardano-cli/test/Test/Golden/Shelley/Genesis/InitialTxIn.hs index 92522c8fe89..5d778479b10 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Genesis/InitialTxIn.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Genesis/InitialTxIn.hs @@ -4,7 +4,6 @@ module Test.Golden.Shelley.Genesis.InitialTxIn ( golden_shelleyGenesisInitialTxIn ) where -import Cardano.Prelude import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenDelegate.hs b/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenDelegate.hs index d60fd6570d7..bf8d988f997 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenDelegate.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenDelegate.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.Genesis.KeyGenDelegate ( golden_shelleyGenesisKeyGenDelegate ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenGenesis.hs b/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenGenesis.hs index 05f3b875c57..210496e7e41 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenGenesis.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenGenesis.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.Genesis.KeyGenGenesis ( golden_shelleyGenesisKeyGenGenesis ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenUtxo.hs b/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenUtxo.hs index a3955d2c706..834aaed7548 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenUtxo.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyGenUtxo.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.Genesis.KeyGenUtxo ( golden_shelleyGenesisKeyGenUtxo ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyHash.hs b/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyHash.hs index e4a911b91e2..5d025e3ef55 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyHash.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Genesis/KeyHash.hs @@ -4,7 +4,6 @@ module Test.Golden.Shelley.Genesis.KeyHash ( golden_shelleyGenesisKeyHash ) where -import Cardano.Prelude import Hedgehog (Property, (===)) import Test.OptParse as OP diff --git a/cardano-cli/test/Test/Golden/Shelley/Key/ConvertCardanoAddressKey.hs b/cardano-cli/test/Test/Golden/Shelley/Key/ConvertCardanoAddressKey.hs index ccfa33984bb..3eac76943ae 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Key/ConvertCardanoAddressKey.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Key/ConvertCardanoAddressKey.hs @@ -7,7 +7,8 @@ module Test.Golden.Shelley.Key.ConvertCardanoAddressKey , golden_convertCardanoAddressShelleyStakeSigningKey ) where -import Cardano.Prelude hiding (readFile) +import Control.Monad (void) +import Data.Text (Text) import Hedgehog (Property, (===)) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Metadata/StakePoolMetadata.hs b/cardano-cli/test/Test/Golden/Shelley/Metadata/StakePoolMetadata.hs index 74cf6d45abb..d8e348c9960 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Metadata/StakePoolMetadata.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Metadata/StakePoolMetadata.hs @@ -4,7 +4,10 @@ module Test.Golden.Shelley.Metadata.StakePoolMetadata ( golden_stakePoolMetadataHash ) where -import Cardano.Prelude +import Control.Monad (void) +import Control.Monad.IO.Class (MonadIO (..)) +import Data.Text (Text) +import qualified Data.Text.IO as Text import Hedgehog (Property) import Test.OptParse as OP @@ -21,7 +24,7 @@ golden_stakePoolMetadataHash = propertyOnce . H.moduleWorkspace "tmp" $ \tempDir outputStakePoolMetadataHashFp <- noteTempFile tempDir "stake-pool-metadata-hash.txt" -- Write the example stake pool metadata to disk - liftIO $ writeFile stakePoolMetadataFile exampleStakePoolMetadata + liftIO $ Text.writeFile stakePoolMetadataFile exampleStakePoolMetadata -- Hash the stake pool metadata void $ execCardanoCLI diff --git a/cardano-cli/test/Test/Golden/Shelley/MultiSig/Address.hs b/cardano-cli/test/Test/Golden/Shelley/MultiSig/Address.hs index e7f36104462..b38390ab31c 100644 --- a/cardano-cli/test/Test/Golden/Shelley/MultiSig/Address.hs +++ b/cardano-cli/test/Test/Golden/Shelley/MultiSig/Address.hs @@ -6,7 +6,6 @@ module Test.Golden.Shelley.MultiSig.Address , golden_shelleyAtLeastMultiSigAddressBuild ) where -import Cardano.Prelude import Hedgehog (Property) import Test.OptParse as OP diff --git a/cardano-cli/test/Test/Golden/Shelley/Node/IssueOpCert.hs b/cardano-cli/test/Test/Golden/Shelley/Node/IssueOpCert.hs index 9c8a69c31c8..c6e16a99496 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Node/IssueOpCert.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Node/IssueOpCert.hs @@ -4,7 +4,8 @@ module Test.Golden.Shelley.Node.IssueOpCert ( golden_shelleyNodeIssueOpCert ) where -import Cardano.Prelude +import Control.Monad (void) +import Control.Monad.IO.Class (MonadIO (..)) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Node/KeyGen.hs b/cardano-cli/test/Test/Golden/Shelley/Node/KeyGen.hs index 9db379cba09..202bf84a8fa 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Node/KeyGen.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Node/KeyGen.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.Node.KeyGen ( golden_shelleyNodeKeyGen ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Node/KeyGenKes.hs b/cardano-cli/test/Test/Golden/Shelley/Node/KeyGenKes.hs index 12b0691d9a8..905ed447b20 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Node/KeyGenKes.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Node/KeyGenKes.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.Node.KeyGenKes ( golden_shelleyNodeKeyGenKes ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Node/KeyGenVrf.hs b/cardano-cli/test/Test/Golden/Shelley/Node/KeyGenVrf.hs index ab119749eae..3bfdb2f2aed 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Node/KeyGenVrf.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Node/KeyGenVrf.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.Node.KeyGenVrf ( golden_shelleyNodeKeyGenVrf ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/StakeAddress/Build.hs b/cardano-cli/test/Test/Golden/Shelley/StakeAddress/Build.hs index 6aec2cc188f..0ce6fdba477 100644 --- a/cardano-cli/test/Test/Golden/Shelley/StakeAddress/Build.hs +++ b/cardano-cli/test/Test/Golden/Shelley/StakeAddress/Build.hs @@ -4,7 +4,6 @@ module Test.Golden.Shelley.StakeAddress.Build ( golden_shelleyStakeAddressBuild ) where -import Cardano.Prelude import Hedgehog (Property) import Test.OptParse as OP diff --git a/cardano-cli/test/Test/Golden/Shelley/StakeAddress/DeregistrationCertificate.hs b/cardano-cli/test/Test/Golden/Shelley/StakeAddress/DeregistrationCertificate.hs index b67664aae8b..15fcb7674c1 100644 --- a/cardano-cli/test/Test/Golden/Shelley/StakeAddress/DeregistrationCertificate.hs +++ b/cardano-cli/test/Test/Golden/Shelley/StakeAddress/DeregistrationCertificate.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.StakeAddress.DeregistrationCertificate ( golden_shelleyStakeAddressDeregistrationCertificate ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import System.FilePath (()) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/StakeAddress/KeyGen.hs b/cardano-cli/test/Test/Golden/Shelley/StakeAddress/KeyGen.hs index fe61fc98671..c7229a182a8 100644 --- a/cardano-cli/test/Test/Golden/Shelley/StakeAddress/KeyGen.hs +++ b/cardano-cli/test/Test/Golden/Shelley/StakeAddress/KeyGen.hs @@ -4,10 +4,10 @@ module Test.Golden.Shelley.StakeAddress.KeyGen ( golden_shelleyStakeAddressKeyGen ) where -import Cardano.Prelude import Hedgehog (Property) import Test.OptParse +import Control.Monad (void) import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H diff --git a/cardano-cli/test/Test/Golden/Shelley/StakeAddress/RegistrationCertificate.hs b/cardano-cli/test/Test/Golden/Shelley/StakeAddress/RegistrationCertificate.hs index bd9dd507f03..75e1f0c8cd4 100644 --- a/cardano-cli/test/Test/Golden/Shelley/StakeAddress/RegistrationCertificate.hs +++ b/cardano-cli/test/Test/Golden/Shelley/StakeAddress/RegistrationCertificate.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.StakeAddress.RegistrationCertificate ( golden_shelleyStakeAddressRegistrationCertificate ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import System.FilePath (()) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/StakePool/RegistrationCertificate.hs b/cardano-cli/test/Test/Golden/Shelley/StakePool/RegistrationCertificate.hs index f90ebe8c2ed..9c74f476fbe 100644 --- a/cardano-cli/test/Test/Golden/Shelley/StakePool/RegistrationCertificate.hs +++ b/cardano-cli/test/Test/Golden/Shelley/StakePool/RegistrationCertificate.hs @@ -4,10 +4,10 @@ module Test.Golden.Shelley.StakePool.RegistrationCertificate ( golden_shelleyStakePoolRegistrationCertificate ) where -import Cardano.Prelude import Hedgehog (Property) import Test.OptParse +import Control.Monad (void) import qualified Hedgehog.Extras.Test.Base as H import qualified Hedgehog.Extras.Test.File as H diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegationCertificate.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegationCertificate.hs index 0acfb42e956..7f3d59427ca 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegationCertificate.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/GenesisKeyDelegationCertificate.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Certificates.GenesisKeyDelegationCertifi ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/MIRCertificate.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/MIRCertificate.hs index 15f531f76a3..61a9abd2945 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/MIRCertificate.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/MIRCertificate.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Certificates.MIRCertificate ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/OperationalCertificate.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/OperationalCertificate.hs index 62bd4a56a04..97f95711640 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/OperationalCertificate.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/OperationalCertificate.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Certificates.OperationalCertificate ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/StakeAddressCertificates.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/StakeAddressCertificates.hs index 234f13e46ca..a99db5550f2 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/StakeAddressCertificates.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/StakeAddressCertificates.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Certificates.StakeAddressCertificates ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/StakePoolCertificates.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/StakePoolCertificates.hs index 74690847097..a6398e65d0d 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/StakePoolCertificates.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Certificates/StakePoolCertificates.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Certificates.StakePoolCertificates ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/ExtendedPaymentKeys.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/ExtendedPaymentKeys.hs index 8ace17eef02..03b2f7235c8 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/ExtendedPaymentKeys.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/ExtendedPaymentKeys.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Keys.ExtendedPaymentKeys ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs index ea6bcb039aa..63fb68f2104 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisDelegateKeys.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Keys.GenesisDelegateKeys ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisKeys.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisKeys.hs index 05d9c62bb46..2273a67fe8a 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisKeys.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisKeys.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Keys.GenesisKeys ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisUTxOKeys.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisUTxOKeys.hs index e73cc085b48..6574d83db43 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisUTxOKeys.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/GenesisUTxOKeys.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Keys.GenesisUTxOKeys ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/KESKeys.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/KESKeys.hs index d76421db71a..b9f622724cb 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/KESKeys.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/KESKeys.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Keys.KESKeys ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/PaymentKeys.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/PaymentKeys.hs index 0f5a36773f1..b5b68f2b8d3 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/PaymentKeys.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/PaymentKeys.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Keys.PaymentKeys ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/StakeKeys.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/StakeKeys.hs index dfc0a29f87e..4773cb4a6b3 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/StakeKeys.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/StakeKeys.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Keys.StakeKeys ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/VRFKeys.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/VRFKeys.hs index 2410e3b1664..86bad68d08d 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/VRFKeys.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Keys/VRFKeys.hs @@ -5,7 +5,7 @@ module Test.Golden.Shelley.TextEnvelope.Keys.VRFKeys ) where import Cardano.Api (AsType (..), HasTextEnvelope (..)) -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs index 9e00db87dab..2f685416d1a 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/Tx.hs @@ -4,8 +4,7 @@ module Test.Golden.Shelley.TextEnvelope.Tx.Tx ( golden_shelleyTx ) where -import Cardano.Prelude - +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/TxBody.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/TxBody.hs index 36598fb159d..9c235c03d87 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/TxBody.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/TxBody.hs @@ -4,11 +4,10 @@ module Test.Golden.Shelley.TextEnvelope.Tx.TxBody ( golden_shelleyTxBody ) where -import Cardano.Prelude - import Hedgehog (Property) import Test.OptParse +import Control.Monad (void) import qualified Hedgehog.Extras.Test.Base as H {- HLINT ignore "Use camelCase" -} diff --git a/cardano-cli/test/Test/Golden/Shelley/TextView/DecodeCbor.hs b/cardano-cli/test/Test/Golden/Shelley/TextView/DecodeCbor.hs index 789506e7cd7..d37dcf2bb93 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextView/DecodeCbor.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextView/DecodeCbor.hs @@ -4,7 +4,6 @@ module Test.Golden.Shelley.TextView.DecodeCbor ( golden_shelleyTextViewDecodeCbor ) where -import Cardano.Prelude import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Transaction/CalculateMinFee.hs b/cardano-cli/test/Test/Golden/Shelley/Transaction/CalculateMinFee.hs index 2441b0b66df..053bb41e3be 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Transaction/CalculateMinFee.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Transaction/CalculateMinFee.hs @@ -4,7 +4,6 @@ module Test.Golden.Shelley.Transaction.CalculateMinFee ( golden_shelleyTransactionCalculateMinFee ) where -import Cardano.Prelude import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/cardano-cli-golden.hs b/cardano-cli/test/cardano-cli-golden.hs index 5b94752085e..4d58a6efda7 100644 --- a/cardano-cli/test/cardano-cli-golden.hs +++ b/cardano-cli/test/cardano-cli-golden.hs @@ -1,5 +1,3 @@ -import Cardano.Prelude - import Hedgehog.Main (defaultMain) import qualified Test.Golden.Byron.SigningKeys diff --git a/cardano-cli/test/cardano-cli-test.hs b/cardano-cli/test/cardano-cli-test.hs index bd8e9156d4a..12f7847bc00 100644 --- a/cardano-cli/test/cardano-cli-test.hs +++ b/cardano-cli/test/cardano-cli-test.hs @@ -1,4 +1,3 @@ -import Cardano.Prelude import Hedgehog.Main (defaultMain) From e637ffbb702e25669b56203f410fb74c1a06c188 Mon Sep 17 00:00:00 2001 From: John Ky Date: Sun, 29 Jan 2023 14:24:16 -0800 Subject: [PATCH 4/7] Remove NoImplicitPrelude from cardano-testnet --- cardano-testnet/app/cardano-testnet.hs | 3 --- cardano-testnet/cardano-testnet.cabal | 1 - cardano-testnet/src/Parsers/Byron.hs | 7 ------- cardano-testnet/src/Parsers/Version.hs | 5 ----- cardano-testnet/src/Testnet/Byron.hs | 21 +++++---------------- cardano-testnet/src/Testnet/Conf.hs | 7 ------- cardano-testnet/src/Testnet/Parsers.hs | 3 --- cardano-testnet/src/Testnet/Run.hs | 5 ----- cardano-testnet/src/Testnet/Util/Assert.hs | 15 +++------------ cardano-testnet/src/Testnet/Util/Base.hs | 3 --- 10 files changed, 8 insertions(+), 62 deletions(-) diff --git a/cardano-testnet/app/cardano-testnet.hs b/cardano-testnet/app/cardano-testnet.hs index 2b5810ab751..6ebbe1cc756 100644 --- a/cardano-testnet/app/cardano-testnet.hs +++ b/cardano-testnet/app/cardano-testnet.hs @@ -1,10 +1,7 @@ module Main where import Control.Monad -import Data.Function -import Data.Semigroup import Options.Applicative -import System.IO (IO) import Testnet.Parsers (commands) main :: IO () diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index 51101602146..9c1195a903b 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -16,7 +16,6 @@ build-type: Simple common project-config default-language: Haskell2010 - default-extensions: NoImplicitPrelude build-depends: base >= 4.14 && < 4.17 ghc-options: -Wall diff --git a/cardano-testnet/src/Parsers/Byron.hs b/cardano-testnet/src/Parsers/Byron.hs index 48ba97b4d07..750e850c367 100644 --- a/cardano-testnet/src/Parsers/Byron.hs +++ b/cardano-testnet/src/Parsers/Byron.hs @@ -4,16 +4,9 @@ module Parsers.Byron , runByronOptions ) where -import Data.Eq -import Data.Function -import Data.Int -import Data.Maybe -import Data.Semigroup import Options.Applicative -import System.IO (IO) import Testnet.Byron import Testnet.Run (runTestnet) -import Text.Show import qualified Options.Applicative as OA diff --git a/cardano-testnet/src/Parsers/Version.hs b/cardano-testnet/src/Parsers/Version.hs index 86fac359f2f..42b50bc17f9 100644 --- a/cardano-testnet/src/Parsers/Version.hs +++ b/cardano-testnet/src/Parsers/Version.hs @@ -5,15 +5,10 @@ module Parsers.Version ) where import Cardano.Git.Rev (gitRev) -import Data.Eq -import Data.Function -import Data.Monoid import Data.Version (showVersion) import Options.Applicative import Paths_cardano_testnet (version) -import System.IO (IO) import System.Info (arch, compilerName, compilerVersion, os) -import Text.Show import qualified Data.Text as T import qualified System.IO as IO diff --git a/cardano-testnet/src/Testnet/Byron.hs b/cardano-testnet/src/Testnet/Byron.hs index e69d1e3d4bc..db96ca3d217 100644 --- a/cardano-testnet/src/Testnet/Byron.hs +++ b/cardano-testnet/src/Testnet/Byron.hs @@ -11,27 +11,16 @@ module Testnet.Byron , defaultTestnetOptions ) where -import Control.Monad (Monad(..), forM_, void, (=<<), when) +import Control.Monad (forM_, void, when) import Data.Aeson (Value) -import Data.Bool (Bool(..)) import Data.ByteString.Lazy (ByteString) -import Data.Eq (Eq) -import Data.Function (($), (.), flip) -import Data.Functor (Functor(..), (<&>)) -import Data.Int (Int) -import Data.Maybe (Maybe(Just)) -import Data.Ord (Ord((<=))) -import Data.Semigroup (Semigroup((<>))) -import Data.String (String) -import GHC.Num (Num((-))) -import GHC.Real (fromIntegral) +import Data.Functor ((<&>)) import Hedgehog.Extras.Stock.Aeson (rewriteObject) -import Hedgehog.Extras.Stock.IO.Network.Sprocket (Sprocket(..)) +import Hedgehog.Extras.Stock.IO.Network.Sprocket (Sprocket (..)) import Hedgehog.Extras.Stock.Time (showUTCTimeSeconds) +import Ouroboros.Network.PeerSelection.LedgerPeers (UseLedgerAfter (..)) +import Ouroboros.Network.PeerSelection.RelayAccessPoint (RelayAccessPoint (..)) import System.FilePath.Posix (()) -import Text.Show (Show(show)) -import Ouroboros.Network.PeerSelection.LedgerPeers (UseLedgerAfter(..)) -import Ouroboros.Network.PeerSelection.RelayAccessPoint (RelayAccessPoint(..)) import qualified Cardano.Node.Configuration.Topology as NonP2P import qualified Cardano.Node.Configuration.TopologyP2P as P2P diff --git a/cardano-testnet/src/Testnet/Conf.hs b/cardano-testnet/src/Testnet/Conf.hs index 24c31a630d4..08f18121817 100644 --- a/cardano-testnet/src/Testnet/Conf.hs +++ b/cardano-testnet/src/Testnet/Conf.hs @@ -8,14 +8,7 @@ module Testnet.Conf , mkConf ) where -import Control.Monad -import Data.Eq -import Data.Function -import Data.Int -import Data.Maybe import System.FilePath.Posix (()) -import System.IO (FilePath) -import Text.Show import qualified Hedgehog.Extras.Test.Base as H import qualified System.FilePath.Posix as FP diff --git a/cardano-testnet/src/Testnet/Parsers.hs b/cardano-testnet/src/Testnet/Parsers.hs index a2a47d6fd49..af49cf4f38d 100644 --- a/cardano-testnet/src/Testnet/Parsers.hs +++ b/cardano-testnet/src/Testnet/Parsers.hs @@ -2,10 +2,7 @@ module Testnet.Parsers ( commands ) where -import Data.Function -import Data.Monoid import Options.Applicative -import System.IO (IO) import Parsers.Babbage import Parsers.Byron import Parsers.Cardano diff --git a/cardano-testnet/src/Testnet/Run.hs b/cardano-testnet/src/Testnet/Run.hs index 1274a25bf19..fa57ce43030 100644 --- a/cardano-testnet/src/Testnet/Run.hs +++ b/cardano-testnet/src/Testnet/Run.hs @@ -5,13 +5,8 @@ module Testnet.Run import Control.Monad import Control.Monad.IO.Class import Control.Monad.Trans.Resource -import Data.Bool -import Data.Function -import Data.Int -import Data.Maybe import System.Console.ANSI (Color (..), ColorIntensity (..), ConsoleLayer (..), SGR (..)) import System.FilePath (()) -import System.IO (IO) import qualified Control.Concurrent as IO import qualified Control.Concurrent.STM as STM diff --git a/cardano-testnet/src/Testnet/Util/Assert.hs b/cardano-testnet/src/Testnet/Util/Assert.hs index 470ebde5895..8eb3ec69b1b 100644 --- a/cardano-testnet/src/Testnet/Util/Assert.hs +++ b/cardano-testnet/src/Testnet/Util/Assert.hs @@ -10,32 +10,23 @@ module Testnet.Util.Assert , getRelevantLeaderSlots ) where -import Control.Monad (Monad (..), fail) +import Prelude hiding (lines) + import Control.Monad.IO.Class (MonadIO) import Control.Monad.Trans.Reader (ReaderT) import Control.Monad.Trans.Resource (ResourceT) import Data.Aeson (FromJSON (..), Value, (.:)) -import Data.Bool (Bool (..)) -import Data.Eq (Eq (..)) -import Data.Function (($), (.)) -import Data.Functor ((<$>)) -import Data.Int (Int) -import Data.Maybe (Maybe (..), mapMaybe) -import Data.Ord (Ord (..)) -import Data.Semigroup ((<>)) import Data.Text (Text) import Data.Word (Word8) import GHC.Stack (HasCallStack) import Hedgehog (MonadTest) import Hedgehog.Extras.Internal.Test.Integration (IntegrationState) -import System.FilePath (FilePath) -import System.IO (IO) -import Text.Show (Show (..)) import qualified Data.Aeson as Aeson import qualified Data.Aeson.Types as Aeson import qualified Data.ByteString.Lazy as LBS import qualified Data.List as L +import Data.Maybe (mapMaybe) import qualified Data.Maybe as Maybe import qualified Data.Time.Clock as DTC import qualified Hedgehog as H diff --git a/cardano-testnet/src/Testnet/Util/Base.hs b/cardano-testnet/src/Testnet/Util/Base.hs index 749ec63ea72..385461abcff 100644 --- a/cardano-testnet/src/Testnet/Util/Base.hs +++ b/cardano-testnet/src/Testnet/Util/Base.hs @@ -3,9 +3,6 @@ module Testnet.Util.Base , isLinux ) where -import Data.Bool (Bool) -import Data.Eq (Eq (..)) -import Data.Function import GHC.Stack (HasCallStack) import System.Info (os) From 2e338a02a8121221e88470b94631f96c2af4bc53 Mon Sep 17 00:00:00 2001 From: John Ky Date: Sun, 29 Jan 2023 14:29:51 -0800 Subject: [PATCH 5/7] Remove NoImplicitPrelude from cardano-node-chairman --- .../app/Cardano/Chairman/Commands.hs | 3 --- .../app/Cardano/Chairman/Commands/Run.hs | 13 +++++++++---- .../app/Cardano/Chairman/Commands/Version.hs | 5 ----- cardano-node-chairman/app/cardano-node-chairman.hs | 3 --- cardano-node-chairman/cardano-node-chairman.cabal | 2 +- .../test/Spec/Chairman/Cardano.hs | 4 ---- .../test/Spec/Chairman/Chairman.hs | 14 ++------------ 7 files changed, 12 insertions(+), 32 deletions(-) diff --git a/cardano-node-chairman/app/Cardano/Chairman/Commands.hs b/cardano-node-chairman/app/Cardano/Chairman/Commands.hs index e9072baf431..49920874e07 100644 --- a/cardano-node-chairman/app/Cardano/Chairman/Commands.hs +++ b/cardano-node-chairman/app/Cardano/Chairman/Commands.hs @@ -2,10 +2,7 @@ module Cardano.Chairman.Commands where import Cardano.Chairman.Commands.Run import Cardano.Chairman.Commands.Version -import Data.Function -import Data.Monoid import Options.Applicative -import System.IO (IO) {- HLINT ignore "Monoid law, left identity" -} diff --git a/cardano-node-chairman/app/Cardano/Chairman/Commands/Run.hs b/cardano-node-chairman/app/Cardano/Chairman/Commands/Run.hs index eb58e741976..6314dc8d585 100644 --- a/cardano-node-chairman/app/Cardano/Chairman/Commands/Run.hs +++ b/cardano-node-chairman/app/Cardano/Chairman/Commands/Run.hs @@ -7,15 +7,20 @@ module Cardano.Chairman.Commands.Run ( cmdRun ) where +import Cardano.Prelude (ConvertText (..)) + import qualified Cardano.Api as Api -import Cardano.Prelude import Control.Monad.Class.MonadTime (DiffTime) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (runExceptT) import Control.Tracer (Tracer (..), stdoutTracer) -import qualified Data.Text as Text +import Data.Monoid (Last (..)) +import Data.Text (Text) import qualified Data.Time.Clock as DTC import Options.Applicative import qualified Options.Applicative as Opt +import System.Exit (exitFailure) import qualified System.IO as IO import Cardano.Node.Configuration.NodeAddress @@ -102,8 +107,8 @@ run RunOpts ptclConfig <- case getProtocolConfiguration configYamlPc of Nothing -> - panic $ "Node protocol configuration was not specified "<> - "in Config yaml filepath: " <> Text.pack (unConfigPath caConfigYaml) + error $ "Node protocol configuration was not specified "<> + "in Config yaml filepath: " <> unConfigPath caConfigYaml Just ptclConfig -> return ptclConfig eitherSomeProtocol <- runExceptT $ mkConsensusProtocol ptclConfig Nothing diff --git a/cardano-node-chairman/app/Cardano/Chairman/Commands/Version.hs b/cardano-node-chairman/app/Cardano/Chairman/Commands/Version.hs index 84541c480e1..51b196ef2f0 100644 --- a/cardano-node-chairman/app/Cardano/Chairman/Commands/Version.hs +++ b/cardano-node-chairman/app/Cardano/Chairman/Commands/Version.hs @@ -5,15 +5,10 @@ module Cardano.Chairman.Commands.Version ) where import Cardano.Git.Rev (gitRev) -import Data.Eq -import Data.Function -import Data.Monoid import Data.Version (showVersion) import Options.Applicative import Paths_cardano_node_chairman (version) -import System.IO (IO) import System.Info (arch, compilerName, compilerVersion, os) -import Text.Show import qualified Data.Text as T import qualified System.IO as IO diff --git a/cardano-node-chairman/app/cardano-node-chairman.hs b/cardano-node-chairman/app/cardano-node-chairman.hs index 7dda5884639..33d7ac64c65 100644 --- a/cardano-node-chairman/app/cardano-node-chairman.hs +++ b/cardano-node-chairman/app/cardano-node-chairman.hs @@ -2,10 +2,7 @@ module Main where import Cardano.Chairman.Commands import Control.Monad -import Data.Function -import Data.Semigroup import Options.Applicative -import System.IO (IO) main :: IO () main = join diff --git a/cardano-node-chairman/cardano-node-chairman.cabal b/cardano-node-chairman/cardano-node-chairman.cabal index 04831ad1921..d914df1eac7 100644 --- a/cardano-node-chairman/cardano-node-chairman.cabal +++ b/cardano-node-chairman/cardano-node-chairman.cabal @@ -16,7 +16,6 @@ build-type: Simple common project-config default-language: Haskell2010 - default-extensions: NoImplicitPrelude build-depends: base >= 4.14 && < 4.17 ghc-options: -Wall @@ -55,6 +54,7 @@ executable cardano-node-chairman , strict-stm , text , time + , transformers test-suite chairman-tests import: project-config diff --git a/cardano-node-chairman/test/Spec/Chairman/Cardano.hs b/cardano-node-chairman/test/Spec/Chairman/Cardano.hs index 6902c933d3d..38c41cf12e1 100644 --- a/cardano-node-chairman/test/Spec/Chairman/Cardano.hs +++ b/cardano-node-chairman/test/Spec/Chairman/Cardano.hs @@ -4,10 +4,6 @@ module Spec.Chairman.Cardano ( hprop_chairman ) where -import Control.Monad ((=<<)) -import Data.Function -import Data.Functor -import Data.Maybe import Spec.Chairman.Chairman (chairmanOver) import System.FilePath (()) diff --git a/cardano-node-chairman/test/Spec/Chairman/Chairman.hs b/cardano-node-chairman/test/Spec/Chairman/Chairman.hs index e2a84e9390a..33bc3380802 100644 --- a/cardano-node-chairman/test/Spec/Chairman/Chairman.hs +++ b/cardano-node-chairman/test/Spec/Chairman/Chairman.hs @@ -6,22 +6,12 @@ module Spec.Chairman.Chairman ( chairmanOver ) where -import Control.Monad -import Data.Either -import Data.Eq -import Data.Function -import Data.Functor -import Data.Int -import Data.Maybe -import Data.Semigroup -import Data.String -import GHC.Num +import Control.Monad (when) +import Data.Functor ((<&>)) import Hedgehog.Extras.Stock.IO.Network.Sprocket (Sprocket (..)) import Hedgehog.Extras.Test.Base (Integration) import System.Exit (ExitCode (..)) import System.FilePath.Posix (()) -import System.IO (FilePath) -import Text.Show import qualified Hedgehog as H import qualified Hedgehog.Extras.Stock.IO.Network.Sprocket as IO From 93587e456dce65882d442ef1a522b6c01770375c Mon Sep 17 00:00:00 2001 From: John Ky Date: Sun, 29 Jan 2023 15:52:44 -0800 Subject: [PATCH 6/7] Remove NoImplicitPrelude from cardano-node --- cardano-node/app/cardano-node.hs | 1 - cardano-node/cardano-node.cabal | 7 ++-- .../src/Cardano/Node/Configuration/Logging.hs | 27 ++++++++++------ .../src/Cardano/Node/Handlers/Shutdown.hs | 13 +++++--- .../src/Cardano/Node/Protocol/Byron.hs | 9 ++++-- cardano-node/src/Cardano/Node/Queries.hs | 5 +-- cardano-node/src/Cardano/Node/STM.hs | 4 --- .../src/Cardano/Node/Tracing/Era/Byron.hs | 13 ++++---- .../src/Cardano/Node/Tracing/Era/HardFork.hs | 2 -- .../src/Cardano/Node/Tracing/Era/Shelley.hs | 14 ++++---- .../src/Cardano/Node/Tracing/Peers.hs | 3 +- .../src/Cardano/Node/Tracing/StateRep.hs | 8 +++-- .../src/Cardano/Node/Tracing/Tracers.hs | 2 +- .../Tracing/Tracers/BlockReplayProgress.hs | 6 ++-- .../Cardano/Node/Tracing/Tracers/Consensus.hs | 7 ++-- .../Tracers/ConsensusStartupException.hs | 4 +-- .../Cardano/Node/Tracing/Tracers/Diffusion.hs | 5 ++- .../Tracing/Tracers/ForgingThreadStats.hs | 18 +++++------ .../Node/Tracing/Tracers/NodeToClient.hs | 3 +- .../Node/Tracing/Tracers/NodeToNode.hs | 3 +- .../Cardano/Node/Tracing/Tracers/NonP2P.hs | 7 ++-- .../Tracing/Tracers/StartLeadershipCheck.hs | 4 ++- cardano-node/src/Cardano/Tracing/Metrics.hs | 7 ++-- .../Cardano/Tracing/OrphanInstances/Byron.hs | 11 ++++--- .../Tracing/OrphanInstances/HardFork.hs | 2 -- .../Tracing/OrphanInstances/Shelley.hs | 32 +++++++++---------- .../test/Test/Cardano/Node/FilePermissions.hs | 3 ++ cardano-node/test/Test/Cardano/Node/Gen.hs | 27 ++++++++-------- cardano-node/test/Test/Cardano/Node/POM.hs | 4 +-- cardano-node/test/cardano-node-test.hs | 1 - 30 files changed, 137 insertions(+), 115 deletions(-) diff --git a/cardano-node/app/cardano-node.hs b/cardano-node/app/cardano-node.hs index f9354dc3462..97fa0b50f00 100644 --- a/cardano-node/app/cardano-node.hs +++ b/cardano-node/app/cardano-node.hs @@ -1,4 +1,3 @@ -{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index 0ae8f4729bd..fbb1d5d368b 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -27,8 +27,7 @@ flag systemd common project-config default-language: Haskell2010 - default-extensions: NoImplicitPrelude - OverloadedStrings + default-extensions: OverloadedStrings build-depends: base >= 4.14 && < 4.17 ghc-options: -Wall @@ -166,6 +165,7 @@ library , lobemo-backend-ekg , lobemo-backend-monitoring , lobemo-backend-trace-forwarder + , mtl , network , network-mux ^>= 0.2 , nothunks @@ -233,10 +233,13 @@ test-suite cardano-node-test , hedgehog , hedgehog-corpus , iproute + , mtl , ouroboros-consensus , ouroboros-network , mtl + , text , time + , transformers , vector other-modules: Test.Cardano.Node.FilePermissions diff --git a/cardano-node/src/Cardano/Node/Configuration/Logging.hs b/cardano-node/src/Cardano/Node/Configuration/Logging.hs index 174537beeb2..0e3dc9a69dc 100644 --- a/cardano-node/src/Cardano/Node/Configuration/Logging.hs +++ b/cardano-node/src/Cardano/Node/Configuration/Logging.hs @@ -23,17 +23,24 @@ module Cardano.Node.Configuration.Logging , LOContent (..) ) where +import Cardano.Api (textShow) import qualified Cardano.Api as Api -import Cardano.Prelude hiding (trace) import qualified Control.Concurrent as Conc import qualified Control.Concurrent.Async as Async +import Control.Concurrent.MVar (MVar, newMVar) +import Control.Concurrent.STM (STM) +import Control.Exception (IOException) import Control.Exception.Safe (MonadCatch) +import Control.Monad (forM_, forever, void, when) +import Control.Monad.Except (ExceptT) +import Control.Monad.IO.Class (MonadIO (..)) import Control.Monad.Trans.Except.Extra (catchIOExceptT) import "contra-tracer" Control.Tracer import Data.List (nub) import qualified Data.Map.Strict as Map -import Data.Text (pack) +import Data.Maybe (isJust) +import Data.Text (Text, pack) import Data.Time.Clock (UTCTime, getCurrentTime) import Data.Version (showVersion) import System.Metrics.Counter (Counter) @@ -344,7 +351,7 @@ nodeBasicInfo nc (SomeConsensusProtocol whichP pForInfo) nodeStartTime' = do [ ("protocol", pack . show $ ncProtocol nc) , ("version", pack . showVersion $ version) , ("commit", gitRev) - , ("nodeStartTime", show nodeStartTime') + , ("nodeStartTime", textShow nodeStartTime') ] ++ protocolDependentItems logObjects = map (\(nm, msg) -> LogObject ("basicInfo." <> nm) meta (LogMessage msg)) items @@ -352,14 +359,14 @@ nodeBasicInfo nc (SomeConsensusProtocol whichP pForInfo) nodeStartTime' = do where getGenesisValuesByron cfg config = let genesis = byronLedgerConfig config - in [ ("systemStartTime", show (WCT.getSystemStart . getSystemStart $ Consensus.configBlock cfg)) - , ("slotLengthByron", show (WCT.getSlotLength . fromByronSlotLength $ genesisSlotLength genesis)) - , ("epochLengthByron", show (unEpochSize . fromByronEpochSlots $ Gen.configEpochSlots genesis)) + in [ ("systemStartTime", textShow (WCT.getSystemStart . getSystemStart $ Consensus.configBlock cfg)) + , ("slotLengthByron", textShow (WCT.getSlotLength . fromByronSlotLength $ genesisSlotLength genesis)) + , ("epochLengthByron", textShow (unEpochSize . fromByronEpochSlots $ Gen.configEpochSlots genesis)) ] getGenesisValues era config = let genesis = shelleyLedgerGenesis $ shelleyLedgerConfig config - in [ ("systemStartTime", show (SL.sgSystemStart genesis)) - , ("slotLength" <> era, show (WCT.getSlotLength . WCT.mkSlotLength $ SL.sgSlotLength genesis)) - , ("epochLength" <> era, show (unEpochSize . SL.sgEpochLength $ genesis)) - , ("slotsPerKESPeriod" <> era, show (SL.sgSlotsPerKESPeriod genesis)) + in [ ("systemStartTime", textShow (SL.sgSystemStart genesis)) + , ("slotLength" <> era, textShow (WCT.getSlotLength . WCT.mkSlotLength $ SL.sgSlotLength genesis)) + , ("epochLength" <> era, textShow (unEpochSize . SL.sgEpochLength $ genesis)) + , ("slotsPerKESPeriod" <> era, textShow (SL.sgSlotsPerKESPeriod genesis)) ] diff --git a/cardano-node/src/Cardano/Node/Handlers/Shutdown.hs b/cardano-node/src/Cardano/Node/Handlers/Shutdown.hs index b7ab8c163c1..1fe31815125 100644 --- a/cardano-node/src/Cardano/Node/Handlers/Shutdown.hs +++ b/cardano-node/src/Cardano/Node/Handlers/Shutdown.hs @@ -26,13 +26,18 @@ module Cardano.Node.Handlers.Shutdown ) where -import Cardano.Prelude +import Control.Applicative (Alternative (..)) +import Control.Concurrent.Async (race_) +import Control.Exception (try) +import Control.Exception.Base (throwIO) +import Control.Monad (void, when) import Data.Aeson (FromJSON, ToJSON) +import Data.Text (Text, pack) import Generic.Data.Orphans () - -import Data.Text (pack) +import GHC.Generics (Generic) import qualified GHC.IO.Handle.FD as IO (fdToHandle) import qualified Options.Applicative as Opt +import System.Exit (ExitCode (..)) import qualified System.IO as IO import qualified System.IO.Error as IO import System.Posix.Types (Fd (Fd)) @@ -148,7 +153,7 @@ maybeSpawnOnSlotSyncedShutdownHandler sc tr registry chaindb = spawnLimitTerminator :: ShutdownOn -> IO () spawnLimitTerminator limit = void $ forkLinkedWatcher registry "slotLimitTerminator" Watcher { - wFingerprint = identity + wFingerprint = id , wInitial = Nothing , wReader = case limit of diff --git a/cardano-node/src/Cardano/Node/Protocol/Byron.hs b/cardano-node/src/Cardano/Node/Protocol/Byron.hs index 314a331ff9f..4a8ee8f480a 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Byron.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Byron.hs @@ -12,10 +12,12 @@ module Cardano.Node.Protocol.Byron , readLeaderCredentials ) where +import Cardano.Prelude (ConvertText (..), canonicalDecodePretty) -import Cardano.Prelude +import Control.Monad.Except (throwError) import Control.Monad.Trans.Except.Extra (bimapExceptT, firstExceptT, hoistEither, left) import qualified Data.ByteString.Lazy as LB +import Data.Maybe (fromMaybe) import qualified Data.Text as Text import Cardano.Api.Byron @@ -42,6 +44,9 @@ import Cardano.Tracing.OrphanInstances.Shelley () import Cardano.Node.Tracing.Era.Byron () import Cardano.Node.Tracing.Era.HardFork () import Cardano.Node.Tracing.Tracers.ChainDB () +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) +import Data.Text (Text) @@ -134,7 +139,7 @@ readGenesis (GenesisFile file) mbExpectedGenesisHash ncReqNetworkMagic = do $ h where impossible = - panic "fromByronGenesisHash: old and new crypto libs disagree on hash size" + error "fromByronGenesisHash: old and new crypto libs disagree on hash size" diff --git a/cardano-node/src/Cardano/Node/Queries.hs b/cardano-node/src/Cardano/Node/Queries.hs index 9a084408194..c16daea129f 100644 --- a/cardano-node/src/Cardano/Node/Queries.hs +++ b/cardano-node/src/Cardano/Node/Queries.hs @@ -36,12 +36,13 @@ module Cardano.Node.Queries , fromSMaybe ) where -import Cardano.Prelude hiding (All, (:.:)) - +import Control.Monad.STM (atomically) +import Data.ByteString (ByteString) import Data.IORef (IORef, newIORef, readIORef, writeIORef) import qualified Data.Map.Strict as Map import Data.SOP.Strict import qualified Data.UMap as UM +import Data.Word (Word64) import qualified Cardano.Chain.Block as Byron import qualified Cardano.Chain.UTxO as Byron diff --git a/cardano-node/src/Cardano/Node/STM.hs b/cardano-node/src/Cardano/Node/STM.hs index 1c6e8ef23db..0f0f5a82112 100644 --- a/cardano-node/src/Cardano/Node/STM.hs +++ b/cardano-node/src/Cardano/Node/STM.hs @@ -7,10 +7,6 @@ module Cardano.Node.STM , modifyReadTVarIO' ) where -import Data.Function -import Control.Monad -import System.IO (IO) - import qualified Control.Concurrent.STM as STM -- | Mutate the contents of a TVar and return the new value of the TVar (non-strict). diff --git a/cardano-node/src/Cardano/Node/Tracing/Era/Byron.hs b/cardano-node/src/Cardano/Node/Tracing/Era/Byron.hs index 45dce1124ed..87f8cd85eec 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Era/Byron.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Era/Byron.hs @@ -16,9 +16,9 @@ module Cardano.Node.Tracing.Era.Byron () where import Cardano.Tracing.OrphanInstances.Byron () import Cardano.Logging -import Cardano.Prelude -import Data.Aeson (Value (String), (.=)) +import Data.Aeson (Value (String), (.=)) +import Data.ByteString (ByteString) import qualified Data.Set as Set import qualified Data.Text as Text @@ -32,6 +32,7 @@ import Ouroboros.Consensus.Byron.Ledger.Inspect (ByronLedgerUpdate (.. import Ouroboros.Consensus.Ledger.SupportsMempool (GenTx, txId) import Ouroboros.Consensus.Util.Condense (condense) +import Cardano.Api (textShow) import Cardano.Chain.Block (ABlockOrBoundaryHdr (..), AHeader (..), ChainValidationError (..), delegationCertificate) import Cardano.Chain.Byron.API (ApplyMempoolPayloadErr (..)) @@ -49,22 +50,22 @@ instance LogFormatting ApplyMempoolPayloadErr where forMachine _dtal (MempoolTxErr utxoValidationErr) = mconcat [ "kind" .= String "MempoolTxErr" - , "error" .= String (show utxoValidationErr) + , "error" .= String (textShow utxoValidationErr) ] forMachine _dtal (MempoolDlgErr delegScheduleError) = mconcat [ "kind" .= String "MempoolDlgErr" - , "error" .= String (show delegScheduleError) + , "error" .= String (textShow delegScheduleError) ] forMachine _dtal (MempoolUpdateProposalErr iFaceErr) = mconcat [ "kind" .= String "MempoolUpdateProposalErr" - , "error" .= String (show iFaceErr) + , "error" .= String (textShow iFaceErr) ] forMachine _dtal (MempoolUpdateVoteErr iFaceErrr) = mconcat [ "kind" .= String "MempoolUpdateVoteErr" - , "error" .= String (show iFaceErrr) + , "error" .= String (textShow iFaceErrr) ] instance LogFormatting ByronLedgerUpdate where diff --git a/cardano-node/src/Cardano/Node/Tracing/Era/HardFork.hs b/cardano-node/src/Cardano/Node/Tracing/Era/HardFork.hs index c9068248628..67a207c1ca9 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Era/HardFork.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Era/HardFork.hs @@ -15,8 +15,6 @@ module Cardano.Node.Tracing.Era.HardFork () where -import Cardano.Prelude hiding (All) - import Cardano.Tracing.OrphanInstances.HardFork () import Data.Aeson diff --git a/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs b/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs index bb9858b13ce..79643cda838 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Era/Shelley.hs @@ -19,7 +19,9 @@ import Data.Aeson (ToJSON (..), Value (..), (.=)) import qualified Data.Aeson as Aeson import qualified Data.Aeson.Key as Aeson import qualified Data.Aeson.Types as Aeson +import Data.Set (Set) import qualified Data.Set as Set +import Data.Text (Text) import Cardano.Api (textShow) import qualified Cardano.Api as Api @@ -28,7 +30,6 @@ import qualified Cardano.Api.Shelley as Api import qualified Cardano.Crypto.Hash.Class as Crypto import Cardano.Ledger.Crypto (StandardCrypto) import Cardano.Logging -import Cardano.Prelude import Cardano.Slotting.Block (BlockNo (..)) import Ouroboros.Network.Block (SlotNo (..), blockHash, blockNo, blockSlot) @@ -146,7 +147,6 @@ instance Core.Crypto era => LogFormatting (TPraosCannotForge era) where ] - instance ( ShelleyBasedEra era , LogFormatting (PredicateFailure (ShelleyUTXO era)) , LogFormatting (PredicateFailure (ShelleyUTXOW era)) @@ -514,7 +514,7 @@ renderBadInputsUTxOErr txIns renderValueNotConservedErr :: Show val => val -> val -> Value renderValueNotConservedErr consumed produced = String $ - "This transaction consumed " <> show consumed <> " but produced " <> show produced + "This transaction consumed " <> textShow consumed <> " but produced " <> textShow produced instance Core.Crypto (Ledger.Crypto era) => LogFormatting (ShelleyPpupPredFailure era) where forMachine _dtal (NonGenesisUpdatePPUP proposalKeys genesisKeys) = @@ -524,7 +524,7 @@ instance Core.Crypto (Ledger.Crypto era) => LogFormatting (ShelleyPpupPredFailur mconcat [ "kind" .= String "PPUpdateWrongEpoch" , "currentEpoch" .= currEpoch , "intendedEpoch" .= intendedEpoch - , "votingPeriod" .= String (show votingPeriod) + , "votingPeriod" .= String (textShow votingPeriod) ] forMachine _dtal (PVCannotFollowPPUP badPv) = mconcat [ "kind" .= String "PVCannotFollowPPUP" @@ -700,7 +700,7 @@ instance ( LogFormatting (PredicateFailure (Core.EraRule "EPOCH" era)) forMachine dtal (MirFailure f) = forMachine dtal f forMachine _dtal (CorruptRewardUpdate update) = mconcat [ "kind" .= String "CorruptRewardUpdate" - , "update" .= String (show update) ] + , "update" .= String (textShow update) ] instance ( LogFormatting (PredicateFailure (Core.EraRule "POOLREAP" era)) @@ -965,7 +965,7 @@ instance ( Ledger.Era era , Show (PredicateFailure (Ledger.EraRule "LEDGERS" era)) ) => LogFormatting (AlonzoBbodyPredFailure era) where forMachine _ err = mconcat [ "kind" .= String "AlonzoBbodyPredFail" - , "error" .= String (show err) + , "error" .= String (textShow err) ] -------------------------------------------------------------------------------- -- Babbage related @@ -1034,7 +1034,7 @@ instance Core.Crypto crypto => LogFormatting (Praos.PraosValidationErr crypto) w mconcat [ "kind" .= String "VRFKeyBadProof" , "slotNumberUsedInVrfCalculation" .= slotNo , "nonceUsedInVrfCalculation" .= nonce - , "calculatedVrfValue" .= String (show vrfCalculatedVal) + , "calculatedVrfValue" .= String (textShow vrfCalculatedVal) ] Praos.VRFLeaderValueTooBig leaderValue sigma f-> mconcat [ "kind" .= String "VRFLeaderValueTooBig" diff --git a/cardano-node/src/Cardano/Node/Tracing/Peers.hs b/cardano-node/src/Cardano/Node/Tracing/Peers.hs index e3d75380fac..3b01152d5ff 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Peers.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Peers.hs @@ -7,6 +7,7 @@ module Cardano.Node.Tracing.Peers ) where import Cardano.Prelude + import Data.Aeson (FromJSON, ToJSON) import Cardano.Logging @@ -41,4 +42,4 @@ traceNodePeers :: Trace IO NodePeers -> [PeerT blk] -> IO () -traceNodePeers tr ev = traceWith tr $ NodePeers (map ppPeer ev) +traceNodePeers tr ev = traceWith tr $ NodePeers (fmap ppPeer ev) diff --git a/cardano-node/src/Cardano/Node/Tracing/StateRep.hs b/cardano-node/src/Cardano/Node/Tracing/StateRep.hs index 5853ab4cc4e..44a53c527fe 100644 --- a/cardano-node/src/Cardano/Node/Tracing/StateRep.hs +++ b/cardano-node/src/Cardano/Node/Tracing/StateRep.hs @@ -19,11 +19,15 @@ module Cardano.Node.Tracing.StateRep , traceNodeStateShutdown ) where +import Cardano.Api (textShow) + import Cardano.Logging -import Cardano.Prelude + import Data.Aeson +import Data.Text (Text) import Data.Time.Clock import Data.Time.Clock.POSIX +import GHC.Generics (Generic) import Cardano.Node.Protocol.Types (SomeConsensusProtocol (..)) import qualified Ouroboros.Consensus.Block.RealPoint as RP @@ -244,7 +248,7 @@ traceNodeStateStartup traceNodeStateStartup tr ev = case ev of Startup.StartupSocketConfigError e -> - traceWith tr $ NodeStartup $ StartupSocketConfigError (show e) + traceWith tr $ NodeStartup $ StartupSocketConfigError (textShow e) Startup.StartupDBValidation -> traceWith tr $ NodeStartup StartupDBValidation Startup.NetworkConfigUpdate -> diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs index f820515dbf7..b117d973675 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers.hs @@ -13,9 +13,9 @@ module Cardano.Node.Tracing.Tracers ) where import Codec.CBOR.Read (DeserialiseFailure) +import Data.Proxy (Proxy (..)) import Cardano.Logging -import Cardano.Prelude hiding (trace) import Cardano.Node.Tracing.Formatting () import Cardano.Node.Tracing.Tracers.BlockReplayProgress diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/BlockReplayProgress.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/BlockReplayProgress.hs index f03ab8f268f..e964d224419 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/BlockReplayProgress.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/BlockReplayProgress.hs @@ -5,11 +5,13 @@ module Cardano.Node.Tracing.Tracers.BlockReplayProgress , ReplayBlockStats(..) ) where +import Control.Monad.IO.Class (MonadIO) import Data.Aeson (Value (String), (.=)) import Data.Text (pack) +import Cardano.Api (textShow) + import Cardano.Logging -import Cardano.Prelude import Ouroboros.Consensus.Block (realPointSlot) import Ouroboros.Network.Block (pointSlot, unSlotNo) @@ -37,7 +39,7 @@ instance LogFormatting ReplayBlockStats where [ "kind" .= String "ReplayBlockStats" , "progress" .= String (pack $ show rpsProgress) ] - forHuman ReplayBlockStats {..} = "Block replay progress " <> show rpsProgress <> "%" + forHuman ReplayBlockStats {..} = "Block replay progress " <> textShow rpsProgress <> "%" asMetrics ReplayBlockStats {..} = [DoubleM "ChainDB.BlockReplayProgress" rpsProgress] diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs index a8040955ffe..ba5cfcf6da6 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/Consensus.hs @@ -24,13 +24,14 @@ module Cardano.Node.Tracing.Tracers.Consensus import Control.Monad.Class.MonadTime (Time (..)) import Data.Aeson (ToJSON, Value (Number, String), toJSON, (.=)) import qualified Data.Aeson as Aeson +import Data.Foldable (Foldable (..)) +import Data.Int (Int64) import Data.IntPSQ (IntPSQ) import qualified Data.IntPSQ as Pq import Data.SOP.Strict import qualified Data.Text as Text import Data.Time (DiffTime, NominalDiffTime) -import Text.Show - +import Data.Word (Word32, Word64) import Cardano.Slotting.Slot (WithOrigin (..)) @@ -42,7 +43,6 @@ import Cardano.Node.Tracing.Formatting () import Cardano.Node.Tracing.Render import Cardano.Node.Tracing.Tracers.ConsensusStartupException () import Cardano.Node.Tracing.Tracers.StartLeadershipCheck -import Cardano.Prelude hiding (All, Show, show) import Cardano.Protocol.TPraos.OCert (KESPeriod (..)) @@ -58,7 +58,6 @@ import Ouroboros.Network.KeepAlive (TraceKeepAliveClient (..)) import Ouroboros.Network.TxSubmission.Inbound hiding (txId) import Ouroboros.Network.TxSubmission.Outbound - import Ouroboros.Consensus.Block import Ouroboros.Consensus.BlockchainTime (SystemStart (..)) import Ouroboros.Consensus.BlockchainTime.WallClock.Util (TraceBlockchainTimeEvent (..)) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/ConsensusStartupException.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/ConsensusStartupException.hs index 63fe551e2d8..0b5ad06cad6 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/ConsensusStartupException.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/ConsensusStartupException.hs @@ -6,13 +6,11 @@ module Cardano.Node.Tracing.Tracers.ConsensusStartupException ( ConsensusStartupException (..) ) where -import Cardano.Prelude hiding (Show, show) - import Data.Aeson (Value (String), (.=)) import qualified Data.Text as Text -import Text.Show import Cardano.Logging.Types +import Control.Exception (SomeException) -- | Exceptions logged when the consensus is initialising. -- diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Diffusion.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Diffusion.hs index 2574a85a9b6..e7aadec69dd 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Diffusion.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/Diffusion.hs @@ -10,15 +10,14 @@ module Cardano.Node.Tracing.Tracers.Diffusion () where import Cardano.Logging -import Cardano.Prelude hiding (Show, show) import Data.Aeson (Value (String), (.=)) import Data.Text (pack) import Network.Mux (MuxTrace (..), WithMuxBearer (..)) import Network.TypedProtocol.Codec (AnyMessageAndAgency (..)) -import Text.Show import Cardano.Node.Configuration.TopologyP2P (UseLedger (..)) +import qualified Data.List as List import qualified Ouroboros.Network.Diffusion as ND import qualified Ouroboros.Network.NodeToNode as NtN import Ouroboros.Network.PeerSelection.LedgerPeers (NumberOfPeers (..), PoolStake (..), @@ -477,7 +476,7 @@ instance LogFormatting TraceLedgerPeers where mconcat [ "kind" .= String "PickedPeers" , "desiredCount" .= n - , "count" .= length addrs + , "count" .= List.length addrs , "addresses" .= show addrs ] forMachine _dtal (FetchingNewLedgerState cnt) = diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/ForgingThreadStats.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/ForgingThreadStats.hs index 0de411a4082..d68927a36bc 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/ForgingThreadStats.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/ForgingThreadStats.hs @@ -49,11 +49,11 @@ instance LogFormatting ForgeThreadStats where <> " last slot " <> showT ftsLastSlot forMachine _dtal ForgeThreadStats {..} = mconcat [ "kind" .= String "ForgeThreadStats" - , "nodeCannotForgeNum" .= String (show ftsNodeCannotForgeNum) - , "nodeIsLeaderNum" .= String (show ftsNodeIsLeaderNum) - , "blocksForgedNum" .= String (show ftsBlocksForgedNum) - , "slotsMissed" .= String (show ftsSlotsMissedNum) - , "lastSlot" .= String (show ftsLastSlot) + , "nodeCannotForgeNum" .= String (showT ftsNodeCannotForgeNum) + , "nodeIsLeaderNum" .= String (showT ftsNodeIsLeaderNum) + , "blocksForgedNum" .= String (showT ftsBlocksForgedNum) + , "slotsMissed" .= String (showT ftsSlotsMissedNum) + , "lastSlot" .= String (showT ftsLastSlot) ] asMetrics ForgeThreadStats {..} = [ IntM "Forge.NodeCannotForgeNum" (fromIntegral ftsNodeCannotForgeNum) @@ -91,10 +91,10 @@ instance LogFormatting ForgingStats where <> " slots missed " <> showT fsSlotsMissedNum forMachine _dtal ForgingStats {..} = mconcat [ "kind" .= String "ForgingStats" - , "nodeCannotForgeNum" .= String (show fsNodeCannotForgeNum) - , "nodeIsLeaderNum" .= String (show fsNodeIsLeaderNum) - , "blocksForgedNum" .= String (show fsBlocksForgedNum) - , "slotsMissed" .= String (show fsSlotsMissedNum) + , "nodeCannotForgeNum" .= String (showT fsNodeCannotForgeNum) + , "nodeIsLeaderNum" .= String (showT fsNodeIsLeaderNum) + , "blocksForgedNum" .= String (showT fsBlocksForgedNum) + , "slotsMissed" .= String (showT fsSlotsMissedNum) ] asMetrics ForgingStats {..} = [ IntM "Forge.NodeCannotForgeNum" (fromIntegral fsNodeCannotForgeNum) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToClient.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToClient.hs index 6149be8dc3d..790d6b15c00 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToClient.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToClient.hs @@ -15,7 +15,6 @@ import Cardano.Prelude hiding (Show, show) import Data.Aeson (Value (String), (.=)) import Data.Text (pack) import Network.TypedProtocol.Codec (AnyMessageAndAgency (..)) -import Text.Show import Ouroboros.Consensus.Ledger.Query (Query) import Ouroboros.Network.Driver.Simple (TraceSendRecv (..)) @@ -91,7 +90,7 @@ instance MetaTrace (AnyMessageAndAgency ps) => allNamespaces = let cn = allNamespaces :: [Namespace (AnyMessageAndAgency ps)] - in map (nsPrependInner "Send") cn ++ map (nsPrependInner "Receive") cn + in fmap (nsPrependInner "Send") cn ++ fmap (nsPrependInner "Receive") cn -- -------------------------------------------------------------------------------- diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToNode.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToNode.hs index 40492f02ce0..ae975bf5107 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToNode.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToNode.hs @@ -13,11 +13,10 @@ module Cardano.Node.Tracing.Tracers.NodeToNode ) where import Cardano.Logging -import Cardano.Prelude hiding (Show, show) import Data.Aeson (Value (String), toJSON, (.=)) +import Data.Proxy (Proxy (..)) import Data.Text (pack) import Network.TypedProtocol.Codec (AnyMessageAndAgency (..)) -import Text.Show import Cardano.Node.Queries (ConvertTxId) import Cardano.Node.Tracing.Render (renderHeaderHash, renderTxIdForDetails) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/NonP2P.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/NonP2P.hs index 0d4af0a7996..db078e08390 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/NonP2P.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/NonP2P.hs @@ -15,7 +15,6 @@ import Data.Aeson (Value (String), (.=)) import qualified Data.IP as IP import Data.Text (pack) import qualified Network.Socket as Socket -import Text.Show import Ouroboros.Network.NodeToNode (ErrorPolicyTrace (..)) import qualified Ouroboros.Network.NodeToNode as NtN @@ -89,7 +88,7 @@ instance MetaTrace tr => MetaTrace (WithIPList tr) where privacyFor ns (Just (WithIPList _ _ ev)) = privacyFor (nsCast ns) (Just ev) documentFor ns = documentFor (nsCast ns :: Namespace tr) - allNamespaces = map nsCast + allNamespaces = fmap nsCast (allNamespaces :: [Namespace tr]) instance MetaTrace tr => MetaTrace (WithDomainName tr) where @@ -104,7 +103,7 @@ instance MetaTrace tr => MetaTrace (WithDomainName tr) where privacyFor ns (Just (WithDomainName _ ev)) = privacyFor (nsCast ns) (Just ev) documentFor ns = documentFor (nsCast ns :: Namespace tr) - allNamespaces = map nsCast + allNamespaces = fmap nsCast (allNamespaces :: [Namespace tr]) instance MetaTrace (SubscriptionTrace adr) where @@ -334,7 +333,7 @@ instance MetaTrace tr => MetaTrace (NtN.WithAddr addr tr) where privacyFor ns (Just (NtN.WithAddr _ ev)) = privacyFor (nsCast ns) (Just ev) documentFor ns = documentFor (nsCast ns :: Namespace tr) - allNamespaces = map nsCast + allNamespaces = fmap nsCast (allNamespaces :: [Namespace tr]) instance MetaTrace NtN.ErrorPolicyTrace where diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/StartLeadershipCheck.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/StartLeadershipCheck.hs index efec8eae7dd..14e56636bd6 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/StartLeadershipCheck.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/StartLeadershipCheck.hs @@ -13,9 +13,11 @@ module Cardano.Node.Tracing.Tracers.StartLeadershipCheck import Cardano.Logging -import Cardano.Prelude import qualified "trace-dispatcher" Control.Tracer as T + +import Control.Concurrent.STM (atomically) import Data.IORef (readIORef) +import Data.Word (Word64) import qualified Ouroboros.Network.AnchoredFragment as AF import Ouroboros.Network.Block (BlockNo (..), blockNo, unBlockNo) diff --git a/cardano-node/src/Cardano/Tracing/Metrics.hs b/cardano-node/src/Cardano/Tracing/Metrics.hs index 3a2bdba290e..b1477077e1f 100644 --- a/cardano-node/src/Cardano/Tracing/Metrics.hs +++ b/cardano-node/src/Cardano/Tracing/Metrics.hs @@ -21,10 +21,13 @@ module Cardano.Tracing.Metrics , threadStatsProjection ) where -import Cardano.Prelude hiding (All, (:.:)) - +import Control.Concurrent (ThreadId, myThreadId) import Control.Concurrent.STM +import Control.Monad (join) +import Data.Functor (void) +import Data.Int (Int64) import Data.IORef (IORef, atomicModifyIORef', newIORef) +import Data.Map (Map) import qualified Data.Map.Strict as Map diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Byron.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Byron.hs index c4551be85ae..9ef153acec5 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Byron.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Byron.hs @@ -10,9 +10,10 @@ module Cardano.Tracing.OrphanInstances.Byron () where -import Cardano.Prelude +import Cardano.Api (textShow) import Data.Aeson (Value (..)) +import Data.ByteString (ByteString) import qualified Data.Set as Set import qualified Data.Text as Text @@ -47,22 +48,22 @@ instance ToObject ApplyMempoolPayloadErr where toObject _verb (MempoolTxErr utxoValidationErr) = mconcat [ "kind" .= String "MempoolTxErr" - , "error" .= String (show utxoValidationErr) + , "error" .= String (textShow utxoValidationErr) ] toObject _verb (MempoolDlgErr delegScheduleError) = mconcat [ "kind" .= String "MempoolDlgErr" - , "error" .= String (show delegScheduleError) + , "error" .= String (textShow delegScheduleError) ] toObject _verb (MempoolUpdateProposalErr iFaceErr) = mconcat [ "kind" .= String "MempoolUpdateProposalErr" - , "error" .= String (show iFaceErr) + , "error" .= String (textShow iFaceErr) ] toObject _verb (MempoolUpdateVoteErr iFaceErrr) = mconcat [ "kind" .= String "MempoolUpdateVoteErr" - , "error" .= String (show iFaceErrr) + , "error" .= String (textShow iFaceErrr) ] instance ToObject ByronLedgerUpdate where diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/HardFork.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/HardFork.hs index 4f49c371a3f..7a0158056bd 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/HardFork.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/HardFork.hs @@ -17,8 +17,6 @@ module Cardano.Tracing.OrphanInstances.HardFork () where -import Cardano.Prelude hiding (All) - import Data.Aeson import qualified Data.ByteString.Base16 as Base16 import qualified Data.ByteString.Short as SBS diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs index 41b1b76ef32..21ee18cafd8 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Shelley.hs @@ -17,13 +17,13 @@ module Cardano.Tracing.OrphanInstances.Shelley () where -import Cardano.Prelude - import Data.Aeson (Value (..), object) import qualified Data.Aeson as Aeson import qualified Data.Aeson.Key as Aeson import qualified Data.Aeson.Types as Aeson +import Data.Set (Set) import qualified Data.Set as Set +import Data.Text (Text) import qualified Data.Text as Text import Cardano.Api (textShow) @@ -32,11 +32,11 @@ import Cardano.Api.Orphans () import qualified Cardano.Api.Shelley as Api import Cardano.Ledger.Crypto (StandardCrypto) +import Cardano.Node.Tracing.Tracers.KESInfo () import Cardano.Slotting.Block (BlockNo (..)) import Cardano.Tracing.OrphanInstances.Common import Cardano.Tracing.OrphanInstances.Consensus () import Cardano.Tracing.Render (renderTxId) -import Cardano.Node.Tracing.Tracers.KESInfo () import Ouroboros.Consensus.Ledger.SupportsMempool (txId) import qualified Ouroboros.Consensus.Ledger.SupportsMempool as SupportsMempool @@ -501,14 +501,14 @@ instance ( ShelleyBasedEra era , "error" .= String "Too many asset ids in the tx output" ] -renderBadInputsUTxOErr :: Set (TxIn era) -> Aeson.Value +renderBadInputsUTxOErr :: Set (TxIn era) -> Aeson.Value renderBadInputsUTxOErr txIns | Set.null txIns = String "The transaction contains no inputs." | otherwise = String "The transaction contains inputs that do not exist in the UTxO set." renderValueNotConservedErr :: Show val => val -> val -> Aeson.Value renderValueNotConservedErr consumed produced = String $ - "This transaction consumed " <> show consumed <> " but produced " <> show produced + "This transaction consumed " <> textShow consumed <> " but produced " <> textShow produced instance Ledger.Era era => ToObject (ShelleyPpupPredFailure era) where toObject _verb (NonGenesisUpdatePPUP proposalKeys genesisKeys) = @@ -518,7 +518,7 @@ instance Ledger.Era era => ToObject (ShelleyPpupPredFailure era) where mconcat [ "kind" .= String "PPUpdateWrongEpoch" , "currentEpoch" .= currEpoch , "intendedEpoch" .= intendedEpoch - , "votingPeriod" .= String (show votingPeriod) + , "votingPeriod" .= String (textShow votingPeriod) ] toObject _verb (PVCannotFollowPPUP badPv) = mconcat [ "kind" .= String "PVCannotFollowPPUP" @@ -692,7 +692,7 @@ instance ( ToObject (PredicateFailure (Core.EraRule "EPOCH" era)) toObject verb (MirFailure f) = toObject verb f toObject _verb (CorruptRewardUpdate update) = mconcat [ "kind" .= String "CorruptRewardUpdate" - , "update" .= String (show update) ] + , "update" .= String (textShow update) ] instance ( ToObject (PredicateFailure (Core.EraRule "POOLREAP" era)) @@ -1010,24 +1010,24 @@ instance ToJSON (Alonzo.CollectError StandardCrypto) where String $ "Cannot construct a Plutus ScriptContext from this transaction " <> "due to a Byron UTxO being created or spent: " - <> show txOutSource + <> textShow txOutSource Alonzo.TranslationLogicMissingInput txin -> - String $ "Transaction input does not exist in the UTxO: " <> show txin + String $ "Transaction input does not exist in the UTxO: " <> textShow txin Alonzo.RdmrPtrPointsToNothing ptr -> object [ "kind" .= String "RedeemerPointerPointsToNothing" , "ptr" .= (Api.renderScriptWitnessIndex . Api.fromAlonzoRdmrPtr) ptr ] Alonzo.LanguageNotSupported lang -> - String $ "Language not supported: " <> show lang + String $ "Language not supported: " <> textShow lang Alonzo.InlineDatumsNotSupported txOutSource -> - String $ "Inline datums not supported, output source: " <> show txOutSource + String $ "Inline datums not supported, output source: " <> textShow txOutSource Alonzo.ReferenceScriptsNotSupported txOutSource -> - String $ "Reference scripts not supported, output source: " <> show txOutSource + String $ "Reference scripts not supported, output source: " <> textShow txOutSource Alonzo.ReferenceInputsNotSupported txins -> - String $ "Reference inputs not supported: " <> show txins + String $ "Reference inputs not supported: " <> textShow txins Alonzo.TimeTranslationPastHorizon msg -> - String $ "Time translation requested past the horizon: " <> show msg + String $ "Time translation requested past the horizon: " <> textShow msg ] instance ToJSON Alonzo.TagMismatchDescription where @@ -1058,7 +1058,7 @@ instance ( Ledger.Era era , Show (PredicateFailure (Ledger.EraRule "LEDGERS" era)) ) => ToObject (AlonzoBbodyPredFailure era) where toObject _ err = mconcat [ "kind" .= String "AlonzoBbodyPredFail" - , "error" .= String (show err) + , "error" .= String (textShow err) ] -------------------------------------------------------------------------------- @@ -1128,7 +1128,7 @@ instance Core.Crypto crypto => ToObject (Praos.PraosValidationErr crypto) where mconcat [ "kind" .= String "VRFKeyBadProof" , "slotNumberUsedInVrfCalculation" .= slotNo , "nonceUsedInVrfCalculation" .= nonce - , "calculatedVrfValue" .= String (show vrfCalculatedVal) + , "calculatedVrfValue" .= String (textShow vrfCalculatedVal) ] Praos.VRFLeaderValueTooBig leaderValue sigma f-> mconcat [ "kind" .= String "VRFLeaderValueTooBig" diff --git a/cardano-node/test/Test/Cardano/Node/FilePermissions.hs b/cardano-node/test/Test/Cardano/Node/FilePermissions.hs index a78429bebaf..b0970712047 100644 --- a/cardano-node/test/Test/Cardano/Node/FilePermissions.hs +++ b/cardano-node/test/Test/Cardano/Node/FilePermissions.hs @@ -11,6 +11,8 @@ module Test.Cardano.Node.FilePermissions ( tests ) where +import Control.Monad.Except +import Data.Foldable import System.Directory (removeFile) import Cardano.Api @@ -39,6 +41,7 @@ import System.Posix.Files import System.Posix.IO (closeFd, createFile) import System.Posix.Types (FileMode) +import Control.Exception (bracket) import Hedgehog (Gen, classify, forAll) import qualified Hedgehog.Gen as Gen #endif diff --git a/cardano-node/test/Test/Cardano/Node/Gen.hs b/cardano-node/test/Test/Cardano/Node/Gen.hs index a8febe88d6b..ff9fd552a8f 100644 --- a/cardano-node/test/Test/Cardano/Node/Gen.hs +++ b/cardano-node/test/Test/Cardano/Node/Gen.hs @@ -19,25 +19,26 @@ module Test.Cardano.Node.Gen import qualified Data.Aeson as Aeson import qualified Data.Aeson.KeyMap as Aeson.KeyMap -import qualified Data.Vector as Vector import qualified Data.ByteString.Lazy as LBS +import qualified Data.Vector as Vector -import Cardano.Prelude - -import Cardano.Node.Configuration.TopologyP2P (NetworkTopology (..), PublicRootPeers (..), - LocalRootPeersGroups (..), LocalRootPeersGroup (..), RootConfig (..), - NodeSetup (..), PeerAdvertise (..), UseLedger (..)) import Cardano.Node.Configuration.NodeAddress (NodeAddress' (..), NodeHostIPAddress (..), - NodeHostIPv4Address (..), NodeHostIPv6Address (..), - NodeIPAddress, NodeIPv4Address, NodeIPv6Address) + NodeHostIPv4Address (..), NodeHostIPv6Address (..), NodeIPAddress, + NodeIPv4Address, NodeIPv6Address) +import Cardano.Node.Configuration.TopologyP2P (LocalRootPeersGroup (..), + LocalRootPeersGroups (..), NetworkTopology (..), NodeSetup (..), + PeerAdvertise (..), PublicRootPeers (..), RootConfig (..), UseLedger (..)) import Cardano.Slotting.Slot (SlotNo (..)) import Ouroboros.Network.PeerSelection.LedgerPeers (UseLedgerAfter (..)) -import Ouroboros.Network.PeerSelection.RelayAccessPoint ( - DomainAccessPoint (..), RelayAccessPoint (..)) +import Ouroboros.Network.PeerSelection.RelayAccessPoint (DomainAccessPoint (..), + RelayAccessPoint (..)) import qualified Data.IP as IP +import Cardano.Api (textShow) + +import Data.Word (Word32) import Hedgehog (Gen) import Hedgehog.Corpus (cooking) import qualified Hedgehog.Gen as Gen @@ -60,7 +61,7 @@ genNetworkTopologyEncoding = Aeson.encode <$> genNetworkTopologyValue -- | Generate a Aeson.Object which encodes a p2p topology. -- genNetworkTopologyValue :: Gen Aeson.Object -genNetworkTopologyValue = +genNetworkTopologyValue = (\a b c -> Aeson.KeyMap.fromList [ ("localRoots", Aeson.Array . Vector.fromList $ a) , ("publicRoots", Aeson.Array . Vector.fromList $ b) @@ -83,7 +84,7 @@ genNetworkTopologyValue = genPublicRootsValue :: Gen Aeson.Value genPublicRootsValue = - (\a b -> Aeson.Object $ Aeson.KeyMap.fromList + (\a b -> Aeson.Object $ Aeson.KeyMap.fromList [ ("accessPoints", Aeson.Array . Vector.fromList $ a) , ("advertise", Aeson.Bool b) ] @@ -93,7 +94,7 @@ genNetworkTopologyValue = genAccessPointValue :: Gen Aeson.Value genAccessPointValue = (\a -> Aeson.Object $ Aeson.KeyMap.fromList - [ ("address", Aeson.String (show $ naHostAddress a)) + [ ("address", Aeson.String (textShow $ naHostAddress a)) , ("port", Aeson.Number (fromIntegral $ naPort a)) ] ) <$> genNodeIPAddress diff --git a/cardano-node/test/Test/Cardano/Node/POM.hs b/cardano-node/test/Test/Cardano/Node/POM.hs index a1f22f53f58..b31f0143951 100644 --- a/cardano-node/test/Test/Cardano/Node/POM.hs +++ b/cardano-node/test/Test/Cardano/Node/POM.hs @@ -5,8 +5,8 @@ module Test.Cardano.Node.POM ( tests ) where -import Cardano.Prelude - +import Data.Monoid (Last (..)) +import Data.Text (Text) import Data.Time.Clock (secondsToDiffTime) import Cardano.Node.Configuration.POM diff --git a/cardano-node/test/cardano-node-test.hs b/cardano-node/test/cardano-node-test.hs index c17c493db9a..358b3ea6cff 100644 --- a/cardano-node/test/cardano-node-test.hs +++ b/cardano-node/test/cardano-node-test.hs @@ -4,7 +4,6 @@ #define UNIX #endif -import Cardano.Prelude import Hedgehog.Main (defaultMain) #ifdef UNIX From 4d46764dfb3a22602802aed854ab1de4d9adeb54 Mon Sep 17 00:00:00 2001 From: John Ky Date: Mon, 13 Feb 2023 07:08:45 +1100 Subject: [PATCH 7/7] Remove NoImplicitPrelude and avoid import of Cardano.Prelude where possible. --- cardano-cli/cardano-cli.cabal | 3 +- cardano-cli/src/Cardano/CLI/Byron/Commands.hs | 6 +-- cardano-cli/src/Cardano/CLI/Byron/Genesis.hs | 17 ++++++-- cardano-cli/src/Cardano/CLI/Byron/Key.hs | 8 ++-- cardano-cli/src/Cardano/CLI/Byron/Parsers.hs | 19 +++++---- cardano-cli/src/Cardano/CLI/Byron/Tx.hs | 20 +++++---- cardano-cli/src/Cardano/CLI/Helpers.hs | 22 ++++++---- cardano-cli/src/Cardano/CLI/Parsers.hs | 4 +- cardano-cli/src/Cardano/CLI/Render.hs | 8 ++-- cardano-cli/src/Cardano/CLI/Shelley/Key.hs | 4 +- .../src/Cardano/CLI/Shelley/Parsers.hs | 17 ++++++-- cardano-cli/src/Cardano/CLI/Shelley/Run.hs | 5 ++- .../src/Cardano/CLI/Shelley/Run/Address.hs | 6 +-- .../src/Cardano/CLI/Shelley/Run/Genesis.hs | 42 +++++++++++++------ .../src/Cardano/CLI/Shelley/Run/Key.hs | 16 +++---- .../src/Cardano/CLI/Shelley/Run/Node.hs | 10 ++--- .../src/Cardano/CLI/Shelley/Run/Query.hs | 35 ++++++++++------ .../src/Cardano/CLI/Shelley/Run/TextView.hs | 8 ++-- .../Cardano/CLI/Shelley/Run/Transaction.hs | 37 +++++++++------- .../test/Test/Cli/CliIntermediateFormat.hs | 3 +- cardano-cli/test/Test/Cli/JSON.hs | 5 +-- cardano-cli/test/Test/Golden/Byron/TxBody.hs | 3 +- cardano-cli/test/Test/Golden/Byron/Witness.hs | 3 +- .../test/Test/Golden/Shelley/Address/Info.hs | 3 +- .../Test/Golden/Shelley/Genesis/Create.hs | 7 +++- .../Golden/Shelley/TextEnvelope/Tx/Witness.hs | 3 +- .../Golden/Shelley/Transaction/Assemble.hs | 3 +- .../Test/Golden/Shelley/Transaction/Build.hs | 3 +- .../Shelley/Transaction/CreateWitness.hs | 4 +- .../Test/Golden/Shelley/Transaction/Sign.hs | 2 +- cardano-cli/test/Test/Golden/TxView.hs | 2 +- cardano-cli/test/Test/Golden/Version.hs | 3 +- cardano-cli/test/Test/OptParse.hs | 20 ++++----- cardano-cli/test/Test/Utilities.hs | 6 +-- cardano-git-rev/cardano-git-rev.cabal | 4 +- cardano-git-rev/src/Cardano/Git/Rev.hs | 4 +- cardano-git-rev/src/Cardano/Git/RevFromGit.hs | 5 +-- cardano-node-chairman/app/Cardano/Chairman.hs | 15 ++++--- cardano-node/app/cardano-node.hs | 8 ++-- cardano-node/cardano-node.cabal | 4 +- .../Cardano/Node/Configuration/NodeAddress.hs | 4 +- .../src/Cardano/Node/Configuration/POM.hs | 9 ++-- .../Cardano/Node/Configuration/Topology.hs | 13 +++--- .../Cardano/Node/Configuration/TopologyP2P.hs | 13 +++--- cardano-node/src/Cardano/Node/Orphans.hs | 7 +--- cardano-node/src/Cardano/Node/Parsers.hs | 8 +++- cardano-node/src/Cardano/Node/Protocol.hs | 3 +- .../src/Cardano/Node/Protocol/Alonzo.hs | 9 ++-- .../src/Cardano/Node/Protocol/Shelley.hs | 8 ++-- .../src/Cardano/Node/Protocol/Types.hs | 4 +- cardano-node/src/Cardano/Node/Run.hs | 32 ++++++++++---- cardano-node/src/Cardano/Node/Tracing/API.hs | 2 +- .../src/Cardano/Node/Tracing/Documentation.hs | 4 +- .../src/Cardano/Node/Tracing/Formatting.hs | 4 +- .../src/Cardano/Node/Tracing/Peers.hs | 4 +- .../src/Cardano/Node/Tracing/Render.hs | 5 +-- .../Cardano/Node/Tracing/Tracers/ChainDB.hs | 9 ++-- .../Tracing/Tracers/ForgingThreadStats.hs | 6 ++- .../Cardano/Node/Tracing/Tracers/KESInfo.hs | 4 +- .../Node/Tracing/Tracers/NodeToClient.hs | 4 +- .../Cardano/Node/Tracing/Tracers/NonP2P.hs | 3 +- .../src/Cardano/Node/Tracing/Tracers/P2P.hs | 5 +-- .../src/Cardano/Node/Tracing/Tracers/Peer.hs | 20 +++++---- .../Cardano/Node/Tracing/Tracers/Resources.hs | 9 +++- cardano-node/src/Cardano/Node/Types.hs | 8 ++-- cardano-node/src/Cardano/Tracing/Config.hs | 11 +++-- .../Cardano/Tracing/OrphanInstances/Common.hs | 9 ++-- .../Tracing/OrphanInstances/Consensus.hs | 18 ++++---- .../Tracing/OrphanInstances/Network.hs | 10 +++-- cardano-node/src/Cardano/Tracing/Peer.hs | 17 ++++---- cardano-node/src/Cardano/Tracing/Render.hs | 5 +-- cardano-node/src/Cardano/Tracing/Tracers.hs | 12 ++++-- cardano-node/test/Test/Cardano/Node/Json.hs | 2 +- 73 files changed, 402 insertions(+), 276 deletions(-) diff --git a/cardano-cli/cardano-cli.cabal b/cardano-cli/cardano-cli.cabal index 7b5b1e94bbb..bd755948e9a 100644 --- a/cardano-cli/cardano-cli.cabal +++ b/cardano-cli/cardano-cli.cabal @@ -119,10 +119,12 @@ library , cborg >= 0.2.4 && < 0.3 , containers , cryptonite + , deepseq , directory , filepath , formatting , iproute + , mtl , network , optparse-applicative-fork , ouroboros-consensus @@ -174,7 +176,6 @@ test-suite cardano-cli-test , cardano-api:gen , cardano-cli , cardano-node - , cardano-prelude , cardano-slotting ^>= 0.1 , containers , directory diff --git a/cardano-cli/src/Cardano/CLI/Byron/Commands.hs b/cardano-cli/src/Cardano/CLI/Byron/Commands.hs index 579135e6cbe..22a12acc507 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Commands.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Commands.hs @@ -9,12 +9,12 @@ module Cardano.CLI.Byron.Commands , NewCertificateFile (..) ) where -import Cardano.Prelude +import Data.String (IsString) import Cardano.Chain.Update (InstallerHash (..), ProtocolVersion (..), - SoftwareVersion (..), SystemTag (..)) + SoftwareVersion (..), SystemTag (..)) -import Cardano.Api hiding (GenesisParameters) +import Cardano.Api hiding (GenesisParameters) import Cardano.Api.Byron hiding (GenesisParameters) import Cardano.CLI.Byron.Genesis diff --git a/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs b/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs index f70ea3cca01..01096671b20 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Genesis.hs @@ -12,12 +12,21 @@ module Cardano.CLI.Byron.Genesis ) where -import Cardano.Prelude hiding (show, trace) -import Prelude (String) +import Cardano.Prelude (canonicalDecodePretty, canonicalEncodePretty) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans (MonadTrans (..)) +import Control.Monad.Trans.Except (ExceptT (..), withExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, left, right) +import Data.ByteString (ByteString) import qualified Data.ByteString.Lazy as LB +import qualified Data.List as List +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map +import Data.String (IsString) +import Data.Text (Text) +import qualified Data.Text.Encoding as Text +import Data.Text.Lazy (toStrict) import Data.Text.Lazy.Builder (toLazyText) import Data.Time (UTCTime) import Formatting.Buildable @@ -187,7 +196,7 @@ dumpGenesis (NewDirectory outDir) genesisData gs = do findDelegateCert :: SigningKey ByronKey -> ExceptT ByronGenesisError IO Certificate findDelegateCert bSkey@(ByronSigningKey sk) = - case find (isCertForSK sk) (Map.elems dlgCertMap) of + case List.find (isCertForSK sk) (Map.elems dlgCertMap) of Nothing -> left . NoGenesisDelegationForKey . prettyPublicKey $ getVerificationKey bSkey Just x -> right x @@ -196,7 +205,7 @@ dumpGenesis (NewDirectory outDir) genesisData gs = do genesisJSONFile = outDir <> "/genesis.json" printFakeAvvmSecrets :: Crypto.RedeemSigningKey -> ByteString - printFakeAvvmSecrets rskey = encodeUtf8 . toStrict . toLazyText $ build rskey + printFakeAvvmSecrets rskey = Text.encodeUtf8 . toStrict . toLazyText $ build rskey -- Compare a given 'SigningKey' with a 'Certificate' 'VerificationKey' isCertForSK :: Crypto.SigningKey -> Certificate -> Bool diff --git a/cardano-cli/src/Cardano/CLI/Byron/Key.hs b/cardano-cli/src/Cardano/CLI/Byron/Key.hs index 81929fdf16b..17ab0906f57 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Key.hs @@ -14,14 +14,14 @@ module Cardano.CLI.Byron.Key ) where -import Cardano.Prelude hiding (show, trace, (%)) -import Prelude (show) - +import Control.Exception (Exception (..)) +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT, hoistEither, left, right) import qualified Data.ByteString as SB import qualified Data.ByteString.UTF8 as UTF8 -import Data.String (fromString) +import Data.String (IsString, fromString) +import Data.Text (Text) import qualified Data.Text as T import Formatting (build, sformat, (%)) diff --git a/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs b/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs index a7951652e2e..ba8d25876fa 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Parsers.hs @@ -21,19 +21,22 @@ module Cardano.CLI.Byron.Parsers , parseUpdateVoteThd ) where -import Cardano.Prelude -import Prelude (String) +import Cardano.Prelude (ConvertText (..)) -import Control.Monad (fail) +import Control.Monad (when) import qualified Data.Attoparsec.ByteString.Char8 as Atto import Data.Attoparsec.Combinator (()) import qualified Data.ByteString.Char8 as BSC import qualified Data.ByteString.Lazy.Char8 as C8 import qualified Data.Char as Char -import qualified Data.Text as Text +import Data.Foldable +import Data.Text (Text) import Data.Time (UTCTime) import Data.Time.Clock.POSIX (posixSecondsToUTCTime) +import Data.Word (Word16, Word64) import Formatting (build, sformat) +import GHC.Natural (Natural) +import GHC.Word (Word8) import Options.Applicative import qualified Options.Applicative as Opt @@ -301,13 +304,13 @@ parseTxOut = pAddressInEra :: Text -> AddressInEra ByronEra pAddressInEra t = case decodeAddressBase58 t of - Left err -> panic $ "Bad Base58 address: " <> Text.pack (show err) + Left err -> error $ "Bad Base58 address: " <> show err Right byronAddress -> AddressInEra ByronAddressInAnyEra $ ByronAddress byronAddress pLovelaceTxOut :: Word64 -> TxOutValue ByronEra pLovelaceTxOut l = if l > (maxBound :: Word64) - then panic $ show l <> " lovelace exceeds the Word64 upper bound" + then error $ show l <> " lovelace exceeds the Word64 upper bound" else TxOutAdaOnly AdaOnlyInByronEra . Lovelace $ toInteger l readerFromAttoParser :: Atto.Parser a -> Opt.ReadM a @@ -706,7 +709,7 @@ parseUTCTime optname desc = cliParseBase58Address :: Text -> Address ByronAddr cliParseBase58Address t = case decodeAddressBase58 t of - Left err -> panic $ "Bad Base58 address: " <> Text.pack (show err) + Left err -> error $ "Bad Base58 address: " <> show err Right byronAddress -> ByronAddress byronAddress parseFraction :: String -> String -> Parser Rational @@ -735,7 +738,7 @@ parseLovelace optname desc = then fail $ show i <> " lovelace exceeds the Word64 upper bound" else case toByronLovelace (Lovelace i) of Just byronLovelace -> return byronLovelace - Nothing -> panic $ "Error converting lovelace: " <> Text.pack (show i) + Nothing -> error $ "Error converting lovelace: " <> show i readDouble :: ReadM Double readDouble = do diff --git a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs index 9e583872f9c..0c721f4ca2e 100644 --- a/cardano-cli/src/Cardano/CLI/Byron/Tx.hs +++ b/cardano-cli/src/Cardano/CLI/Byron/Tx.hs @@ -22,15 +22,21 @@ module Cardano.CLI.Byron.Tx ) where -import Cardano.Prelude hiding (trace, (%)) -import Prelude (error) - +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, left, newExceptT) +import Data.Bifunctor (Bifunctor (..)) +import Data.ByteString (ByteString) import qualified Data.ByteString as B import qualified Data.ByteString.Lazy as LB +import qualified Data.List as List +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map -import qualified Data.Text as T +import Data.Maybe (fromMaybe, mapMaybe) +import Data.String (IsString) +import Data.Text (Text) import qualified Data.Text as Text +import qualified Data.Text.IO as Text import Formatting (sformat, (%)) import Cardano.Api @@ -128,9 +134,9 @@ genesisUTxOTxIn gc vk genAddr = handleMissingAddr :: Maybe UTxO.TxIn -> UTxO.TxIn handleMissingAddr = fromMaybe . error $ "\nGenesis UTxO has no address\n" - <> T.unpack (prettyAddress (ByronAddress genAddr)) + <> Text.unpack (prettyAddress (ByronAddress genAddr)) <> "\n\nIt has the following, though:\n\n" - <> Cardano.Prelude.concat (T.unpack . prettyAddress <$> map ByronAddress (Map.keys initialUtxo)) + <> List.concatMap (Text.unpack . prettyAddress . ByronAddress) (Map.keys initialUtxo) -- | Generate a transaction spending genesis UTxO at a given address, -- to given outputs, signed by the given key. @@ -233,7 +239,7 @@ nodeSubmitTx network gentx = do } res <- liftIO $ submitTxToNodeLocal connctInfo (TxInByronSpecial gentx ByronEraInCardanoMode) case res of - Net.Tx.SubmitSuccess -> liftIO $ putTextLn "Transaction successfully submitted." + Net.Tx.SubmitSuccess -> liftIO $ Text.putStrLn "Transaction successfully submitted." Net.Tx.SubmitFail reason -> case reason of TxValidationErrorInMode err _eraInMode -> left . ByronTxSubmitError . Text.pack $ show err diff --git a/cardano-cli/src/Cardano/CLI/Helpers.hs b/cardano-cli/src/Cardano/CLI/Helpers.hs index 0a21c25b5a0..0abb0965666 100644 --- a/cardano-cli/src/Cardano/CLI/Helpers.hs +++ b/cardano-cli/src/Cardano/CLI/Helpers.hs @@ -14,8 +14,7 @@ module Cardano.CLI.Helpers , hushM ) where -import Cardano.Prelude -import Prelude (String) +import Cardano.Prelude (ConvertText (..)) import Codec.CBOR.Pretty (prettyHexEnc) import Codec.CBOR.Read (DeserialiseFailure, deserialiseFromBytes) @@ -35,6 +34,15 @@ import qualified Cardano.Chain.Update as Update import qualified Cardano.Chain.UTxO as UTxO import Cardano.CLI.Types +import Control.Exception (Exception (..), IOException) +import Control.Monad (unless, when) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) +import Data.Bifunctor (Bifunctor (..)) +import Data.ByteString (ByteString) +import Data.Functor (void) +import Data.Text (Text) +import qualified Data.Text.IO as Text import qualified System.Directory as IO data HelpersError @@ -55,7 +63,7 @@ renderHelpersError err = IOError' fp ioE -> "Error at: " <> Text.pack fp <> " Error: " <> Text.pack (show ioE) decodeCBOR - :: LByteString + :: LB.ByteString -> (forall s. Decoder s a) -> Either HelpersError (LB.ByteString, a) decodeCBOR bs decoder = @@ -85,22 +93,22 @@ ensureNewFile writer outFile blob = do ensureNewFileLBS :: FilePath -> ByteString -> ExceptT HelpersError IO () ensureNewFileLBS = ensureNewFile BS.writeFile -pPrintCBOR :: LByteString -> ExceptT HelpersError IO () +pPrintCBOR :: LB.ByteString -> ExceptT HelpersError IO () pPrintCBOR bs = do case deserialiseFromBytes decodeTerm bs of Left err -> left $ CBORPrettyPrintError err Right (remaining, decodedVal) -> do - liftIO . putTextLn . toS . prettyHexEnc $ encodeTerm decodedVal + liftIO . Text.putStrLn . toS . prettyHexEnc $ encodeTerm decodedVal unless (LB.null remaining) $ pPrintCBOR remaining -readCBOR :: FilePath -> ExceptT HelpersError IO LByteString +readCBOR :: FilePath -> ExceptT HelpersError IO LB.ByteString readCBOR fp = handleIOExceptT (ReadCBORFileFailure fp . toS . displayException) (LB.readFile fp) -validateCBOR :: CBORObject -> LByteString -> Either HelpersError Text +validateCBOR :: CBORObject -> LB.ByteString -> Either HelpersError Text validateCBOR cborObject bs = case cborObject of CBORBlockByron epochSlots -> do diff --git a/cardano-cli/src/Cardano/CLI/Parsers.hs b/cardano-cli/src/Cardano/CLI/Parsers.hs index 631c7d932c2..59f4613de28 100644 --- a/cardano-cli/src/Cardano/CLI/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Parsers.hs @@ -12,9 +12,9 @@ import Cardano.CLI.Byron.Parsers (backwardsCompatibilityCommands, pars import Cardano.CLI.Render (customRenderHelp) import Cardano.CLI.Run (ClientCommand (..)) import Cardano.CLI.Shelley.Parsers (parseShelleyCommands) -import Cardano.Prelude + +import Data.Foldable import Options.Applicative -import Prelude (String) import qualified Options.Applicative as Opt diff --git a/cardano-cli/src/Cardano/CLI/Render.hs b/cardano-cli/src/Cardano/CLI/Render.hs index 14152632e4b..7d6b8b339ee 100644 --- a/cardano-cli/src/Cardano/CLI/Render.hs +++ b/cardano-cli/src/Cardano/CLI/Render.hs @@ -4,12 +4,10 @@ module Cardano.CLI.Render ( customRenderHelp ) where -import Cardano.Prelude -import Data.Function (id) +import Data.Text (Text) import Options.Applicative import Options.Applicative.Help.Ann import Options.Applicative.Help.Types (helpText, renderHelp) -import Prelude (String) import Prettyprinter import Prettyprinter.Render.Util.SimpleDocTree @@ -17,6 +15,8 @@ import qualified Data.Text as T import qualified System.Environment as IO import qualified System.IO.Unsafe as IO +import Cardano.Api (textShow) + cliHelpTraceEnabled :: Bool cliHelpTraceEnabled = IO.unsafePerformIO $ do mValue <- IO.lookupEnv "CLI_HELP_TRACE" @@ -44,7 +44,7 @@ customRenderHelpAsHtml cols renderElement :: Ann -> Text -> Text renderElement ann x = if cliHelpTraceEnabled then case ann of - AnnTrace _ name -> "" <> x <> "" + AnnTrace _ name -> "" <> x <> "" AnnStyle _ -> x else x wrapper = if cliHelpTraceEnabled diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Key.hs b/cardano-cli/src/Cardano/CLI/Shelley/Key.hs index e4c35287584..762a042a0a7 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Key.hs @@ -26,10 +26,12 @@ module Cardano.CLI.Shelley.Key ) where import Cardano.Api -import Cardano.Prelude +import Control.Monad.IO.Class (MonadIO (..)) +import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString as BS import qualified Data.List.NonEmpty as NE +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs index ee527378683..c3e0358551f 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Parsers.hs @@ -14,22 +14,30 @@ module Cardano.CLI.Shelley.Parsers , parseTxIn ) where -import Cardano.Prelude hiding (All, Any) -import Prelude (String) +import Cardano.Prelude (ConvertText (..)) -import Control.Monad.Fail (fail) import qualified Data.Aeson as Aeson import qualified Data.Aeson.Parser as Aeson.Parser import qualified Data.Attoparsec.ByteString.Char8 as Atto +import Data.Bifunctor +import Data.ByteString (ByteString) import qualified Data.ByteString.Base16 as B16 import qualified Data.ByteString.Char8 as BSC +import Data.Foldable +import Data.Functor (($>)) import qualified Data.IP as IP +import Data.List.NonEmpty (NonEmpty) import qualified Data.List.NonEmpty as NE +import Data.Maybe (fromMaybe) +import Data.Ratio ((%)) import qualified Data.Set as Set +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text import Data.Time.Clock (UTCTime) import Data.Time.Format (defaultTimeLocale, parseTimeOrError) +import Data.Word (Word64) +import GHC.Natural (Natural) import Network.Socket (PortNumber) import Options.Applicative hiding (help, str) import qualified Options.Applicative as Opt @@ -41,6 +49,7 @@ import qualified Text.Parsec.Error as Parsec import qualified Text.Parsec.Language as Parsec import qualified Text.Parsec.String as Parsec import qualified Text.Parsec.Token as Parsec +import Text.Read (readEither, readMaybe) import qualified Cardano.Ledger.BaseTypes as Shelley import qualified Cardano.Ledger.Shelley.TxBody as Shelley @@ -2799,7 +2808,7 @@ pSingleHostAddress = singleHostAddress singleHostAddress ipv4 ipv6 port = case (ipv4, ipv6) of (Nothing, Nothing) -> - panic "Please enter either an IPv4 or IPv6 address for the pool relay" + error "Please enter either an IPv4 or IPv6 address for the pool relay" (Just i4, Nothing) -> StakePoolRelayIp (Just i4) Nothing (Just port) (Nothing, Just i6) -> diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run.hs index 1af3a805893..bdab475dd8c 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run.hs @@ -4,6 +4,9 @@ module Cardano.CLI.Shelley.Run , runShelleyClientCommand ) where +import Control.Monad.Trans.Except (ExceptT) +import Data.Text (Text) + import Cardano.Api import Control.Monad.Trans.Except.Extra (firstExceptT) @@ -22,8 +25,6 @@ import Cardano.CLI.Shelley.Run.Transaction -- Block, System, DevOps import Cardano.CLI.Shelley.Run.Genesis import Cardano.CLI.Shelley.Run.TextView -import Cardano.Prelude (ExceptT) -import Data.Text (Text) data ShelleyClientCmdError = ShelleyCmdAddressError !ShelleyAddressCmdError diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs index 6e2b891cc85..91c921475ba 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Address.hs @@ -11,8 +11,11 @@ module Cardano.CLI.Shelley.Run.Address , makeStakeAddressRef ) where +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, left, newExceptT) import qualified Data.ByteString.Char8 as BS +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.IO as Text @@ -27,9 +30,6 @@ import Cardano.CLI.Shelley.Parsers (AddressCmd (..), AddressKeyType (. import Cardano.CLI.Shelley.Run.Address.Info (ShelleyAddressInfoError, runAddressInfo) import Cardano.CLI.Shelley.Run.Read import Cardano.CLI.Types -import Cardano.Prelude (MonadIO (..)) -import Control.Monad.Trans.Except (ExceptT) -import Data.Text (Text) data ShelleyAddressCmdError = ShelleyAddressCmdAddressInfoError !ShelleyAddressInfoError diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs index ac965110c71..dd9309e3129 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Genesis.hs @@ -30,28 +30,47 @@ module Cardano.CLI.Shelley.Run.Genesis , readProtocolParametersSourceSpec ) where -import Cardano.Prelude hiding (unlines) -import Prelude (String, error, id, unlines, zip3) - +import Control.DeepSeq (NFData, force) +import Control.Exception (IOException) +import Control.Monad (forM, forM_, unless, when) +import Control.Monad.Except (MonadError (..), runExceptT) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT, throwE, withExceptT) import Data.Aeson hiding (Key) import qualified Data.Aeson as Aeson import Data.Aeson.Encode.Pretty (encodePretty) import qualified Data.Aeson.KeyMap as Aeson +import Data.Bifunctor (Bifunctor (..)) import qualified Data.Binary.Get as Bin +import Data.ByteString (ByteString) import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Char (isDigit) import Data.Coerce (coerce) +import Data.Data (Proxy (..)) +import Data.Either (fromRight) +import Data.Function (on) +import Data.Functor (void) +import Data.Functor.Identity import qualified Data.List as List import qualified Data.List.Split as List import qualified Data.ListMap as ListMap +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map - +import Data.Maybe (fromMaybe) import qualified Data.Sequence.Strict as Seq import Data.String (fromString) +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.IO as Text import Data.Time.Clock (NominalDiffTime, UTCTime, addUTCTime, getCurrentTime, secondsToNominalDiffTime) +import Data.Word (Word64) +import GHC.Generics (Generic) +import qualified System.IO as IO +import qualified System.Random as Random +import System.Random (StdGen) +import Text.Read (readMaybe) import Cardano.Binary (Annotated (Annotated), ToCBOR (..)) @@ -122,8 +141,7 @@ import Data.ListMap (ListMap (..)) import qualified Cardano.CLI.IO.Lazy as Lazy -import qualified System.Random as Random -import System.Random (StdGen) +import Cardano.Prelude (canonicalEncodePretty) data ShelleyGenesisCmdError = ShelleyGenesisCmdAesonDecodeError !FilePath !Text @@ -457,7 +475,7 @@ generateShelleyNodeSecrets shelleyDelegateKeys shelleyGenesisvkeys = do opCertInputs :: [(VerificationKey KesKey, SigningKey GenesisDelegateExtendedKey)] opCertInputs = zip (map getVerificationKey kesKeys) shelleyDelegateKeys createOpCert :: (VerificationKey KesKey, SigningKey GenesisDelegateExtendedKey) -> (OperationalCertificate, OperationalCertificateIssueCounter) - createOpCert (kesKey, delegateKey) = either (error . show) identity eResult + createOpCert (kesKey, delegateKey) = either (error . show) id eResult where eResult = issueOperationalCertificate kesKey (Right delegateKey) (KESPeriod 0) counter counter = OperationalCertificateIssueCounter 0 (convert . getVerificationKey $ delegateKey) @@ -639,7 +657,7 @@ runGenesisCreateCardano (GenesisDir rootdir) findDelegateCert :: Genesis.GenesisData -> SigningKey ByronKey -> ExceptT ByronGenesisError IO Dlg.Certificate findDelegateCert byronGenesis bSkey@(ByronSigningKey sk) = do - case find (isCertForSK sk) (Map.elems $ dlgCertMap byronGenesis) of + case List.find (isCertForSK sk) (Map.elems $ dlgCertMap byronGenesis) of Nothing -> throwE . NoGenesisDelegationForKey . Byron.prettyPublicKey $ getVerificationKey bSkey Just x -> pure x @@ -740,7 +758,7 @@ runGenesisCreateStaked (GenesisDir rootdir) void $ writeFileGenesis (rootdir "genesis.alonzo.json") $ WritePretty alonzoGenesis --TODO: rationalise the naming convention on these genesis json files. - liftIO $ Text.hPutStrLn stderr $ mconcat $ + liftIO $ Text.hPutStrLn IO.stderr $ mconcat $ [ "generated genesis with: " , textShow genNumGenesisKeys, " genesis keys, " , textShow genNumUTxOKeys, " non-delegating UTxO keys, " @@ -1157,7 +1175,7 @@ writeFileGenesis fpath genesis = do WritePretty a -> LBS.toStrict $ encodePretty a WriteCanonical a -> LBS.toStrict . renderCanonicalJSON - . either (error "error parsing json that was just encoded!?") identity + . either (error "error parsing json that was just encoded!?") id . parseCanonicalJSON . canonicalEncodePretty $ a @@ -1272,8 +1290,8 @@ extractFileNameIndexes files = do [] -> return () files' -> throwError (ShelleyGenesisCmdFilesNoIndex files') case filter (\g -> length g > 1) - . groupBy ((==) `on` snd) - . sortBy (compare `on` snd) + . List.groupBy ((==) `on` snd) + . List.sortBy (compare `on` snd) $ [ (file, ix) | (file, Just ix) <- filesIxs ] of [] -> return () (g:_) -> throwError (ShelleyGenesisCmdFilesDupIndex (map fst g)) diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs index 10a235e2963..191fa6161d1 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Key.hs @@ -12,9 +12,17 @@ module Cardano.CLI.Shelley.Run.Key , decodeBech32 ) where +import Control.Exception (Exception (..), IOException) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) +import Data.Bifunctor (Bifunctor (..)) +import Data.ByteString (ByteString) import qualified Data.ByteString as BS import qualified Data.ByteString.Char8 as BSC +import Data.Text (Text) import qualified Data.Text as Text +import qualified Data.Text.Encoding as Text +import System.Exit (exitFailure) import qualified Control.Exception as Exception import Control.Monad.Trans.Except.Extra (firstExceptT, hoistEither, left, newExceptT) @@ -39,14 +47,6 @@ import Cardano.CLI.Shelley.Key (VerificationKeyTextOrFile (..), VerificationKeyTextOrFileError, readVerificationKeyTextOrFileAnyOf, renderVerificationKeyTextOrFileError) import Cardano.CLI.Types (SigningKeyFile (..), VerificationKeyFile (..)) -import Cardano.Prelude (MonadIO (..)) -import Control.Exception (Exception (..), IOException) -import Control.Monad.Trans.Except (ExceptT) -import Data.Bifunctor (Bifunctor (..)) -import Data.ByteString (ByteString) -import Data.Text (Text) -import qualified Data.Text.Encoding as Text -import System.Exit (exitFailure) data ShelleyKeyCmdError diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Node.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Node.hs index 8681faefb68..3319f0dd61c 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Node.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Node.hs @@ -9,14 +9,14 @@ module Cardano.CLI.Shelley.Run.Node , readColdVerificationKeyOrFile ) where -import Cardano.Prelude hiding ((<.>)) -import Prelude (id) - +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) +import Control.Monad.Trans.Except.Extra (firstExceptT, hoistEither, newExceptT) import qualified Data.ByteString.Char8 as BS import Data.String (fromString) +import Data.Text (Text) import qualified Data.Text as Text - -import Control.Monad.Trans.Except.Extra (firstExceptT, hoistEither, newExceptT) +import Data.Word (Word64) import Cardano.Api import Cardano.Api.Shelley diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs index cd7758b9159..9e0318c8688 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Query.hs @@ -26,16 +26,13 @@ module Cardano.CLI.Shelley.Run.Query , executeQuery ) where -import Cardano.Prelude hiding (All) -import Prelude (String, id) - import Cardano.Api import qualified Cardano.Api as Api import Cardano.Api.Byron import Cardano.Api.Orphans () import Cardano.Api.Shelley -import Control.Monad.Trans.Except (except) +import Control.Monad.Trans.Except (ExceptT (..), except, runExcept, runExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, handleIOExceptT, hoistEither, hoistMaybe, left, onLeft, onNothing) import Data.Aeson as Aeson @@ -97,6 +94,20 @@ import qualified Ouroboros.Consensus.HardFork.History as Consensus import qualified Ouroboros.Consensus.Protocol.Abstract as Consensus import qualified Ouroboros.Consensus.Protocol.Praos.Common as Consensus +import Control.Monad (forM, forM_, join) +import Control.Monad.IO.Class (MonadIO) +import Control.Monad.IO.Unlift (MonadIO (..)) +import Control.Monad.Trans.Class +import Data.Bifunctor (Bifunctor (..)) +import Data.Function ((&)) +import Data.Functor ((<&>)) +import qualified Data.List as List +import Data.Map.Strict (Map) +import Data.Proxy (Proxy (..)) +import Data.Set (Set) +import Data.Text (Text) +import Data.Text.Lazy (toStrict) +import GHC.Records (HasField) import qualified Ouroboros.Consensus.HardFork.History.Qry as Qry import qualified Ouroboros.Network.Protocol.LocalStateQuery.Type as LocalStateQuery @@ -142,15 +153,15 @@ renderShelleyQueryCmdError err = ShelleyQueryCmdHelpersError helpersErr -> renderHelpersError helpersErr ShelleyQueryCmdAcquireFailure acquireFail -> Text.pack $ show acquireFail ShelleyQueryCmdByronEra -> "This query cannot be used for the Byron era" - ShelleyQueryCmdPoolIdError poolId -> "The pool id does not exist: " <> show poolId + ShelleyQueryCmdPoolIdError poolId -> "The pool id does not exist: " <> textShow poolId ShelleyQueryCmdEraConsensusModeMismatch (AnyConsensusMode cMode) (AnyCardanoEra era) -> - "Consensus mode and era mismatch. Consensus mode: " <> show cMode <> - " Era: " <> show era + "Consensus mode and era mismatch. Consensus mode: " <> textShow cMode <> + " Era: " <> textShow era ShelleyQueryCmdEraMismatch (EraMismatch ledgerEra queryEra) -> "\nAn error mismatch occurred." <> "\nSpecified query era: " <> queryEra <> "\nCurrent ledger era: " <> ledgerEra ShelleyQueryCmdUnsupportedMode mode -> "Unsupported mode: " <> renderMode mode - ShelleyQueryCmdPastHorizon e -> "Past horizon: " <> show e + ShelleyQueryCmdPastHorizon e -> "Past horizon: " <> textShow e ShelleyQueryCmdSystemStartUnavailable -> "System start unavailable" ShelleyQueryCmdGenesisReadError err' -> Text.pack $ displayError err' ShelleyQueryCmdLeaderShipError e -> Text.pack $ displayError e @@ -171,7 +182,7 @@ renderShelleyQueryCmdError err = "Failed to decode StakeSnapshot. Error: " <> Text.pack (show decoderError) ShelleyQueryCmdUnsupportedNtcVersion (UnsupportedNtcVersionError minNtcVersion ntcVersion) -> "Unsupported feature for the node-to-client protocol version.\n" <> - "This query requires at least " <> show minNtcVersion <> " but the node negotiated " <> show ntcVersion <> ".\n" <> + "This query requires at least " <> textShow minNtcVersion <> " but the node negotiated " <> textShow ntcVersion <> ".\n" <> "Later node versions support later protocol versions (but development protocol versions are not enabled in the node by default)." runQueryCmd :: QueryCmd -> ExceptT ShelleyQueryCmdError IO () @@ -791,9 +802,9 @@ data ShelleyQueryCmdLocalStateQueryError renderLocalStateQueryError :: ShelleyQueryCmdLocalStateQueryError -> Text renderLocalStateQueryError lsqErr = case lsqErr of - AcquireFailureError err -> "Local state query acquire failure: " <> show err + AcquireFailureError err -> "Local state query acquire failure: " <> textShow err EraMismatchError err -> - "A query from a certain era was applied to a ledger from a different era: " <> show err + "A query from a certain era was applied to a ledger from a different era: " <> textShow err ByronProtocolNotSupportedError -> "The attempted local state query does not support the Byron protocol." ShelleyProtocolEraMismatch -> @@ -1275,7 +1286,7 @@ runQueryLeadershipSchedule (AnyConsensusModeParams cModeParams) network -> SystemStart -> LBS.ByteString printLeadershipScheduleAsJson leadershipSlots eInfo sStart = - encodePretty $ showLeadershipSlot <$> sort (Set.toList leadershipSlots) + encodePretty $ showLeadershipSlot <$> List.sort (Set.toList leadershipSlots) where showLeadershipSlot :: SlotNo -> Aeson.Value showLeadershipSlot lSlot@(SlotNo sn) = diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/TextView.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/TextView.hs index 7bed2a21130..dbc41b7ddd1 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/TextView.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/TextView.hs @@ -4,8 +4,9 @@ module Cardano.CLI.Shelley.Run.TextView , runTextViewCmd ) where -import Cardano.Prelude - +import Control.Monad.Trans.Except (ExceptT) +import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Text (Text) import qualified Data.Text as Text import Cardano.CLI.Helpers (HelpersError, pPrintCBOR, renderHelpersError) @@ -13,10 +14,9 @@ import Cardano.CLI.Shelley.Parsers import Cardano.Api +import Control.Monad.IO.Class (MonadIO (..)) import Control.Monad.Trans.Except.Extra (firstExceptT, newExceptT) -import qualified Data.ByteString.Lazy.Char8 as LBS - data ShelleyTextViewFileError = TextViewReadFileError (FileError TextEnvelopeError) | TextViewCBORPrettyPrintError !HelpersError diff --git a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs index 0af9860cd2d..f08ca6d043d 100644 --- a/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs +++ b/cardano-cli/src/Cardano/CLI/Shelley/Run/Transaction.hs @@ -18,22 +18,29 @@ module Cardano.CLI.Shelley.Run.Transaction , toTxOutInAnyEra ) where -import Cardano.Prelude hiding (All, Any) -import Prelude (String, error) - +import Control.Monad (forM_) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT, hoistEither, hoistMaybe, left, newExceptT) import Data.Aeson.Encode.Pretty (encodePretty) +import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString.Char8 as BS import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Data ((:~:) (..)) +import Data.Foldable (Foldable (..)) import qualified Data.List as List +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map +import Data.Maybe (catMaybes, fromMaybe) +import Data.Set (Set) import qualified Data.Set as Set +import Data.Text (Text) import qualified Data.Text as Text +import qualified Data.Text.IO as Text import Data.Type.Equality (TestEquality (..)) import qualified System.IO as IO - import Cardano.Api import Cardano.Api.Byron hiding (SomeByronSigningKey (..)) import Cardano.Api.Shelley @@ -125,7 +132,7 @@ renderShelleyTxCmdError err = ShelleyTxCmdReadWitnessSigningDataError witSignDataErr -> renderReadWitnessSigningDataError witSignDataErr ShelleyTxCmdRequiredSignerByronKeyError (SigningKeyFile fp) -> - "Byron key witness was used as a required signer: " <> show fp + "Byron key witness was used as a required signer: " <> textShow fp ShelleyTxCmdWriteFileError fileErr -> Text.pack (displayError fileErr) ShelleyTxCmdSocketEnvError envSockErr -> renderEnvSocketError envSockErr ShelleyTxCmdTxSubmitError res -> "Error while submitting tx: " <> res @@ -156,14 +163,14 @@ renderShelleyTxCmdError err = ShelleyTxCmdWitnessEraMismatch era era' (WitnessFile file) -> "The era of a witness does not match the era of the transaction. " <> "The transaction is for the " <> renderEra era <> " era, but the " <> - "witness in " <> show file <> " is for the " <> renderEra era' <> " era." + "witness in " <> textShow file <> " is for the " <> renderEra era' <> " era." ShelleyTxCmdScriptLanguageNotSupportedInEra (AnyScriptLanguage lang) era -> - "The script language " <> show lang <> " is not supported in the " <> + "The script language " <> textShow lang <> " is not supported in the " <> renderEra era <> " era." ShelleyTxCmdEraConsensusModeMismatch fp mode era -> - "Submitting " <> renderEra era <> " era transaction (" <> show fp <> + "Submitting " <> renderEra era <> " era transaction (" <> textShow fp <> ") is not supported in the " <> renderMode mode <> " consensus mode." ShelleyTxCmdPolicyIdsMissing policyids -> "The \"--mint\" flag specifies an asset with a policy Id, but no \ @@ -178,7 +185,7 @@ renderShelleyTxCmdError err = ShelleyTxCmdUnsupportedMode mode -> "Unsupported mode: " <> renderMode mode ShelleyTxCmdByronEra -> "This query cannot be used for the Byron era" ShelleyTxCmdEraConsensusModeMismatchTxBalance fp mode era -> - "Cannot balance " <> renderEra era <> " era transaction body (" <> show fp <> + "Cannot balance " <> renderEra era <> " era transaction body (" <> textShow fp <> ") because is not supported in the " <> renderMode mode <> " consensus mode." ShelleyTxCmdBalanceTxBody err' -> Text.pack $ displayError err' ShelleyTxCmdTxInsDoNotExist e -> @@ -195,9 +202,9 @@ renderShelleyTxCmdError err = "Execution units not available in the protocol parameters. This is \ \likely due to not being in the Alonzo era" ShelleyTxCmdReferenceScriptsNotSupportedInEra (AnyCardanoEra era) -> - "TxCmd: Reference scripts not supported in era: " <> show era + "TxCmd: Reference scripts not supported in era: " <> textShow era ShelleyTxCmdTxEraCastErr (EraCastError value fromEra toEra) -> - "Unable to cast era from " <> show fromEra <> " to " <> show toEra <> " the value " <> show value + "Unable to cast era from " <> textShow fromEra <> " to " <> textShow toEra <> " the value " <> textShow value ShelleyTxCmdQueryConvenienceError e -> renderQueryConvenienceError e ShelleyTxCmdQueryNotScriptLocked e -> @@ -757,7 +764,7 @@ runTxBuild era (AnyConsensusModeParams cModeParams) networkId mScriptValidity pparams stakePools txEraUtxo txBodyContent cAddr mOverrideWits - putStrLn $ "Estimated transaction fee: " <> (show fee :: String) + liftIO $ putStrLn $ "Estimated transaction fee: " <> (show fee :: String) return balancedTxBody @@ -915,7 +922,7 @@ toTxOutInAnyEra era (TxOutAnyEra addr' val' mDatumHash refScriptFp) = do toTxDatumReferenceScriptBabbage sup inlineDatumRefScriptSupp mDatumHash refScriptFp (Nothing, Just _) -> -- TODO: Figure out how to make this state unrepresentable - panic "toTxOutInAnyEra: Should not be possible that inline datums are allowed but datums are not" + error "toTxOutInAnyEra: Should not be possible that inline datums are allowed but datums are not" pure $ TxOut addr val datum refScript where getReferenceScript @@ -1145,7 +1152,7 @@ runTxSubmit (AnyConsensusModeParams cModeParams) network txFile = do res <- liftIO $ submitTxToNodeLocal localNodeConnInfo txInMode case res of - Net.Tx.SubmitSuccess -> liftIO $ putTextLn "Transaction successfully submitted." + Net.Tx.SubmitSuccess -> liftIO $ Text.putStrLn "Transaction successfully submitted." Net.Tx.SubmitFail reason -> case reason of TxValidationErrorInMode err _eraInMode -> left . ShelleyTxCmdTxSubmitError . Text.pack $ show err @@ -1231,7 +1238,7 @@ runTxCreatePolicyId :: ScriptFile -> ExceptT ShelleyTxCmdError IO () runTxCreatePolicyId (ScriptFile sFile) = do ScriptInAnyLang _ script <- firstExceptT ShelleyTxCmdScriptFileError $ readFileScriptInAnyLang sFile - liftIO . putTextLn . serialiseToRawBytesHexText $ hashScript script + liftIO . Text.putStrLn . serialiseToRawBytesHexText $ hashScript script -- | Error reading the data required to construct a key witness. diff --git a/cardano-cli/test/Test/Cli/CliIntermediateFormat.hs b/cardano-cli/test/Test/Cli/CliIntermediateFormat.hs index 6b1272a81e5..f89c4b82593 100644 --- a/cardano-cli/test/Test/Cli/CliIntermediateFormat.hs +++ b/cardano-cli/test/Test/Cli/CliIntermediateFormat.hs @@ -5,7 +5,8 @@ module Test.Cli.CliIntermediateFormat ( tests ) where -import Cardano.Prelude +import Control.Monad (void) + import Hedgehog (Property, discover) import Test.OptParse diff --git a/cardano-cli/test/Test/Cli/JSON.hs b/cardano-cli/test/Test/Cli/JSON.hs index 4d39ed017bc..bc6dfe456c4 100644 --- a/cardano-cli/test/Test/Cli/JSON.hs +++ b/cardano-cli/test/Test/Cli/JSON.hs @@ -3,8 +3,6 @@ module Test.Cli.JSON where -import Cardano.Prelude hiding (filter) - import Cardano.Api.Shelley import Test.Gen.Cardano.Api.Typed (genLovelace, genSlotNo, genStakeAddress, genVerificationKeyHash) @@ -13,6 +11,7 @@ import Data.Aeson import qualified Data.Map.Strict as Map import Data.Time import Data.Time.Clock.System +import Data.Word (Word64) import Cardano.CLI.Shelley.Output (QueryKesPeriodInfoOutput (..), createOpCertIntervalInfo) @@ -38,7 +37,7 @@ genDelegationsAndRewards = do let delegMapAmt = Map.fromList $ zip sAddrs sLovelace poolIDs <- Gen.list r genPoolId let delegMapPool = Map.fromList $ zip sAddrs poolIDs - return $ DelegationsAndRewards (delegMapAmt,delegMapPool) + return $ DelegationsAndRewards (delegMapAmt, delegMapPool) genOpCertIntervalInformation :: Gen OpCertIntervalInformation genOpCertIntervalInformation = do diff --git a/cardano-cli/test/Test/Golden/Byron/TxBody.hs b/cardano-cli/test/Test/Golden/Byron/TxBody.hs index 1d77c774927..3b86ac46729 100644 --- a/cardano-cli/test/Test/Golden/Byron/TxBody.hs +++ b/cardano-cli/test/Test/Golden/Byron/TxBody.hs @@ -4,10 +4,9 @@ module Test.Golden.Byron.TxBody ( golden_byronTxBody ) where -import Cardano.Prelude import Hedgehog (Property) {- HLINT ignore "Use camelCase" -} golden_byronTxBody :: Property -golden_byronTxBody = panic "TODO" +golden_byronTxBody = error "TODO" diff --git a/cardano-cli/test/Test/Golden/Byron/Witness.hs b/cardano-cli/test/Test/Golden/Byron/Witness.hs index 870d1a66f36..7225db71db0 100644 --- a/cardano-cli/test/Test/Golden/Byron/Witness.hs +++ b/cardano-cli/test/Test/Golden/Byron/Witness.hs @@ -4,10 +4,9 @@ module Test.Golden.Byron.Witness ( golden_byronWitness ) where -import Cardano.Prelude import Hedgehog (Property) {- HLINT ignore "Use camelCase" -} golden_byronWitness :: Property -golden_byronWitness = panic "TODO" +golden_byronWitness = error "TODO" diff --git a/cardano-cli/test/Test/Golden/Shelley/Address/Info.hs b/cardano-cli/test/Test/Golden/Shelley/Address/Info.hs index faaaf146922..2a06eeccc92 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Address/Info.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Address/Info.hs @@ -4,7 +4,8 @@ module Test.Golden.Shelley.Address.Info ( golden_shelleyAddressInfo ) where -import Cardano.Prelude +import Control.Monad (when) + import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Genesis/Create.hs b/cardano-cli/test/Test/Golden/Shelley/Genesis/Create.hs index c1de85744d1..cc94da74499 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Genesis/Create.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Genesis/Create.hs @@ -5,9 +5,12 @@ module Test.Golden.Shelley.Genesis.Create ( golden_shelleyGenesisCreate ) where -import Cardano.Prelude +import Control.Monad (void) +import Control.Monad.IO.Class (MonadIO (..)) +import Data.Bifunctor (Bifunctor (..)) +import Data.Foldable (for_) + import Hedgehog (Property, forAll, (===)) -import Prelude (String) import Test.OptParse as OP import qualified Data.Aeson as J diff --git a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/Witness.hs b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/Witness.hs index 7e84324e127..d40a52ae9fa 100644 --- a/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/Witness.hs +++ b/cardano-cli/test/Test/Golden/Shelley/TextEnvelope/Tx/Witness.hs @@ -4,10 +4,9 @@ module Test.Golden.Shelley.TextEnvelope.Tx.Witness ( golden_shelleyWitness ) where -import Cardano.Prelude import Hedgehog (Property) {- HLINT ignore "Use camelCase" -} golden_shelleyWitness :: Property -golden_shelleyWitness = panic "TODO" +golden_shelleyWitness = error "TODO" diff --git a/cardano-cli/test/Test/Golden/Shelley/Transaction/Assemble.hs b/cardano-cli/test/Test/Golden/Shelley/Transaction/Assemble.hs index f10893822c8..630b2b331bf 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Transaction/Assemble.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Transaction/Assemble.hs @@ -4,7 +4,8 @@ module Test.Golden.Shelley.Transaction.Assemble ( golden_shelleyTransactionAssembleWitness_SigningKey ) where -import Cardano.Prelude +import Control.Monad (void) + import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Transaction/Build.hs b/cardano-cli/test/Test/Golden/Shelley/Transaction/Build.hs index c2064d5ff99..bc178959829 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Transaction/Build.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Transaction/Build.hs @@ -8,8 +8,7 @@ module Test.Golden.Shelley.Transaction.Build , golden_shelleyTransactionBuild_WithdrawalScriptWitnessed ) where -import Cardano.Prelude -import Prelude (String) +import Control.Monad (void) import qualified Data.ByteString.Base16 as Base16 import qualified Data.ByteString.Char8 as BSC diff --git a/cardano-cli/test/Test/Golden/Shelley/Transaction/CreateWitness.hs b/cardano-cli/test/Test/Golden/Shelley/Transaction/CreateWitness.hs index 50342e3b8c2..de3cbfd37b4 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Transaction/CreateWitness.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Transaction/CreateWitness.hs @@ -4,9 +4,7 @@ module Test.Golden.Shelley.Transaction.CreateWitness ( golden_shelleyTransactionSigningKeyWitness ) where -import Cardano.Prelude -import Prelude (String) - +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/Shelley/Transaction/Sign.hs b/cardano-cli/test/Test/Golden/Shelley/Transaction/Sign.hs index ede89c46c58..e1f27ed1a2a 100644 --- a/cardano-cli/test/Test/Golden/Shelley/Transaction/Sign.hs +++ b/cardano-cli/test/Test/Golden/Shelley/Transaction/Sign.hs @@ -4,7 +4,7 @@ module Test.Golden.Shelley.Transaction.Sign ( golden_shelleyTransactionSign ) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/Golden/TxView.hs b/cardano-cli/test/Test/Golden/TxView.hs index aa11cb5c310..a9b7f85a63d 100644 --- a/cardano-cli/test/Test/Golden/TxView.hs +++ b/cardano-cli/test/Test/Golden/TxView.hs @@ -2,7 +2,7 @@ module Test.Golden.TxView (txViewTests) where -import Cardano.Prelude +import Control.Monad (void) import Hedgehog (Group (..), Property, checkSequential) import Hedgehog.Extras (Integration, moduleWorkspace, note_, propertyOnce) diff --git a/cardano-cli/test/Test/Golden/Version.hs b/cardano-cli/test/Test/Golden/Version.hs index 9548b39a2ca..31f9ef6db8e 100644 --- a/cardano-cli/test/Test/Golden/Version.hs +++ b/cardano-cli/test/Test/Golden/Version.hs @@ -4,7 +4,8 @@ module Test.Golden.Version ( golden_version ) where -import Cardano.Prelude +import Control.Monad (void) + import Hedgehog (Property) import Test.OptParse diff --git a/cardano-cli/test/Test/OptParse.hs b/cardano-cli/test/Test/OptParse.hs index 4a875e1e59b..bf53850a92c 100644 --- a/cardano-cli/test/Test/OptParse.hs +++ b/cardano-cli/test/Test/OptParse.hs @@ -9,10 +9,6 @@ module Test.OptParse , noteTempFile ) where -import Cardano.Prelude hiding (lines, readFile, stderr, stdout) -import Prelude (String) -import qualified Prelude - import Control.Monad.Catch import qualified GHC.Stack as GHC @@ -20,6 +16,8 @@ import Cardano.Api import Cardano.CLI.Shelley.Run.Read +import Control.Monad.IO.Class (MonadIO (..)) +import GHC.Stack (CallStack, HasCallStack) import qualified Hedgehog as H import qualified Hedgehog.Extras.Test.Process as H import Hedgehog.Internal.Property (Diff, MonadTest, liftTest, mkTest) @@ -59,7 +57,7 @@ checkTextEnvelopeFormat tve reference created = do => Either (FileError TextEnvelopeError) TextEnvelope -> m TextEnvelope handleTextEnvelope (Right refTextEnvelope) = return refTextEnvelope - handleTextEnvelope (Left fileErr) = failWithCustom callStack Nothing . displayError $ fileErr + handleTextEnvelope (Left fileErr) = failWithCustom GHC.callStack Nothing . displayError $ fileErr typeTitleEquivalence :: MonadTest m => TextEnvelope -> TextEnvelope -> m () typeTitleEquivalence (TextEnvelope refType refTitle _) @@ -87,13 +85,13 @@ cardanoCliPath = "cardano-cli" -- | Return the input file path after annotating it relative to the project root directory noteInputFile :: (MonadTest m, HasCallStack) => FilePath -> m FilePath -noteInputFile filePath = withFrozenCallStack $ do +noteInputFile filePath = GHC.withFrozenCallStack $ do H.annotate $ cardanoCliPath <> "/" <> filePath return filePath -- | Return the test file path after annotating it relative to the project root directory noteTempFile :: (MonadTest m, HasCallStack) => FilePath -> FilePath -> m FilePath -noteTempFile tempDir filePath = withFrozenCallStack $ do +noteTempFile tempDir filePath = GHC.withFrozenCallStack $ do let relPath = tempDir <> "/" <> filePath H.annotate $ cardanoCliPath <> "/" <> relPath return relPath @@ -117,7 +115,7 @@ equivalence x y = do ok <- H.eval (x == y) if ok then H.success - else failDiffCustom callStack x y + else failDiffCustom GHC.callStack x y -- | Takes a 'CallStack' so the error can be rendered at the appropriate call site. failWithCustom :: MonadTest m => CallStack -> Maybe Diff -> String -> m a @@ -129,7 +127,7 @@ failDiffCustom :: (MonadTest m, Show a) => CallStack -> a -> a -> m () failDiffCustom cS x y = case valueDiff <$> mkValue x <*> mkValue y of Nothing -> - withFrozenCallStack $ + GHC.withFrozenCallStack $ failWithCustom cS Nothing $ Prelude.unlines [ "Failed" @@ -140,11 +138,11 @@ failDiffCustom cS x y = ] Just vdiff@(ValueSame _) -> - withFrozenCallStack $ + GHC.withFrozenCallStack $ failWithCustom cS (Just $ H.Diff "━━━ Failed (" "" "no differences" "" ") ━━━" vdiff) "" Just vdiff -> - withFrozenCallStack $ + GHC.withFrozenCallStack $ failWithCustom cS (Just $ H.Diff "━━━ Failed (" "- lhs" ") (" "+ rhs" ") ━━━" vdiff) "" diff --git a/cardano-cli/test/Test/Utilities.hs b/cardano-cli/test/Test/Utilities.hs index bd686e40a5c..b4b67f92bc4 100644 --- a/cardano-cli/test/Test/Utilities.hs +++ b/cardano-cli/test/Test/Utilities.hs @@ -1,11 +1,11 @@ module Test.Utilities (diffVsGoldenFile) where -import Cardano.Prelude -import Prelude (String) -import qualified Prelude +import Cardano.Prelude (ConvertText (..)) +import Control.Monad.IO.Class (MonadIO (liftIO)) import Data.Algorithm.Diff (PolyDiff (Both), getGroupedDiff) import Data.Algorithm.DiffOutput (ppDiff) +import GHC.Stack (callStack) import Hedgehog (MonadTest) import Hedgehog.Extras.Test.Base (failMessage) diff --git a/cardano-git-rev/cardano-git-rev.cabal b/cardano-git-rev/cardano-git-rev.cabal index 959a1a47061..60c864ec774 100644 --- a/cardano-git-rev/cardano-git-rev.cabal +++ b/cardano-git-rev/cardano-git-rev.cabal @@ -17,7 +17,6 @@ extra-source-files: README.md common project-config default-language: Haskell2010 - default-extensions: NoImplicitPrelude build-depends: base >= 4.14 && < 4.17 ghc-options: -Wall @@ -36,8 +35,7 @@ library exposed-modules: Cardano.Git.Rev Cardano.Git.RevFromGit - build-depends: cardano-prelude - , file-embed + build-depends: file-embed , process , template-haskell , text diff --git a/cardano-git-rev/src/Cardano/Git/Rev.hs b/cardano-git-rev/src/Cardano/Git/Rev.hs index 140d1de5369..0c02d54cfc8 100644 --- a/cardano-git-rev/src/Cardano/Git/Rev.hs +++ b/cardano-git-rev/src/Cardano/Git/Rev.hs @@ -6,10 +6,10 @@ module Cardano.Git.Rev ( gitRev ) where -import Cardano.Prelude - import Data.FileEmbed (dummySpaceWith) +import Data.Text (Text) import qualified Data.Text as T +import Data.Text.Encoding (decodeUtf8) import Cardano.Git.RevFromGit (gitRevFromGit) diff --git a/cardano-git-rev/src/Cardano/Git/RevFromGit.hs b/cardano-git-rev/src/Cardano/Git/RevFromGit.hs index 47566c889a3..f760d24cd41 100644 --- a/cardano-git-rev/src/Cardano/Git/RevFromGit.hs +++ b/cardano-git-rev/src/Cardano/Git/RevFromGit.hs @@ -2,10 +2,9 @@ module Cardano.Git.RevFromGit ( gitRevFromGit ) where -import Cardano.Prelude -import Prelude (String) - +import Control.Exception (catch) import qualified Language.Haskell.TH as TH +import System.Exit (ExitCode (..)) import qualified System.IO as IO import System.IO.Error (isDoesNotExistError) import System.Process (readProcessWithExitCode) diff --git a/cardano-node-chairman/app/Cardano/Chairman.hs b/cardano-node-chairman/app/Cardano/Chairman.hs index b341ebc19dd..f970e51d324 100644 --- a/cardano-node-chairman/app/Cardano/Chairman.hs +++ b/cardano-node-chairman/app/Cardano/Chairman.hs @@ -11,16 +11,19 @@ module Cardano.Chairman (chairmanTest) where -import Cardano.Prelude hiding (ByteString, STM, atomically, catch, show, throwIO) -import Prelude (String, error, show) - import Control.Concurrent.Class.MonadSTM.Strict +import Control.Monad (void) import Control.Monad.Class.MonadAsync import Control.Monad.Class.MonadThrow import Control.Monad.Class.MonadTimer import Control.Tracer import Data.Coerce (coerce) +import qualified Data.List as List +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map +import Data.Ord (comparing) +import Data.Proxy (Proxy (..)) +import Data.Word (Word64) import Ouroboros.Consensus.Block.Abstract import Ouroboros.Consensus.Config.SecurityParam @@ -122,7 +125,7 @@ consensusCondition cMode chains securityParam = | (peerid1, chain1) <- Map.toList chains , (peerid2, chain2) <- Map.toList chains ] - in case find (forkTooLong . snd) forks of + in case List.find (forkTooLong . snd) forks of Just ((peerid1, peerid2), (intersection, tip1, tip2)) ->do let apiTip1 = fromConsensusTip cMode $ AF.anchorToTip tip1 apiTip2 = fromConsensusTip cMode $ AF.anchorToTip tip2 @@ -139,7 +142,7 @@ consensusCondition cMode chains securityParam = ConsensusSuccess -- the minimum intersection point: (fromAnchor - $ minimumBy (comparing AF.anchorToBlockNo) + $ List.minimumBy (comparing AF.anchorToBlockNo) [ intersection | (_,(intersection,_,_)) <- forks ]) -- all the chain tips: [ (peerid, fromConsensusTip cMode $ AF.anchorToTip (AF.headAnchor chain)) @@ -234,7 +237,7 @@ progressCondition :: BlockNo -> ConsensusSuccess -> Either ProgressFailure ProgressSuccess progressCondition minBlockNo (ConsensusSuccess _ tips) = do - case find (\(_, ct) -> getBlockNo ct < minBlockNo) tips of + case List.find (\(_, ct) -> getBlockNo ct < minBlockNo) tips of Just (peerid, tip) -> Left (ProgressFailure minBlockNo peerid tip) Nothing -> Right (ProgressSuccess minBlockNo) where diff --git a/cardano-node/app/cardano-node.hs b/cardano-node/app/cardano-node.hs index 97fa0b50f00..fa657def745 100644 --- a/cardano-node/app/cardano-node.hs +++ b/cardano-node/app/cardano-node.hs @@ -1,15 +1,13 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} -import Cardano.Prelude -import qualified Data.Text as Text -import Prelude (String) - import Options.Applicative import qualified Options.Applicative as Opt import Options.Applicative.Help ((<$$>)) import Cardano.Git.Rev (gitRev) +import qualified Data.Text as Text +import qualified Data.Text.IO as Text import Data.Version (showVersion) import Paths_cardano_node (version) import System.Info (arch, compilerName, compilerVersion, os) @@ -84,7 +82,7 @@ parseVersionCmd = runVersionCommand :: IO () runVersionCommand = - putTextLn $ mconcat + Text.putStrLn $ mconcat [ "cardano-node ", renderVersion version , " - ", Text.pack os, "-", Text.pack arch , " - ", Text.pack compilerName, "-", renderVersion compilerVersion diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index fbb1d5d368b..188d1af8aeb 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -151,6 +151,7 @@ library , cborg ^>= 0.2.4 , contra-tracer , containers + , deepseq , directory , dns , ekg @@ -211,7 +212,6 @@ executable cardano-node build-depends: base >= 4.14 && < 4.17 , cardano-git-rev , cardano-node - , cardano-prelude , optparse-applicative-fork , text @@ -227,7 +227,6 @@ test-suite cardano-node-test , bytestring , cardano-api , cardano-node - , cardano-prelude , cardano-slotting ^>= 0.1 , directory , hedgehog @@ -239,7 +238,6 @@ test-suite cardano-node-test , mtl , text , time - , transformers , vector other-modules: Test.Cardano.Node.FilePermissions diff --git a/cardano-node/src/Cardano/Node/Configuration/NodeAddress.hs b/cardano-node/src/Cardano/Node/Configuration/NodeAddress.hs index 00389812459..bb5e9e8104d 100644 --- a/cardano-node/src/Cardano/Node/Configuration/NodeAddress.hs +++ b/cardano-node/src/Cardano/Node/Configuration/NodeAddress.hs @@ -30,16 +30,16 @@ module Cardano.Node.Configuration.NodeAddress ) where import Cardano.Api -import Cardano.Prelude -import Prelude (fail) import Data.Aeson (FromJSON (..), ToJSON (..), Value (..), object, withObject, (.:), (.=)) import Data.IP (IP (..), IPv4, IPv6) import qualified Data.IP as IP +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text import qualified Network.DNS as DNS (Domain) import Network.Socket (PortNumber, SockAddr (..)) +import Text.Read (readMaybe) import Ouroboros.Network.PeerSelection.RootPeersDNS (DomainAccessPoint (..)) diff --git a/cardano-node/src/Cardano/Node/Configuration/POM.hs b/cardano-node/src/Cardano/Node/Configuration/POM.hs index ddf05b66fd3..ccd19eb09c8 100644 --- a/cardano-node/src/Cardano/Node/Configuration/POM.hs +++ b/cardano-node/src/Cardano/Node/Configuration/POM.hs @@ -21,18 +21,17 @@ module Cardano.Node.Configuration.POM ) where -import Cardano.Prelude -import qualified GHC.Show as Show -import Prelude (String) - -import Control.Monad (fail) import Data.Aeson import qualified Data.Aeson.Types as Aeson +import Data.Bifunctor (Bifunctor (..)) +import Data.Monoid (Last (..)) +import Data.Text (Text) import qualified Data.Text as Text import Data.Time.Clock (DiffTime) import Data.Yaml (decodeFileThrow) import Generic.Data (gmappend) import Generic.Data.Orphans () +import GHC.Generics (Generic) import Options.Applicative import System.FilePath (takeDirectory, ()) diff --git a/cardano-node/src/Cardano/Node/Configuration/Topology.hs b/cardano-node/src/Cardano/Node/Configuration/Topology.hs index dda648012e5..826431f33bc 100644 --- a/cardano-node/src/Cardano/Node/Configuration/Topology.hs +++ b/cardano-node/src/Cardano/Node/Configuration/Topology.hs @@ -15,14 +15,17 @@ module Cardano.Node.Configuration.Topology ) where -import Cardano.Prelude -import Prelude (String) - +import Control.Exception (Exception (..), IOException) import qualified Control.Exception as Exception import Data.Aeson +import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Foldable +import Data.Text (Text) import qualified Data.Text as Text +import Data.Word (Word64) +import Text.Read (readMaybe) import Cardano.Node.Configuration.NodeAddress import Cardano.Node.Configuration.POM (NodeConfiguration (..)) @@ -152,6 +155,6 @@ readTopologyFile nc = do readTopologyFileOrError :: NodeConfiguration -> IO NetworkTopology readTopologyFileOrError nc = readTopologyFile nc - >>= either (\err -> panic $ "Cardano.Node.Configuration.Topology.readTopologyFile: " - <> err) + >>= either (\err -> error $ "Cardano.Node.Configuration.Topology.readTopologyFile: " + <> Text.unpack err) pure diff --git a/cardano-node/src/Cardano/Node/Configuration/TopologyP2P.hs b/cardano-node/src/Cardano/Node/Configuration/TopologyP2P.hs index c52866d899a..1f9aebbd638 100644 --- a/cardano-node/src/Cardano/Node/Configuration/TopologyP2P.hs +++ b/cardano-node/src/Cardano/Node/Configuration/TopologyP2P.hs @@ -24,14 +24,17 @@ module Cardano.Node.Configuration.TopologyP2P ) where -import Cardano.Prelude hiding (ap) -import Prelude (String) - +import Control.Exception (IOException) import qualified Control.Exception as Exception +import Control.Exception.Base (Exception (..)) +import Control.Monad (MonadPlus (..)) import Data.Aeson +import Data.Bifunctor (Bifunctor (..)) import qualified Data.ByteString as BS import qualified Data.ByteString.Lazy.Char8 as LBS +import Data.Text (Text) import qualified Data.Text as Text +import Data.Word (Word64) import "contra-tracer" Control.Tracer (Tracer, traceWith) @@ -268,6 +271,6 @@ readTopologyFileOrError :: Tracer IO (StartupTrace blk) -> NodeConfiguration -> IO NetworkTopology readTopologyFileOrError tr nc = readTopologyFile tr nc - >>= either (\err -> panic $ "Cardano.Node.Configuration.TopologyP2P.readTopologyFile: " - <> err) + >>= either (\err -> error $ "Cardano.Node.Configuration.TopologyP2P.readTopologyFile: " + <> Text.unpack err) pure diff --git a/cardano-node/src/Cardano/Node/Orphans.hs b/cardano-node/src/Cardano/Node/Orphans.hs index f8cb7741df9..360969f12f5 100644 --- a/cardano-node/src/Cardano/Node/Orphans.hs +++ b/cardano-node/src/Cardano/Node/Orphans.hs @@ -1,14 +1,11 @@ {-# LANGUAGE FlexibleInstances #-} -{-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE NamedFieldPuns #-} +{-# LANGUAGE StandaloneDeriving #-} {-# OPTIONS_GHC -Wno-orphans #-} module Cardano.Node.Orphans () where -import Cardano.Prelude -import Prelude (fail) - import Cardano.Api.Orphans () import Data.Aeson.Types @@ -16,8 +13,8 @@ import qualified Data.Text as Text import Cardano.BM.Data.Tracer (TracingVerbosity (..)) import qualified Cardano.Chain.Update as Update -import Cardano.Ledger.Crypto (StandardCrypto) import qualified Cardano.Ledger.CompactAddress as Ledger +import Cardano.Ledger.Crypto (StandardCrypto) import Ouroboros.Network.NodeToNode (AcceptedConnectionsLimit (..)) instance FromJSON TracingVerbosity where diff --git a/cardano-node/src/Cardano/Node/Parsers.hs b/cardano-node/src/Cardano/Node/Parsers.hs index 51df5b31807..49ab0856919 100644 --- a/cardano-node/src/Cardano/Node/Parsers.hs +++ b/cardano-node/src/Cardano/Node/Parsers.hs @@ -11,14 +11,18 @@ module Cardano.Node.Parsers , renderHelpDoc ) where -import Cardano.Prelude -import Prelude (String) +import Cardano.Prelude (ConvertText (..)) +import Data.Maybe (fromMaybe) +import Data.Monoid (Last (..)) +import Data.Text (Text) import Data.Time.Clock (secondsToDiffTime) +import Data.Word (Word32) import Options.Applicative hiding (str) import qualified Options.Applicative as Opt import qualified Options.Applicative.Help as OptI import System.Posix.Types (Fd (..)) +import Text.Read (readMaybe) import Ouroboros.Consensus.Mempool.API (MempoolCapacityBytes (..), MempoolCapacityBytesOverride (..)) diff --git a/cardano-node/src/Cardano/Node/Protocol.hs b/cardano-node/src/Cardano/Node/Protocol.hs index cc63e94990a..8e1491aa36c 100644 --- a/cardano-node/src/Cardano/Node/Protocol.hs +++ b/cardano-node/src/Cardano/Node/Protocol.hs @@ -4,8 +4,7 @@ module Cardano.Node.Protocol , ProtocolInstantiationError(..) ) where -import Cardano.Prelude - +import Control.Monad.Trans.Except (ExceptT) import Control.Monad.Trans.Except.Extra (firstExceptT) import Cardano.Api diff --git a/cardano-node/src/Cardano/Node/Protocol/Alonzo.hs b/cardano-node/src/Cardano/Node/Protocol/Alonzo.hs index 9a0bdefbbb1..39f5a779e09 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Alonzo.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Alonzo.hs @@ -8,20 +8,19 @@ module Cardano.Node.Protocol.Alonzo , validateGenesis ) where -import Prelude (String) -import Cardano.Prelude - import Cardano.Api import qualified Cardano.Ledger.Alonzo.Genesis as Alonzo -import Cardano.Node.Types import Cardano.Node.Orphans () +import Cardano.Node.Types import Cardano.Tracing.OrphanInstances.HardFork () import Cardano.Tracing.OrphanInstances.Shelley () -import Cardano.Node.Protocol.Shelley (readGenesisAny, GenesisReadError) +import Cardano.Node.Protocol.Shelley (GenesisReadError, readGenesisAny) + +import Control.Monad.Except (ExceptT) -- -- Alonzo genesis diff --git a/cardano-node/src/Cardano/Node/Protocol/Shelley.hs b/cardano-node/src/Cardano/Node/Protocol/Shelley.hs index ab8a071dbca..8f616c20a5e 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Shelley.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Shelley.hs @@ -20,9 +20,11 @@ module Cardano.Node.Protocol.Shelley , validateGenesis ) where +import Cardano.Prelude (ConvertText (..)) +import Control.Exception (IOException) +import Control.Monad.Except (ExceptT, MonadError (..)) + import qualified Cardano.Api as Api -import Cardano.Prelude -import Prelude (String, id) import qualified Data.Aeson as Aeson import qualified Data.ByteString as BS @@ -310,7 +312,7 @@ newtype GenesisValidationError = GenesisValidationErrors [Shelley.ValidationErr] instance Error GenesisValidationError where displayError (GenesisValidationErrors vErrs) = - T.unpack (unlines (map Shelley.describeValidationErr vErrs)) + T.unpack (T.unlines (map Shelley.describeValidationErr vErrs)) data PraosLeaderCredentialsError = diff --git a/cardano-node/src/Cardano/Node/Protocol/Types.hs b/cardano-node/src/Cardano/Node/Protocol/Types.hs index eadc1984971..a026080dd30 100644 --- a/cardano-node/src/Cardano/Node/Protocol/Types.hs +++ b/cardano-node/src/Cardano/Node/Protocol/Types.hs @@ -12,10 +12,10 @@ module Cardano.Node.Protocol.Types ) where import qualified Cardano.Api as Api -import Cardano.Prelude (Generic, NFData) -import Prelude +import Control.DeepSeq (NFData) import Data.Aeson +import GHC.Generics (Generic) import NoThunks.Class (NoThunks) import Cardano.Node.Orphans () diff --git a/cardano-node/src/Cardano/Node/Run.hs b/cardano-node/src/Cardano/Node/Run.hs index 00a7a0a9d39..47a2e617dd3 100644 --- a/cardano-node/src/Cardano/Node/Run.hs +++ b/cardano-node/src/Cardano/Node/Run.hs @@ -9,6 +9,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeApplications #-} +{-# OPTIONS_GHC -Wno-unused-imports #-} + #if !defined(mingw32_HOST_OS) #define UNIX #endif @@ -19,17 +21,31 @@ module Cardano.Node.Run ) where import qualified Cardano.Api as Api -import Cardano.Prelude hiding (ByteString, STM, atomically, show, take, trace) + +import Cardano.Prelude (FatalError (..)) + +import Data.Bits import Data.IP (toSockAddr) -import Prelude (String, id, show) +import Control.Concurrent (killThread, mkWeakThreadId, myThreadId) import Control.Concurrent.Class.MonadSTM.Strict +import Control.Exception (try) +import Control.Monad (forM_, unless, void, when) +import Control.Monad.Class.MonadThrow (MonadThrow (..)) +import Control.Monad.IO.Class (MonadIO (..)) +import Control.Monad.Trans.Except (ExceptT, runExceptT) import Control.Monad.Trans.Except.Extra (left) import "contra-tracer" Control.Tracer +import Data.Either (partitionEithers) +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map -import Data.Text (breakOn, pack, take) +import Data.Maybe (catMaybes, mapMaybe) +import Data.Monoid (Last (..)) +import Data.Proxy (Proxy (..)) +import Data.Text (Text, breakOn, pack) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text +import qualified Data.Text.IO as Text import Data.Time.Clock (getCurrentTime) import Data.Time.Clock.POSIX (utcTimeToPOSIXSeconds) import Data.Version (showVersion) @@ -37,7 +53,7 @@ import Network.HostName (getHostName) import Network.Socket (Socket) import System.Directory (canonicalizePath, createDirectoryIfMissing, makeAbsolute) import System.Environment (lookupEnv) - +import System.Exit (exitFailure) #ifdef UNIX import GHC.Weak (deRefWeak) import System.Posix.Files @@ -115,7 +131,7 @@ runNode cmdPc = do configYamlPc <- parseNodeConfigurationFP . getLast $ pncConfigFile cmdPc nc <- case makeNodeConfiguration $ defaultPartialNodeConfiguration <> configYamlPc <> cmdPc of - Left err -> panic $ "Error in creating the NodeConfiguration: " <> Text.pack err + Left err -> error $ "Error in creating the NodeConfiguration: " <> err Right nc' -> return nc' putStrLn $ "Node configuration: " <> show nc @@ -124,7 +140,7 @@ runNode cmdPc = do Just vrfFp -> do vrf <- runExceptT $ checkVRFFilePermissions vrfFp case vrf of Left err -> - putTextLn (renderVRFPrivateKeyFilePermissionError err) >> exitFailure + Text.putStrLn (renderVRFPrivateKeyFilePermissionError err) >> exitFailure Right () -> pure () Nothing -> pure () @@ -214,7 +230,7 @@ handleNodeWithTracers cmdPc nc p networkMagic runP = do p loggingLayer <- case eLoggingLayer of - Left err -> putTextLn (Text.pack $ show err) >> exitFailure + Left err -> Text.putStrLn (Text.pack $ show err) >> exitFailure Right res -> return res !trace <- setupTrace loggingLayer let tracer = contramap pack $ toLogObject trace @@ -289,7 +305,7 @@ setupTrace loggingLayer = do where hostname = do hn0 <- pack <$> getHostName - return $ take 8 $ fst $ breakOn "." hn0 + return $ Text.take 8 $ fst $ breakOn "." hn0 {- -- TODO: needs to be finished (issue #4362) diff --git a/cardano-node/src/Cardano/Node/Tracing/API.hs b/cardano-node/src/Cardano/Node/Tracing/API.hs index bd797893cd9..dddfbd8d36f 100644 --- a/cardano-node/src/Cardano/Node/Tracing/API.hs +++ b/cardano-node/src/Cardano/Node/Tracing/API.hs @@ -7,7 +7,7 @@ module Cardano.Node.Tracing.API ( initTraceDispatcher ) where -import Cardano.Prelude (first) +import Data.Bifunctor (first) import Prelude import "contra-tracer" Control.Tracer (traceWith) diff --git a/cardano-node/src/Cardano/Node/Tracing/Documentation.hs b/cardano-node/src/Cardano/Node/Tracing/Documentation.hs index c87c21b254d..59b8866dec5 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Documentation.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Documentation.hs @@ -17,8 +17,11 @@ module Cardano.Node.Tracing.Documentation , docTracers ) where +import Control.Exception (SomeException) import Data.Aeson.Types (ToJSON) +import Data.Proxy (Proxy (..)) import qualified Data.Text.IO as T +import GHC.Generics (Generic) import Network.Mux (MuxTrace (..), WithMuxBearer (..)) import qualified Network.Socket as Socket import qualified Options.Applicative as Opt @@ -26,7 +29,6 @@ import qualified Options.Applicative as Opt import Cardano.Logging import Cardano.Logging.Resources import Cardano.Logging.Resources.Types () -import Cardano.Prelude hiding (trace) import Cardano.Node.Tracing.DefaultTraceConfig (defaultCardanoConfig) import Cardano.Node.Tracing.Formatting () diff --git a/cardano-node/src/Cardano/Node/Tracing/Formatting.hs b/cardano-node/src/Cardano/Node/Tracing/Formatting.hs index 09d680c4dd1..b688285bcf0 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Formatting.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Formatting.hs @@ -7,11 +7,11 @@ module Cardano.Node.Tracing.Formatting ( ) where -import Cardano.Prelude () import Data.Aeson (Value (String), toJSON, (.=)) +import Data.Proxy (Proxy(..)) +import Data.Void (Void) import Cardano.Logging (LogFormatting (..)) -import Cardano.Prelude hiding (Show, show) import Cardano.Node.Tracing.Render (renderHeaderHashForDetails) diff --git a/cardano-node/src/Cardano/Node/Tracing/Peers.hs b/cardano-node/src/Cardano/Node/Tracing/Peers.hs index 3b01152d5ff..b4d3a6726d8 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Peers.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Peers.hs @@ -6,9 +6,9 @@ module Cardano.Node.Tracing.Peers , traceNodePeers ) where -import Cardano.Prelude - import Data.Aeson (FromJSON, ToJSON) +import Data.Text (Text) +import GHC.Generics (Generic) import Cardano.Logging diff --git a/cardano-node/src/Cardano/Node/Tracing/Render.hs b/cardano-node/src/Cardano/Node/Tracing/Render.hs index 0412f71c79c..a5795c1c8b0 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Render.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Render.hs @@ -24,10 +24,9 @@ module Cardano.Node.Tracing.Render , renderWithOrigin ) where -import Cardano.Prelude -import Prelude (id) - import qualified Data.ByteString.Base16 as B16 +import Data.Proxy (Proxy (..)) +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs index 21a18ab404f..5f347183eca 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/ChainDB.hs @@ -12,19 +12,21 @@ module Cardano.Node.Tracing.Tracers.ChainDB ( withAddedToCurrentChainEmptyLimited ) where +import Cardano.Prelude (maximumDef) + import Data.Aeson (Value (String), toJSON, (.=)) +import Data.Int (Int64) +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text +import Data.Word (Word64) import Numeric (showFFloat) -import Prelude (id) -import Text.Show import Cardano.Logging import Cardano.Node.Tracing.Era.Byron () import Cardano.Node.Tracing.Era.Shelley () import Cardano.Node.Tracing.Formatting () import Cardano.Node.Tracing.Render -import Cardano.Prelude hiding (Show, show, trace) import Ouroboros.Consensus.Block import Ouroboros.Consensus.HeaderValidation (HeaderEnvelopeError (..), HeaderError (..), @@ -46,7 +48,6 @@ import qualified Ouroboros.Consensus.Storage.VolatileDB as VolDB import Ouroboros.Consensus.Util.Condense (condense) import Ouroboros.Consensus.Util.Enclose - import qualified Ouroboros.Network.AnchoredFragment as AF -- {-# ANN module ("HLint: ignore Redundant bracket" :: Text) #-} diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/ForgingThreadStats.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/ForgingThreadStats.hs index d68927a36bc..9f9a50b5259 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/ForgingThreadStats.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/ForgingThreadStats.hs @@ -10,9 +10,13 @@ module Cardano.Node.Tracing.Tracers.ForgingThreadStats ) where import Cardano.Logging -import Cardano.Prelude hiding (All, concat, (:.:)) + +import Control.Concurrent (ThreadId, myThreadId) +import Control.Monad.IO.Class (MonadIO (..)) import Data.Aeson (Value (..), (.=)) +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map +import Data.Maybe (fromMaybe) import Cardano.Node.Tracing.Tracers.StartLeadershipCheck (ForgeTracerType) import Cardano.Slotting.Slot (SlotNo (..)) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/KESInfo.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/KESInfo.hs index 006c8cc0146..1c01aa08305 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/KESInfo.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/KESInfo.hs @@ -16,13 +16,13 @@ module Cardano.Node.Tracing.Tracers.KESInfo traceAsKESInfo ) where +import Control.Monad.IO.Class (MonadIO) import Data.Aeson (ToJSON (..), Value (..), (.=)) +import Data.Proxy (Proxy) import qualified Data.Text as Text -import Prelude (show) import Cardano.Logging import Cardano.Node.Queries (GetKESInfo (..)) -import Cardano.Prelude hiding (All, Show, show) import Cardano.Protocol.TPraos.OCert (KESPeriod (KESPeriod)) import Ouroboros.Consensus.Block.Forging diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToClient.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToClient.hs index 790d6b15c00..a4a2a18bc94 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToClient.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/NodeToClient.hs @@ -11,9 +11,9 @@ module Cardano.Node.Tracing.Tracers.NodeToClient () where import Cardano.Logging -import Cardano.Prelude hiding (Show, show) import Data.Aeson (Value (String), (.=)) -import Data.Text (pack) +import Data.Text (Text, pack) + import Network.TypedProtocol.Codec (AnyMessageAndAgency (..)) import Ouroboros.Consensus.Ledger.Query (Query) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/NonP2P.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/NonP2P.hs index db078e08390..c60d9f138b1 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/NonP2P.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/NonP2P.hs @@ -10,7 +10,8 @@ module Cardano.Node.Tracing.Tracers.NonP2P () where import Cardano.Logging -import Cardano.Prelude hiding (Show, show) + +import Control.Exception (Exception (..), SomeException (..)) import Data.Aeson (Value (String), (.=)) import qualified Data.IP as IP import Data.Text (pack) diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs index 8f125bcd77a..e882bc65125 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/P2P.hs @@ -12,16 +12,15 @@ module Cardano.Node.Tracing.Tracers.P2P () where import Cardano.Logging -import Cardano.Prelude hiding (group, show) import Data.Aeson (Object, ToJSON, ToJSONKey, Value (..), object, toJSON, toJSONList, (.=)) import Data.Aeson.Types (listValue) -import Data.List (last) +import Data.Bifunctor (Bifunctor (..)) +import Data.Foldable (Foldable (..)) import qualified Data.Map.Strict as Map import qualified Data.Set as Set import Data.Text (pack) import Network.Socket (SockAddr (..)) -import Prelude (show) import Cardano.Node.Configuration.TopologyP2P () import Cardano.Tracing.OrphanInstances.Network () diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Peer.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Peer.hs index 396cd56b57d..0da0dad0238 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Peer.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/Peer.hs @@ -12,15 +12,19 @@ module Cardano.Node.Tracing.Tracers.Peer where -- , ppPeer -- ) where -import Cardano.Prelude hiding (atomically) -import Prelude (String) - import qualified Control.Concurrent.Class.MonadSTM.Strict as STM import "contra-tracer" Control.Tracer +import Control.Concurrent (threadDelay) +import Control.Concurrent.Async +import Control.Monad (forever) import Data.Aeson (ToJSON (..), Value (..), toJSON, (.=)) +import Data.Functor ((<&>)) +import qualified Data.List as List +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import qualified Data.Set as Set +import Data.Text (Text) import qualified Data.Text as Text import Text.Printf (printf) @@ -125,9 +129,9 @@ getCurrentPeers nkd = mapNodeKernelDataIO extractPeers nkd instance LogFormatting [PeerT blk] where forMachine _ [] = mempty forMachine dtal xs = mconcat - [ "peers" .= toJSON (foldl' (\acc x -> forMachine dtal x : acc) [] xs) + [ "peers" .= toJSON (List.foldl' (\acc x -> forMachine dtal x : acc) [] xs) ] - forHuman peers = Text.concat $ intersperse ", " (map ppPeer peers) + forHuman peers = Text.concat $ List.intersperse ", " (map ppPeer peers) asMetrics peers = [IntM "Net.PeersFromNodeKernel" (fromIntegral (length peers))] instance LogFormatting (PeerT blk) where @@ -135,9 +139,9 @@ instance LogFormatting (PeerT blk) where mconcat [ "peerAddress" .= String (Text.pack . show . remoteAddress $ cid) , "peerStatus" .= String (Text.pack . ppStatus $ status) , "peerSlotNo" .= String (Text.pack . ppMaxSlotNo . peerFetchMaxSlotNo $ inflight) - , "peerReqsInF" .= String (show . peerFetchReqsInFlight $ inflight) - , "peerBlocksInF" .= String (show . Set.size . peerFetchBlocksInFlight $ inflight) - , "peerBytesInF" .= String (show . peerFetchBytesInFlight $ inflight) + , "peerReqsInF" .= String (Text.pack . show . peerFetchReqsInFlight $ inflight) + , "peerBlocksInF" .= String (Text.pack . show . Set.size . peerFetchBlocksInFlight $ inflight) + , "peerBytesInF" .= String (Text.pack . show . peerFetchBytesInFlight $ inflight) ] instance MetaTrace [PeerT blk] where diff --git a/cardano-node/src/Cardano/Node/Tracing/Tracers/Resources.hs b/cardano-node/src/Cardano/Node/Tracing/Tracers/Resources.hs index 074c7bcb87f..945c1dc8e20 100644 --- a/cardano-node/src/Cardano/Node/Tracing/Tracers/Resources.hs +++ b/cardano-node/src/Cardano/Node/Tracing/Tracers/Resources.hs @@ -4,10 +4,15 @@ module Cardano.Node.Tracing.Tracers.Resources ( startResourceTracer ) where +import Control.Concurrent (threadDelay) +import Control.Concurrent.Async (async) +import Control.Monad (forM_) +import Control.Monad.Class.MonadAsync (link) +import Control.Monad.Cont (forever) + import "contra-tracer" Control.Tracer import Cardano.Logging.Resources -import Cardano.Prelude hiding (trace) startResourceTracer :: Tracer IO ResourceStats @@ -22,5 +27,5 @@ startResourceTracer tr delayMilliseconds = do mbrs <- readResourceStats forM_ mbrs $ \rs -> traceWith tr rs threadDelay (delayMilliseconds * 1000) - maybe (pure ()) (traceWith tr) mbrs + forM_ mbrs $ \rs -> traceWith tr rs threadDelay (delayMilliseconds * 1000) diff --git a/cardano-node/src/Cardano/Node/Types.hs b/cardano-node/src/Cardano/Node/Types.hs index 0753a5835eb..dc55cb6d547 100644 --- a/cardano-node/src/Cardano/Node/Types.hs +++ b/cardano-node/src/Cardano/Node/Types.hs @@ -29,11 +29,13 @@ module Cardano.Node.Types , renderVRFPrivateKeyFilePermissionError ) where -import Cardano.Prelude -import Prelude (fail) - import Data.Aeson +import Data.ByteString (ByteString) +import Data.Monoid (Last) +import Data.String (IsString) +import Data.Text (Text) import qualified Data.Text as Text +import Data.Word (Word16, Word8) import Cardano.Api import qualified Cardano.Chain.Update as Byron diff --git a/cardano-node/src/Cardano/Tracing/Config.hs b/cardano-node/src/Cardano/Tracing/Config.hs index 3d1cf49ccad..0c37a57fcff 100644 --- a/cardano-node/src/Cardano/Tracing/Config.hs +++ b/cardano-node/src/Cardano/Tracing/Config.hs @@ -22,14 +22,19 @@ module Cardano.Tracing.Config , TraceInboundGovernorCounters ) where -import Cardano.Prelude -import Prelude (String) - +import Control.Monad (MonadPlus (..)) import Data.Aeson import qualified Data.Aeson.Key as Aeson import Data.Aeson.Types +import Data.Bifunctor (Bifunctor (..)) +import Data.Monoid (Last (..)) +import Data.Proxy (Proxy (..)) +import Data.Text (Text) import qualified Data.Text as Text import Generic.Data (gmappend) +import GHC.Generics (Generic) +import GHC.TypeLits (KnownSymbol, Symbol, symbolVal) + import Cardano.BM.Tracing (TracingVerbosity (..)) import Cardano.Node.Orphans () diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Common.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Common.hs index b6ff5a01986..3f3e862daf0 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Common.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Common.hs @@ -5,7 +5,6 @@ {-# LANGUAGE GeneralizedNewtypeDeriving #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE StandaloneDeriving #-} -{-# LANGUAGE TypeApplications #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} @@ -40,16 +39,16 @@ module Cardano.Tracing.OrphanInstances.Common , mkLOMeta ) where -import Cardano.Prelude -import Prelude (fail) - import Data.Aeson hiding (Value) import qualified Data.ByteString.Base16 as B16 import qualified Data.ByteString.Short as SBS import Data.Scientific (coefficient) +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text +import Data.Void (Void) import Network.Socket (PortNumber) +import Text.Read (readMaybe) import Cardano.BM.Data.LogItem (LOContent (..), LogObject (..), PrivacyAnnotation (..), mkLOMeta) @@ -83,7 +82,7 @@ instance FromJSON TracingVerbosity where <> "Encountered: " <> show invalid instance FromJSON PortNumber where - parseJSON (Number portNum) = case readMaybe . show @Integer @Text $ coefficient portNum of + parseJSON (Number portNum) = case readMaybe . show $ coefficient portNum of Just port -> pure port Nothing -> fail $ show portNum <> " is not a valid port number." parseJSON invalid = fail $ "Parsing of port number failed due to type mismatch. " diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs index 7e1e8546a7c..bafe808449a 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Consensus.hs @@ -1,6 +1,7 @@ {-# LANGUAGE DeriveGeneric #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} +{-# LANGUAGE InstanceSigs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NamedFieldPuns #-} @@ -12,17 +13,19 @@ {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -Wno-orphans #-} -{-# LANGUAGE InstanceSigs #-} module Cardano.Tracing.OrphanInstances.Consensus () where -import Cardano.Prelude hiding (show) -import Prelude (id, show) - +import Cardano.Prelude (maximumDef) import Data.Aeson (Value (..)) -import Data.Text (pack) +import qualified Data.Aeson as Aeson +import Data.Data (Proxy (..)) +import Data.Foldable (Foldable (..)) +import Data.Text (Text, pack) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text +import Data.Word (Word32) +import GHC.Generics (Generic) import Numeric (showFFloat) import Cardano.Slotting.Slot (fromWithOrigin) @@ -33,7 +36,8 @@ import Cardano.Tracing.Render (renderChainHash, renderChunkNo, renderH renderPointForVerbosity, renderRealPoint, renderRealPointAsPhrase, renderTipBlockNo, renderTipHash, renderWithOrigin) -import Cardano.Node.Tracing.Tracers.ConsensusStartupException (ConsensusStartupException (..)) +import Cardano.Node.Tracing.Tracers.ConsensusStartupException + (ConsensusStartupException (..)) import Ouroboros.Consensus.Block (BlockProtocol, BlockSupportsProtocol, CannotForge, ConvertRawHash (..), ForgeStateUpdateError, Header, RealPoint, blockNo, @@ -79,7 +83,7 @@ import Ouroboros.Network.Point (withOrigin) import qualified Ouroboros.Consensus.Storage.ChainDB as ChainDB -- TODO: 'TraceCacheEvent' should be exported by the 'Impl' module -import qualified Data.Aeson as Aeson +import Data.Function (on) import qualified Ouroboros.Consensus.Storage.ImmutableDB.API as ImmDB import qualified Ouroboros.Consensus.Storage.ImmutableDB.Impl.Types as ImmDB import qualified Ouroboros.Consensus.Storage.LedgerDB.OnDisk as LedgerDB diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs index 85b981358fc..17802abaf55 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Network.hs @@ -15,17 +15,19 @@ module Cardano.Tracing.OrphanInstances.Network () where -import Cardano.Prelude hiding (group, show) -import Prelude (String, show) - +import Control.Exception (Exception (..), SomeException (..)) import Control.Monad.Class.MonadTime (DiffTime, Time (..)) import Data.Aeson (Value (..)) import qualified Data.Aeson as Aeson import Data.Aeson.Types (listValue) +import Data.Bifunctor (Bifunctor (..)) +import Data.Data (Proxy (..)) +import Data.Foldable (Foldable (..)) +import Data.Functor.Identity (Identity (..)) import qualified Data.IP as IP import qualified Data.Map.Strict as Map import qualified Data.Set as Set -import Data.Text (pack) +import Data.Text (Text, pack) import Network.TypedProtocol.Codec (AnyMessageAndAgency (..)) import Network.TypedProtocol.Core (PeerHasAgency (..)) diff --git a/cardano-node/src/Cardano/Tracing/Peer.hs b/cardano-node/src/Cardano/Tracing/Peer.hs index ee521d4eb73..b1317a93364 100644 --- a/cardano-node/src/Cardano/Tracing/Peer.hs +++ b/cardano-node/src/Cardano/Tracing/Peer.hs @@ -10,14 +10,17 @@ module Cardano.Tracing.Peer , tracePeers ) where -import Cardano.Prelude hiding (atomically) -import Prelude (String) - import qualified Control.Concurrent.Class.MonadSTM.Strict as STM +import Control.DeepSeq (NFData (..)) import Data.Aeson (ToJSON (..), Value (..), toJSON, (.=)) +import Data.Functor ((<&>)) +import qualified Data.List as List +import Data.Map.Strict (Map) import qualified Data.Map.Strict as Map import qualified Data.Set as Set +import Data.Text (Text) import qualified Data.Text as Text +import GHC.Generics (Generic) import NoThunks.Class (AllowThunk (..), NoThunks) import Text.Printf (printf) @@ -128,7 +131,7 @@ instance ToObject [Peer blk] where toObject verb xs = mconcat [ "kind" .= String "NodeKernelPeers" , "peers" .= toJSON - (foldl' (\acc x -> toObject verb x : acc) [] xs) + (List.foldl' (\acc x -> toObject verb x : acc) [] xs) ] instance ToObject (Peer blk) where @@ -136,7 +139,7 @@ instance ToObject (Peer blk) where mconcat [ "peerAddress" .= String (Text.pack . show . remoteAddress $ cid) , "peerStatus" .= String (Text.pack . ppStatus $ status) , "peerSlotNo" .= String (Text.pack . ppMaxSlotNo . peerFetchMaxSlotNo $ inflight) - , "peerReqsInF" .= String (show . peerFetchReqsInFlight $ inflight) - , "peerBlocksInF" .= String (show . Set.size . peerFetchBlocksInFlight $ inflight) - , "peerBytesInF" .= String (show . peerFetchBytesInFlight $ inflight) + , "peerReqsInF" .= String (Text.pack . show . peerFetchReqsInFlight $ inflight) + , "peerBlocksInF" .= String (Text.pack . show . Set.size . peerFetchBlocksInFlight $ inflight) + , "peerBytesInF" .= String (Text.pack . show . peerFetchBytesInFlight $ inflight) ] diff --git a/cardano-node/src/Cardano/Tracing/Render.hs b/cardano-node/src/Cardano/Tracing/Render.hs index 00d9bdded15..eca66d988d2 100644 --- a/cardano-node/src/Cardano/Tracing/Render.hs +++ b/cardano-node/src/Cardano/Tracing/Render.hs @@ -22,10 +22,9 @@ module Cardano.Tracing.Render , renderWithOrigin ) where -import Cardano.Prelude -import Prelude (id) - import qualified Data.ByteString.Base16 as B16 +import Data.Proxy (Proxy(..)) +import Data.Text (Text) import qualified Data.Text as Text import qualified Data.Text.Encoding as Text diff --git a/cardano-node/src/Cardano/Tracing/Tracers.hs b/cardano-node/src/Cardano/Tracing/Tracers.hs index d215e36ba55..5ea305ffa23 100644 --- a/cardano-node/src/Cardano/Tracing/Tracers.hs +++ b/cardano-node/src/Cardano/Tracing/Tracers.hs @@ -27,18 +27,24 @@ module Cardano.Tracing.Tracers , traceCounter ) where -import Cardano.Prelude hiding (show) -import Prelude (String, show) - import GHC.Clock (getMonotonicTimeNSec) import Codec.CBOR.Read (DeserialiseFailure) +import Control.Concurrent (MVar, modifyMVar_) +import Control.Concurrent.STM (STM, atomically) +import Control.Monad (forM_, when) import Data.Aeson (ToJSON (..), Value (..)) +import Data.Functor ((<&>)) +import Data.Int (Int64) import Data.IntPSQ (IntPSQ) import qualified Data.IntPSQ as Pq import qualified Data.Map.Strict as Map +import Data.Proxy (Proxy (..)) +import Data.Text (Text) import qualified Data.Text as Text import Data.Time (NominalDiffTime, UTCTime) +import Data.Word (Word64) +import GHC.TypeLits (KnownNat, Nat, natVal) import qualified System.Metrics.Counter as Counter import qualified System.Metrics.Gauge as Gauge import qualified System.Metrics.Label as Label diff --git a/cardano-node/test/Test/Cardano/Node/Json.hs b/cardano-node/test/Test/Cardano/Node/Json.hs index 73bacf4479b..d3159fc66d2 100644 --- a/cardano-node/test/Test/Cardano/Node/Json.hs +++ b/cardano-node/test/Test/Cardano/Node/Json.hs @@ -4,10 +4,10 @@ module Test.Cardano.Node.Json ( tests ) where -import Cardano.Prelude import Cardano.Node.Configuration.TopologyP2P (NetworkTopology) import Data.Aeson (decode, encode, fromJSON, toJSON) +import Data.Maybe (isJust) import Hedgehog (Property, discover) import qualified Hedgehog