Skip to content

Commit

Permalink
Take all dependecies from Hackage or CHaP
Browse files Browse the repository at this point in the history
This also updates the version of `ledger` for repliminary support for
the Conway era. The `network` and `consensus` dependencies are also
updated.
  • Loading branch information
erikd committed Mar 9, 2023
1 parent 3d85d16 commit e249427
Show file tree
Hide file tree
Showing 89 changed files with 1,277 additions and 189 deletions.
1 change: 1 addition & 0 deletions .github/workflows/check-mainnet-config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:
copyFile "mainnet-alonzo-genesis.json"
copyFile "mainnet-byron-genesis.json"
copyFile "mainnet-conway-genesis.json"
copyFile "mainnet-config.json"
copyFile "mainnet-shelley-genesis.json"
copyFile "mainnet-topology.json"
Expand Down
1 change: 1 addition & 0 deletions bench/locli/locli.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ library
, ouroboros-consensus
-- for Data.SOP.Strict:
, ouroboros-network
, ouroboros-network-api
, process
, quiet
, scientific
Expand Down
2 changes: 1 addition & 1 deletion bench/locli/src/Cardano/Unlog/LogObject.hs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ interpreters = map3ple Map.fromList . unzip3 . fmap ent $
<*> pure 1

-- Ledger snapshots:
, (,,,) "TraceLedgerEvent.TookSnapshot" "LedgerEvent.TookSnapshot" "ChainDB.LedgerEvent.TookSnapshot" $
, (,,,) "TraceSnapshotEvent.TookSnapshot" "LedgerEvent.TookSnapshot" "ChainDB.LedgerEvent.TookSnapshot" $
\_ -> pure LOLedgerTookSnapshot

-- Tx receive path & mempool:
Expand Down
5 changes: 0 additions & 5 deletions bench/locli/src/Data/CDF.hs
Original file line number Diff line number Diff line change
Expand Up @@ -265,11 +265,6 @@ class KnownCDF a where
instance KnownCDF I where cdfIx = CDFI
instance KnownCDF (CDF I) where cdfIx = CDF2

type family CDFProj a where
CDFProj (CDF I a) = I a
CDFProj (CDF (CDF I) a) = CDF I a
-- indexCDF i d = snd $ cdfSamples (trace (printf "i=%d of %d" i (length $ cdfSamples d) :: String) d) !! i

liftCDFVal :: forall a p. Real a => a -> CDFIx p -> p a
liftCDFVal x = \case
CDFI -> I x
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,13 @@ import Ouroboros.Consensus.Node.Run (RunNode)
import Ouroboros.Consensus.Shelley.Eras (StandardCrypto)

import Ouroboros.Network.Channel (Channel (..))
import Ouroboros.Network.ControlMessage (continueForever)
import Ouroboros.Network.DeltaQ (defaultGSV)
import Ouroboros.Network.Driver (runPeerWithLimits)
import Ouroboros.Network.KeepAlive
import Ouroboros.Network.Magic
import Ouroboros.Network.Mux (MuxPeer (..), OuroborosApplication (..), OuroborosBundle,
RunMiniProtocol (..), continueForever)
RunMiniProtocol (..))
import Ouroboros.Network.NodeToClient (IOManager, chainSyncPeerNull)
import Ouroboros.Network.NodeToNode (NetworkConnectTracers (..))
import qualified Ouroboros.Network.NodeToNode as NtN
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ assume_cbor_properties
&& prop_bsCostsMary
&& prop_bsCostsAlonzo
&& prop_bsCostsBabbage
&& prop_bsCostsConway

-- The cost of map entries in metadata follows a step function.
-- This assumes the map indices are [0..n].
Expand All @@ -42,11 +43,13 @@ prop_mapCostsAllegra :: Bool
prop_mapCostsMary :: Bool
prop_mapCostsAlonzo :: Bool
prop_mapCostsBabbage :: Bool
prop_mapCostsConway :: Bool
prop_mapCostsShelley = measureMapCosts AsShelleyEra == assumeMapCosts AsShelleyEra
prop_mapCostsAllegra = measureMapCosts AsAllegraEra == assumeMapCosts AsAllegraEra
prop_mapCostsMary = measureMapCosts AsMaryEra == assumeMapCosts AsMaryEra
prop_mapCostsAlonzo = measureMapCosts AsAlonzoEra == assumeMapCosts AsAlonzoEra
prop_mapCostsBabbage = measureMapCosts AsBabbageEra == assumeMapCosts AsBabbageEra
prop_mapCostsConway = measureMapCosts AsConwayEra == assumeMapCosts AsConwayEra

assumeMapCosts :: forall era . IsShelleyBasedEra era => AsType era -> [Int]
assumeMapCosts _proxy = stepFunction [
Expand All @@ -63,19 +66,22 @@ assumeMapCosts _proxy = stepFunction [
ShelleyBasedEraMary -> 39
ShelleyBasedEraAlonzo -> 42
ShelleyBasedEraBabbage -> 42
ShelleyBasedEraConway -> 42

-- Bytestring costs are not LINEAR !!
-- Costs are piecewise linear for payload sizes [0..23] and [24..64].
prop_bsCostsShelley :: Bool
prop_bsCostsAllegra :: Bool
prop_bsCostsMary :: Bool
prop_bsCostsAlonzo :: Bool
prop_bsCostsBabbage :: Bool
prop_bsCostsBabbage :: Bool
prop_bsCostsConway :: Bool
prop_bsCostsShelley = measureBSCosts AsShelleyEra == [37..60] ++ [62..102]
prop_bsCostsAllegra = measureBSCosts AsAllegraEra == [39..62] ++ [64..104]
prop_bsCostsMary = measureBSCosts AsMaryEra == [39..62] ++ [64..104]
prop_bsCostsAlonzo = measureBSCosts AsAlonzoEra == [42..65] ++ [67..107]
prop_bsCostsBabbage = measureBSCosts AsBabbageEra == [42..65] ++ [67..107]
prop_bsCostsConway = measureBSCosts AsConwayEra == [42..65] ++ [67..107]

stepFunction :: [(Int, Int)] -> [Int]
stepFunction f = scanl1 (+) steps
Expand Down Expand Up @@ -149,6 +155,7 @@ mkMetadata size
ShelleyBasedEraMary -> 39
ShelleyBasedEraAlonzo -> 39 -- TODO: check minSize for Alonzo
ShelleyBasedEraBabbage -> 39 -- TODO: check minSize for Babbage
ShelleyBasedEraConway -> 39 -- TODO: check minSize for Conway
nettoSize = size - minSize

-- At 24 the CBOR representation changes.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ txSubmissionClient tr bmtr initialTxSource endOfProtocolCallback =
TokNonBlocking -> pure $ SendMsgReplyTxIds
(NonBlockingReply $ txToIdSize <$> newTxs)
(client stateC)

requestTxs ::
LocalState era
-> [GenTxId CardanoBlock]
Expand Down Expand Up @@ -192,6 +192,7 @@ txSubmissionClient tr bmtr initialTxSource endOfProtocolCallback =
ShelleyBasedEraMary -> toConsensusGenTx $ TxInMode tx MaryEraInCardanoMode
ShelleyBasedEraAlonzo -> toConsensusGenTx $ TxInMode tx AlonzoEraInCardanoMode
ShelleyBasedEraBabbage -> toConsensusGenTx $ TxInMode tx BabbageEraInCardanoMode
ShelleyBasedEraConway -> toConsensusGenTx $ TxInMode tx ConwayEraInCardanoMode

fromGenTxId :: GenTxId CardanoBlock -> TxId
fromGenTxId (Block.GenTxIdShelley (Mempool.ShelleyTxId i)) = fromShelleyTxId i
Expand Down
2 changes: 2 additions & 0 deletions bench/tx-generator/src/Cardano/Benchmarking/Script/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ liftCoreWithEra era coreCall = withEra era ( liftIO . runExceptT . coreCall)
withEra :: AnyCardanoEra -> (forall era. IsShelleyBasedEra era => AsType era -> ActionM x) -> ActionM x
withEra era action = do
case era of
AnyCardanoEra ConwayEra -> action AsConwayEra
AnyCardanoEra BabbageEra -> action AsBabbageEra
AnyCardanoEra AlonzoEra -> action AsAlonzoEra
AnyCardanoEra MaryEra -> action AsMaryEra
Expand Down Expand Up @@ -189,6 +190,7 @@ queryRemoteProtocolParameters = do
AnyCardanoEra MaryEra -> callQuery $ QueryInEra MaryEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraMary QueryProtocolParameters
AnyCardanoEra AlonzoEra -> callQuery $ QueryInEra AlonzoEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraAlonzo QueryProtocolParameters
AnyCardanoEra BabbageEra -> callQuery $ QueryInEra BabbageEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraBabbage QueryProtocolParameters
AnyCardanoEra ConwayEra -> callQuery $ QueryInEra ConwayEraInCardanoMode $ QueryInShelleyBasedEra ShelleyBasedEraConway QueryProtocolParameters

getProtocolParameters :: ActionM ProtocolParameters
getProtocolParameters = do
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,23 @@ getGenesis (SomeConsensusProtocol CardanoBlockType proto)
ProtocolInfoArgsCardano
_
ProtocolParamsShelleyBased{shelleyBasedGenesis = genesis}
_ _ _ _ _ _ _ _ _ _ = proto
_ _ _ _ _ _ _ _ _ _ _ _ = proto

-- | extract the path to genesis file from a NodeConfiguration for Cardano protocol
getGenesisPath :: NodeConfiguration -> Maybe GenesisFile
getGenesisPath nodeConfig
= case ncProtocolConfig nodeConfig of
NodeProtocolConfigurationCardano _ shelleyConfig _ _ -> Just $ npcShelleyGenesisFile shelleyConfig
NodeProtocolConfigurationCardano _ shelleyConfig _ _ _ -> Just $ npcShelleyGenesisFile shelleyConfig
_ -> Nothing

mkConsensusProtocol :: NodeConfiguration -> IO (Either TxGenError SomeConsensusProtocol)
mkConsensusProtocol nodeConfig
= case ncProtocolConfig nodeConfig of
NodeProtocolConfigurationByron _ -> pure $ Left $ TxGenError "NodeProtocolConfigurationByron not supported"
NodeProtocolConfigurationShelley _ -> pure $ Left $ TxGenError "NodeProtocolConfigurationShelley not supported"
NodeProtocolConfigurationCardano byronConfig shelleyConfig alonzoConfig hardforkConfig
NodeProtocolConfigurationCardano byronConfig shelleyConfig alonzoConfig conwayConfig hardforkConfig
-> first ProtocolError
<$> runExceptT (mkSomeConsensusProtocolCardano byronConfig shelleyConfig alonzoConfig hardforkConfig Nothing)
<$> runExceptT (mkSomeConsensusProtocolCardano byronConfig shelleyConfig alonzoConfig conwayConfig hardforkConfig Nothing)

-- | Creates a NodeConfiguration from a config file;
-- the result is devoid of any keys/credentials
Expand Down
1 change: 1 addition & 0 deletions bench/tx-generator/src/Cardano/TxGenerator/Tx.hs
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ genTx protocolParameters (collateral, collFunds) fee metadata inFunds outputs
ShelleyBasedEraMary -> TxValidityNoUpperBound ValidityNoUpperBoundInMaryEra
ShelleyBasedEraAlonzo -> TxValidityNoUpperBound ValidityNoUpperBoundInAlonzoEra
ShelleyBasedEraBabbage -> TxValidityNoUpperBound ValidityNoUpperBoundInBabbageEra
ShelleyBasedEraConway -> TxValidityNoUpperBound ValidityNoUpperBoundInConwayEra


txSizeInBytes :: forall era. IsShelleyBasedEra era =>
Expand Down
5 changes: 3 additions & 2 deletions bench/tx-generator/src/Cardano/TxGenerator/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ liftAnyEra f x = case x of
InAnyCardanoEra AllegraEra a -> InAnyCardanoEra AllegraEra $ f a
InAnyCardanoEra MaryEra a -> InAnyCardanoEra MaryEra $ f a
InAnyCardanoEra AlonzoEra a -> InAnyCardanoEra AlonzoEra $ f a
InAnyCardanoEra BabbageEra a -> InAnyCardanoEra BabbageEra $ f a
InAnyCardanoEra BabbageEra a -> InAnyCardanoEra BabbageEra $ f a
InAnyCardanoEra ConwayEra a -> InAnyCardanoEra ConwayEra $ f a

keyAddress :: forall era. IsShelleyBasedEra era => NetworkId -> SigningKey PaymentKey -> AddressInEra era
keyAddress networkId k
Expand Down Expand Up @@ -61,7 +62,7 @@ mkTxValidityUpperBound =
TxValidityUpperBound (fromJust $ validityUpperBoundSupportedInEra (cardanoEra @era))

mkTxOutValueAdaOnly :: forall era . IsShelleyBasedEra era => Lovelace -> TxOutValue era
mkTxOutValueAdaOnly l = either
mkTxOutValueAdaOnly l = either
(`TxOutAdaOnly` l)
(\p -> TxOutValue p $ lovelaceToValue l)
(multiAssetSupportedInEra (cardanoEra @era))
Expand Down
3 changes: 3 additions & 0 deletions bench/tx-generator/tx-generator.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -117,9 +117,12 @@ library
, ouroboros-consensus
, ouroboros-consensus-byron
, ouroboros-consensus-cardano
, ouroboros-consensus-diffusion
, ouroboros-consensus-shelley
, ouroboros-network
, ouroboros-network-api
, ouroboros-network-framework
, ouroboros-network-protocols
, plutus-ledger-api
, plutus-scripts-bench
, plutus-tx
Expand Down
31 changes: 3 additions & 28 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ index-state: 2023-03-06T05:24:58Z

index-state:
, hackage.haskell.org 2023-03-06T05:24:58Z
, cardano-haskell-packages 2022-12-14T00:40:15Z
, cardano-haskell-packages 2023-02-28T09:20:07Z

packages:
cardano-api
Expand Down Expand Up @@ -95,7 +95,8 @@ constraints:
-- TODO: these should be set in cabal files, but avoiding setting them in lower dependencies for initial CHaP release
, cardano-prelude >= 0.1.0.1
, base-deriving-via >= 0.1.0.0
, cardano-binary >= 1.5.0
-- The cardano-binary API changes in 1.6.*.
, cardano-binary == 1.5.*
, cardano-binary-test >= 1.3.0
, cardano-crypto-class >= 2.0.0.1
, cardano-crypto-praos >= 2.0.0.0.1
Expand Down Expand Up @@ -178,29 +179,3 @@ allow-newer:
-- IMPORTANT
-- Do NOT add more source-repository-package stanzas here unless they are strictly
-- temporary! Please read the section in CONTRIBUTING about updating dependencies.

-- And has the adjustments for the ledger refactor
source-repository-package
type: git
location: https://github.com/input-output-hk/ouroboros-network
tag: 679c7da2079a5e9972a1c502b6a4d6af3eb76945
--sha256: 138mqd5cv0b13giwjvlz3pr6l1cwgpn38n0q3m11mrjwwmmxl0mw
subdir:
monoidal-synchronisation
network-mux
ouroboros-consensus
ouroboros-consensus-byron
ouroboros-consensus-cardano
ouroboros-consensus-protocol
ouroboros-consensus-shelley
ouroboros-network
ouroboros-network-framework
ouroboros-network-testing
ouroboros-consensus-cardano-tools

-- Waiting for proper Windows ghc-9.2 release.
source-repository-package
type: git
location: https://github.com/input-output-hk/snap-core
tag: b87b2ffa52bf58867a7239ebe74f61b1a2c762d2
--sha256: 0ndm57z5zpxd5n8s47kh8k1jfqf3b78qv7gkgrx9wwaajs9bf196
4 changes: 4 additions & 0 deletions cardano-api/cardano-api.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ library
, cardano-data ^>= 0.1
, cardano-ledger-alonzo ^>= 0.1
, cardano-ledger-babbage ^>= 0.1
, cardano-ledger-conway
, cardano-ledger-byron ^>= 0.1
, cardano-ledger-core ^>= 0.1
, cardano-ledger-shelley-ma ^>= 0.1
Expand All @@ -145,10 +146,13 @@ library
, ouroboros-consensus
, ouroboros-consensus-byron
, ouroboros-consensus-cardano
, ouroboros-consensus-diffusion
, ouroboros-consensus-protocol
, ouroboros-consensus-shelley
, ouroboros-network
, ouroboros-network-api
, ouroboros-network-framework
, ouroboros-network-protocols
, parsec
, plutus-ledger-api:{plutus-ledger-api, plutus-ledger-api-testlib} ^>=1.1
, prettyprinter
Expand Down
11 changes: 11 additions & 0 deletions cardano-api/gen/Test/Gen/Cardano/Api/Typed.hs
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,12 @@ genTxOutDatumHashTxContext era = case era of
, TxOutDatumInTx ScriptDataInBabbageEra <$> genHashableScriptData
, TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInBabbageEra <$> genHashableScriptData
]
ConwayEra -> Gen.choice
[ pure TxOutDatumNone
, TxOutDatumHash ScriptDataInConwayEra <$> genHashScriptData
, TxOutDatumInTx ScriptDataInConwayEra <$> genHashableScriptData
, TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInConwayEra <$> genHashableScriptData
]

genTxOutDatumHashUTxOContext :: CardanoEra era -> Gen (TxOutDatum CtxUTxO era)
genTxOutDatumHashUTxOContext era = case era of
Expand All @@ -925,6 +931,11 @@ genTxOutDatumHashUTxOContext era = case era of
, TxOutDatumHash ScriptDataInBabbageEra <$> genHashScriptData
, TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInBabbageEra <$> genHashableScriptData
]
ConwayEra -> Gen.choice
[ pure TxOutDatumNone
, TxOutDatumHash ScriptDataInConwayEra <$> genHashScriptData
, TxOutDatumInline ReferenceTxInsScriptsInlineDatumsInConwayEra <$> genHashableScriptData
]

mkDummyHash :: forall h a. CRYPTO.HashAlgorithm h => Int -> CRYPTO.Hash h a
mkDummyHash = coerce . CRYPTO.hashWithSerialiser @h CBOR.toCBOR
Expand Down
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api.hs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module Cardano.Api (
MaryEra,
AlonzoEra,
BabbageEra,
ConwayEra,
CardanoEra(..),
IsCardanoEra(..),
AnyCardanoEra(..),
Expand Down
13 changes: 13 additions & 0 deletions cardano-api/src/Cardano/Api/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,12 @@ instance Show (Block era) where
. showsPrec 11 block
)

showsPrec p (ShelleyBlock ShelleyBasedEraConway block) =
showParen (p >= 11)
( showString "ShelleyBlock ShelleyBasedEraConway "
. showsPrec 11 block
)

getBlockTxs :: forall era . Block era -> [Tx era]
getBlockTxs (ByronBlock Consensus.ByronBlock { Consensus.byronBlockRaw }) =
case byronBlockRaw of
Expand Down Expand Up @@ -190,6 +196,7 @@ obtainConsensusShelleyCompatibleEra ShelleyBasedEraAllegra f = f
obtainConsensusShelleyCompatibleEra ShelleyBasedEraMary f = f
obtainConsensusShelleyCompatibleEra ShelleyBasedEraAlonzo f = f
obtainConsensusShelleyCompatibleEra ShelleyBasedEraBabbage f = f
obtainConsensusShelleyCompatibleEra ShelleyBasedEraConway f = f

-- ----------------------------------------------------------------------------
-- Block in a consensus mode
Expand Down Expand Up @@ -247,6 +254,10 @@ fromConsensusBlock CardanoMode =
BlockInMode (ShelleyBlock ShelleyBasedEraBabbage b')
BabbageEraInCardanoMode

Consensus.BlockConway b' ->
BlockInMode (ShelleyBlock ShelleyBasedEraConway b')
ConwayEraInCardanoMode

toConsensusBlock
:: ConsensusBlockForMode mode ~ block
=> Consensus.LedgerSupportsProtocol
Expand All @@ -269,6 +280,7 @@ toConsensusBlock bInMode =
BlockInMode (ShelleyBlock ShelleyBasedEraMary b') MaryEraInCardanoMode -> Consensus.BlockMary b'
BlockInMode (ShelleyBlock ShelleyBasedEraAlonzo b') AlonzoEraInCardanoMode -> Consensus.BlockAlonzo b'
BlockInMode (ShelleyBlock ShelleyBasedEraBabbage b') BabbageEraInCardanoMode -> Consensus.BlockBabbage b'
BlockInMode (ShelleyBlock ShelleyBasedEraConway b') ConwayEraInCardanoMode -> Consensus.BlockConway b'

-- ----------------------------------------------------------------------------
-- Block headers
Expand Down Expand Up @@ -307,6 +319,7 @@ getBlockHeader (ShelleyBlock shelleyEra block) = case shelleyEra of
ShelleyBasedEraMary -> go
ShelleyBasedEraAlonzo -> go
ShelleyBasedEraBabbage -> go
ShelleyBasedEraConway -> go
where
go :: Consensus.ShelleyCompatible (ConsensusProtocol era) (ShelleyLedgerEra era)
=> BlockHeader
Expand Down
1 change: 1 addition & 0 deletions cardano-api/src/Cardano/Api/Convenience/Constraints.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ getIsCardanoEraConstraint AllegraEra f = f
getIsCardanoEraConstraint MaryEra f = f
getIsCardanoEraConstraint AlonzoEra f = f
getIsCardanoEraConstraint BabbageEra f = f
getIsCardanoEraConstraint ConwayEra f = f
Loading

0 comments on commit e249427

Please sign in to comment.