Skip to content

Commit ffcef82

Browse files
committed
hide cells in TUI
1 parent 997d326 commit ffcef82

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

src/kontrol/cli.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -647,6 +647,30 @@ def parse(s: str) -> list[T]:
647647
help='Print elements in hexadecimal encoding.',
648648
)
649649

650+
view_kcfg_args.add_argument(
651+
'--omit-code-cells',
652+
dest='omit_code_cells',
653+
default=None,
654+
action='store_true',
655+
help='Hide cells that contain bytecode in the TUI.',
656+
)
657+
658+
view_kcfg_args.add_argument(
659+
'--omit-interim-cells',
660+
dest='omit_interim_cells',
661+
default=None,
662+
action='store_true',
663+
help='Hide the <callStack> and <interimStates> cells in the TUI.',
664+
)
665+
666+
view_kcfg_args.add_argument(
667+
'--omit-cost-cells',
668+
dest='omit_cost_cells',
669+
default=None,
670+
action='store_true',
671+
help='Hide the gas-related cells in the TUI.',
672+
)
673+
650674
minimize_proof_args = command_parser.add_parser(
651675
'minimize-proof',
652676
help='Minimize the KCFG of the proof for a given test.',

src/kontrol/display.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,9 +283,22 @@ def foundry_view(foundry: Foundry, options: ViewKcfgOptions) -> None:
283283
def _custom_view(elem: KCFGElem) -> Iterable[str]:
284284
return custom_view(contract_name, elem, compilation_unit)
285285

286+
omit_cells = []
287+
if options.omit_code_cells:
288+
omit_cells.extend(['<program>', '<code>', '<jumpDests>'])
289+
if options.omit_interim_cells:
290+
omit_cells.extend(['<callStack>', '<interimStates>'])
291+
if options.omit_cost_cells:
292+
omit_cells.extend(['<gas>', '<memoryUsed>', '<callGas>', '<refund>'])
286293
printer = PrettyPrinter(foundry.kevm.definition, patch_symbol_table=KEVM._kevm_patch_symbol_table)
287-
cterm_show = CTermShow(printer.print)
294+
cterm_show = CTermShow(printer.print, omit_labels=omit_cells)
288295
node_printer = foundry_node_printer(foundry, cterm_show, contract_name, proof)
289296

290-
viewer = APRProofViewer(proof, foundry.kevm, node_printer=node_printer, custom_view=_custom_view)
297+
viewer = APRProofViewer(
298+
proof,
299+
foundry.kevm,
300+
node_printer=node_printer,
301+
custom_view=_custom_view,
302+
cterm_show=cterm_show,
303+
)
291304
viewer.run()

src/kontrol/options.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -743,11 +743,17 @@ def get_argument_type() -> dict[str, Callable]:
743743
class ViewKcfgOptions(FoundryTestOptions, LoggingOptions, FoundryOptions):
744744

745745
use_hex_encoding: bool
746+
omit_code_cells: bool
747+
omit_interim_cells: bool
748+
omit_cost_cells: bool
746749

747750
@staticmethod
748751
def default() -> dict[str, Any]:
749752
return {
750753
'use_hex_encoding': False,
754+
'omit_code_cells': False,
755+
'omit_interim_cells': False,
756+
'omit_cost_cells': False,
751757
}
752758

753759
@staticmethod

src/kontrol/utils.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ def kontrol_toml_file_contents() -> str:
275275
[view-kcfg.default]
276276
foundry-project-root = '.'
277277
use-hex-encoding = false
278+
omit-code-cells = true
279+
omit-interim-cells = true
280+
omit-cost-cells = true
281+
278282
"""
279283

280284

0 commit comments

Comments
 (0)