Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/kontrol/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,30 @@ def parse(s: str) -> list[T]:
help='Print elements in hexadecimal encoding.',
)

view_kcfg_args.add_argument(
'--omit-code-cells',
dest='omit_code_cells',
default=None,
action='store_true',
help='Hide cells that contain bytecode in the TUI.',
Copy link
Contributor

Choose a reason for hiding this comment

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

For the benefit of the user, maybe we could explicitly list the cells that will be omitted here? For example:

Suggested change
help='Hide cells that contain bytecode in the TUI.',
help='Hide cells that contain bytecode in the TUI (<program>, <code> and <jumpDests>).',

)

view_kcfg_args.add_argument(
'--omit-interim-cells',
dest='omit_interim_cells',
default=None,
action='store_true',
help='Hide the <callStack> and <interimStates> cells in the TUI.',
)

view_kcfg_args.add_argument(
'--omit-cost-cells',
dest='omit_cost_cells',
default=None,
action='store_true',
help='Hide the gas-related cells in the TUI.',
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above:

Suggested change
help='Hide the gas-related cells in the TUI.',
help='Hide the gas-related cells in the TUI (<gas>, <memoryUsed>, <callGas> and <refund>).',

)

minimize_proof_args = command_parser.add_parser(
'minimize-proof',
help='Minimize the KCFG of the proof for a given test.',
Expand Down
17 changes: 15 additions & 2 deletions src/kontrol/display.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,22 @@ def foundry_view(foundry: Foundry, options: ViewKcfgOptions) -> None:
def _custom_view(elem: KCFGElem) -> Iterable[str]:
return custom_view(contract_name, elem, compilation_unit)

omit_cells = []
if options.omit_code_cells:
omit_cells.extend(['<program>', '<code>', '<jumpDests>'])
if options.omit_interim_cells:
omit_cells.extend(['<callStack>', '<interimStates>'])
if options.omit_cost_cells:
omit_cells.extend(['<gas>', '<memoryUsed>', '<callGas>', '<refund>'])
printer = PrettyPrinter(foundry.kevm.definition, patch_symbol_table=KEVM._kevm_patch_symbol_table)
cterm_show = CTermShow(printer.print)
cterm_show = CTermShow(printer.print, omit_labels=omit_cells)
node_printer = foundry_node_printer(foundry, cterm_show, contract_name, proof)

viewer = APRProofViewer(proof, foundry.kevm, node_printer=node_printer, custom_view=_custom_view)
viewer = APRProofViewer(
proof,
foundry.kevm,
node_printer=node_printer,
custom_view=_custom_view,
cterm_show=cterm_show,
)
viewer.run()
6 changes: 6 additions & 0 deletions src/kontrol/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,17 @@ def get_argument_type() -> dict[str, Callable]:
class ViewKcfgOptions(FoundryTestOptions, LoggingOptions, FoundryOptions):

use_hex_encoding: bool
omit_code_cells: bool
omit_interim_cells: bool
omit_cost_cells: bool

@staticmethod
def default() -> dict[str, Any]:
return {
'use_hex_encoding': False,
'omit_code_cells': False,
'omit_interim_cells': False,
'omit_cost_cells': False,
}

@staticmethod
Expand Down
4 changes: 4 additions & 0 deletions src/kontrol/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,10 @@ def kontrol_toml_file_contents() -> str:
[view-kcfg.default]
foundry-project-root = '.'
use-hex-encoding = false
omit-code-cells = true
omit-interim-cells = true
omit-cost-cells = true

"""


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
│ pc: 16687
│ callDepth: 0
│ statusCode: STATUSCODE:StatusCode
│ src: lib/forge-std/src/console.sol:10:12
│ src: lib/forge-std/src/console.sol:9:11
│ method: test%UnitTest.test_checkInitialBalance(uint256)
│ (1 step)
Expand All @@ -22,7 +22,7 @@
│ pc: 16687
│ callDepth: 0
│ statusCode: STATUSCODE:StatusCode
│ src: lib/forge-std/src/console.sol:10:12
│ src: lib/forge-std/src/console.sol:9:11
│ method: test%UnitTest.test_checkInitialBalance(uint256)
│ (646 steps)
Expand All @@ -31,7 +31,7 @@
│ pc: 16687
│ callDepth: 0
│ statusCode: STATUSCODE:StatusCode
│ src: lib/forge-std/src/console.sol:10:12
│ src: lib/forge-std/src/console.sol:9:11
│ method: test%UnitTest.test_checkInitialBalance(uint256)
│ (1 step)
Expand All @@ -40,7 +40,7 @@
│ pc: 16687
│ callDepth: 0
│ statusCode: STATUSCODE:StatusCode
│ src: lib/forge-std/src/console.sol:10:12
│ src: lib/forge-std/src/console.sol:9:11
│ method: test%UnitTest.test_checkInitialBalance(uint256)
│ (205 steps)
Expand Down