Skip to content

Commit 9421178

Browse files
committed
Post-process logs paranoically
1 parent ab6e2e1 commit 9421178

File tree

1 file changed

+30
-18
lines changed

1 file changed

+30
-18
lines changed

booster/tools/booster/Proxy.hs

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -216,11 +216,12 @@ respondEither cfg@ProxyConfig{statsVar, boosterState} booster kore req = case re
216216
SimplifyResult
217217
{ state = koreRes.state
218218
, logs =
219-
combineLogs
220-
[ timing
221-
, boosterRes.logs
222-
, map RPCLog.logEntryEraseTerms <$> koreRes.logs
223-
]
219+
postProcessLogs
220+
<$> combineLogs
221+
[ timing
222+
, boosterRes.logs
223+
, koreRes.logs
224+
]
224225
}
225226
koreError ->
226227
-- can only be an error
@@ -287,6 +288,9 @@ respondEither cfg@ProxyConfig{statsVar, boosterState} booster kore req = case re
287288
in Execute result'
288289
other -> other
289290

291+
postProcessLogs :: [RPCLog.LogEntry] -> [RPCLog.LogEntry]
292+
postProcessLogs !logs = map RPCLog.logEntryEraseTerms . filter (not . isSimplificationLogEntry) $ logs
293+
290294
executionLoop ::
291295
LogSettings ->
292296
KoreDefinition ->
@@ -319,7 +323,12 @@ respondEither cfg@ProxyConfig{statsVar, boosterState} booster kore req = case re
319323
Left logsOnly -> do
320324
-- state was simplified to \bottom, return vacuous
321325
Log.logInfoNS "proxy" "Vacuous state after simplification"
322-
pure . Right . Execute $ makeVacuous logsOnly boosterResult
326+
pure . Right . Execute $
327+
makeVacuous
328+
( postProcessLogs
329+
<$> logsOnly
330+
)
331+
boosterResult
323332
Right (simplifiedBoosterState, boosterStateSimplificationLogs) -> do
324333
let accumulatedLogs =
325334
combineLogs
@@ -333,7 +342,8 @@ respondEither cfg@ProxyConfig{statsVar, boosterState} booster kore req = case re
333342
( currentDepth + boosterResult.depth
334343
, time + bTime
335344
, koreTime
336-
, accumulatedLogs
345+
, postProcessLogs
346+
<$> accumulatedLogs
337347
)
338348
r{ExecuteRequest.state = execStateToKoreJson simplifiedBoosterState}
339349
-- if we stop for a reason in fallbackReasons (default [Aborted, Stuck, Branching],
@@ -348,7 +358,7 @@ respondEither cfg@ProxyConfig{statsVar, boosterState} booster kore req = case re
348358
Left logsOnly -> do
349359
-- state was simplified to \bottom, return vacuous
350360
Log.logInfoNS "proxy" "Vacuous state after simplification"
351-
pure . Right . Execute $ makeVacuous logsOnly boosterResult
361+
pure . Right . Execute $ makeVacuous (postProcessLogs <$> logsOnly) boosterResult
352362
Right (simplifiedBoosterState, boosterStateSimplificationLogs) -> do
353363
-- attempt to do one step in the old backend
354364
(kResult, kTime) <-
@@ -378,14 +388,15 @@ respondEither cfg@ProxyConfig{statsVar, boosterState} booster kore req = case re
378388
[ rpcLogs
379389
, boosterResult.logs
380390
, boosterStateSimplificationLogs
381-
, map RPCLog.logEntryEraseTerms . filter (not . isSimplificationLogEntry) <$> koreResult.logs
391+
, koreResult.logs
382392
, fallbackLog
383393
]
384394
loopState newLogs =
385395
( currentDepth + boosterResult.depth + koreResult.depth
386396
, time + bTime + kTime
387397
, koreTime + kTime
388-
, combineLogs $ accumulatedLogs : newLogs
398+
, postProcessLogs
399+
<$> combineLogs (accumulatedLogs : newLogs)
389400
)
390401
continueWith newLogs nextState =
391402
executionLoop
@@ -451,12 +462,13 @@ respondEither cfg@ProxyConfig{statsVar, boosterState} booster kore req = case re
451462
result
452463
{ depth = currentDepth + boosterResult.depth + koreResult.depth
453464
, logs =
454-
combineLogs
455-
[ rpcLogs
456-
, boosterResult.logs
457-
, map RPCLog.logEntryEraseTerms <$> result.logs
458-
, fallbackLog
459-
]
465+
postProcessLogs
466+
<$> combineLogs
467+
[ rpcLogs
468+
, boosterResult.logs
469+
, map RPCLog.logEntryEraseTerms <$> result.logs
470+
, fallbackLog
471+
]
460472
}
461473
-- can only be an error at this point
462474
res -> pure res
@@ -477,7 +489,7 @@ respondEither cfg@ProxyConfig{statsVar, boosterState} booster kore req = case re
477489
( currentDepth + boosterResult.depth
478490
, time + bTime
479491
, koreTime
480-
, combineLogs $ rpcLogs : boosterResult.logs : newLogs
492+
, postProcessLogs <$> combineLogs (rpcLogs : boosterResult.logs : newLogs)
481493
)
482494
r{ExecuteRequest.state = nextState}
483495
Right result -> do
@@ -486,7 +498,7 @@ respondEither cfg@ProxyConfig{statsVar, boosterState} booster kore req = case re
486498
Execute
487499
result
488500
{ depth = currentDepth + boosterResult.depth
489-
, logs = combineLogs [rpcLogs, result.logs]
501+
, logs = postProcessLogs <$> combineLogs [rpcLogs, result.logs]
490502
}
491503
-- can only be an error at this point
492504
res -> pure res

0 commit comments

Comments
 (0)