Skip to content
Open
Show file tree
Hide file tree
Changes from 3 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
67 changes: 65 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 2025-06-22T20:18:27Z
, cardano-haskell-packages 2025-07-14T17:31:29Z
, hackage.haskell.org 2025-07-22T09:13:54Z
, cardano-haskell-packages 2025-07-28T14:33:19Z

packages:
cardano-cli
Expand Down Expand Up @@ -65,3 +65,66 @@ if impl (ghc >= 9.12)
-- https://github.com/kapralVV/Unique/issues/11
, Unique:hashable

allow-newer:
, cardano-ledger-byron
-- https://github.com/phadej/vec/issues/121
, ral:QuickCheck
, fin:QuickCheck
, bin:QuickCheck

constraints:


source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-api
tag: 076f7e966ec1d6457b1b9ec5ceee0f9e598fed12
--sha256: sha256-XmuQTZdD/ZdCNlRuD+V5cNslEM05xwTACmMunzuCCJY=
subdir:
cardano-api



source-repository-package
type: git
location: https://github.com/IntersectMBO/ouroboros-consensus
tag: 15fc8c4fee64473350e1904347bfd5852f9cdbfa
--sha256: sha256-Tvw0dLGZkBAflpvcEwl7Acnrux9H5UaniW5YwMvIeIs=
subdir:
ouroboros-consensus
ouroboros-consensus-cardano
ouroboros-consensus-diffusion
ouroboros-consensus-protocol
sop-extras
strict-sop-core

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-ledger
tag: 20485948f78ab139d246695e540f9ec00963a16e
--sha256: sha256-SHnyp+GvNeR82UXoKeDEgsp1AUE2yF5dGL4HIZm0zK8=
subdir:
eras/allegra/impl
eras/alonzo/impl
eras/alonzo/test-suite
eras/babbage/impl
eras/babbage/test-suite
eras/byron/chain/executable-spec
eras/byron/crypto
eras/byron/ledger/executable-spec
eras/byron/ledger/impl
eras/conway/impl
eras/dijkstra
eras/mary/impl
eras/shelley/impl
eras/shelley-ma/test-suite
eras/shelley/test-suite
libs/cardano-data
libs/cardano-ledger-api
libs/cardano-ledger-binary
libs/cardano-ledger-core
libs/cardano-protocol-tpraos
libs/non-integral
libs/set-algebra
libs/small-steps
libs/vector-map
7 changes: 5 additions & 2 deletions cardano-cli/cardano-cli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ library
cardano-ledger-api,
cardano-ledger-conway,
cardano-ledger-core,
cardano-ping ^>=0.8,
cardano-ping ^>=0.9,
cardano-prelude,
cardano-protocol-tpraos,
cardano-slotting ^>=0.2.0.0,
Expand All @@ -278,12 +278,15 @@ library
network,
network-uri,
optparse-applicative-fork,
ouroboros-consensus,
ouroboros-consensus-cardano,
prettyprinter,
prettyprinter-ansi-terminal,
random,
rio,
sop-extras,
split,
strict-stm,
io-classes:strict-stm,
text,
time,
transformers,
Expand Down
3 changes: 3 additions & 0 deletions cardano-cli/src/Cardano/CLI/Compatible/Governance/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ runCompatibleGovernanceActionCreateProtocolParametersUpdateCmd eraBasedPParams'
ShelleyBasedEraBabbage ->
shelleyToBabbageProtocolParametersUpdate sbe eraBasedPParams'
ShelleyBasedEraConway -> conwayProtocolParametersUpdate sbe eraBasedPParams'
ShelleyBasedEraDijkstra ->
-- TODO: Dijkstra
error "runCompatibleGovernanceActionCreateProtocolParametersUpdateCmd: Dijkstra not supported yet"

maybeAddUpdatedCostModel
:: GovernanceActionProtocolParametersUpdateCmdArgs era
Expand Down
11 changes: 10 additions & 1 deletion cardano-cli/src/Cardano/CLI/Compatible/Json/Friendly.hs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,14 @@ getScriptWitnessDetails era tb =
Ledger.ConwayRewarding (L.AsIxItem _ rp) -> addLabelToPurpose Rewarding rp
Ledger.ConwayVoting (L.AsIxItem _ vp) -> addLabelToPurpose Voting vp
Ledger.ConwayProposing (L.AsIxItem _ pp) -> addLabelToPurpose Proposing pp

friendlyPurpose AlonzoEraOnwardsDijkstra purpose =
case purpose of
Ledger.ConwaySpending (L.AsIxItem _ sp) -> addLabelToPurpose Spending (friendlyInput sp)
Ledger.ConwayMinting (L.AsIxItem _ mp) -> addLabelToPurpose Minting mp
Ledger.ConwayCertifying (L.AsIxItem _ cp) -> addLabelToPurpose Certifying cp
Ledger.ConwayRewarding (L.AsIxItem _ rp) -> addLabelToPurpose Rewarding rp
Ledger.ConwayVoting (L.AsIxItem _ vp) -> addLabelToPurpose Voting vp
Ledger.ConwayProposing (L.AsIxItem _ pp) -> addLabelToPurpose Proposing pp
friendlyInput :: Ledger.TxIn -> Aeson.Value
friendlyInput (Ledger.TxIn (Ledger.TxId txidHash) ix) =
Aeson.String $
Expand Down Expand Up @@ -738,6 +745,8 @@ renderCertificate sbe = \case
[ "Drep credential" .= drepCredential
, "anchor " .= mbAnchor
]
-- TODO: Dijkstra
_ -> error "renderCertificate: Dijkstra"
where
conwayToObject
:: ()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pTxOutDatum =
AlonzoEraOnwardsBabbage ->
pBabbageDatumFunctionality <|> pure TxOutDatumByNone
AlonzoEraOnwardsConway -> pConwayDatumFunctionality <|> pure TxOutDatumByNone
AlonzoEraOnwardsDijkstra -> pConwayDatumFunctionality <|> pure TxOutDatumByNone
)
where
pAlonzoDatumFunctionality =
Expand Down
1 change: 1 addition & 0 deletions cardano-cli/src/Cardano/CLI/Environment.hs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ anyCardanoEraToEra (AnyCardanoEra era) =
AlonzoEra -> Nothing
BabbageEra -> Nothing
ConwayEra -> Just Exp.ConwayEra
DijkstraEra -> Nothing

envCliEra :: EnvCli -> Maybe (Exp.Era Exp.ConwayEra)
envCliEra envCli = do
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Genesis/Option.hs
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,8 @@ pGenesisCreateTestNetData envCli =
<*> pNumGenesisKeys
<*> pNumPools
<*> pNumStakeDelegs
<*> (case Exp.useEra @era of Exp.ConwayEra -> pNumCommittee) -- Committee doesn't exist in babbage
<*> (case Exp.useEra @era of Exp.ConwayEra -> pNumDReps) -- DReps don't exist in babbage
<*> pNumCommittee
<*> pNumDReps
<*> pNumStuffedUtxoCount
<*> pNumUtxoKeys
<*> pSupply
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,9 @@ pGovActionProtocolParametersUpdate = \case
<*> pAlonzoOnwardsPParams
<*> pIntroducedInBabbagePParams
<*> pIntroducedInConwayPParams
ShelleyBasedEraDijkstra ->
-- TODO: Dijkstra
error "pGovActionProtocolParametersUpdate: Dijkstra era not supported yet"

pGovernanceActionTreasuryWithdrawalCmd
:: Exp.IsEra era => Maybe (Parser (Cmd.GovernanceActionCmds era))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,10 @@ addCostModelsToEraBasedProtocolParametersUpdate
cmdls
(ConwayEraBasedProtocolParametersUpdate common aOn inB inC) =
ConwayEraBasedProtocolParametersUpdate common (aOn{alCostModels = SJust cmdls}) inB inC
addCostModelsToEraBasedProtocolParametersUpdate
AlonzoEraOnwardsDijkstra
_
_ = error "addCostModelsToEraBasedProtocolParametersUpdate: Dijkstra not supported yet" -- TODO: Dijkstra

runGovernanceActionTreasuryWithdrawalCmd
:: forall era e
Expand Down
70 changes: 49 additions & 21 deletions cardano-cli/src/Cardano/CLI/EraBased/Query/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,13 @@
import Cardano.CLI.Type.Output qualified as O
import Cardano.Crypto.Hash (hashToBytesAsHex)
import Cardano.Ledger.Api.State.Query qualified as L
import Cardano.Ledger.Conway.State (ChainAccountState (..))
import Cardano.Slotting.EpochInfo (EpochInfo (..), epochInfoSlotToUTCTime, hoistEpochInfo)
import Cardano.Slotting.Time (RelativeTime (..), toRelativeTime)
import Ouroboros.Consensus.Cardano.Block as Consensus
import Ouroboros.Consensus.HardFork.Combinator.NetworkVersion
import Ouroboros.Consensus.Node.NetworkProtocolVersion
import Ouroboros.Consensus.Shelley.Ledger.NetworkProtocolVersion

import RIO hiding (toList)

Expand All @@ -77,6 +82,7 @@
import Data.Coerce (coerce)
import Data.List qualified as List
import Data.Map.Strict qualified as Map
import Data.SOP.Index
import Data.Sequence qualified as Seq
import Data.Set qualified as Set
import Data.Text qualified as Text
Expand Down Expand Up @@ -872,7 +878,7 @@
} = do
result <-
fromEitherIOCli
( executeLocalStateQueryExpr nodeConnInfo target $ runExceptT $ do
( executeLocalStateQueryExprWithVersion nodeConnInfo target $ \globalNtcVersion -> runExceptT $ do
AnyCardanoEra cEra <-
lift queryCurrentEra
& onLeft (left . QueryCmdUnsupportedNtcVersion)
Expand All @@ -882,9 +888,11 @@

result <- easyRunQuery (queryLedgerPeerSnapshot sbe)

shelleyNtcVersion <- hoistEither $ getShelleyNodeToClientVersion era globalNtcVersion

hoist liftIO $
obtainCommonConstraints era $
case decodeBigLedgerPeerSnapshot result of
case decodeBigLedgerPeerSnapshot shelleyNtcVersion result of
Left (bs, _decoderError) -> pure $ Left bs
Right snapshot -> pure $ Right snapshot
)
Expand Down Expand Up @@ -1057,6 +1065,28 @@

-- -------------------------------------------------------------------------------------------------

getShelleyNodeToClientVersion
:: Exp.Era era -> NodeToClientVersion -> Either QueryCmdError ShelleyNodeToClientVersion
getShelleyNodeToClientVersion era globalNtcVersion =
case supportedNodeToClientVersions (Proxy @(CardanoBlock StandardCrypto)) Map.! globalNtcVersion of
HardForkNodeToClientEnabled _ np ->
case era of
Exp.ConwayEra ->
case projectNP conwayIndex np of
EraNodeToClientDisabled -> Left QueryCmdNodeToClientDisabled
EraNodeToClientEnabled shelleyNtcVersion -> return shelleyNtcVersion
Exp.DijkstraEra ->
case projectNP dijkstraIndex np of
EraNodeToClientDisabled -> Left QueryCmdNodeToClientDisabled
EraNodeToClientEnabled shelleyNtcVersion -> return shelleyNtcVersion
HardForkNodeToClientDisabled _ -> Left QueryCmdNodeToClientDisabled

conwayIndex :: Index (x'1 : x'2 : x'3 : x'4 : x'5 : x'6 : x : xs1) x
conwayIndex = (IS (IS (IS (IS (IS (IS IZ))))))

dijkstraIndex :: Index (x'1 : x'2 : x'3 : x'4 : x'5 : x'6 : x'7 : x : xs1) x
dijkstraIndex = (IS (IS (IS (IS (IS (IS (IS IZ)))))))

writeStakeAddressInfo
:: StakeAddressInfoData
-> Vary [FormatJson, FormatYaml]
Expand Down Expand Up @@ -1212,7 +1242,7 @@
. Vary.on (\FormatCborBin -> CBOR.serialize $ toLedgerUTxO (convert era) utxo)
. Vary.on (\FormatCborHex -> Base16.encode . CBOR.serialize $ toLedgerUTxO (convert era) utxo)
. Vary.on (\FormatJson -> Json.encodeJson utxo)
. Vary.on (\FormatText -> strictTextToLazyBytestring $ filteredUTxOsToText (convert era) utxo)
. Vary.on (\FormatText -> strictTextToLazyBytestring $ filteredUTxOsToText utxo)
. Vary.on (\FormatYaml -> Json.encodeYaml utxo)
$ Vary.exhaustiveCase
)
Expand All @@ -1221,32 +1251,29 @@
. newExceptT
$ writeLazyByteStringOutput mOutFile output

filteredUTxOsToText :: Exp.Era era -> UTxO era -> Text
filteredUTxOsToText era (UTxO utxo) = do
filteredUTxOsToText :: UTxO era -> Text
filteredUTxOsToText (UTxO utxo) = do
mconcat
[ Text.unlines [title, Text.replicate (Text.length title + 2) "-"]
, Text.unlines $ case era of
Exp.ConwayEra ->
map (utxoToText era) $ toList utxo
, Text.unlines $
map (utxoToText) $
toList utxo
]
where
title :: Text
title =
" TxHash TxIx Amount"

utxoToText
:: Exp.Era era
-> (TxIn, TxOut CtxUTxO era)
:: (TxIn, TxOut CtxUTxO era)
-> Text
utxoToText sbe txInOutTuple =
case sbe of
Exp.ConwayEra ->
let (TxIn (TxId txhash) (TxIx index), TxOut _ value mDatum _) = txInOutTuple
in mconcat
[ Text.decodeLatin1 (hashToBytesAsHex txhash)
, textShowN 6 index
, " " <> printableValue value <> " + " <> Text.pack (show mDatum)
]
utxoToText txInOutTuple =
let (TxIn (TxId txhash) (TxIx index), TxOut _ value mDatum _) = txInOutTuple
in mconcat
[ Text.decodeLatin1 (hashToBytesAsHex txhash)
, textShowN 6 index
, " " <> printableValue value <> " + " <> Text.pack (show mDatum)
]
where
textShowN :: Show a => Int -> a -> Text
textShowN len x =
Expand Down Expand Up @@ -1901,12 +1928,13 @@
}
, Cmd.mOutFile
} = conwayEraOnwardsConstraints eon $ do
L.AccountState (L.Coin treasury) _reserves <-
chainAccountState <-
fromExceptTCli $
runQuery nodeConnInfo target $
queryAccountState eon

let output = LBS.pack $ show treasury
let (L.Coin treasury) = casTreasury chainAccountState
output = LBS.pack $ show treasury

fromEitherCIOCli @(FileError ()) $
writeLazyByteStringOutput mOutFile output
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ obtainConstraints v =
Api.PlutusScriptV1 -> id
Api.PlutusScriptV2 -> id
Api.PlutusScriptV3 -> id
Api.PlutusScriptV4 -> id

getVersion :: forall era. Era era -> L.Version
getVersion e = obtainCommonConstraints e $ L.eraProtVerLow @(LedgerEra era)
Expand Down
13 changes: 7 additions & 6 deletions cardano-cli/src/Cardano/CLI/EraBased/Transaction/Run.hs
Original file line number Diff line number Diff line change
Expand Up @@ -545,10 +545,12 @@ runTransactionBuildEstimateCmd -- TODO change type
toShelleyLedgerPParamsShim
:: Exp.Era era -> L.PParams (Exp.LedgerEra era) -> L.PParams (ShelleyLedgerEra era)
toShelleyLedgerPParamsShim Exp.ConwayEra pp = pp
toShelleyLedgerPParamsShim Exp.DijkstraEra pp = pp

fromShelleyLedgerPParamsShim
:: Exp.Era era -> L.PParams (ShelleyLedgerEra era) -> L.PParams (Exp.LedgerEra era)
fromShelleyLedgerPParamsShim Exp.ConwayEra pp = pp
fromShelleyLedgerPParamsShim Exp.DijkstraEra pp = pp

getPoolDeregistrationInfo
:: Exp.Era era
Expand All @@ -574,14 +576,13 @@ getStakeDeregistrationInfo (Exp.Certificate cert) =
getConwayDeregistrationInfo Exp.useEra cert

getConwayDeregistrationInfo
:: Exp.Era era
:: forall era
. Exp.Era era
-> L.TxCert (Exp.LedgerEra era)
-> Maybe (StakeCredential, Lovelace)
getConwayDeregistrationInfo e cert =
case e of
Exp.ConwayEra -> do
(stakeCred, depositRefund) <- L.getUnRegDepositTxCert cert
return (fromShelleyStakeCredential stakeCred, depositRefund)
getConwayDeregistrationInfo e cert = do
(stakeCred, depositRefund) <- obtainCommonConstraints e $ L.getUnRegDepositTxCert cert
return (fromShelleyStakeCredential stakeCred, depositRefund)

getExecutionUnitPrices :: CardanoEra era -> LedgerProtocolParameters era -> Maybe L.Prices
getExecutionUnitPrices cEra (LedgerProtocolParameters pp) =
Expand Down
4 changes: 2 additions & 2 deletions cardano-cli/src/Cardano/CLI/Orphan.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ import Cardano.Api.Experimental as Exp
import Cardano.Api.Ledger qualified as L

import Cardano.CLI.Type.Error.ScriptDecodeError
import Cardano.Ledger.CertState qualified as L
import Cardano.Ledger.Conway.Governance qualified as L
import Cardano.Ledger.State qualified as L
import Cardano.Ledger.Conway.State qualified as L

import Control.Exception
import Data.Aeson
Expand Down Expand Up @@ -103,3 +102,4 @@ instance Error [(Word64, TxMetadataRangeError)] where
-- Move to cardano-api
instance Convert Era AllegraEraOnwards where
convert Exp.ConwayEra = AllegraEraOnwardsConway
convert Exp.DijkstraEra = AllegraEraOnwardsDijkstra
2 changes: 2 additions & 0 deletions cardano-cli/src/Cardano/CLI/Read.hs
Original file line number Diff line number Diff line change
Expand Up @@ -894,3 +894,5 @@ deserialisePlutusScript bs = do
FromSomeType (AsPlutusScript AsPlutusScriptV2) (AnyPlutusScript PlutusScriptV2)
AnyPlutusScriptVersion PlutusScriptV3 ->
FromSomeType (AsPlutusScript AsPlutusScriptV3) (AnyPlutusScript PlutusScriptV3)
AnyPlutusScriptVersion PlutusScriptV4 ->
FromSomeType (AsPlutusScript AsPlutusScriptV4) (AnyPlutusScript PlutusScriptV4)
Loading
Loading