@@ -248,7 +248,7 @@ applyBlock env blk = do
248
248
, apSlotDetails = details
249
249
, apStakeSlice = getStakeSlice env newState False
250
250
, apEvents = ledgerEvents
251
- , apCommittee = getCommittee newLedgerState
251
+ , apGovActionState = getGovState newLedgerState
252
252
, apDepositsMap = DepositsMap deposits
253
253
}
254
254
else defaultApplyResult details
@@ -277,7 +277,7 @@ applyBlock env blk = do
277
277
, Generic. neAdaPots = maybeToStrict mPots
278
278
, Generic. neEpochUpdate = Generic. epochUpdate newState
279
279
, Generic. neDRepState = maybeToStrict $ getDrepState newState
280
- , Generic. neEnacted = maybeToStrict $ getEnacted newState
280
+ , Generic. neEnacted = maybeToStrict $ getGovState newState
281
281
}
282
282
283
283
applyToEpochBlockNo :: Bool -> Bool -> EpochBlockNo -> EpochBlockNo
@@ -294,18 +294,12 @@ applyBlock env blk = do
294
294
finaliseDrepDistr ledger =
295
295
ledger & newEpochStateT %~ forceDRepPulsingState @ StandardConway
296
296
297
- getEnacted :: ExtLedgerState CardanoBlock -> Maybe (ConwayGovState StandardConway )
298
- getEnacted ls = case ledgerState ls of
297
+ getGovState :: ExtLedgerState CardanoBlock -> Maybe (ConwayGovState StandardConway )
298
+ getGovState ls = case ledgerState ls of
299
299
LedgerStateConway cls ->
300
300
Just $ Consensus. shelleyLedgerState cls ^. Shelley. newEpochStateGovStateL
301
301
_ -> Nothing
302
302
303
- getCommittee :: ExtLedgerState CardanoBlock -> Maybe (StrictMaybe (Committee StandardConway ))
304
- getCommittee ls = case ledgerState ls of
305
- LedgerStateConway cls ->
306
- Just $ Consensus. shelleyLedgerState cls ^. (Shelley. newEpochStateGovStateL . cgsCommitteeL)
307
- _ -> Nothing
308
-
309
303
getStakeSlice :: HasLedgerEnv -> CardanoLedgerState -> Bool -> Generic. StakeSliceRes
310
304
getStakeSlice env cls isMigration =
311
305
case clsEpochBlockNo cls of
@@ -860,32 +854,33 @@ findAdaPots = go
860
854
go (_ : rest) = go rest
861
855
862
856
-- | Given an committee action id and the current GovState, return the proposed committee.
863
- -- If the id is not included in the proposals, return Nothing.
864
- findProposedCommittee :: GovActionId StandardCrypto -> ConwayGovState StandardConway -> Maybe (Committee StandardConway )
857
+ -- If it's not a Committee action or is not included in the proposals, return Nothing.
858
+ findProposedCommittee :: GovActionId StandardCrypto -> ConwayGovState StandardConway -> Either Text ( Maybe (Committee StandardConway ) )
865
859
findProposedCommittee gaId cgs = do
866
860
(rootCommittee, updateList) <- findRoot gaId
867
861
computeCommittee rootCommittee updateList
868
862
where
869
863
ps = cgsProposals cgs
870
864
findRoot = findRootRecursively []
871
865
872
- findRootRecursively :: [GovAction StandardConway ] -> GovActionId StandardCrypto -> Maybe (StrictMaybe (Committee StandardConway ), [GovAction StandardConway ])
866
+ findRootRecursively :: [GovAction StandardConway ] -> GovActionId StandardCrypto -> Either Text (StrictMaybe (Committee StandardConway ), [GovAction StandardConway ])
873
867
findRootRecursively acc gid = do
874
- gas <- proposalsLookupId gid ps
868
+ gas <- fromNothing ( " Didn't find proposal " <> textShow gid) $ proposalsLookupId gid ps
875
869
let ga = pProcGovAction (gasProposalProcedure gas)
876
870
case ga of
877
- NoConfidence _ -> Just (Ledger. SNothing , acc)
878
- UpdateCommittee Ledger. SNothing _ _ _ -> Just (cgsCommittee cgs, ga : acc)
871
+ NoConfidence _ -> Right (Ledger. SNothing , acc)
872
+ UpdateCommittee Ledger. SNothing _ _ _ -> Right (cgsCommittee cgs, ga : acc)
879
873
UpdateCommittee gpid _ _ _
880
874
| gpid == ps ^. pRootsL . grCommitteeL . prRootL ->
881
- Just (cgsCommittee cgs, ga : acc)
875
+ Right (cgsCommittee cgs, ga : acc)
882
876
UpdateCommittee (Ledger. SJust gpid) _ _ _ -> findRootRecursively (ga : acc) (unGovPurposeId gpid)
883
- _ -> Nothing
877
+ _ -> Left " Found invalid gov action referenced by committee "
884
878
885
- computeCommittee :: StrictMaybe (Committee StandardConway ) -> [GovAction StandardConway ] -> Maybe (Committee StandardConway )
879
+ computeCommittee :: StrictMaybe (Committee StandardConway ) -> [GovAction StandardConway ] -> Either Text ( Maybe (Committee StandardConway ) )
886
880
computeCommittee sCommittee actions =
887
- Ledger. strictMaybeToMaybe $ foldl applyCommitteeUpdate sCommittee actions
881
+ Ledger. strictMaybeToMaybe <$> foldM applyCommitteeUpdate sCommittee actions
888
882
889
883
applyCommitteeUpdate scommittee = \ case
890
- UpdateCommittee _ toRemove toAdd q -> Ledger. SJust $ updatedCommittee toRemove toAdd q scommittee
891
- _ -> Ledger. SNothing -- Should never happen since the accumulator only gets UpdateCommittee
884
+ UpdateCommittee _ toRemove toAdd q -> Right $ Ledger. SJust $ updatedCommittee toRemove toAdd q scommittee
885
+ _ -> Left " Unexpected gov action." -- Should never happen since the accumulator only includes UpdateCommittee
886
+ fromNothing err = maybe (Left err) Right
0 commit comments