Skip to content

Make it build with ghc-9.12 #1968

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

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
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
67 changes: 42 additions & 25 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ repository cardano-haskell-packages
d4a35cd3121aa00d18544bb0ac01c3e1691d618f462c46129271bccf39f7e8ee

index-state:
, hackage.haskell.org 2024-10-10T00:52:24Z
, cardano-haskell-packages 2024-11-26T16:00:26Z
, hackage.haskell.org 2025-04-15T19:49:23Z
, cardano-haskell-packages 2025-04-16T08:24:34Z

packages:
cardano-db
Expand Down Expand Up @@ -67,34 +67,51 @@ package snap-server
-- only if the `cardano-node` is compiled with `+rtview`.
flags: -openssl

allow-newer:
, swagger2:aeson
-- The version of ouroboros-consensus specified by cardano-node uses an earlier version of
-- quickcheck-state-machine that does not compile with ghc-9.10 so we allow a never version
-- that builds with ghc-9.10 (and earlier).
, ouroboros-consensus:quickcheck-state-machine
package cardano-ledger-shelley
flags: -XAllowAmbiguousTypes

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

constraints:
-- STM 2.5.2 is broken: https://github.com/haskell/stm/issues/76
, stm >= 2.5.3.1
-- Earlier versions do not compile with ghc-9.10.
, quickcheck-state-machine ^>= 0.10
-- esqueleto >= 3.6 has API chamges
, esqueleto ^>= 3.5.11.2

-- ---------------------------------------------------------
-- New version of `text` exposes a `show` function and in the `node`
-- code,`Data.Text` is being imported unqualified (bad idea IMO) which
-- then clashes with the `show` in `Prelude`.
, text < 2.1.2

, cardano-node ^>= 10.3

if impl (ghc >= 9.12)
allow-newer:
-- https://github.com/phadej/vec/issues/118
, bin:base
, fin:base
, ral:base

-- https://github.com/haskellari/tree-diff/issues/97
, tree-diff:base

-- https://github.com/kapralVV/Unique/issues/11
, Unique:hashable

-- https://github.com/Gabriella439/Haskell-Pipes-Safe-Library/pull/70
, pipes-safe:base

-- https://github.com/phadej/insert-ordered-containers/issues/65
, insert-ordered-containers:base
, insert-ordered-containers:hashable

-- https://github.com/GetShopTV/swagger2/issues/256
, swagger2:base
, swagger2:template-haskell

-- https://github.com/haskellari/postgresql-simple/issues/152
, postgresql-simple:base
, postgresql-simple:template-haskell

-- The two following one-liners will cut off / restore the remainder of this file (for nix-shell users):
-- when using the "cabal" wrapper script provided by nix-shell.
-- --------------------------- 8< --------------------------
-- Please do not put any `source-repository-package` clause above this line.

source-repository-package
type: git
location: https://github.com/IntersectMBO/cardano-node
tag: 36871ba0cd3e86a5dbcfd6878cdb7168bb4e56a1
--sha256: sha256-v0q8qHdI6LKc8mP43QZt3UGdTNDQXE0aF6QapvZsTvU=
subdir:
cardano-node
cardano-submit-api
trace-dispatcher
trace-forward
trace-resources
4 changes: 2 additions & 2 deletions cardano-db-sync/cardano-db-sync.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ library
, cardano-client
, cardano-crypto
, cardano-crypto-class
, cardano-crypto-praos
, cardano-crypto-wrapper
, cardano-data
, cardano-db
Expand All @@ -164,7 +165,7 @@ library
, cardano-ledger-binary
, cardano-ledger-byron
, cardano-ledger-core
, cardano-ledger-conway ^>= 1.17.3
, cardano-ledger-conway >= 1.17.3
, cardano-ledger-binary
, cardano-ledger-mary
, cardano-ledger-shelley >= 1.12.3.0
Expand Down Expand Up @@ -222,7 +223,6 @@ library
, time
, transformers
, transformers-except
, typed-protocols
, unix
, vector
, wide-word
Expand Down
3 changes: 2 additions & 1 deletion cardano-db-sync/src/Cardano/DbSync/Cache/Epoch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import Cardano.DbSync.Era.Shelley.Generic.StakeDist (getSecurityParameter)
import Cardano.DbSync.Error (SyncNodeError (..))
import Cardano.DbSync.Ledger.Types (HasLedgerEnv (..))
import Cardano.DbSync.LocalStateQuery (NoLedgerEnv (..))
import Cardano.Ledger.BaseTypes.NonZero (NonZero (..))
import Cardano.Prelude
import Control.Concurrent.Class.MonadSTM.Strict (readTVarIO, writeTVar)
import Data.Map.Strict (deleteMin, insert, lookupMax, size, split)
Expand Down Expand Up @@ -106,7 +107,7 @@ writeToMapEpochCache syncEnv cache latestEpoch = do
-- To make sure our Map Epoch doesn't get too large so we use something slightly bigger than K value "securityParam"
-- and once the map gets larger than that number we delete the first inserted item making room for another Epoch.
scaledMapEpoch =
if size mapEpoch > fromEnum securityParam
if size mapEpoch > fromEnum (unNonZero securityParam)
then deleteMin mapEpoch
else mapEpoch

Expand Down
5 changes: 2 additions & 3 deletions cardano-db-sync/src/Cardano/DbSync/Cache/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import Control.Concurrent.Class.MonadSTM.Strict (
import qualified Data.Map.Strict as Map
import Data.Time.Clock (UTCTime)
import Data.WideWord.Word128 (Word128)
import Ouroboros.Consensus.Cardano.Block (StandardCrypto)

type StakePoolCache = Map PoolKeyHash DB.PoolHashId

Expand Down Expand Up @@ -79,12 +78,12 @@ data CacheInternal = CacheInternal
, cStake :: !(StrictTVar IO StakeCache)
, cPools :: !(StrictTVar IO StakePoolCache)
, cDatum :: !(StrictTVar IO (LRUCache DataHash DB.DatumId))
, cMultiAssets :: !(StrictTVar IO (LRUCache (PolicyID StandardCrypto, AssetName) DB.MultiAssetId))
, cMultiAssets :: !(StrictTVar IO (LRUCache (PolicyID, AssetName) DB.MultiAssetId))
, cPrevBlock :: !(StrictTVar IO (Maybe (DB.BlockId, ByteString)))
, cStats :: !(StrictTVar IO CacheStatistics)
, cEpoch :: !(StrictTVar IO CacheEpoch)
, cAddress :: !(StrictTVar IO (LRUCache ByteString V.AddressId))
, cTxIds :: !(StrictTVar IO (FIFOCache (Ledger.TxId StandardCrypto) DB.TxId))
, cTxIds :: !(StrictTVar IO (FIFOCache Ledger.TxId DB.TxId))
}

data CacheStatistics = CacheStatistics
Expand Down
6 changes: 3 additions & 3 deletions cardano-db-sync/src/Cardano/DbSync/Config/Cardano.hs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ import Ouroboros.Consensus.Cardano.Node
import Ouroboros.Consensus.Config (TopLevelConfig (..), emptyCheckpointsMap)
import Ouroboros.Consensus.Ledger.Basics (LedgerConfig)
import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolInfo)
import Ouroboros.Consensus.Cardano.Block (StandardCrypto)
import qualified Ouroboros.Consensus.Node.ProtocolInfo as Consensus
import Ouroboros.Consensus.Shelley.Eras (StandardCrypto)
import Ouroboros.Consensus.Shelley.Node (ShelleyGenesis (..))

-- Usually only one constructor, but may have two when we are preparing for a HFC event.
Expand All @@ -48,14 +48,14 @@ data GenesisConfig
!Byron.Config
!ShelleyConfig
!AlonzoGenesis
!(ConwayGenesis StandardCrypto)
!ConwayGenesis

genesisProtocolMagicId :: GenesisConfig -> ProtocolMagicId
genesisProtocolMagicId ge =
case ge of
GenesisCardano _cfg _bCfg sCfg _aCfg _cCfg -> shelleyProtocolMagicId (scConfig sCfg)
where
shelleyProtocolMagicId :: ShelleyGenesis StandardCrypto -> ProtocolMagicId
shelleyProtocolMagicId :: ShelleyGenesis -> ProtocolMagicId
shelleyProtocolMagicId sCfg = ProtocolMagicId (sgNetworkMagic sCfg)

readCardanoGenesisConfig ::
Expand Down
7 changes: 3 additions & 4 deletions cardano-db-sync/src/Cardano/DbSync/Config/Conway.hs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import Cardano.Ledger.BaseTypes (EpochInterval (..))
import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Conway.Genesis (ConwayGenesis (..))
import Cardano.Ledger.Conway.PParams (UpgradeConwayPParams (..))
import Cardano.Ledger.Crypto (StandardCrypto ())
import Cardano.Ledger.Plutus.CostModels (mkCostModel)
import Cardano.Ledger.Plutus.Language (Language (..))
import Cardano.Prelude
Expand All @@ -37,7 +36,7 @@ data ConwayGenesisError

readConwayGenesisConfig ::
SyncNodeConfig ->
ExceptIO SyncNodeError (ConwayGenesis StandardCrypto)
ExceptIO SyncNodeError ConwayGenesis
readConwayGenesisConfig SyncNodeConfig {..} =
case dncConwayGenesisFile of
Just file -> readConwayGenesisConfig' file dncConwayGenesisHash
Expand Down Expand Up @@ -66,7 +65,7 @@ readConwayGenesisConfig SyncNodeConfig {..} =
readGenesis ::
GenesisFile ->
Maybe GenesisHashConway ->
ExceptIO ConwayGenesisError (ConwayGenesis StandardCrypto)
ExceptIO ConwayGenesisError ConwayGenesis
readGenesis (GenesisFile file) expectedHash = do
content <- readFile' file
checkExpectedGenesisHash expectedHash content
Expand All @@ -78,7 +77,7 @@ readFile' file =
(GenesisReadError file . show)
(ByteString.readFile file)

decodeGenesis :: (Text -> ConwayGenesisError) -> ByteString -> ExceptIO ConwayGenesisError (ConwayGenesis StandardCrypto)
decodeGenesis :: (Text -> ConwayGenesisError) -> ByteString -> ExceptIO ConwayGenesisError ConwayGenesis
decodeGenesis f =
firstExceptT (f . Text.pack)
. hoistEither
Expand Down
3 changes: 1 addition & 2 deletions cardano-db-sync/src/Cardano/DbSync/Config/Shelley.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,14 @@ import qualified Data.ByteString.Char8 as BS
import Data.Text (Text)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import Ouroboros.Consensus.Shelley.Eras (StandardCrypto)
import Ouroboros.Consensus.Shelley.Ledger.Block ()
import Ouroboros.Consensus.Shelley.Node (ShelleyGenesis (..))

-- Everything in this file should be in ouroboros-consensus so that both 'node' and 'db-=sync'
-- can use it.

data ShelleyConfig = ShelleyConfig
{ scConfig :: !(ShelleyGenesis StandardCrypto)
{ scConfig :: !ShelleyGenesis
, scGenesisHash :: !GenesisHashShelley
}

Expand Down
19 changes: 12 additions & 7 deletions cardano-db-sync/src/Cardano/DbSync/Config/Types.hs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ import qualified Cardano.Chain.Update as Byron
import Cardano.Crypto (RequiresNetworkMagic (..))
import qualified Cardano.Crypto.Hash as Crypto
import Cardano.Db (MigrationDir, PGPassSource (..), TxOutTableType (..))
import Cardano.Ledger.Conway (ConwayEra)
import Cardano.Prelude
import Cardano.Slotting.Slot (SlotNo (..))
import Control.Monad (fail)
Expand All @@ -79,7 +80,11 @@ import Data.Aeson.Key (fromText)
import Data.Aeson.Types (Pair, Parser, typeMismatch)
import Data.ByteString.Short (ShortByteString (), fromShort, toShort)
import Data.Default.Class (Default (..))
import Ouroboros.Consensus.Cardano.CanHardFork (TriggerHardFork (..))
import Ouroboros.Consensus.Cardano (CardanoHardForkTrigger)
import Ouroboros.Consensus.Cardano.Block (AllegraEra, AlonzoEra, BabbageEra, MaryEra, ShelleyEra, StandardCrypto)
import Ouroboros.Consensus.Protocol.Praos (Praos)
import Ouroboros.Consensus.Protocol.TPraos (TPraos)
import Ouroboros.Consensus.Shelley.Ledger.Block (ShelleyBlock)

newtype LogFileDir = LogFileDir
{ unLogFileDir :: FilePath
Expand Down Expand Up @@ -135,12 +140,12 @@ data SyncNodeConfig = SyncNodeConfig
, dncConwayGenesisFile :: !(Maybe GenesisFile)
, dncConwayGenesisHash :: !(Maybe GenesisHashConway)
, dncByronProtocolVersion :: !Byron.ProtocolVersion
, dncShelleyHardFork :: !TriggerHardFork
, dncAllegraHardFork :: !TriggerHardFork
, dncMaryHardFork :: !TriggerHardFork
, dncAlonzoHardFork :: !TriggerHardFork
, dncBabbageHardFork :: !TriggerHardFork
, dncConwayHardFork :: !TriggerHardFork
, dncShelleyHardFork :: !(CardanoHardForkTrigger (ShelleyBlock (TPraos StandardCrypto) ShelleyEra))
, dncAllegraHardFork :: !(CardanoHardForkTrigger (ShelleyBlock (TPraos StandardCrypto) AllegraEra))
, dncMaryHardFork :: !(CardanoHardForkTrigger (ShelleyBlock (TPraos StandardCrypto) MaryEra))
, dncAlonzoHardFork :: !(CardanoHardForkTrigger (ShelleyBlock (TPraos StandardCrypto) AlonzoEra))
, dncBabbageHardFork :: !(CardanoHardForkTrigger (ShelleyBlock (Praos StandardCrypto) BabbageEra))
, dncConwayHardFork :: !(CardanoHardForkTrigger (ShelleyBlock (Praos StandardCrypto) ConwayEra))
, dncInsertOptions :: !SyncInsertOptions
, dncIpfsGateway :: [Text]
}
Expand Down
Loading
Loading