diff --git a/bench/plutus-scripts-bench/plutus-scripts-bench.cabal b/bench/plutus-scripts-bench/plutus-scripts-bench.cabal index 5102b134cf0..01137b531cd 100644 --- a/bench/plutus-scripts-bench/plutus-scripts-bench.cabal +++ b/bench/plutus-scripts-bench/plutus-scripts-bench.cabal @@ -72,7 +72,7 @@ library -- IOG dependencies -------------------------- build-depends: - , cardano-api ^>= 8.8 + , cardano-api ^>= 8.12 , plutus-ledger-api >=1.0.0 , plutus-tx >=1.0.0 , plutus-tx-plugin >=1.0.0 diff --git a/bench/tx-generator/tx-generator.cabal b/bench/tx-generator/tx-generator.cabal index e1714336cfe..b19cdef4237 100644 --- a/bench/tx-generator/tx-generator.cabal +++ b/bench/tx-generator/tx-generator.cabal @@ -97,9 +97,9 @@ library , attoparsec , base16-bytestring , bytestring - , cardano-api ^>= 8.8 + , cardano-api ^>= 8.12 , cardano-binary - , cardano-cli ^>= 8.4 + , cardano-cli ^>= 8.5 , cardano-crypto-class , cardano-crypto-wrapper , cardano-data @@ -193,8 +193,8 @@ test-suite tx-generator-apitest , bytestring , filepath , optparse-applicative-fork - , cardano-api ^>= 8.8 - , cardano-cli ^>= 8.4 + , cardano-api ^>= 8.12 + , cardano-cli ^>= 8.5 , cardano-node , plutus-tx , transformers @@ -209,8 +209,8 @@ test-suite tx-generator-apitest , bytestring , filepath , optparse-applicative-fork - , cardano-api ^>= 8.8 - , cardano-cli ^>= 8.4 + , cardano-api ^>= 8.12 + , cardano-cli ^>= 8.5 , cardano-node , transformers , transformers-except diff --git a/cabal.project b/cabal.project index 37dd3d7166f..877e728a28f 100644 --- a/cabal.project +++ b/cabal.project @@ -14,7 +14,7 @@ repository cardano-haskell-packages -- you need to run if you change them index-state: , hackage.haskell.org 2023-07-27T21:50:17Z - , cardano-haskell-packages 2023-07-27T18:37:22Z + , cardano-haskell-packages 2023-08-06T03:00:00Z packages: cardano-client-demo diff --git a/cardano-client-demo/StakeCredentialHistory.hs b/cardano-client-demo/StakeCredentialHistory.hs index 41df59e30c4..2d31a1754a7 100644 --- a/cardano-client-demo/StakeCredentialHistory.hs +++ b/cardano-client-demo/StakeCredentialHistory.hs @@ -1,6 +1,7 @@ {-# LANGUAGE BangPatterns #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} +{-# LANGUAGE GADTs #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE ScopedTypeVariables #-} @@ -15,11 +16,14 @@ import Cardano.Ledger.Compactible (Compactible (..)) import qualified Cardano.Ledger.Core as LC import Cardano.Ledger.Crypto (StandardCrypto) import qualified Cardano.Ledger.Shelley.API as L +import qualified Cardano.Ledger.Shelley.API as Shelley import qualified Cardano.Ledger.Shelley.Rewards as L import qualified Cardano.Ledger.Shelley.RewardUpdate as L import qualified Cardano.Ledger.UMap as UM import qualified Ouroboros.Consensus.Shelley.Ledger as Shelley +import qualified Cardano.Api.Ledger as L +import qualified Cardano.Ledger.Coin as L import qualified Codec.Binary.Bech32 as Bech32 import Control.Monad.Trans.Except (runExceptT) import Control.Monad.Trans.Fail.String @@ -254,7 +258,7 @@ main = do _ (BlockInMode (Block (BlockHeader slotNo _blockHeaderHash (BlockNo _blockNoI)) transactions) - _era) + eim) state -> do let getGoSnapshot = L.unStake . L.ssStake . L.ssStakeGo . L.esSnapshots . L.nesEs getBalances = UM.rewardMap @@ -286,8 +290,8 @@ main = do ("conway", L.nesEL ls, Just (L.nesRu ls, getGoSnapshot ls, getBalances ls, getPV ls)) let txBodyComponents = map ( (\(TxBody txbc) -> txbc) . getTxBody ) transactions - - mapM_ (delegationEvents targetCredAsAPI epochNo slotNo) txBodyComponents + let sbe'm = shelleyBasedEraFromEraInMode eim + mapM_ (delegationEvents sbe'm targetCredAsAPI epochNo slotNo) txBodyComponents mapM_ (withdrawalEvents targetCredAsAPI epochNo slotNo) txBodyComponents lastcheck <- displayCheckpoint slotNo (lastCheckpoint state) (checkpoint args) @@ -315,7 +319,6 @@ main = do return () where - -- CheckPoints -- displayCheckpoint :: SlotNo -> SlotNo -> CheckPoint -> IO SlotNo displayCheckpoint _ lastcheck CheckPointOff = return lastcheck @@ -337,31 +340,64 @@ main = do else return pvLast -- Delegation Events -- - delegationEvents :: StakeCredential -> EpochNo -> SlotNo -> TxBodyContent ViewTx era -> IO () - delegationEvents t epochNo slotNo txbc = case txCertificates txbc of - TxCertificatesNone -> return () - TxCertificates _ cs _ -> mapM_ msg $ mapMaybe (targetedCert t epochNo slotNo) cs - - targetedCert :: StakeCredential -> EpochNo -> SlotNo -> Certificate era -> Maybe (Event c) - targetedCert t epochNo slotNo = \case - StakeAddressRegistrationCertificate cred -> - if t == cred then Just (StakeRegistrationEvent epochNo slotNo) else Nothing - StakeAddressDeregistrationCertificate cred -> - if t == cred then Just (StakeDeRegistrationEvent epochNo slotNo) else Nothing - StakeAddressPoolDelegationCertificate cred pool -> - if t == cred then Just (DelegationEvent slotNo pool) else Nothing - StakePoolRegistrationCertificate pool -> - inPoolCert t slotNo pool - StakePoolRetirementCertificate _ _ -> Nothing - GenesisKeyDelegationCertificate {} -> Nothing - MIRCertificate pot (StakeAddressesMIR mir) -> - inMir t epochNo slotNo mir pot - MIRCertificate _ (SendToReservesMIR _) -> Nothing - MIRCertificate _ (SendToTreasuryMIR _) -> Nothing - - -- TODO CIP-1694 These are also delegation events. Should there be new events for these? - CommitteeDelegationCertificate _ _ -> Nothing - CommitteeHotKeyDeregistrationCertificate _ -> Nothing + delegationEvents :: Maybe (ShelleyBasedEra era) -> StakeCredential -> EpochNo -> SlotNo -> TxBodyContent ViewTx era -> IO () + delegationEvents sbe'm t epochNo slotNo txbc = do + case (txCertificates txbc, sbe'm) of + (TxCertificates _ cs _, Just sbe) -> mapM_ msg $ mapMaybe (targetedCert sbe t epochNo slotNo) cs + (_, _) -> return () + + targetedCert :: ShelleyBasedEra era -> StakeCredential -> EpochNo -> SlotNo -> Certificate era -> Maybe (Event c) + targetedCert sbe t epochNo slotNo = shelleyBasedEraConstraints sbe $ \case + ShelleyRelatedCertificate _ c -> + case c of + L.ShelleyTxCertDelegCert (L.ShelleyRegCert cred) -> + if t == fromShelleyStakeCredential cred then Just (StakeRegistrationEvent epochNo slotNo) else Nothing + L.ShelleyTxCertDelegCert (L.ShelleyUnRegCert cred) -> + if t == fromShelleyStakeCredential cred then Just (StakeDeRegistrationEvent epochNo slotNo) else Nothing + L.ShelleyTxCertDelegCert (L.ShelleyDelegCert cred poolId) -> + if t == fromShelleyStakeCredential cred then Just (DelegationEvent slotNo (StakePoolKeyHash poolId)) else Nothing + L.ShelleyTxCertPool (L.RetirePool _poolId _retirementEpoch) -> + Nothing + L.ShelleyTxCertPool (L.RegPool poolParams) -> + inPoolCert t slotNo (fromShelleyPoolParams poolParams) + L.ShelleyTxCertGenesisDeleg (L.GenesisDelegCert _genesisKeyHash _delegateKeyHash _vrfKeyHash) -> + Nothing + L.ShelleyTxCertMir (L.MIRCert pot (L.StakeAddressesMIR mir)) -> do + let addrs = flip map (Map.assocs mir) $ \(cred, L.DeltaCoin coin) -> (fromShelleyStakeCredential cred, Lovelace coin) + inMir t epochNo slotNo addrs pot + L.ShelleyTxCertMir (L.MIRCert _pot (L.SendToOppositePotMIR _coin)) -> do + Nothing -- TODO: unsure if Nothing + + -- TODO: Any events for ConwayCertificates? + ConwayCertificate w cert -> + conwayEraOnwardsConstraints w $ + case cert of + L.RegDRepTxCert _credential _coin -> + Nothing + L.UnRegDRepTxCert _credential _coin -> + Nothing + L.AuthCommitteeHotKeyTxCert (Shelley.KeyHash _coldKey) (Shelley.KeyHash _hotKey) -> + Nothing + L.ResignCommitteeColdTxCert (Shelley.KeyHash _coldKey) -> + Nothing + L.RegTxCert _stakeCredential -> + Nothing + L.UnRegTxCert _stakeCredential -> + Nothing + L.RegDepositTxCert _stakeCredential _deposit -> + Nothing + L.UnRegDepositTxCert _stakeCredential _refund -> + Nothing + L.DelegTxCert _stakeCredential _delegatee -> + Nothing + L.RegDepositDelegTxCert _stakeCredential _delegatee _deposit -> + Nothing + L.RegPoolTxCert _poolParams -> + Nothing + L.RetirePoolTxCert (Shelley.KeyHash _kh) _epoch -> + Nothing + L.DelegStakeTxCert _stakeCredential (Shelley.KeyHash _kh) -> + Nothing stakeCredentialFromStakeAddress (StakeAddress _ cred) = fromShelleyStakeCredential cred @@ -412,3 +448,16 @@ main = do -- Reward Calculation End Event -- rewardEndEvent epochLast epochCurrent slot rs t = epochEvent epochLast epochCurrent slot rs t RewardEndEvent + +shelleyBasedEraFromEraInMode :: EraInMode era mode -> Maybe (ShelleyBasedEra era) +shelleyBasedEraFromEraInMode = \case + ByronEraInByronMode -> Nothing + ByronEraInCardanoMode -> Nothing + ShelleyEraInCardanoMode -> Just ShelleyBasedEraShelley + ShelleyEraInShelleyMode -> Just ShelleyBasedEraShelley + AllegraEraInCardanoMode -> Just ShelleyBasedEraAllegra + MaryEraInCardanoMode -> Just ShelleyBasedEraMary + AlonzoEraInCardanoMode -> Just ShelleyBasedEraAlonzo + BabbageEraInCardanoMode -> Just ShelleyBasedEraBabbage + ConwayEraInCardanoMode -> Just ShelleyBasedEraConway + diff --git a/cardano-node-chairman/cardano-node-chairman.cabal b/cardano-node-chairman/cardano-node-chairman.cabal index bcf61af32eb..fcf1d2940a5 100644 --- a/cardano-node-chairman/cardano-node-chairman.cabal +++ b/cardano-node-chairman/cardano-node-chairman.cabal @@ -88,5 +88,5 @@ test-suite chairman-tests ghc-options: -threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T build-tool-depends: cardano-node:cardano-node - , cardano-cli:cardano-cli ^>= 8.3 + , cardano-cli:cardano-cli ^>= 8.5 , cardano-node-chairman:cardano-node-chairman diff --git a/cardano-node/ChangeLog.md b/cardano-node/ChangeLog.md index 681d4906a67..c4647316669 100644 --- a/cardano-node/ChangeLog.md +++ b/cardano-node/ChangeLog.md @@ -1,6 +1,13 @@ # Changelog for cardano-node -# 8.2.0 -- July 2023 +## 8.2.1 -- August 2023 + +- prevent SIGHUP from killing node during ledger replay +- upgrade cardano-cli to 8.4.1.0 +- upgrade cardano-api to 8.10.2.0 + + +## 8.2.0 -- July 2023 ### node changes diff --git a/cardano-node/cardano-node.cabal b/cardano-node/cardano-node.cabal index 9a3a94abb0d..35831f253d3 100644 --- a/cardano-node/cardano-node.cabal +++ b/cardano-node/cardano-node.cabal @@ -1,7 +1,7 @@ cabal-version: 3.0 name: cardano-node -version: 8.2.0 +version: 8.2.1 synopsis: The cardano full node description: The cardano full node. category: Cardano, @@ -137,7 +137,7 @@ library , async , base16-bytestring , bytestring - , cardano-api ^>= 8.8 + , cardano-api ^>= 8.12 , cardano-crypto-class , cardano-crypto-wrapper , cardano-git-rev @@ -235,7 +235,7 @@ test-suite cardano-node-test , aeson >= 1.5.6.0 , bytestring , cardano-crypto-class - , cardano-api ^>= 8.8 + , cardano-api ^>= 8.12 , cardano-ledger-core , cardano-node , cardano-slotting >= 0.1 diff --git a/cardano-node/src/Cardano/Tracing/OrphanInstances/Common.hs b/cardano-node/src/Cardano/Tracing/OrphanInstances/Common.hs index 3f3e862daf0..51398ebe0c6 100644 --- a/cardano-node/src/Cardano/Tracing/OrphanInstances/Common.hs +++ b/cardano-node/src/Cardano/Tracing/OrphanInstances/Common.hs @@ -40,12 +40,9 @@ module Cardano.Tracing.OrphanInstances.Common ) where 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) @@ -59,9 +56,6 @@ import Cardano.BM.Tracing (HasPrivacyAnnotation (..), HasSeverityAnnot Severity (..), ToObject (..), Tracer (..), TracingVerbosity (..), Transformable (..)) import Cardano.Node.Handlers.Shutdown () -import Ouroboros.Consensus.Byron.Ledger.Block (ByronHash (..)) -import Ouroboros.Consensus.HardFork.Combinator (OneEraHash (..)) -import Ouroboros.Network.Block (HeaderHash, Tip (..)) -- | A bit of a weird one, but needed because some of the very general -- consensus interfaces are sometimes instantiated to 'Void', when there are -- no cases needed. @@ -88,21 +82,6 @@ instance FromJSON PortNumber where parseJSON invalid = fail $ "Parsing of port number failed due to type mismatch. " <> "Encountered: " <> show invalid -instance ToJSON (HeaderHash blk) => ToJSON (Tip blk) where - toJSON TipGenesis = object [ "genesis" .= True ] - toJSON (Tip slotNo headerHash blockNo) = - object - [ "slotNo" .= slotNo - , "headerHash" .= headerHash - , "blockNo" .= blockNo - ] - -instance ToJSON (OneEraHash xs) where - toJSON (OneEraHash bs) = - toJSON . Text.decodeLatin1 . B16.encode . SBS.fromShort $ bs - -deriving newtype instance ToJSON ByronHash - instance HasPrivacyAnnotation ResourceStats instance HasSeverityAnnotation ResourceStats where getSeverityAnnotation _ = Info diff --git a/cardano-submit-api/cardano-submit-api.cabal b/cardano-submit-api/cardano-submit-api.cabal index 98f0d265ef1..6cea40ee499 100644 --- a/cardano-submit-api/cardano-submit-api.cabal +++ b/cardano-submit-api/cardano-submit-api.cabal @@ -39,9 +39,9 @@ library , aeson , async , bytestring - , cardano-api ^>= 8.8 + , cardano-api ^>= 8.12 , cardano-binary - , cardano-cli ^>= 8.4 + , cardano-cli ^>= 8.5 , cardano-crypto-class ^>= 2.1 , cardano-ledger-byron ^>= 1.0 , formatting @@ -86,7 +86,7 @@ executable cardano-submit-api ghc-options: -threaded -rtsopts "-with-rtsopts=-T -I0" build-depends: base , optparse-applicative-fork - , cardano-cli ^>= 8.4 + , cardano-cli ^>= 8.5 , cardano-crypto-class ^>= 2.1 , cardano-submit-api diff --git a/cardano-testnet/cardano-testnet.cabal b/cardano-testnet/cardano-testnet.cabal index aa553877496..5afa816bcfa 100644 --- a/cardano-testnet/cardano-testnet.cabal +++ b/cardano-testnet/cardano-testnet.cabal @@ -34,8 +34,8 @@ library build-depends: aeson , ansi-terminal , bytestring - , cardano-api ^>= 8.8 - , cardano-cli ^>= 8.4 + , cardano-api ^>= 8.12 + , cardano-cli ^>= 8.5 , cardano-crypto-class , cardano-crypto-wrapper , cardano-ledger-alonzo @@ -150,7 +150,7 @@ test-suite cardano-testnet-golden ghc-options: -threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T build-tool-depends: cardano-node:cardano-node - , cardano-cli:cardano-cli ^>= 8.4 + , cardano-cli:cardano-cli ^>= 8.5 , cardano-submit-api:cardano-submit-api , cardano-testnet:cardano-testnet @@ -176,8 +176,8 @@ test-suite cardano-testnet-test build-depends: aeson , async , bytestring - , cardano-api ^>= 8.8 - , cardano-cli ^>= 8.4 + , cardano-api ^>= 8.12 + , cardano-cli ^>= 8.5 , cardano-crypto-class , cardano-testnet , containers @@ -194,6 +194,6 @@ test-suite cardano-testnet-test ghc-options: -threaded -rtsopts -with-rtsopts=-N -with-rtsopts=-T build-tool-depends: cardano-node:cardano-node - , cardano-cli:cardano-cli ^>= 8.4 + , cardano-cli:cardano-cli ^>= 8.5 , cardano-submit-api:cardano-submit-api , cardano-testnet:cardano-testnet diff --git a/flake.lock b/flake.lock index 4d9d886573d..8249b1d2545 100644 --- a/flake.lock +++ b/flake.lock @@ -3,11 +3,11 @@ "CHaP": { "flake": false, "locked": { - "lastModified": 1690483556, - "narHash": "sha256-UOIamXYb+xLDrTYs41BaaCun2C3P/cscH4jQ+/1R3w0=", + "lastModified": 1691169578, + "narHash": "sha256-XtSSU0RI4c/BbUM80Z/3qZCOMriSqUwvJvjBU+g7YdI=", "owner": "input-output-hk", "repo": "cardano-haskell-packages", - "rev": "290243bf6425a011825ce4afa79d05b4bf1c6024", + "rev": "3615dfca0ee10cb5e66f0524725c4c775a2b7f83", "type": "github" }, "original": {