@@ -48,6 +48,7 @@ import Control.State.Transition (
48
48
)
49
49
import Data.Default (Default , def )
50
50
import Data.Foldable (fold )
51
+ import qualified Data.Map.Merge.Strict as Map
51
52
import qualified Data.Map.Strict as Map
52
53
import Data.Set (Set )
53
54
import qualified Data.Set as Set
@@ -128,6 +129,20 @@ poolReapTransition = do
128
129
TRC (_, PoolreapState us a cs0, e) <- judgmentContext
129
130
let
130
131
ps0 = cs0 ^. certPStateL
132
+ -- find the set of VRF keys that are no longer relevant, since they have been overwritten
133
+ -- via pool re-registration
134
+ danglingVrfs =
135
+ Set. fromList $
136
+ Map. elems $
137
+ Map. merge
138
+ Map. dropMissing
139
+ Map. dropMissing
140
+ ( Map. zipWithMaybeMatched $ \ _ sps spsF ->
141
+ if sps ^. spsVrfL /= spsF ^. spsVrfL then Just (sps ^. spsVrfL) else Nothing
142
+ )
143
+ (ps0 ^. psStakePoolsL)
144
+ (ps0 ^. psFutureStakePoolsL)
145
+
131
146
-- activate future stakePools
132
147
ps =
133
148
ps0
@@ -202,7 +217,8 @@ poolReapTransition = do
202
217
& certPStateL . psStakePoolsL %~ (`Map.withoutKeys` retired)
203
218
& certPStateL . psRetiringL %~ (`Map.withoutKeys` retired)
204
219
& certPStateL . psDepositsCompactL .~ remainingDeposits
205
- & certPStateL . psVRFKeyHashesL %~ (`Set.difference` retiredVRFs)
220
+ & certPStateL . psVRFKeyHashesL
221
+ %~ (\ s -> (s `Set.difference` retiredVRFs) `Set.difference` danglingVrfs)
206
222
)
207
223
208
224
renderPoolReapViolation ::
0 commit comments