Skip to content

Commit

Permalink
Upgrade cardano-base dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
tdammers authored and lehins committed Oct 31, 2024
1 parent 5d2d753 commit e2f0944
Show file tree
Hide file tree
Showing 19 changed files with 131 additions and 325 deletions.
26 changes: 23 additions & 3 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,23 @@ source-repository-package
-- points to a commit in `MAlonzo-code` if you were fiddling with the SRP
-- as part of your PR.

source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-base
tag: 5d87496a4748726d8c3fe122871c072a70e14c60
--sha256: sha256-oW+msm9TfnUFpFzKdPN7oqjeJXbaqhrpsSk94peyH28=
subdir:
-- cardano-binary
cardano-crypto-class
cardano-crypto-tests
cardano-crypto-praos
cardano-mempool

index-state:
-- Bump this if you need newer packages from Hackage
, hackage.haskell.org 2024-08-05T20:07:24Z
, hackage.haskell.org 2024-10-30T00:00:00Z
-- Bump this if you need newer packages from CHaP
, cardano-haskell-packages 2024-09-20T19:39:13Z
, cardano-haskell-packages 2024-10-30T11:23:17Z

packages:
eras/allegra/impl
Expand Down Expand Up @@ -88,7 +100,7 @@ packages:
libs/cardano-ledger-conformance
libs/cardano-ledger-test
libs/plutus-preprocessor
libs/ledger-state
-- libs/ledger-state
libs/constrained-generators
libs/cardano-ledger-repl-environment

Expand All @@ -110,6 +122,14 @@ package cardano-ledger-mary
package cardano-ledger-conway
flags: +asserts

allow-newer:
-- Plutus-core has an upper bound on cardano-crypto-class that would prevent
-- us from depending on the updated KES API; however, these changes to
-- cardano-crypto-class are inconsequential for plutus-core, so until the
-- dependency from plutus-core to cardano-crypto-class is updated, we will
-- have to add this exemption.
plutus-core:cardano-crypto-class

-- Always write GHC env files, because they are needed for repl and by the doctests.
write-ghc-environment-files: always

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ module Test.Cardano.Ledger.Shelley.Examples.Consensus where

import Cardano.Crypto.DSIGN as DSIGN
import Cardano.Crypto.Hash as Hash
import Cardano.Crypto.KES as KES
import Cardano.Crypto.Seed as Seed
import qualified Cardano.Crypto.VRF as VRF
import Cardano.Ledger.AuxiliaryData
Expand Down Expand Up @@ -181,7 +182,7 @@ exampleShelleyLedgerBlock tx = Block blockHeader blockBody
KeyPair vKeyCold _ = aikCold keys

blockHeader :: BHeader (EraCrypto era)
blockHeader = BHeader blockHeaderBody (signedKES () 0 blockHeaderBody hotKey)
blockHeader = BHeader blockHeaderBody (unsoundPureSignedKES () 0 blockHeaderBody hotKey)

blockHeaderBody :: BHBody (EraCrypto era)
blockHeaderBody =
Expand Down
11 changes: 6 additions & 5 deletions eras/shelley/test-suite/src/Test/Cardano/Ledger/Shelley/Utils.hs
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ import Cardano.Crypto.Hash (
hashToBytes,
)
import Cardano.Crypto.KES (
KESAlgorithm (..),
deriveVerKeyKES,
genKeyKES,
UnsoundPureKESAlgorithm (..),
unsoundPureDeriveVerKeyKES,
unsoundPureGenKeyKES,
)
import Cardano.Crypto.Seed (Seed, mkSeedFromBytes)
import Cardano.Crypto.VRF (
Expand Down Expand Up @@ -210,10 +210,11 @@ mkCertifiedVRF a sk =
-- | For testing purposes, generate a deterministic KES key pair given a seed.
mkKESKeyPair :: Crypto c => RawSeed -> KESKeyPair c
mkKESKeyPair seed =
let sk = genKeyKES $ mkSeedFromWords seed
let sk = unsoundPureGenKeyKES (mkSeedFromWords seed)
vk = unsoundPureDeriveVerKeyKES sk
in KESKeyPair
{ kesSignKey = sk
, kesVerKey = deriveVerKeyKES sk
, kesVerKey = vk
}

runShelleyBase :: ShelleyBase a -> a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ import Cardano.Ledger.Coin (
)
import Cardano.Ledger.Compactible
import Cardano.Ledger.Credential (Credential, Ptr (..))
import qualified Cardano.Ledger.Crypto as Cr
import Cardano.Ledger.Crypto
import qualified Cardano.Ledger.EpochBoundary as EB
import Cardano.Ledger.Keys (KeyRole (..), asWitness, coerceKeyRole)
import Cardano.Ledger.PoolDistr (
Expand Down Expand Up @@ -154,15 +154,15 @@ mkStake ::
EB.Stake c
mkStake = EB.Stake . GHC.Exts.fromList . map (fmap toCompactCoinError)

initUTxO :: Cr.Crypto c => UTxO (ShelleyEra c)
initUTxO :: Crypto c => UTxO (ShelleyEra c)
initUTxO =
genesisCoins
genesisId
[ ShelleyTxOut Cast.aliceAddr (Val.inject aliceInitCoin)
, ShelleyTxOut Cast.bobAddr (Val.inject bobInitCoin)
]

initStPoolLifetime :: forall c. Cr.Crypto c => ChainState (ShelleyEra c)
initStPoolLifetime :: forall c. Crypto c => ChainState (ShelleyEra c)
initStPoolLifetime = initSt initUTxO

--
Expand All @@ -185,7 +185,7 @@ dariaMIR = Coin 99
feeTx1 :: Coin
feeTx1 = Coin 3

txbodyEx1 :: Cr.Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx1 :: Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx1 =
ShelleyTxBody
(Set.fromList [TxIn genesisId minBound])
Expand Down Expand Up @@ -292,7 +292,7 @@ aliceCoinEx2Ptr = aliceCoinEx1 <-> (aliceCoinEx2Base <+> feeTx2)

-- | The transaction delegates Alice's and Bob's stake to Alice's pool.
-- Additionally, we split Alice's ADA between a base address and a pointer address.
txbodyEx2 :: forall c. Cr.Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx2 :: forall c. Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx2 =
ShelleyTxBody
{ stbInputs = Set.fromList [TxIn (txIdTxBody (txbodyEx1 @c)) minBound]
Expand Down Expand Up @@ -420,7 +420,7 @@ blockEx3 =
0
(mkOCert (coreNodeKeysBySchedule @(ShelleyEra c) ppEx 110) 0 (KESPeriod 0))

snapEx3 :: Cr.Crypto c => EB.SnapShot c
snapEx3 :: Crypto c => EB.SnapShot c
snapEx3 =
EB.SnapShot
{ EB.ssStake =
Expand Down Expand Up @@ -463,7 +463,7 @@ feeTx4 = Coin 5
aliceCoinEx4Base :: Coin
aliceCoinEx4Base = aliceCoinEx2Base <-> feeTx4

txbodyEx4 :: forall c. Cr.Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx4 :: forall c. Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx4 =
ShelleyTxBody
{ stbInputs = Set.fromList [TxIn (txIdTxBody txbodyEx2) minBound]
Expand Down Expand Up @@ -563,7 +563,7 @@ blockEx5 =
10
(mkOCert (coreNodeKeysBySchedule @(ShelleyEra c) ppEx 220) 1 (KESPeriod 10))

snapEx5 :: forall c. Cr.Crypto c => EB.SnapShot c
snapEx5 :: forall c. Crypto c => EB.SnapShot c
snapEx5 =
EB.SnapShot
{ EB.ssStake =
Expand All @@ -580,7 +580,7 @@ snapEx5 =
, EB.ssPoolParams = [(aikColdKeyHash Cast.alicePoolKeys, Cast.alicePoolParams)]
}

pdEx5 :: forall c. Cr.Crypto c => PoolDistr c
pdEx5 :: forall c. Crypto c => PoolDistr c
pdEx5 =
PoolDistr
( Map.singleton
Expand Down Expand Up @@ -752,7 +752,7 @@ alicePerfEx8 = likelihood blocks t (epochSize $ EpochNo 3)
relativeStake = fromRational (stake % tot)
f = activeSlotCoeff testGlobals

nonMyopicEx8 :: forall c. Cr.Crypto c => NonMyopic c
nonMyopicEx8 :: forall c. Crypto c => NonMyopic c
nonMyopicEx8 =
NonMyopic
(Map.singleton (aikColdKeyHash Cast.alicePoolKeys) alicePerfEx8)
Expand All @@ -762,7 +762,7 @@ pulserEx8 :: forall c. ExMock c => PulsingRewUpdate c
pulserEx8 =
makeCompletedPulser (BlocksMade $ Map.singleton (aikColdKeyHash Cast.alicePoolKeys) 1) expectedStEx7

rewardUpdateEx8 :: forall c. Cr.Crypto c => RewardUpdate c
rewardUpdateEx8 :: forall c. Crypto c => RewardUpdate c
rewardUpdateEx8 =
RewardUpdate
{ deltaT = deltaT8
Expand Down Expand Up @@ -822,7 +822,7 @@ blockEx9 =
20
(mkOCert (coreNodeKeysBySchedule @(ShelleyEra c) ppEx 410) 2 (KESPeriod 20))

snapEx9 :: forall c. Cr.Crypto c => EB.SnapShot c
snapEx9 :: forall c. Crypto c => EB.SnapShot c
snapEx9 =
snapEx5
{ EB.ssStake =
Expand Down Expand Up @@ -863,7 +863,7 @@ bobAda10 =
<+> Coin 7
<-> feeTx10

txbodyEx10 :: Cr.Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx10 :: Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx10 =
ShelleyTxBody
(Set.fromList [mkTxInPartial genesisId 1])
Expand Down Expand Up @@ -929,7 +929,7 @@ aliceCoinEx11Ptr = aliceCoinEx4Base <-> feeTx11
aliceRetireEpoch :: EpochNo
aliceRetireEpoch = EpochNo 5

txbodyEx11 :: forall c. Cr.Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx11 :: forall c. Crypto c => ShelleyTxBody (ShelleyEra c)
txbodyEx11 =
ShelleyTxBody
(Set.fromList [TxIn (txIdTxBody txbodyEx4) minBound])
Expand Down Expand Up @@ -973,7 +973,7 @@ blockEx11 =
reserves12 :: Coin
reserves12 = addDeltaCoin reserves7 deltaR8

alicePerfEx11 :: forall c. Cr.Crypto c => Likelihood
alicePerfEx11 :: forall c. Crypto c => Likelihood
alicePerfEx11 = applyDecay decayFactor alicePerfEx8 <> epoch4Likelihood
where
epoch4Likelihood = likelihood blocks t (epochSize $ EpochNo 4)
Expand All @@ -985,7 +985,7 @@ alicePerfEx11 = applyDecay decayFactor alicePerfEx8 <> epoch4Likelihood
Coin supply = maxLLSupply <-> reserves12
f = activeSlotCoeff testGlobals

nonMyopicEx11 :: forall c. Cr.Crypto c => NonMyopic c
nonMyopicEx11 :: forall c. Crypto c => NonMyopic c
nonMyopicEx11 =
NonMyopic
(Map.singleton (aikColdKeyHash Cast.alicePoolKeys) (alicePerfEx11 @c))
Expand All @@ -994,7 +994,7 @@ nonMyopicEx11 =
pulserEx11 :: forall c. ExMock c => PulsingRewUpdate c
pulserEx11 = makeCompletedPulser (BlocksMade mempty) expectedStEx10

rewardUpdateEx11 :: forall c. Cr.Crypto c => RewardUpdate c
rewardUpdateEx11 :: forall c. Crypto c => RewardUpdate c
rewardUpdateEx11 =
RewardUpdate
{ deltaT = DeltaCoin 0
Expand Down Expand Up @@ -1044,7 +1044,7 @@ blockEx12 =
25
(mkOCert (coreNodeKeysBySchedule @(ShelleyEra c) ppEx 510) 3 (KESPeriod 25))

snapEx12 :: forall c. Cr.Crypto c => EB.SnapShot c
snapEx12 :: forall c. Crypto c => EB.SnapShot c
snapEx12 =
snapEx9
{ EB.ssStake =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
module Test.Cardano.Ledger.Shelley.Serialisation.Golden.Encoding (tests) where

import qualified Cardano.Crypto.Hash as Monomorphic
import Cardano.Crypto.KES (SignedKES)
import Cardano.Crypto.KES (SignedKES, unsoundPureSignedKES)
import Cardano.Crypto.VRF (CertifiedVRF)
import Cardano.Ledger.Address (Addr (..), RewardAccount (..))
import Cardano.Ledger.BaseTypes (
Expand Down Expand Up @@ -76,7 +76,6 @@ import Cardano.Ledger.Keys (
hashKey,
hashVerKeyVRF,
signedDSIGN,
signedKES,
)
import Cardano.Ledger.PoolParams (
PoolMetadata (..),
Expand Down Expand Up @@ -382,7 +381,7 @@ testBHBSigTokens ::
testBHBSigTokens = e
where
s =
signedKES @(KES (EraCrypto era))
unsoundPureSignedKES @(KES (EraCrypto era))
()
0
(testBHB @era)
Expand Down Expand Up @@ -990,7 +989,7 @@ tests =
)
, -- checkEncodingCBOR "block_header"
let sig :: (SignedKES (KES C_Crypto) (BHBody C_Crypto))
sig = signedKES () 0 (testBHB @C) (kesSignKey $ testKESKeys @C_Crypto)
sig = unsoundPureSignedKES () 0 (testBHB @C) (kesSignKey $ testKESKeys @C_Crypto)
in checkEncodingCBORAnnotated
shelleyProtVer
"block_header"
Expand All @@ -1001,7 +1000,7 @@ tests =
)
, -- checkEncodingCBOR "empty_block"
let sig :: (SignedKES (KES C_Crypto) (BHBody C_Crypto))
sig = signedKES () 0 (testBHB @C) (kesSignKey $ testKESKeys @C_Crypto)
sig = unsoundPureSignedKES () 0 (testBHB @C) (kesSignKey $ testKESKeys @C_Crypto)
bh = BHeader (testBHB @C) sig
txns = ShelleyTxSeq StrictSeq.Empty
in checkEncodingCBORAnnotated
Expand All @@ -1014,7 +1013,7 @@ tests =
)
, -- checkEncodingCBOR "rich_block"
let sig :: SignedKES (KES C_Crypto) (BHBody C_Crypto)
sig = signedKES () 0 (testBHB @C) (kesSignKey $ testKESKeys @C_Crypto)
sig = unsoundPureSignedKES () 0 (testBHB @C) (kesSignKey $ testKESKeys @C_Crypto)
bh = BHeader (testBHB @C) sig
tout = StrictSeq.singleton $ ShelleyTxOut @C testAddrE (Coin 2)
txb :: Word64 -> ShelleyTxBody C
Expand Down
Loading

0 comments on commit e2f0944

Please sign in to comment.