Skip to content

Implement better booster logging #3826

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Apr 29, 2024

Conversation

goodlyrottenapple
Copy link
Contributor

@goodlyrottenapple goodlyrottenapple commented Apr 23, 2024

This PR structured logs which allow us to more easily trace rewriting and simplifications:

[Info#proxy] Starting execute request
[booster][execute][smt] Starting new SMT solver
[booster][execute][smt] Solver ready to use
[booster][execute][smt] Checking definition prelude
[booster][execute][term 58b79a1][detail] <generatedTop>(<foundry>(<kevm>(<k>(kseq(#execute_EVM_KItem(), VarCONTINUATION:SortK{})), <exit-code>(VarEXITCODE_CELL:SortInt{}), <mode>(NORMAL()), <schedule>(SHANGHAI_EVM()), <useGas>("false"), <ethereum>(<evm>(<output>(VarOUTPUT_CELL:SortBytes{}), <statusCode>(VarSTATUSCODE:SortStatusCode{}), <callStack>(VarCALLSTACK_CELL:SortList{}), <interimStates>(VarINTERIMSTATES_CELL:SortList{}), <touchedAccounts>(VarTOUCHEDACCOUNTS_CELL:SortSet{}), <callState>(<program>("`\128`@R4\128\NAKa\NUL\DLEW`\NUL\128\253...truncated"), <jumpDests>({"16", "87", "92", "353", "344", "365", "332", "397", "381", "296", "217", "224", "200", "205", "111", "106", "167", "162", "129", "181", "186", "143", "148", "745", "720", "618", "623", "600", "653", "686", "680", "593", "570", "575", "518", "551", "529", "452", "475", "494", "416", "431"} ), <id>(VarCONTRACT_ID:SortInt{}), <caller>(VarCALLER_ID:SortInt{}), <callData>(_+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes("\156&\224\&7", _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV0_x_114b9705:SortInt{}), _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV1_y_114b9705:SortInt{}), #buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV2_z_114b9705:SortInt{}))))), <callValue>("0"), <wordStack>(.WordStack_EVM-TYPES_WordStack()), <localMem>(""), <pc>("0"), <gas>("0"), <memoryUsed>("0"), <callGas>("0"), <static>(VarSTATIC_CELL:SortBool{}), <callDepth>(VarCALLDEPTH_CELL:SortInt{})), <substate>(<selfDestruct>(VarSELFDESTRUCT_CELL:SortSet{}), <log>(VarLOG_CELL:SortList{}), <refund>("0"), <accessedAccounts>(VarACCESSEDACCOUNTS_CELL:SortSet{}), <accessedStorage>(VarACCESSEDSTORAGE_CELL:SortMap{})), <gasPrice>(VarGASPRICE_CELL:SortInt{}), <origin>(VarORIGIN_ID:SortInt{}), <blockhashes>(VarBLOCKHASHES_CELL:SortList{}), <block>(<previousHash>(VarPREVIOUSHASH_CELL:SortInt{}), <ommersHash>(VarOMMERSHASH_CELL:SortInt{}), <coinbase>(VarCOINBASE_CELL:SortInt{}), <stateRoot>(VarSTATEROOT_CELL:SortInt{}), <transactionsRoot>(VarTRANSACTIONSROOT_CELL:SortInt{}), <receiptsRoot>(VarRECEIPTSROOT_CELL:SortInt{}), <logsBloom>(VarLOGSBLOOM_CELL:SortBytes{}), <difficulty>(VarDIFFICULTY_CELL:SortInt{}), <number>(VarNUMBER_CELL:SortInt{}), <gasLimit>(VarGASLIMIT_CELL:SortInt{}), <gasUsed>(VarGASUSED_CELL:SortGas{}), <timestamp>(VarTIMESTAMP_CELL:SortInt{}), <extraData>(VarEXTRADATA_CELL:SortBytes{}), <mixHash>(VarMIXHASH_CELL:SortInt{}), <blockNonce>(VarBLOCKNONCE_CELL:SortInt{}), <baseFee>(VarBASEFEE_CELL:SortInt{}), <withdrawalsRoot>(VarWITHDRAWALSROOT_CELL:SortInt{}), <ommerBlockHeaders>(VarOMMERBLOCKHEADERS_CELL:SortJSON{}))), <network>(<chainID>(VarCHAINID_CELL:SortInt{}), <accounts>({<acctID>(VarCONTRACT_ID:SortInt{}) -> <account>(<acctID>(VarCONTRACT_ID:SortInt{}), <balance>(VarCONTRACT_BAL:SortInt{}), <code>("`\128`@R4\128\NAKa\NUL\DLEW`\NUL\128\253...truncated"), <storage>(VarCONTRACT_STORAGE:SortMap{}), <origStorage>(VarCONTRACT_ORIGSTORAGE:SortMap{}), <nonce>(VarCONTRACT_NONCE:SortInt{})), VarACCOUNTS_REST:SortAccountCellMap{}}), <txOrder>(VarTXORDER_CELL:SortList{}), <txPending>(VarTXPENDING_CELL:SortList{}), <messages>(VarMESSAGES_CELL:SortMessageCellMap{})))), <cheatcodes>(<prank>(<prevCaller>(VarPREVCALLER_CELL:SortAccount{}), <prevOrigin>(VarPREVORIGIN_CELL:SortAccount{}), <newCaller>(VarNEWCALLER_CELL:SortAccount{}), <newOrigin>(VarNEWORIGIN_CELL:SortAccount{}), <active>("false"), <depth>(VarDEPTH_CELL:SortInt{}), <singleCall>("false")), <expectedRevert>(<isRevertExpected>("false"), <expectedReason>(VarEXPECTEDREASON_CELL:SortBytes{}), <expectedDepth>(VarEXPECTEDDEPTH_CELL:SortInt{})), <expectedOpcode>(<isOpcodeExpected>("false"), <expectedAddress>(VarEXPECTEDADDRESS_CELL:SortAccount{}), <expectedValue>(VarEXPECTEDVALUE_CELL:SortInt{}), <expectedData>(VarEXPECTEDDATA_CELL:SortBytes{}), <opcodeType>(VarOPCODETYPE_CELL:SortOpcodeType{})), <expectEmit>(<recordEvent>("false"), <isEventExpected>("false"), <checkedTopics>(VarCHECKEDTOPICS_CELL:SortList{}), <checkedData>(VarCHECKEDDATA_CELL:SortBool{}), <expectedEventAddress>(VarEXPECTEDEVENTADDRESS_CELL:SortAccount{})), <whitelist>(<isCallWhitelistActive>("false"), <isStorageWhitelistActive>("false"), <addressSet>({}), <storageSlotSet>({})), <mockCalls>({})), <KEVMTracing>(<activeTracing>("false"), <traceStorage>("false"), <traceWordStack>("false"), <traceMemory>("false"), <recordedTrace>("false"), <traceData>([]))), <generatedCounter>(VarGENERATEDCOUNTER_CELL:SortInt{})) /\ notBool_(AccountCellMap:in_keys(<acctID>(VarCONTRACT_ID:SortInt{}), VarACCOUNTS_REST:SortAccountCellMap{})) /\ _<Int_(VarCALLER_ID:SortInt{}, "1461501637330902...truncated") /\ _<=Int_("0", VarCALLER_ID:SortInt{}) /\ notBool_(_andBool_(_<Int_("0", VarCALLER_ID:SortInt{}), _<=Int_(VarCALLER_ID:SortInt{}, "9"))) /\ _=/=Int_(VarCALLER_ID:SortInt{}, "6453264744265472...truncated") /\ _<=Int_("0", VarCONTRACT_BAL:SortInt{}) /\ _<Int_(VarCONTRACT_BAL:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarCONTRACT_ID:SortInt{}) /\ _<Int_(VarCONTRACT_ID:SortInt{}, "1461501637330902...truncated") /\ _=/=Int_(VarCONTRACT_ID:SortInt{}, "6453264744265472...truncated") /\ notBool_(_andBool_(_<Int_("0", VarCONTRACT_ID:SortInt{}), _<=Int_(VarCONTRACT_ID:SortInt{}, "9"))) /\ _<Int_(VarCONTRACT_NONCE:SortInt{}, "1844674407370955...truncated") /\ _<=Int_("0", VarCONTRACT_NONCE:SortInt{}) /\ _<=Int_(VarNUMBER_CELL:SortInt{}, "5789604461865809...truncated") /\ _<=Int_("0", VarNUMBER_CELL:SortInt{}) /\ _<=Int_("0", VarORIGIN_ID:SortInt{}) /\ _=/=Int_(VarORIGIN_ID:SortInt{}, "6453264744265472...truncated") /\ _<Int_(VarORIGIN_ID:SortInt{}, "1461501637330902...truncated") /\ notBool_(_andBool_(_<Int_("0", VarORIGIN_ID:SortInt{}), _<=Int_(VarORIGIN_ID:SortInt{}, "9"))) /\ _<Int_(VarTIMESTAMP_CELL:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarTIMESTAMP_CELL:SortInt{}) /\ _<Int_(VarVV0_x_114b9705:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarVV0_x_114b9705:SortInt{}) /\ _<Int_(VarVV1_y_114b9705:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarVV1_y_114b9705:SortInt{}) /\ _<Int_(VarVV2_z_114b9705:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarVV2_z_114b9705:SortInt{})
[booster][execute][term 58b79a1][rewrite UNKNOWN][detail] BASIC-BLOCK-8-TO-6
[booster][execute][term 58b79a1][rewrite UNKNOWN][match][abort] Uncertain about match with rule. Remainder: [(_+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes("w\SYN\STX\247", _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", Rule#VarVV0_x_114b9705:SortInt{}), #buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", Rule#VarVV1_y_114b9705:SortInt{}))), _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes("\156&\224\&7", _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV0_x_114b9705:SortInt{}), _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV1_y_114b9705:SortInt{}), #buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV2_z_114b9705:SortInt{}))))), ({"16", "87", "92", "353", "344", "365", "332", "397", "381", "296", "217", "224", "200", "205", "111", "106", "167", "162", "129", "181", "186", "143", "148", "745", "720", "618", "623", "600", "653", "686", "680", "593", "570", "575", "518", "551", "529", "452", "475", "494", "416", "431"} , {"16", "87", "92", "353", "344", "365", "332", "397", "381", "296", "217", "224", "200", "205", "111", "106", "167", "162", "129", "181", "186", "143", "148", "745", "720", "618", "623", "600", "653", "686", "680", "593", "570", "575", "518", "551", "529", "452", "475", "494", "416", "431"} ), ({}, {}), ({}, {})]
[booster][execute][term 58b79a1][detail] <generatedTop>(<foundry>(<kevm>(<k>(kseq(#execute_EVM_KItem(), VarCONTINUATION:SortK{})), <exit-code>(VarEXITCODE_CELL:SortInt{}), <mode>(NORMAL()), <schedule>(SHANGHAI_EVM()), <useGas>("false"), <ethereum>(<evm>(<output>(VarOUTPUT_CELL:SortBytes{}), <statusCode>(VarSTATUSCODE:SortStatusCode{}), <callStack>(VarCALLSTACK_CELL:SortList{}), <interimStates>(VarINTERIMSTATES_CELL:SortList{}), <touchedAccounts>(VarTOUCHEDACCOUNTS_CELL:SortSet{}), <callState>(<program>("`\128`@R4\128\NAKa\NUL\DLEW`\NUL\128\253...truncated"), <jumpDests>({"16", "87", "92", "353", "344", "365", "332", "397", "381", "296", "217", "224", "200", "205", "111", "106", "167", "162", "129", "181", "186", "143", "148", "745", "720", "618", "623", "600", "653", "686", "680", "593", "570", "575", "518", "551", "529", "452", "475", "494", "416", "431"} ), <id>(VarCONTRACT_ID:SortInt{}), <caller>(VarCALLER_ID:SortInt{}), <callData>(_+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes("\156&\224\&7", _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV0_x_114b9705:SortInt{}), _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV1_y_114b9705:SortInt{}), #buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV2_z_114b9705:SortInt{}))))), <callValue>("0"), <wordStack>(.WordStack_EVM-TYPES_WordStack()), <localMem>(""), <pc>("0"), <gas>("0"), <memoryUsed>("0"), <callGas>("0"), <static>(VarSTATIC_CELL:SortBool{}), <callDepth>(VarCALLDEPTH_CELL:SortInt{})), <substate>(<selfDestruct>(VarSELFDESTRUCT_CELL:SortSet{}), <log>(VarLOG_CELL:SortList{}), <refund>("0"), <accessedAccounts>(VarACCESSEDACCOUNTS_CELL:SortSet{}), <accessedStorage>(VarACCESSEDSTORAGE_CELL:SortMap{})), <gasPrice>(VarGASPRICE_CELL:SortInt{}), <origin>(VarORIGIN_ID:SortInt{}), <blockhashes>(VarBLOCKHASHES_CELL:SortList{}), <block>(<previousHash>(VarPREVIOUSHASH_CELL:SortInt{}), <ommersHash>(VarOMMERSHASH_CELL:SortInt{}), <coinbase>(VarCOINBASE_CELL:SortInt{}), <stateRoot>(VarSTATEROOT_CELL:SortInt{}), <transactionsRoot>(VarTRANSACTIONSROOT_CELL:SortInt{}), <receiptsRoot>(VarRECEIPTSROOT_CELL:SortInt{}), <logsBloom>(VarLOGSBLOOM_CELL:SortBytes{}), <difficulty>(VarDIFFICULTY_CELL:SortInt{}), <number>(VarNUMBER_CELL:SortInt{}), <gasLimit>(VarGASLIMIT_CELL:SortInt{}), <gasUsed>(VarGASUSED_CELL:SortGas{}), <timestamp>(VarTIMESTAMP_CELL:SortInt{}), <extraData>(VarEXTRADATA_CELL:SortBytes{}), <mixHash>(VarMIXHASH_CELL:SortInt{}), <blockNonce>(VarBLOCKNONCE_CELL:SortInt{}), <baseFee>(VarBASEFEE_CELL:SortInt{}), <withdrawalsRoot>(VarWITHDRAWALSROOT_CELL:SortInt{}), <ommerBlockHeaders>(VarOMMERBLOCKHEADERS_CELL:SortJSON{}))), <network>(<chainID>(VarCHAINID_CELL:SortInt{}), <accounts>({<acctID>(VarCONTRACT_ID:SortInt{}) -> <account>(<acctID>(VarCONTRACT_ID:SortInt{}), <balance>(VarCONTRACT_BAL:SortInt{}), <code>("`\128`@R4\128\NAKa\NUL\DLEW`\NUL\128\253...truncated"), <storage>(VarCONTRACT_STORAGE:SortMap{}), <origStorage>(VarCONTRACT_ORIGSTORAGE:SortMap{}), <nonce>(VarCONTRACT_NONCE:SortInt{})), VarACCOUNTS_REST:SortAccountCellMap{}}), <txOrder>(VarTXORDER_CELL:SortList{}), <txPending>(VarTXPENDING_CELL:SortList{}), <messages>(VarMESSAGES_CELL:SortMessageCellMap{})))), <cheatcodes>(<prank>(<prevCaller>(VarPREVCALLER_CELL:SortAccount{}), <prevOrigin>(VarPREVORIGIN_CELL:SortAccount{}), <newCaller>(VarNEWCALLER_CELL:SortAccount{}), <newOrigin>(VarNEWORIGIN_CELL:SortAccount{}), <active>("false"), <depth>(VarDEPTH_CELL:SortInt{}), <singleCall>("false")), <expectedRevert>(<isRevertExpected>("false"), <expectedReason>(VarEXPECTEDREASON_CELL:SortBytes{}), <expectedDepth>(VarEXPECTEDDEPTH_CELL:SortInt{})), <expectedOpcode>(<isOpcodeExpected>("false"), <expectedAddress>(VarEXPECTEDADDRESS_CELL:SortAccount{}), <expectedValue>(VarEXPECTEDVALUE_CELL:SortInt{}), <expectedData>(VarEXPECTEDDATA_CELL:SortBytes{}), <opcodeType>(VarOPCODETYPE_CELL:SortOpcodeType{})), <expectEmit>(<recordEvent>("false"), <isEventExpected>("false"), <checkedTopics>(VarCHECKEDTOPICS_CELL:SortList{}), <checkedData>(VarCHECKEDDATA_CELL:SortBool{}), <expectedEventAddress>(VarEXPECTEDEVENTADDRESS_CELL:SortAccount{})), <whitelist>(<isCallWhitelistActive>("false"), <isStorageWhitelistActive>("false"), <addressSet>({}), <storageSlotSet>({})), <mockCalls>({})), <KEVMTracing>(<activeTracing>("false"), <traceStorage>("false"), <traceWordStack>("false"), <traceMemory>("false"), <recordedTrace>("false"), <traceData>([]))), <generatedCounter>(VarGENERATEDCOUNTER_CELL:SortInt{})) /\ notBool_(AccountCellMap:in_keys(<acctID>(VarCONTRACT_ID:SortInt{}), VarACCOUNTS_REST:SortAccountCellMap{})) /\ _<Int_(VarCALLER_ID:SortInt{}, "1461501637330902...truncated") /\ _<=Int_("0", VarCALLER_ID:SortInt{}) /\ notBool_(_andBool_(_<Int_("0", VarCALLER_ID:SortInt{}), _<=Int_(VarCALLER_ID:SortInt{}, "9"))) /\ _=/=Int_(VarCALLER_ID:SortInt{}, "6453264744265472...truncated") /\ _<=Int_("0", VarCONTRACT_BAL:SortInt{}) /\ _<Int_(VarCONTRACT_BAL:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarCONTRACT_ID:SortInt{}) /\ _<Int_(VarCONTRACT_ID:SortInt{}, "1461501637330902...truncated") /\ _=/=Int_(VarCONTRACT_ID:SortInt{}, "6453264744265472...truncated") /\ notBool_(_andBool_(_<Int_("0", VarCONTRACT_ID:SortInt{}), _<=Int_(VarCONTRACT_ID:SortInt{}, "9"))) /\ _<Int_(VarCONTRACT_NONCE:SortInt{}, "1844674407370955...truncated") /\ _<=Int_("0", VarCONTRACT_NONCE:SortInt{}) /\ _<=Int_(VarNUMBER_CELL:SortInt{}, "5789604461865809...truncated") /\ _<=Int_("0", VarNUMBER_CELL:SortInt{}) /\ _<=Int_("0", VarORIGIN_ID:SortInt{}) /\ _=/=Int_(VarORIGIN_ID:SortInt{}, "6453264744265472...truncated") /\ _<Int_(VarORIGIN_ID:SortInt{}, "1461501637330902...truncated") /\ notBool_(_andBool_(_<Int_("0", VarORIGIN_ID:SortInt{}), _<=Int_(VarORIGIN_ID:SortInt{}, "9"))) /\ _<Int_(VarTIMESTAMP_CELL:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarTIMESTAMP_CELL:SortInt{}) /\ _<Int_(VarVV0_x_114b9705:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarVV0_x_114b9705:SortInt{}) /\ _<Int_(VarVV1_y_114b9705:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarVV1_y_114b9705:SortInt{}) /\ _<Int_(VarVV2_z_114b9705:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarVV2_z_114b9705:SortInt{})
[booster][execute][term 58b79a1][simplify][term 58b79a1][detail] <generatedTop>(<foundry>(<kevm>(<k>(kseq(#execute_EVM_KItem(), VarCONTINUATION:SortK{})), <exit-code>(VarEXITCODE_CELL:SortInt{}), <mode>(NORMAL()), <schedule>(SHANGHAI_EVM()), <useGas>("false"), <ethereum>(<evm>(<output>(VarOUTPUT_CELL:SortBytes{}), <statusCode>(VarSTATUSCODE:SortStatusCode{}), <callStack>(VarCALLSTACK_CELL:SortList{}), <interimStates>(VarINTERIMSTATES_CELL:SortList{}), <touchedAccounts>(VarTOUCHEDACCOUNTS_CELL:SortSet{}), <callState>(<program>("`\128`@R4\128\NAKa\NUL\DLEW`\NUL\128\253...truncated"), <jumpDests>({"16", "87", "92", "353", "344", "365", "332", "397", "381", "296", "217", "224", "200", "205", "111", "106", "167", "162", "129", "181", "186", "143", "148", "745", "720", "618", "623", "600", "653", "686", "680", "593", "570", "575", "518", "551", "529", "452", "475", "494", "416", "431"} ), <id>(VarCONTRACT_ID:SortInt{}), <caller>(VarCALLER_ID:SortInt{}), <callData>(_+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes("\156&\224\&7", _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV0_x_114b9705:SortInt{}), _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV1_y_114b9705:SortInt{}), #buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV2_z_114b9705:SortInt{}))))), <callValue>("0"), <wordStack>(.WordStack_EVM-TYPES_WordStack()), <localMem>(""), <pc>("0"), <gas>("0"), <memoryUsed>("0"), <callGas>("0"), <static>(VarSTATIC_CELL:SortBool{}), <callDepth>(VarCALLDEPTH_CELL:SortInt{})), <substate>(<selfDestruct>(VarSELFDESTRUCT_CELL:SortSet{}), <log>(VarLOG_CELL:SortList{}), <refund>("0"), <accessedAccounts>(VarACCESSEDACCOUNTS_CELL:SortSet{}), <accessedStorage>(VarACCESSEDSTORAGE_CELL:SortMap{})), <gasPrice>(VarGASPRICE_CELL:SortInt{}), <origin>(VarORIGIN_ID:SortInt{}), <blockhashes>(VarBLOCKHASHES_CELL:SortList{}), <block>(<previousHash>(VarPREVIOUSHASH_CELL:SortInt{}), <ommersHash>(VarOMMERSHASH_CELL:SortInt{}), <coinbase>(VarCOINBASE_CELL:SortInt{}), <stateRoot>(VarSTATEROOT_CELL:SortInt{}), <transactionsRoot>(VarTRANSACTIONSROOT_CELL:SortInt{}), <receiptsRoot>(VarRECEIPTSROOT_CELL:SortInt{}), <logsBloom>(VarLOGSBLOOM_CELL:SortBytes{}), <difficulty>(VarDIFFICULTY_CELL:SortInt{}), <number>(VarNUMBER_CELL:SortInt{}), <gasLimit>(VarGASLIMIT_CELL:SortInt{}), <gasUsed>(VarGASUSED_CELL:SortGas{}), <timestamp>(VarTIMESTAMP_CELL:SortInt{}), <extraData>(VarEXTRADATA_CELL:SortBytes{}), <mixHash>(VarMIXHASH_CELL:SortInt{}), <blockNonce>(VarBLOCKNONCE_CELL:SortInt{}), <baseFee>(VarBASEFEE_CELL:SortInt{}), <withdrawalsRoot>(VarWITHDRAWALSROOT_CELL:SortInt{}), <ommerBlockHeaders>(VarOMMERBLOCKHEADERS_CELL:SortJSON{}))), <network>(<chainID>(VarCHAINID_CELL:SortInt{}), <accounts>({<acctID>(VarCONTRACT_ID:SortInt{}) -> <account>(<acctID>(VarCONTRACT_ID:SortInt{}), <balance>(VarCONTRACT_BAL:SortInt{}), <code>("`\128`@R4\128\NAKa\NUL\DLEW`\NUL\128\253...truncated"), <storage>(VarCONTRACT_STORAGE:SortMap{}), <origStorage>(VarCONTRACT_ORIGSTORAGE:SortMap{}), <nonce>(VarCONTRACT_NONCE:SortInt{})), VarACCOUNTS_REST:SortAccountCellMap{}}), <txOrder>(VarTXORDER_CELL:SortList{}), <txPending>(VarTXPENDING_CELL:SortList{}), <messages>(VarMESSAGES_CELL:SortMessageCellMap{})))), <cheatcodes>(<prank>(<prevCaller>(VarPREVCALLER_CELL:SortAccount{}), <prevOrigin>(VarPREVORIGIN_CELL:SortAccount{}), <newCaller>(VarNEWCALLER_CELL:SortAccount{}), <newOrigin>(VarNEWORIGIN_CELL:SortAccount{}), <active>("false"), <depth>(VarDEPTH_CELL:SortInt{}), <singleCall>("false")), <expectedRevert>(<isRevertExpected>("false"), <expectedReason>(VarEXPECTEDREASON_CELL:SortBytes{}), <expectedDepth>(VarEXPECTEDDEPTH_CELL:SortInt{})), <expectedOpcode>(<isOpcodeExpected>("false"), <expectedAddress>(VarEXPECTEDADDRESS_CELL:SortAccount{}), <expectedValue>(VarEXPECTEDVALUE_CELL:SortInt{}), <expectedData>(VarEXPECTEDDATA_CELL:SortBytes{}), <opcodeType>(VarOPCODETYPE_CELL:SortOpcodeType{})), <expectEmit>(<recordEvent>("false"), <isEventExpected>("false"), <checkedTopics>(VarCHECKEDTOPICS_CELL:SortList{}), <checkedData>(VarCHECKEDDATA_CELL:SortBool{}), <expectedEventAddress>(VarEXPECTEDEVENTADDRESS_CELL:SortAccount{})), <whitelist>(<isCallWhitelistActive>("false"), <isStorageWhitelistActive>("false"), <addressSet>({}), <storageSlotSet>({})), <mockCalls>({})), <KEVMTracing>(<activeTracing>("false"), <traceStorage>("false"), <traceWordStack>("false"), <traceMemory>("false"), <recordedTrace>("false"), <traceData>([]))), <generatedCounter>(VarGENERATEDCOUNTER_CELL:SortInt{})) /\ notBool_(AccountCellMap:in_keys(<acctID>(VarCONTRACT_ID:SortInt{}), VarACCOUNTS_REST:SortAccountCellMap{})) /\ _<Int_(VarCALLER_ID:SortInt{}, "1461501637330902...truncated") /\ _<=Int_("0", VarCALLER_ID:SortInt{}) /\ notBool_(_andBool_(_<Int_("0", VarCALLER_ID:SortInt{}), _<=Int_(VarCALLER_ID:SortInt{}, "9"))) /\ _=/=Int_(VarCALLER_ID:SortInt{}, "6453264744265472...truncated") /\ _<=Int_("0", VarCONTRACT_BAL:SortInt{}) /\ _<Int_(VarCONTRACT_BAL:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarCONTRACT_ID:SortInt{}) /\ _<Int_(VarCONTRACT_ID:SortInt{}, "1461501637330902...truncated") /\ _=/=Int_(VarCONTRACT_ID:SortInt{}, "6453264744265472...truncated") /\ notBool_(_andBool_(_<Int_("0", VarCONTRACT_ID:SortInt{}), _<=Int_(VarCONTRACT_ID:SortInt{}, "9"))) /\ _<Int_(VarCONTRACT_NONCE:SortInt{}, "1844674407370955...truncated") /\ _<=Int_("0", VarCONTRACT_NONCE:SortInt{}) /\ _<=Int_(VarNUMBER_CELL:SortInt{}, "5789604461865809...truncated") /\ _<=Int_("0", VarNUMBER_CELL:SortInt{}) /\ _<=Int_("0", VarORIGIN_ID:SortInt{}) /\ _=/=Int_(VarORIGIN_ID:SortInt{}, "6453264744265472...truncated") /\ _<Int_(VarORIGIN_ID:SortInt{}, "1461501637330902...truncated") /\ notBool_(_andBool_(_<Int_("0", VarORIGIN_ID:SortInt{}), _<=Int_(VarORIGIN_ID:SortInt{}, "9"))) /\ _<Int_(VarTIMESTAMP_CELL:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarTIMESTAMP_CELL:SortInt{}) /\ _<Int_(VarVV0_x_114b9705:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarVV0_x_114b9705:SortInt{}) /\ _<Int_(VarVV1_y_114b9705:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarVV1_y_114b9705:SortInt{}) /\ _<Int_(VarVV2_z_114b9705:SortInt{}, "1157920892373161...truncated") /\ _<=Int_("0", VarVV2_z_114b9705:SortInt{})
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][detail] <generatedTop>(<foundry>(<kevm>(<k>(kseq(#execute_EVM_KItem(), VarCONTINUATION:SortK{})), <exit-code>(VarEXITCODE_CELL:SortInt{}), <mode>(NORMAL()), <schedule>(SHANGHAI_EVM()), <useGas>("false"), <ethereum>(<evm>(<output>(VarOUTPUT_CELL:SortBytes{}), <statusCode>(VarSTATUSCODE:SortStatusCode{}), <callStack>(VarCALLSTACK_CELL:SortList{}), <interimStates>(VarINTERIMSTATES_CELL:SortList{}), <touchedAccounts>(VarTOUCHEDACCOUNTS_CELL:SortSet{}), <callState>(<program>("`\128`@R4\128\NAKa\NUL\DLEW`\NUL\128\253...truncated"), <jumpDests>({"16", "87", "92", "353", "344", "365", "332", "397", "381", "296", "217", "224", "200", "205", "111", "106", "167", "162", "129", "181", "186", "143", "148", "745", "720", "618", "623", "600", "653", "686", "680", "593", "570", "575", "518", "551", "529", "452", "475", "494", "416", "431"} ), <id>(VarCONTRACT_ID:SortInt{}), <caller>(VarCALLER_ID:SortInt{}), <callData>(_+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes("\156&\224\&7", _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV0_x_114b9705:SortInt{}), _+Bytes__BYTES-HOOKED_Bytes_Bytes_Bytes(#buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV1_y_114b9705:SortInt{}), #buf(_,_)_BUF-SYNTAX_Bytes_Int_Int("32", VarVV2_z_114b9705:SortInt{}))))), <callValue>("0"), <wordStack>(.WordStack_EVM-TYPES_WordStack()), <localMem>(""), <pc>("0"), <gas>("0"), <memoryUsed>("0"), <callGas>("0"), <static>(VarSTATIC_CELL:SortBool{}), <callDepth>(VarCALLDEPTH_CELL:SortInt{})), <substate>(<selfDestruct>(VarSELFDESTRUCT_CELL:SortSet{}), <log>(VarLOG_CELL:SortList{}), <refund>("0"), <accessedAccounts>(VarACCESSEDACCOUNTS_CELL:SortSet{}), <accessedStorage>(VarACCESSEDSTORAGE_CELL:SortMap{})), <gasPrice>(VarGASPRICE_CELL:SortInt{}), <origin>(VarORIGIN_ID:SortInt{}), <blockhashes>(VarBLOCKHASHES_CELL:SortList{}), <block>(<previousHash>(VarPREVIOUSHASH_CELL:SortInt{}), <ommersHash>(VarOMMERSHASH_CELL:SortInt{}), <coinbase>(VarCOINBASE_CELL:SortInt{}), <stateRoot>(VarSTATEROOT_CELL:SortInt{}), <transactionsRoot>(VarTRANSACTIONSROOT_CELL:SortInt{}), <receiptsRoot>(VarRECEIPTSROOT_CELL:SortInt{}), <logsBloom>(VarLOGSBLOOM_CELL:SortBytes{}), <difficulty>(VarDIFFICULTY_CELL:SortInt{}), <number>(VarNUMBER_CELL:SortInt{}), <gasLimit>(VarGASLIMIT_CELL:SortInt{}), <gasUsed>(VarGASUSED_CELL:SortGas{}), <timestamp>(VarTIMESTAMP_CELL:SortInt{}), <extraData>(VarEXTRADATA_CELL:SortBytes{}), <mixHash>(VarMIXHASH_CELL:SortInt{}), <blockNonce>(VarBLOCKNONCE_CELL:SortInt{}), <baseFee>(VarBASEFEE_CELL:SortInt{}), <withdrawalsRoot>(VarWITHDRAWALSROOT_CELL:SortInt{}), <ommerBlockHeaders>(VarOMMERBLOCKHEADERS_CELL:SortJSON{}))), <network>(<chainID>(VarCHAINID_CELL:SortInt{}), <accounts>({<acctID>(VarCONTRACT_ID:SortInt{}) -> <account>(<acctID>(VarCONTRACT_ID:SortInt{}), <balance>(VarCONTRACT_BAL:SortInt{}), <code>("`\128`@R4\128\NAKa\NUL\DLEW`\NUL\128\253...truncated"), <storage>(VarCONTRACT_STORAGE:SortMap{}), <origStorage>(VarCONTRACT_ORIGSTORAGE:SortMap{}), <nonce>(VarCONTRACT_NONCE:SortInt{})), VarACCOUNTS_REST:SortAccountCellMap{}}), <txOrder>(VarTXORDER_CELL:SortList{}), <txPending>(VarTXPENDING_CELL:SortList{}), <messages>(VarMESSAGES_CELL:SortMessageCellMap{})))), <cheatcodes>(<prank>(<prevCaller>(VarPREVCALLER_CELL:SortAccount{}), <prevOrigin>(VarPREVORIGIN_CELL:SortAccount{}), <newCaller>(VarNEWCALLER_CELL:SortAccount{}), <newOrigin>(VarNEWORIGIN_CELL:SortAccount{}), <active>("false"), <depth>(VarDEPTH_CELL:SortInt{}), <singleCall>("false")), <expectedRevert>(<isRevertExpected>("false"), <expectedReason>(VarEXPECTEDREASON_CELL:SortBytes{}), <expectedDepth>(VarEXPECTEDDEPTH_CELL:SortInt{})), <expectedOpcode>(<isOpcodeExpected>("false"), <expectedAddress>(VarEXPECTEDADDRESS_CELL:SortAccount{}), <expectedValue>(VarEXPECTEDVALUE_CELL:SortInt{}), <expectedData>(VarEXPECTEDDATA_CELL:SortBytes{}), <opcodeType>(VarOPCODETYPE_CELL:SortOpcodeType{})), <expectEmit>(<recordEvent>("false"), <isEventExpected>("false"), <checkedTopics>(VarCHECKEDTOPICS_CELL:SortList{}), <checkedData>(VarCHECKEDDATA_CELL:SortBool{}), <expectedEventAddress>(VarEXPECTEDEVENTADDRESS_CELL:SortAccount{})), <whitelist>(<isCallWhitelistActive>("false"), <isStorageWhitelistActive>("false"), <addressSet>({}), <storageSlotSet>({})), <mockCalls>({})), <KEVMTracing>(<activeTracing>("false"), <traceStorage>("false"), <traceWordStack>("false"), <traceMemory>("false"), <recordedTrace>("false"), <traceData>([]))), <generatedCounter>(VarGENERATEDCOUNTER_CELL:SortInt{}))
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][function 00be500][detail] ...kproj/evm-semantics/buf.md :  (49, 10)
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][function 00be500][failure] Concreteness constraint violated: term has variables
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][function d38a123][detail] ...kproj/evm-semantics/buf.md :  (52, 10)
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][function d38a123][failure] Concreteness constraint violated: term has variables
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][simplification 5a8ecf6][detail] BYTES-SIMPLIFICATION.buf-asWord-invert-lr-len-gt
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][simplification 5a8ecf6][match][failure] Uncertain about match with rule. Remainder: [(#asWord(_)_EVM-TYPES_Int_Bytes(Eq#VarB:SortBytes{}), VarVV0_x_114b9705:SortInt{})]
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][simplification 4ec7f53][detail] BYTES-SIMPLIFICATION.buf-asWord-invert-lr-len-leq
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][simplification 4ec7f53][match][failure] Uncertain about match with rule. Remainder: [(#asWord(_)_EVM-TYPES_Int_Bytes(Eq#VarB:SortBytes{}), VarVV0_x_114b9705:SortInt{})]
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][function 00be500][detail] ...kproj/evm-semantics/buf.md :  (49, 10)
[booster][execute][term 58b79a1][simplify][term 58b79a1][term 24777d8][function 00be500][failure] Concreteness constraint violated: term has variables

To turn on this new logging, pass --log-context "booster*" to the rpc server. If this produces too much loging, we can filter the logs as they are being emitted via a glob syntax filter. e.g. --log-context "*success" will only log all successful matches/rewrites/simplifications and --log-context "*rewrite*match*success" will only log successful matches with a rewrite rule. Conversely, we can also use --not-log-context "*detail" to supress pretty printing terms/rule locations or --not-log-context "*failure" to hide all failures or a combination, such as --log-context "*success*" --not-log-context "*constraint*" --not-log-context "*simplify*" to log any successes not inside a constraint or simplification context.

Logging contexts

[booster]

top level context signifying computation in the booster backend. [kore] will be used as top-level context in the kore backend

[execute]/[add-module]/[get-model]

top-level (right below [booster]) contexts corresponding to rpc calls

[term <hash>]

nested context tying any logs within to a particular term. We use the internal hash of a term and pretty print each new term inside a [detail] context, e.g.:

...[term 2749139][detail] _<Int_(VarCALLER_ID:SortInt{}, "1461501637330902...truncated")

then we can have e.g.

...[term 2749139][simplification 772d650][match][failure] Symbols differ: minInt(_,_)_INT-COMMON_Int_Int_Int(Eq#VarB:SortInt{}, Eq#VarC:SortInt{}) "1461501637330902...truncated"

[simplify]

top-level or nested context signfying the simplification phase of the whole configuration, either when a simplify request is received i.e. context [booster][simplify] or inside the execute request when unification is unclear and the booster attempts to simplify the configuration before re-trying to apply rewrite rules:

[booster][execute][term 58b79a1][simplify]...

[rewrite <hash>]/[simplification <hash>]/[function <hash>]

signifies we are in a context of attemitng to apply a rewrite/simplification/function rule. The <hash> used is the rule's unique id, truncated to the first 7 letters. We also emit a nested [detail] context, specifying the rule label/location for convenience:

[simplification b67b7ce][detail] ...evm-semantics/lemmas/lemmas.k :  (217, 10)

[constraint]

nested context, signifying evaluation/simplification of a constraint, usually a requires clause of a rule.

[match]

nested context, for running the matching algorithm. usual logs include:

...[match][success] Substitution: Eq#VarB:SortBool{} -> _==Int_("1997931255"...
...[match][failure] Uncertain about match with rule. Remainder: [(_==Int_(Eq#VarX:SortInt{}, "0"), ...
...[match][abort] Uncertain about match with rule. Remainder: [(PUSH(_)_EVM_PushOp_Int(Rule#VarN:SortInt{})...

[failure]/[abort]

both nested contexts indicate a failure. roughly speaking, [failure] is an indicator that a rule does not apply, whereas an [abort] is usually indicative of the booster being unable/unsure about proceeding and often falls back to the old backend, tho this is more complicated in equation application, where aborts may be recoverable from. perhaps we need slightly different labels, tho it will be obvious that a failure/abort happened inside a function/simplification application from the preceeding context(s).

[success]

context used for printing successful match or rewrite. will usually have the following shapes:

rewritten one term into another:

...[term 6b25517][success][term c75f0d1][detail] ...
...[term 585d8c3][llvm][success][term 98b0892][detail] "true"

rewritten a subterm inside a term:

...[simplify][term cf6a9a6][term 42b88c6][llvm][success][term 6c1e8f3][detail]...

succesfully matched:

...[match][success] Substitution: Eq#VarB1:SortBytes{} -> "\156&\224\&7" , ...

[smt]

nested context for any smt operations

[booster][execute][term 8d61dc1][rewrite e3b68cc][smt] Predicates to check: _<Int_(VarCONTRACT_BAL:SortInt{}, "0")
[booster][execute][term 8d61dc1][rewrite e3b68cc][smt] Check of Given ∧ P and Given ∧ !P produced (Unsat,Sat)

[llvm]

log any calls to the llvm simplifier here. usually it will be of the form:

...[constraint][term 585d8c3][detail] _<=Int_("0", "32")
...[constraint][term 585d8c3][llvm][success][term 98b0892][detail] "true"

@goodlyrottenapple goodlyrottenapple changed the title Implement better logging Implement better booster logging Apr 23, 2024
@goodlyrottenapple goodlyrottenapple marked this pull request as ready for review April 24, 2024 10:10
@@ -113,13 +110,12 @@ respond stateVar =
]
Right (pat, substitution, unsupported) -> do
unless (null unsupported) $ do
withKorePatternContext (KoreJson.KJAnd (externaliseSort $ sortOfPattern pat) unsupported) $
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have an idea how to avoid duplicating the log message here. As I understand, we only have to have duplicates for warnings. Then we could create a special variant of the logMessage function, say logWarning, which would append [warning] at the tail of the context. We than make a static glob pattern *warning that is enabled by default.

Copy link
Contributor

@geo2a geo2a left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love it! Let's get it merged once we've run the performance tests to make sure there are no accidents.

We should update README.md with a rough grammar of these context expressions and an example (just using the one form the PR description).

I've left comment about an idea on how we could recover warning and error-level messages without duplicating them. We can try it out in a follow-up.

@goodlyrottenapple
Copy link
Contributor Author

looks like there might be a bit of a slowdown in kevm:

Test sam-incremental-logging-update-experiment time master-089deaf61 time (sam-incremental-logging-update-experiment/master-089deaf61) time
kontrol/test-storetest-teststoreload-0-spec.k 49.95 57.63 0.8667360749609578
kontrol/test-storetest-testaccesses-0-spec.k 49.94 56.19 0.8887702438156255
kontrol/test-expectreverttest-testfail_expectrevert_failandsuccess-0-spec.k 58.03 64.87 0.8945583474641591
kontrol/test-arithmetictest-test_wdiv_rounding-uint256-uint256-0-spec.k 61.41 63.95 0.9602814698983579
bihu/forwardToHotWallet-success-2-spec.k 52.48 50.69 1.0353126849477214
benchmarks/staticloop00-a0lt10-spec.k 48.01 46.36 1.0355910267471957
erc20/ds/transferFrom-failure-2-b-spec.k 90.92 87.68 1.0369525547445255
benchmarks/ecrecover00-siginvalid-spec.k 60.09 57.81 1.0394395433316035
erc20/hkg/transfer-success-1-spec.k 50.93 48.89 1.041726324401718
mcd/cat-file-addr-pass-rough-spec.k 57.0 54.6 1.043956043956044
erc20/ds/transfer-failure-1-b-spec.k 91.62 87.72 1.0444596443228455
mcd/flipper-bids-pass-rough-spec.k 79.3 75.55 1.0496360026472535
benchmarks/ecrecover00-sigvalid-spec.k 62.05 58.98 1.052051542895897
benchmarks/encode-keccak00-spec.k 50.29 47.79 1.0523121992048545
erc20/ds/transferFrom-failure-1-b-spec.k 141.88 134.67 1.0535382787554763
erc20/hkg/transferFrom-success-1-spec.k 70.02 66.36 1.0551537070524413
erc20/ds/transferFrom-failure-1-a-spec.k 87.26 82.65 1.0557773744706593
benchmarks/structarg01-spec.k 55.63 52.44 1.0608314263920673
erc20/hkg/transferFrom-success-2-spec.k 66.61 62.77 1.0611757208857735
bihu/forwardToHotWallet-success-1-spec.k 60.53 57.02 1.0615573482988425
erc20/ds/transfer-success-1-spec.k 125.34 117.93 1.0628338845077587
erc20/ds/approve-success-spec.k 63.38 59.57 1.0639583683061944
mcd/vat-slip-pass-rough-spec.k 107.46 100.75 1.0666004962779156
erc20/ds/transfer-success-2-spec.k 74.25 68.44 1.0848918760958504
erc20/ds/transferFrom-success-1-spec.k 97.4 88.76 1.0973411446597567
erc20/ds/transferFrom-success-2-spec.k 85.86 78.24 1.09739263803681
kontrol/test-arithmetictest-test_wmul_weakly_increasing_positive-uint256-uint256-0-spec.k 80.18 72.41 1.107305620770612
kontrol/test-expectreverttest-testfail_expectrevert_bytes4-0-spec.k 66.81 57.57 1.160500260552371
kontrol/test-allowchangestest-testallow-0-spec.k 58.76 50.31 1.1679586563307494
TOTAL 2103.39 2008.6000000000001 1.0471920740814495

@ehildenb
Copy link
Member

5% is OK if this is the information we need. We should check Kontrol as well, make sure it's not any more.

@JuanCoRo
Copy link
Member

It would be great for Kontrol if you could also include the timestamps of each log entry!
This could be toggled if the verbosity is too high or if it causes further slowdown. Having timestamps on this would help us debug runtimeverification/kontrol#526, for instance.

Also, from what I see, can some [detail] logs print the entire configuration? If this is the case, can something go wrong when the configuration is enormous? I can help test this with a massive configuration if you'd like!

@virgil-serbanuta
Copy link
Contributor

FWIW, from the PR description it seems that, if a term is simplified multiple times, it gets the same hash/identifier. If it's reasonable, it would be nice to have a way to differentiate the various simplification attempts, perhaps a counter, e.g. instead of [term 58b79a1][simplify] one could have [term 58b79a1][simplify 1] or [term 58b79a1:5][simplify].

@goodlyrottenapple
Copy link
Contributor Author

FWIW, from the PR description it seems that, if a term is simplified multiple times, it gets the same hash/identifier. If it's reasonable, it would be nice to have a way to differentiate the various simplification attempts, perhaps a counter, e.g. instead of [term 58b79a1][simplify] one could have [term 58b79a1][simplify 1] or [term 58b79a1:5][simplify].

From the log above, something like [simplify][term 58b79a1][term 24777d8][function 00be500] means we are in the simplifier, attempting to simplify term 58b79a1, specifically, a sub-term 24777d8 to which we are trying to apply the function equation 00be500. Further in the logs, we attempt to apply a different equation, namely simplification 5a8ecf6. Given the way the contexts work, we can't change the outer-most hash until we re-assemble the term and exit the simplification context

@goodlyrottenapple
Copy link
Contributor Author

It would be great for Kontrol if you could also include the timestamps of each log entry! This could be toggled if the verbosity is too high or if it causes further slowdown. Having timestamps on this would help us debug runtimeverification/kontrol#526, for instance.

Yes, I think this is something we can add, however the library we use for logging atm is not well suited for logging with timestamps. I can try to hack something in, but the performance may not be stellar. @jberthold perhaps we should switch to using fast-logger?

Also, from what I see, can some [detail] logs print the entire configuration? If this is the case, can something go wrong when the configuration is enormous? I can help test this with a massive configuration if you'd like!

Yes, that could be a problem. Would be great if you have a tarball with such configuration for me to try. We could either truncate the log if it is an issue, or one can use --not-log-context "*detail" to suppress all the detail messages

Copy link
Member

@jberthold jberthold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few suggestions but there is nothing major that caught my attention. This change is huge so we might find things to be adjusted after using the new logging for a while.

Comment on lines -787 to 859
(rewriteStep cutLabels terminalLabels pat')
(withPatternContext pat' $ rewriteStep cutLabels terminalLabels pat')
>>= \case
Right (RewriteFinished mlbl uniqueId single, cache) -> do
whenJust mlbl $ \lbl ->
emitRewriteTrace $ RewriteSingleStep lbl uniqueId pat' single
updateCache cache
incrementCounter
doSteps False single
Right (terminal@(RewriteTerminal lbl uniqueId single), _cache) -> do
Right (terminal@(RewriteTerminal lbl uniqueId single), _cache) -> withPatternContext pat' $ do
emitRewriteTrace $ RewriteSingleStep lbl uniqueId pat' single
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(nit) Maybe instead of repeating withPatternContext pat' , we could group the \case under the first one, too?

    withPatternContext pat' $ do
        result <- rewriteStep cutLabels ...
        case result of
            Right (RewriteFinished ...) -> do ...

(do-notation to avoid bracketing a humongous case expression)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that won't work because we don't want to put withPatternContext pat' $ around a recursive call to doSteps. Otherwise we will get a massive chain of [execute][term ...]...[term ...], one [term ...] for each iteration of the loop

@jberthold
Copy link
Member

Maybe the PR description should go into a file in booster/docs?

Comment on lines 448 to 449
withContext "abort" $ logMessage ("Recursion limit exceeded" :: Text)
logWarnNS "booster" "Recursion limit exceeded"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Good to have this as a new warning.
When I looked at the CI results for this PR I noticed that the new test derived from Petar's issue is emitting a large number of those Recursion limit exceeded
We could point the user to the --equation-max-recursion parameter (assuming the name is stable).

@jberthold jberthold merged commit 7735c2f into master Apr 29, 2024
@jberthold jberthold deleted the sam/incremental-logging-update-experiment branch April 29, 2024 23:44
rv-jenkins added a commit that referenced this pull request May 7, 2024
Combines #3833  and #3831

- in Kore, implement rendering of oneline logs prefixed with the context
stack, in the spirit of
#3826

- add `--log-format <standard|oneline|json> (default:oneline)` to
`kore-rpc-booster`.
- to recover the old behaviour of `-l Rewrite` and friends, use
`--log-format standard`, i.e. `kore-rpc-booster --log-format standard -l
Rewrite`
- if any `--log-context` is passed, the log format is effectively
override to be `oneline`

- in `booster/tools/booster/Server.hs`, construct a log action to be
passed to Kore. If no `--log-context` options are passed, then the old
`-l RewriteKore` and fields levels still work with `--log-format
standard`. If `--log-context` is passed, then the complete set of
proxy-compatible Kore log entries is enabled, and the filtering is done
using the glob context filter late in the colog pipeline.

Things to do in a follow-up:
- json logging is inconsistent, both the interface and the
implementation:
- to get simplification JSON logs from both Booster and Kore, we
currently need to give two options: `kore-rpc-booster --log-format json
-l SimplifyJson`, which is not ideal. We need to remove `-l
SimplifyJson` and forward the log format to Booster instead.
- To implement the previous item in a clean way, we actually need to
stop emitting the logs at `SimplifyJson` level and instead render the
regular log items as json.
- file logging is inconsistent. It is currently not possible to redirect
Booster's contextual logs into a file.
- the performance of context filtering in Kore is likely terrible, since
we match the while log message, as a string, against the glob pattern.
There is not penalty if the contextual logging is off however.

---------

Co-authored-by: github-actions <[email protected]>
Co-authored-by: Jost Berthold <[email protected]>
Co-authored-by: rv-jenkins <[email protected]>
rv-jenkins pushed a commit to runtimeverification/k that referenced this pull request May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants