Skip to content

Commit

Permalink
Update dependency on cardano-ledger-specs
Browse files Browse the repository at this point in the history
The main reason is to pull in:
IntersectMBO/cardano-ledger#1943
  • Loading branch information
mrBliss committed Oct 28, 2020
1 parent 53c6b69 commit 07baf50
Show file tree
Hide file tree
Showing 8 changed files with 39 additions and 39 deletions.
4 changes: 2 additions & 2 deletions cabal.project
Expand Up @@ -152,8 +152,8 @@ source-repository-package
source-repository-package
type: git
location: https://github.com/input-output-hk/cardano-ledger-specs
tag: 1a2d7717682f8191cf818362df28ac20fac19b83
--sha256: 136pp0653w8chk53wnz6mlkdhf0ldglrb74p1i93d1xnf6ssvjhs
tag: 623bbb8d4b13bcb0157c5c576a69536387f1b5be
--sha256: 0nspz67p6ixw4zr6q4r2gzn37583mlag8f1g5pk0i4f1yisi69d1
subdir:
byron/chain/executable-spec
byron/crypto
Expand Down
Expand Up @@ -31,8 +31,6 @@ import Ouroboros.Consensus.Ledger.Basics (LedgerConfig, LedgerState,
applyChainTick)
import Ouroboros.Consensus.NodeId (CoreNodeId (..))

import Cardano.Binary (toCBOR)

import Cardano.Crypto (toVerification)
import qualified Cardano.Crypto.Signing as Byron

Expand All @@ -45,9 +43,10 @@ import qualified Shelley.Spec.Ledger.Address.Bootstrap as SL
(makeBootstrapWitness)
import qualified Shelley.Spec.Ledger.API as SL
import qualified Shelley.Spec.Ledger.BaseTypes as SL (truncateUnitInterval)
import qualified Shelley.Spec.Ledger.Keys as SL (hashWithSerialiser,
signedDSIGN)
import qualified Shelley.Spec.Ledger.Tx as SL (WitnessSetHKD (..))
import qualified Shelley.Spec.Ledger.TxBody as SL (EraIndependentTxBody,
eraIndTxBodyHash)
import qualified Shelley.Spec.Ledger.UTxO as SL (makeWitnessVKey)

import Ouroboros.Consensus.Shelley.Ledger (GenTx, ShelleyBlock,
mkShelleyTx)
Expand Down Expand Up @@ -187,8 +186,8 @@ migrateUTxO migrationInfo curSlot lcfg lst
, SL._wdrls = SL.Wdrl Map.empty
}

bodyHash :: SL.Hash c (SL.TxBody (ShelleyEra c))
bodyHash = SL.hashWithSerialiser toCBOR body
bodyHash :: SL.Hash c SL.EraIndependentTxBody
bodyHash = SL.eraIndTxBodyHash body

-- Witness the use of bootstrap address's utxo.
byronWit :: SL.BootstrapWitness (ShelleyEra c)
Expand All @@ -199,16 +198,16 @@ migrateUTxO migrationInfo curSlot lcfg lst
-- Witness the stake delegation.
delegWit :: SL.WitVKey 'SL.Witness (ShelleyEra c)
delegWit =
SL.WitVKey
(Shelley.mkVerKey stakingSK)
(SL.signedDSIGN @c stakingSK bodyHash)
SL.makeWitnessVKey
bodyHash
(Shelley.mkKeyPair stakingSK)

-- Witness the pool registration.
poolWit :: SL.WitVKey 'SL.Witness (ShelleyEra c)
poolWit =
SL.WitVKey
(Shelley.mkVerKey poolSK)
(SL.signedDSIGN @c poolSK bodyHash)
SL.makeWitnessVKey
bodyHash
(Shelley.mkKeyPair poolSK)

in
if Map.null picked then Nothing else
Expand All @@ -217,10 +216,9 @@ migrateUTxO migrationInfo curSlot lcfg lst
{ SL._body = body
, SL._metadata = SL.SNothing
, SL._witnessSet = SL.WitnessSet
{ SL.addrWits = Set.fromList [delegWit, poolWit]
, SL.bootWits = Set.singleton byronWit
, SL.msigWits = Map.empty
}
(Set.fromList [delegWit, poolWit])
mempty
(Set.singleton byronWit)
}

| otherwise = Nothing
Expand Down Expand Up @@ -262,7 +260,7 @@ migrateUTxO migrationInfo curSlot lcfg lst
, SL._poolMargin = SL.truncateUnitInterval 0
, SL._poolOwners = Set.singleton $ Shelley.mkKeyHash poolSK
, SL._poolPledge = pledge
, SL._poolPubKey = Shelley.mkKeyHash poolSK
, SL._poolId = Shelley.mkKeyHash poolSK
, SL._poolRAcnt =
SL.RewardAcnt Shelley.networkId $ Shelley.mkCredential poolSK
, SL._poolRelays = StrictSeq.empty
Expand Down
Expand Up @@ -440,7 +440,7 @@ exampleNewEpochState = SL.NewEpochState {
rewardUpdate :: SL.RewardUpdate era
rewardUpdate = SL.RewardUpdate {
deltaT = SL.Coin 10
, deltaR = SL.Coin (- 100)
, deltaR = SL.DeltaCoin (- 100)
, rs = Map.singleton (keyToCredential exampleStakeKey) (SL.Coin 10)
, deltaF = SL.DeltaCoin (- 3)
, nonMyopic = nonMyopic
Expand Down Expand Up @@ -491,7 +491,7 @@ exampleKeys =

examplePoolParams :: forall era. ShelleyBasedEra era => SL.PoolParams era
examplePoolParams = SL.PoolParams {
_poolPubKey = SL.hashKey $ SL.vKey $ SL.cold poolKeys
_poolId = SL.hashKey $ SL.vKey $ SL.cold poolKeys
, _poolVrf = SL.hashVerKeyVRF $ snd $ SL.vrf poolKeys
, _poolPledge = SL.Coin 1
, _poolCost = SL.Coin 5
Expand Down
Expand Up @@ -12,11 +12,16 @@ module Test.Consensus.Shelley.MockCrypto (
, CanMock
) where

import Test.QuickCheck (Arbitrary)

import Cardano.Crypto.DSIGN (MockDSIGN)
import Cardano.Crypto.Hash (HashAlgorithm)
import Cardano.Crypto.KES (MockKES)

import Cardano.Ledger.Core (Value)
import Cardano.Ledger.Crypto (Crypto (..))
import qualified Shelley.Spec.Ledger.API as SL

import Test.Cardano.Crypto.VRF.Fake (FakeVRF)
import qualified Test.Shelley.Spec.Ledger.ConcreteCryptoTypes as SL (Mock)
import qualified Test.Shelley.Spec.Ledger.Utils as SL (ShelleyTest)
Expand Down Expand Up @@ -53,4 +58,6 @@ type CanMock era =
, SL.Mock (EraCrypto era)
-- TODO #2677 the generators in the ledger impose this constraint
, SL.ShelleyTest era
, Arbitrary (SL.WitnessSet era)
, Arbitrary (Value era)
)
Expand Up @@ -28,6 +28,7 @@ module Test.ThreadNet.Infra.Shelley (
, mkProtocolShelley
, mkSetDecentralizationParamTxs
, mkVerKey
, mkKeyPair
, networkId
, tpraosSlotLength
, initialLovelacePerCoreNode
Expand Down Expand Up @@ -85,7 +86,6 @@ import Ouroboros.Consensus.Shelley.Ledger (GenTx (..),
import Ouroboros.Consensus.Shelley.Node
import Ouroboros.Consensus.Shelley.Protocol

import qualified Test.Shelley.Spec.Ledger.ConcreteCryptoTypes as CSL
import qualified Test.Shelley.Spec.Ledger.Generator.Core as Gen

{-------------------------------------------------------------------------------
Expand Down Expand Up @@ -143,13 +143,13 @@ data CoreNodeKeyInfo c = CoreNodeKeyInfo
)
}

coreNodeKeys :: forall c. CSL.Mock c => CoreNode c -> CoreNodeKeyInfo c
coreNodeKeys :: forall c. TPraosCrypto c => CoreNode c -> CoreNodeKeyInfo c
coreNodeKeys CoreNode{cnGenesisKey, cnDelegateKey, cnStakingKey} =
CoreNodeKeyInfo {
cnkiCoreNode =
( mkDSIGNKeyPair cnGenesisKey
( mkKeyPair cnGenesisKey
, Gen.AllIssuerKeys
{ Gen.cold = mkDSIGNKeyPair cnDelegateKey
{ Gen.cold = mkKeyPair cnDelegateKey
-- 'CoreNodeKeyInfo' is used for all sorts of generators, not
-- only transaction generators. To generate transactions we
-- don't need all these keys, hence the 'error's.
Expand All @@ -158,11 +158,8 @@ coreNodeKeys CoreNode{cnGenesisKey, cnDelegateKey, cnStakingKey} =
, Gen.hk = error "hk used while generating transactions"
}
)
, cnkiKeyPair = (mkDSIGNKeyPair cnDelegateKey, mkDSIGNKeyPair cnStakingKey)
, cnkiKeyPair = (mkKeyPair cnDelegateKey, mkKeyPair cnStakingKey)
}
where
mkDSIGNKeyPair :: SL.SignKeyDSIGN c -> SL.KeyPair kd c
mkDSIGNKeyPair k = SL.KeyPair (SL.VKey $ deriveVerKeyDSIGN k) k

genCoreNode ::
forall c. TPraosCrypto c
Expand Down Expand Up @@ -358,7 +355,7 @@ mkGenesisConfig pVer k f d maxLovelaceSupply slotLength kesCfg coreNodes =
initialStake = ShelleyGenesisStaking
{ sgsPools = Map.fromList
[ (pk, pp)
| pp@(SL.PoolParams { _poolPubKey = pk }) <- Map.elems coreNodeToPoolMapping
| pp@(SL.PoolParams { _poolId = pk }) <- Map.elems coreNodeToPoolMapping
]
-- The staking key maps to the key hash of the pool, which is set to the
-- "delegate key" in order that nodes may issue blocks both as delegates
Expand All @@ -376,7 +373,7 @@ mkGenesisConfig pVer k f d maxLovelaceSupply slotLength kesCfg coreNodes =
coreNodeToPoolMapping = Map.fromList [
( SL.hashKey . SL.VKey . deriveVerKeyDSIGN $ cnStakingKey
, SL.PoolParams
{ SL._poolPubKey = poolHash
{ SL._poolId = poolHash
, SL._poolVrf = vrfHash
-- Each core node pledges its full stake to the pool.
, SL._poolPledge = SL.Coin $ fromIntegral initialLovelacePerCoreNode
Expand Down Expand Up @@ -441,11 +438,7 @@ mkSetDecentralizationParamTxs coreNodes pVer ttl dNew =
scheduledEpoch = EpochNo 0

witnessSet :: SL.WitnessSet (ShelleyEra c)
witnessSet = SL.WitnessSet
{ addrWits = signatures
, bootWits = Set.empty
, msigWits = Map.empty
}
witnessSet = SL.WitnessSet signatures mempty mempty

-- Every node signs the transaction body, since it includes a " vote " from
-- every node.
Expand Down Expand Up @@ -527,6 +520,9 @@ mkKeyHash = SL.hashKey . mkVerKey
mkVerKey :: TPraosCrypto c => SL.SignKeyDSIGN c -> SL.VKey r c
mkVerKey = SL.VKey . deriveVerKeyDSIGN

mkKeyPair :: TPraosCrypto c => SL.SignKeyDSIGN c -> SL.KeyPair r c
mkKeyPair sk = SL.KeyPair { vKey = mkVerKey sk, sKey = sk }

mkKeyHashVrf :: (HashAlgorithm h, VRFAlgorithm vrf)
=> SignKeyVRF vrf
-> Hash h (VerKeyVRF vrf)
Expand Down
@@ -1,4 +1,5 @@
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableSuperClasses #-}
module Ouroboros.Consensus.Shelley.Eras (
-- * Eras based on the Shelley ledger
Expand Down
Expand Up @@ -29,7 +29,6 @@ import Ouroboros.Consensus.Util.Condense

import qualified Shelley.Spec.Ledger.API as SL
import Shelley.Spec.Ledger.BaseTypes (strictMaybeToMaybe)
import qualified Shelley.Spec.Ledger.LedgerState as SL (proposals)
import qualified Shelley.Spec.Ledger.PParams as SL (PParamsUpdate)

import Ouroboros.Consensus.Shelley.Eras (EraCrypto)
Expand Down
Expand Up @@ -93,8 +93,7 @@ import Ouroboros.Consensus.Util.CBOR (decodeWithOrigin,
import Ouroboros.Consensus.Util.Versioned

import qualified Shelley.Spec.Ledger.API as SL
import qualified Shelley.Spec.Ledger.LedgerState as SL (RewardAccounts,
proposals)
import qualified Shelley.Spec.Ledger.LedgerState as SL (RewardAccounts)
import qualified Shelley.Spec.Ledger.STS.Chain as SL (PredicateFailure)

import Ouroboros.Consensus.Shelley.Eras (EraCrypto)
Expand Down

0 comments on commit 07baf50

Please sign in to comment.