Skip to content

Commit 3b4a01a

Browse files
committed
Remove future VRFS from set of known VRFs on pool re-registration
1 parent 86230c4 commit 3b4a01a

File tree

1 file changed

+10
-2
lines changed
  • eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules

1 file changed

+10
-2
lines changed

eras/shelley/impl/src/Cardano/Ledger/Shelley/Rules/Pool.hs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ poolDelegationTransition ::
215215
poolDelegationTransition = do
216216
TRC
217217
( PoolEnv cEpoch pp
218-
, ps@PState {psStakePools, psVRFKeyHashes}
218+
, ps@PState {psStakePools, psFutureStakePools, psVRFKeyHashes}
219219
, poolCert
220220
) <-
221221
judgmentContext
@@ -269,9 +269,17 @@ poolDelegationTransition = do
269269
& psVRFKeyHashesL %~ Set.insert ppVrf
270270
Just _ -> do
271271
-- re-register Pool
272+
273+
-- If a pool re-registers with a fresh VRF, we have to add it to the list,
274+
-- but also remove th potential VRF stored in previous re-registration within the same epoch,
275+
-- which we can retrieve from futureStakePools. We first delete and then insert the new one,
276+
-- so in case they are the same, it will still end up in the set.
272277
let updateVRFs
273278
| hasMatchingVRF = id
274-
| otherwise = psVRFKeyHashesL %~ Set.insert ppVrf
279+
| otherwise = psVRFKeyHashesL %~ (Set.insert ppVrf . withoutFutureVrf)
280+
where
281+
withoutFutureVrf s = maybe s (`Set.delete` s) futureVrf
282+
futureVrf = (^. spsVrfL) <$> Map.lookup ppId psFutureStakePools
275283
tellEvent $ ReregisterPool ppId
276284
-- hk is already registered, so we want to reregister it. That means adding it
277285
-- to the Future pool params (if it is not there already), and overriding the

0 commit comments

Comments
 (0)