Skip to content

Commit ec93356

Browse files
committed
Add logs of pruned states and rewriting in proxy
1 parent d321576 commit ec93356

File tree

1 file changed

+30
-20
lines changed

1 file changed

+30
-20
lines changed

booster/tools/booster/Proxy.hs

Lines changed: 30 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -621,16 +621,22 @@ respondEither cfg@ProxyConfig{boosterState} booster kore req = case req of
621621
second unzip $ partitionEithers simplifiedNexts
622622
newLogs = simplifiedStateLogs : logsOnly <> filteredNextLogs
623623

624-
pure $ case reason of
624+
when (length filteredNexts < maybe 0 length nextStates) $
625+
Booster.Log.withContext CtxProxy $
626+
Booster.Log.logMessage'
627+
(Text.pack ("Pruned #Bottom states: " <> show (length nextStates)))
628+
629+
case reason of
625630
Branching
626-
| null filteredNexts ->
627-
Right
628-
res
629-
{ reason = Stuck
630-
, nextStates = Nothing
631-
, logs = combineLogs $ res.logs : simplifiedStateLogs : logsOnly
632-
}
633-
| length filteredNexts == 1 ->
631+
| null filteredNexts -> do
632+
pure $
633+
Right
634+
res
635+
{ reason = Stuck
636+
, nextStates = Nothing
637+
, logs = combineLogs $ res.logs : simplifiedStateLogs : logsOnly
638+
}
639+
| length filteredNexts == 1 -> do
634640
-- all but one next states are bottom, execution should proceed
635641
-- Note that we've effectively made a rewrite step here, so we need to
636642
-- extract the rule-id information from the result we proceed with
@@ -646,24 +652,28 @@ respondEither cfg@ProxyConfig{boosterState} booster kore req = case req of
646652
}
647653
, origin = RPCLog.Proxy
648654
}
649-
in Left
655+
Booster.Log.withContext CtxProxy $
656+
Booster.Log.logMessage' ("Continuing after rewriting with rule " <> rewriteRuleId)
657+
pure $
658+
Left
650659
( execStateToKoreJson onlyNext
651660
, logsOnly <> filteredNextLogs <> [Just [proxyRewriteStepLog]]
652661
)
653662
-- otherwise falling through to _otherReason
654663
CutPointRule
655664
| null filteredNexts ->
656-
Right $ makeVacuous (combineLogs $ res.logs : newLogs) res
665+
pure $ Right $ makeVacuous (combineLogs $ res.logs : newLogs) res
657666
_otherReason ->
658-
Right $
659-
res
660-
{ state = simplifiedState
661-
, nextStates =
662-
if null filteredNexts
663-
then Nothing
664-
else Just filteredNexts
665-
, logs = combineLogs $ res.logs : newLogs
666-
}
667+
pure $
668+
Right $
669+
res
670+
{ state = simplifiedState
671+
, nextStates =
672+
if null filteredNexts
673+
then Nothing
674+
else Just filteredNexts
675+
, logs = combineLogs $ res.logs : newLogs
676+
}
667677

668678
data LogSettings = LogSettings
669679
{ logSuccessfulRewrites :: Maybe Bool

0 commit comments

Comments
 (0)