Skip to content

Commit 10683af

Browse files
committed
WIP new Ledger: adapt to change of StakePoolParams
1 parent adfff05 commit 10683af

File tree

4 files changed

+36
-28
lines changed

4 files changed

+36
-28
lines changed

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/PeerSelection.hs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@ instance SL.EraCertState era => LedgerSupportsPeerSelection (ShelleyBlock proto
3737
poolDistr :: SL.PoolDistr
3838
poolDistr = SL.nesPd shelleyLedgerState
3939

40+
futurePoolParams
41+
, poolParams ::
42+
Map (SL.KeyHash 'SL.StakePool) SL.StakePoolParams
43+
(futurePoolParams, poolParams) =
44+
( SL.psFutureStakePoolParams pstate
45+
, Map.mapWithKey SL.stakePoolStateToStakePoolParams (SL.psStakePools pstate)
46+
)
47+
4048
-- Sort stake pools by descending stake
4149
orderByStake ::
4250
SL.PoolDistr ->
@@ -72,14 +80,14 @@ instance SL.EraCertState era => LedgerSupportsPeerSelection (ShelleyBlock proto
7280
-- Note that a stake pool can have multiple registered relays
7381
pparamsLedgerRelayAccessPoints ::
7482
(LedgerRelayAccessPoint -> StakePoolRelay) ->
75-
SL.StakePoolState ->
83+
SL.StakePoolParams ->
7684
Maybe (NonEmpty StakePoolRelay)
7785
pparamsLedgerRelayAccessPoints injStakePoolRelay =
7886
NE.nonEmpty
7987
. force
8088
. mapMaybe (fmap injStakePoolRelay . relayToLedgerRelayAccessPoint)
8189
. toList
82-
. SL.spsRelays
90+
. SL.sppRelays
8391

8492
-- Combine the stake pools registered in the future and the current pool
8593
-- parameters, and remove duplicates.
@@ -88,8 +96,8 @@ instance SL.EraCertState era => LedgerSupportsPeerSelection (ShelleyBlock proto
8896
poolLedgerRelayAccessPoints =
8997
Map.unionWith
9098
(\futureRelays currentRelays -> NE.nub (futureRelays <> currentRelays))
91-
(Map.mapMaybe (pparamsLedgerRelayAccessPoints FutureRelay) (SL.psStakePools pstate))
92-
(Map.mapMaybe (pparamsLedgerRelayAccessPoints CurrentRelay) (SL.psFutureStakePools pstate))
99+
(Map.mapMaybe (pparamsLedgerRelayAccessPoints FutureRelay) futurePoolParams)
100+
(Map.mapMaybe (pparamsLedgerRelayAccessPoints CurrentRelay) poolParams)
93101

94102
pstate :: SL.PState era
95103
pstate =

ouroboros-consensus-cardano/src/shelley/Ouroboros/Consensus/Shelley/Ledger/Query.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ data instance BlockQuery (ShelleyBlock proto era) fp result where
232232
BlockQuery
233233
(ShelleyBlock proto era)
234234
QFNoTables
235-
(Map (SL.KeyHash 'SL.StakePool) SL.PoolParams)
235+
(Map (SL.KeyHash 'SL.StakePool) SL.StakePoolParams)
236236
GetRewardInfoPools ::
237237
BlockQuery
238238
(ShelleyBlock proto era)

ouroboros-consensus-cardano/src/unstable-cardano-testlib/Test/ThreadNet/TxGen/Cardano.hs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -256,19 +256,19 @@ migrateUTxO migrationInfo curSlot lcfg lst
256256
(SL.StakeRefBase $ Shelley.mkCredential stakingSK)
257257

258258
-- A simplistic individual pool
259-
poolParams :: SL.Coin -> SL.PoolParams
259+
poolParams :: SL.Coin -> SL.StakePoolParams
260260
poolParams pledge =
261-
SL.PoolParams
262-
{ SL.ppCost = SL.Coin 1
263-
, SL.ppMetadata = SL.SNothing
264-
, SL.ppMargin = minBound
265-
, SL.ppOwners = Set.singleton $ Shelley.mkKeyHash poolSK
266-
, SL.ppPledge = pledge
267-
, SL.ppId = Shelley.mkKeyHash poolSK
268-
, SL.ppRewardAccount =
261+
SL.StakePoolParams
262+
{ SL.sppCost = SL.Coin 1
263+
, SL.sppMetadata = SL.SNothing
264+
, SL.sppMargin = minBound
265+
, SL.sppOwners = Set.singleton $ Shelley.mkKeyHash poolSK
266+
, SL.sppPledge = pledge
267+
, SL.sppId = Shelley.mkKeyHash poolSK
268+
, SL.sppRewardAccount =
269269
SL.RewardAccount Shelley.networkId $ Shelley.mkCredential poolSK
270-
, SL.ppRelays = StrictSeq.empty
271-
, SL.ppVrf = Shelley.mkKeyHashVrf @c vrfSK
270+
, SL.sppRelays = StrictSeq.empty
271+
, SL.sppVrf = Shelley.mkKeyHashVrf @c vrfSK
272272
}
273273

274274
-----

ouroboros-consensus-cardano/src/unstable-shelley-testlib/Test/ThreadNet/Infra/Shelley.hs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ mkGenesisConfig pVer k f d maxLovelaceSupply slotLength kesCfg coreNodes =
417417
{ sgsPools =
418418
ListMap
419419
[ (pk, pp)
420-
| pp@SL.PoolParams{ppId = pk} <- Map.elems coreNodeToPoolMapping
420+
| pp@SL.StakePoolParams{sppId = pk} <- Map.elems coreNodeToPoolMapping
421421
]
422422
, -- The staking key maps to the key hash of the pool, which is set to the
423423
-- "delegate key" in order that nodes may issue blocks both as delegates
@@ -432,23 +432,23 @@ mkGenesisConfig pVer k f d maxLovelaceSupply slotLength kesCfg coreNodes =
432432
}
433433
where
434434
coreNodeToPoolMapping ::
435-
Map (SL.KeyHash 'SL.StakePool) SL.PoolParams
435+
Map (SL.KeyHash 'SL.StakePool) SL.StakePoolParams
436436
coreNodeToPoolMapping =
437437
Map.fromList
438438
[ ( SL.hashKey . SL.VKey . deriveVerKeyDSIGN $ cnStakingKey
439-
, SL.PoolParams
440-
{ SL.ppId = poolHash
441-
, SL.ppVrf = vrfHash
439+
, SL.StakePoolParams
440+
{ SL.sppId = poolHash
441+
, SL.sppVrf = vrfHash
442442
, -- Each core node pledges its full stake to the pool.
443-
SL.ppPledge = SL.Coin $ fromIntegral initialLovelacePerCoreNode
444-
, SL.ppCost = SL.Coin 1
445-
, SL.ppMargin = minBound
443+
SL.sppPledge = SL.Coin $ fromIntegral initialLovelacePerCoreNode
444+
, SL.sppCost = SL.Coin 1
445+
, SL.sppMargin = minBound
446446
, -- Reward accounts live in a separate "namespace" to other
447447
-- accounts, so it should be fine to use the same address.
448-
SL.ppRewardAccount = SL.RewardAccount networkId $ mkCredential cnDelegateKey
449-
, SL.ppOwners = Set.singleton poolOwnerHash
450-
, SL.ppRelays = Seq.empty
451-
, SL.ppMetadata = SL.SNothing
448+
SL.sppRewardAccount = SL.RewardAccount networkId $ mkCredential cnDelegateKey
449+
, SL.sppOwners = Set.singleton poolOwnerHash
450+
, SL.sppRelays = Seq.empty
451+
, SL.sppMetadata = SL.SNothing
452452
}
453453
)
454454
| CoreNode{cnDelegateKey, cnStakingKey, cnVRF} <- coreNodes

0 commit comments

Comments
 (0)