Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration work for node 8.7.0 #440

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ repository cardano-haskell-packages
-- See CONTRIBUTING for information about these, including some Nix commands
-- you need to run if you change them
index-state:
, hackage.haskell.org 2023-08-08T19:56:09Z
, cardano-haskell-packages 2023-11-10T12:47:36Z
, hackage.haskell.org 2023-11-09T23:50:15Z
, cardano-haskell-packages 2023-11-17T15:33:21Z

packages:
cardano-cli
Expand Down
4 changes: 3 additions & 1 deletion cardano-cli/app/cardano-cli.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#define UNIX
#endif

import Cardano.CLI.Pretty

import Cardano.CLI.Environment (getEnvCli)
import Cardano.CLI.Options (opts, pref)
import Cardano.CLI.Run (renderClientCommandError, runClientCommand)
Expand All @@ -31,4 +33,4 @@ main = toplevelExceptionHandler $ do
#endif
co <- Opt.customExecParser pref (opts envCli)

orDie renderClientCommandError $ runClientCommand co
orDie (prettyToText . renderClientCommandError) $ runClientCommand co
2 changes: 1 addition & 1 deletion cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ library
, binary
, bytestring
, canonical-json
, cardano-api ^>= 8.31.0.0
, cardano-api ^>= 8.33.0.0
, cardano-binary
, cardano-crypto
, cardano-crypto-class ^>= 2.1.2
Expand Down
18 changes: 10 additions & 8 deletions cardano-cli/src/Cardano/CLI/Byron/Delegation.hs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}

Expand All @@ -13,6 +14,7 @@ module Cardano.CLI.Byron.Delegation
where

import Cardano.Api.Byron
import Cardano.Api.Pretty

import qualified Cardano.Chain.Delegation as Dlg
import Cardano.Chain.Slotting (EpochNumber)
Expand Down Expand Up @@ -41,14 +43,14 @@ data ByronDelegationError
| ByronDelegationKeyError !ByronKeyFailure
deriving Show

renderByronDelegationError :: ByronDelegationError -> Text
renderByronDelegationError err =
case err of
CertificateValidationErrors certFp errs ->
"Certificate validation error(s) at: " <> textShow certFp <> " Errors: " <> textShow errs
DlgCertificateDeserialisationFailed certFp deSererr ->
"Certificate deserialisation error at: " <> textShow certFp <> " Error: " <> textShow deSererr
ByronDelegationKeyError kerr -> renderByronKeyFailure kerr
renderByronDelegationError :: ByronDelegationError -> Doc ann
renderByronDelegationError = \case
CertificateValidationErrors certFp errs ->
"Certificate validation error(s) at: " <> pshow certFp <> " Errors: " <> pshow errs
DlgCertificateDeserialisationFailed certFp deSererr ->
"Certificate deserialisation error at: " <> pshow certFp <> " Error: " <> pshow deSererr
ByronDelegationKeyError kerr ->
renderByronKeyFailure kerr

-- TODO: we need to support password-protected secrets.
-- | Issue a certificate for genesis delegation to a delegate key, signed by the
Expand Down
50 changes: 25 additions & 25 deletions cardano-cli/src/Cardano/CLI/Byron/Genesis.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{-# LANGUAGE GeneralisedNewtypeDeriving #-}

{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.Byron.Genesis
( ByronGenesisError(..)
Expand All @@ -12,9 +12,10 @@ module Cardano.CLI.Byron.Genesis
)
where

import Cardano.Api (Key (..), NetworkId, textShow, writeSecrets)
import Cardano.Api (Key (..), NetworkId, writeSecrets)
import Cardano.Api.Byron (ByronKey, SerialiseAsRawBytes (..), SigningKey (..),
toByronRequiresNetworkMagic)
import Cardano.Api.Pretty

import qualified Cardano.Chain.Common as Common
import Cardano.Chain.Delegation hiding (Map, epoch)
Expand Down Expand Up @@ -59,29 +60,28 @@ data ByronGenesisError

deriving Show

renderByronGenesisError :: ByronGenesisError -> Text
renderByronGenesisError err =
case err of
ProtocolParametersParseFailed pParamFp parseError ->
"Protocol parameters parse failed at: " <> textShow pParamFp <> " Error: " <> parseError
ByronDelegationCertSerializationError bDelegSerErr ->
"Error while serializing the delegation certificate: " <> textShow bDelegSerErr
ByronDelegationKeySerializationError bKeySerErr ->
"Error while serializing the delegation key: " <> textShow bKeySerErr
PoorKeyFailure bKeyFailure ->
"Error creating poor keys: " <> textShow bKeyFailure
MakeGenesisDelegationError genDelegError ->
"Error creating genesis delegation: " <> textShow genDelegError
GenesisGenerationError genDataGenError ->
"Error generating genesis: " <> textShow genDataGenError
GenesisOutputDirAlreadyExists genOutDir ->
"Genesis output directory already exists: " <> textShow genOutDir
GenesisReadError genFp genDataError ->
"Error while reading genesis file at: " <> textShow genFp <> " Error: " <> textShow genDataError
GenesisSpecError genSpecError ->
"Error while creating genesis spec" <> textShow genSpecError
NoGenesisDelegationForKey verKey ->
"Error while creating genesis, no delegation certificate for this verification key:" <> textShow verKey
renderByronGenesisError :: ByronGenesisError -> Doc ann
renderByronGenesisError = \case
ProtocolParametersParseFailed pParamFp parseError ->
"Protocol parameters parse failed at: " <> pshow pParamFp <> " Error: " <> pretty parseError
ByronDelegationCertSerializationError bDelegSerErr ->
"Error while serializing the delegation certificate: " <> pshow bDelegSerErr
ByronDelegationKeySerializationError bKeySerErr ->
"Error while serializing the delegation key: " <> pshow bKeySerErr
PoorKeyFailure bKeyFailure ->
"Error creating poor keys: " <> pshow bKeyFailure
MakeGenesisDelegationError genDelegError ->
"Error creating genesis delegation: " <> pshow genDelegError
GenesisGenerationError genDataGenError ->
"Error generating genesis: " <> pshow genDataGenError
GenesisOutputDirAlreadyExists genOutDir ->
"Genesis output directory already exists: " <> pshow genOutDir
GenesisReadError genFp genDataError ->
"Error while reading genesis file at: " <> pshow genFp <> " Error: " <> pshow genDataError
GenesisSpecError genSpecError ->
"Error while creating genesis spec" <> pshow genSpecError
NoGenesisDelegationForKey verKey ->
"Error while creating genesis, no delegation certificate for this verification key:" <> pshow verKey

newtype NewDirectory =
NewDirectory FilePath
Expand Down
32 changes: 16 additions & 16 deletions cardano-cli/src/Cardano/CLI/Byron/Key.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.Byron.Key
( -- * Keys
Expand All @@ -16,6 +17,7 @@ module Cardano.CLI.Byron.Key
where

import Cardano.Api.Byron
import Cardano.Api.Pretty

import qualified Cardano.Chain.Common as Common
import Cardano.CLI.Types.Common
Expand All @@ -32,7 +34,6 @@ import Data.Text (Text)
import qualified Data.Text as T
import Formatting (build, sformat, (%))


data ByronKeyFailure
= ReadSigningKeyFailure !FilePath !Text
| ReadVerificationKeyFailure !FilePath !Text
Expand All @@ -42,21 +43,20 @@ data ByronKeyFailure
| CannotMigrateFromNonLegacySigningKey !FilePath
deriving Show

renderByronKeyFailure :: ByronKeyFailure -> Text
renderByronKeyFailure err =
case err of
CannotMigrateFromNonLegacySigningKey fp ->
"Migrate from non-legacy Byron key unnecessary: " <> textShow fp
ReadSigningKeyFailure sKeyFp readErr ->
"Error reading signing key at: " <> textShow sKeyFp <> " Error: " <> textShow readErr
ReadVerificationKeyFailure vKeyFp readErr ->
"Error reading verification key at: " <> textShow vKeyFp <> " Error: " <> textShow readErr
LegacySigningKeyDeserialisationFailed fp ->
"Error attempting to deserialise a legacy signing key at: " <> textShow fp
SigningKeyDeserialisationFailed sKeyFp ->
"Error deserialising signing key at: " <> textShow sKeyFp
VerificationKeyDeserialisationFailed vKeyFp deSerError ->
"Error deserialising verification key at: " <> textShow vKeyFp <> " Error: " <> textShow deSerError
renderByronKeyFailure :: ByronKeyFailure -> Doc ann
renderByronKeyFailure = \case
CannotMigrateFromNonLegacySigningKey fp ->
"Migrate from non-legacy Byron key unnecessary: " <> pshow fp
ReadSigningKeyFailure sKeyFp readErr ->
"Error reading signing key at: " <> pshow sKeyFp <> " Error: " <> pshow readErr
ReadVerificationKeyFailure vKeyFp readErr ->
"Error reading verification key at: " <> pshow vKeyFp <> " Error: " <> pshow readErr
LegacySigningKeyDeserialisationFailed fp ->
"Error attempting to deserialise a legacy signing key at: " <> pshow fp
SigningKeyDeserialisationFailed sKeyFp ->
"Error deserialising signing key at: " <> pshow sKeyFp
VerificationKeyDeserialisationFailed vKeyFp deSerError ->
"Error deserialising verification key at: " <> pshow vKeyFp <> " Error: " <> pshow deSerError

newtype NewSigningKeyFile =
NewSigningKeyFile FilePath
Expand Down
5 changes: 3 additions & 2 deletions cardano-cli/src/Cardano/CLI/Byron/Parsers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ module Cardano.CLI.Byron.Parsers
import Cardano.Api hiding (GenesisParameters, UpdateProposal)
import Cardano.Api.Byron (Address (..), ByronProtocolParametersUpdate (..),
toByronLovelace)
import Cardano.Api.Pretty
import Cardano.Api.Shelley (ReferenceScript (ReferenceScriptNone))

import Cardano.Chain.Common (BlockCount (..), TxFeePolicy (..), TxSizeLinear (..),
Expand Down Expand Up @@ -265,7 +266,7 @@ parseTxIdAtto = (<?> "Transaction ID (hexadecimal)") $ do
bstr <- Atto.takeWhile1 Char.isHexDigit
case deserialiseFromRawBytesHex AsTxId bstr of
Right addr -> return addr
Left e -> fail $ "Incorrect transaction id format: " ++ displayError e
Left e -> fail $ prettyToString $ "Incorrect transaction id format: " <> prettyError e

parseTxIxAtto :: Atto.Parser TxIx
parseTxIxAtto = toEnum <$> Atto.decimal
Expand Down Expand Up @@ -293,7 +294,7 @@ parseTxOut =
pLovelaceTxOut l =
if l > (maxBound :: Word64)
then error $ show l <> " lovelace exceeds the Word64 upper bound"
else TxOutValueByron ByronEraOnlyByron . Lovelace $ toInteger l
else TxOutValueByron . Lovelace $ toInteger l

readerFromAttoParser :: Atto.Parser a -> Opt.ReadM a
readerFromAttoParser p =
Expand Down
21 changes: 11 additions & 10 deletions cardano-cli/src/Cardano/CLI/Byron/Run.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.Byron.Run
( ByronClientCmdError
Expand Down Expand Up @@ -33,6 +34,7 @@ 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
import Prettyprinter

-- | Data type that encompasses all the possible errors of the
-- Byron client.
Expand All @@ -46,16 +48,15 @@ data ByronClientCmdError
| ByronCmdVoteError !ByronVoteError
deriving Show

renderByronClientCmdError :: ByronClientCmdError -> Text
renderByronClientCmdError err =
case err of
ByronCmdDelegationError e -> renderByronDelegationError e
ByronCmdGenesisError e -> renderByronGenesisError e
ByronCmdHelpersError e -> renderHelpersError e
ByronCmdKeyFailure e -> renderByronKeyFailure e
ByronCmdTxError e -> renderByronTxError e
ByronCmdUpdateProposalError e -> renderByronUpdateProposalError e
ByronCmdVoteError e -> renderByronVoteError e
renderByronClientCmdError :: ByronClientCmdError -> Doc ann
renderByronClientCmdError = \case
ByronCmdDelegationError e -> renderByronDelegationError e
ByronCmdGenesisError e -> renderByronGenesisError e
ByronCmdHelpersError e -> renderHelpersError e
ByronCmdKeyFailure e -> renderByronKeyFailure e
ByronCmdTxError e -> renderByronTxError e
ByronCmdUpdateProposalError e -> renderByronUpdateProposalError e
ByronCmdVoteError e -> renderByronVoteError e

runByronClientCommand :: ByronCommand -> ExceptT ByronClientCmdError IO ()
runByronClientCommand c =
Expand Down
23 changes: 12 additions & 11 deletions cardano-cli/src/Cardano/CLI/Byron/Tx.hs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE NamedFieldPuns #-}

module Cardano.CLI.Byron.Tx
Expand All @@ -26,6 +27,7 @@ where

import Cardano.Api
import Cardano.Api.Byron
import Cardano.Api.Pretty

import qualified Cardano.Binary as Binary
import qualified Cardano.Chain.Common as Common
Expand Down Expand Up @@ -63,16 +65,15 @@ data ByronTxError
| ByronTxSubmitErrorEraMismatch !EraMismatch
deriving Show

renderByronTxError :: ByronTxError -> Text
renderByronTxError err =
case err of
ByronTxSubmitError res -> "Error while submitting tx: " <> res
ByronTxSubmitErrorEraMismatch EraMismatch{ledgerEraName, otherEraName} ->
"The era of the node and the tx do not match. " <>
"The node is running in the " <> ledgerEraName <>
" era, but the transaction is for the " <> otherEraName <> " era."
TxDeserialisationFailed txFp decErr ->
"Transaction deserialisation failed at " <> textShow txFp <> " Error: " <> textShow decErr
renderByronTxError :: ByronTxError -> Doc ann
renderByronTxError = \case
ByronTxSubmitError res -> "Error while submitting tx: " <> pretty res
ByronTxSubmitErrorEraMismatch EraMismatch{ledgerEraName, otherEraName} ->
"The era of the node and the tx do not match. " <>
"The node is running in the " <> pretty ledgerEraName <>
" era, but the transaction is for the " <> pretty otherEraName <> " era."
TxDeserialisationFailed txFp decErr ->
"Transaction deserialisation failed at " <> pshow txFp <> " Error: " <> pshow decErr

newtype NewTxFile =
NewTxFile FilePath
Expand Down Expand Up @@ -244,7 +245,7 @@ nodeSubmitTx nodeSocketPath network gentx = do
localNodeNetworkId = network,
localConsensusModeParams = CardanoModeParams (EpochSlots 21600)
}
res <- liftIO $ submitTxToNodeLocal connctInfo (TxInByronSpecial ByronEraOnlyByron gentx)
res <- liftIO $ submitTxToNodeLocal connctInfo (TxInByronSpecial gentx)
case res of
Net.Tx.SubmitSuccess -> liftIO $ Text.putStrLn "Transaction successfully submitted."
Net.Tx.SubmitFail reason ->
Expand Down
33 changes: 17 additions & 16 deletions cardano-cli/src/Cardano/CLI/Byron/UpdateProposal.hs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{-# LANGUAGE DataKinds #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE LambdaCase #-}

module Cardano.CLI.Byron.UpdateProposal
( ByronUpdateProposalError(..)
Expand All @@ -9,9 +10,10 @@ module Cardano.CLI.Byron.UpdateProposal
, submitByronUpdateProposal
) where

import Cardano.Api (NetworkId, SerialiseAsRawBytes (..), SocketPath, textShow)
import Cardano.Api (NetworkId, SerialiseAsRawBytes (..), SocketPath)
import Cardano.Api.Byron (AsType (AsByronUpdateProposal), ByronProtocolParametersUpdate,
ByronUpdateProposal, makeByronUpdateProposal, toByronLedgerUpdateProposal)
import Cardano.Api.Pretty

import Cardano.Chain.Update (InstallerHash (..), ProtocolVersion (..),
SoftwareVersion (..), SystemTag (..))
Expand Down Expand Up @@ -41,21 +43,20 @@ data ByronUpdateProposalError
| UpdateProposalDecodingError !FilePath
deriving Show

renderByronUpdateProposalError :: ByronUpdateProposalError -> Text
renderByronUpdateProposalError err =
case err of
ByronReadUpdateProposalFileFailure fp rErr ->
"Error reading update proposal at " <> textShow fp <> " Error: " <> textShow rErr
ByronUpdateProposalWriteError hErr ->
"Error writing update proposal: " <> renderHelpersError hErr
ByronUpdateProposalGenesisReadError fp rErr ->
"Error reading update proposal at: " <> textShow fp <> " Error: " <> textShow rErr
ByronUpdateProposalTxError txErr ->
"Error submitting update proposal: " <> textShow txErr
ReadSigningKeyFailure fp rErr ->
"Error reading signing key at: " <> textShow fp <> " Error: " <> textShow rErr
UpdateProposalDecodingError fp ->
"Error decoding update proposal at: " <> textShow fp
renderByronUpdateProposalError :: ByronUpdateProposalError -> Doc ann
renderByronUpdateProposalError = \case
ByronReadUpdateProposalFileFailure fp rErr ->
"Error reading update proposal at " <> pshow fp <> " Error: " <> pshow rErr
ByronUpdateProposalWriteError hErr ->
"Error writing update proposal: " <> renderHelpersError hErr
ByronUpdateProposalGenesisReadError fp rErr ->
"Error reading update proposal at: " <> pshow fp <> " Error: " <> pshow rErr
ByronUpdateProposalTxError txErr ->
"Error submitting update proposal: " <> pshow txErr
ReadSigningKeyFailure fp rErr ->
"Error reading signing key at: " <> pshow fp <> " Error: " <> pshow rErr
UpdateProposalDecodingError fp ->
"Error decoding update proposal at: " <> pshow fp

runProposalCreation
:: NetworkId
Expand Down
Loading
Loading