Skip to content

Printer documentation

Vara Prasad edited this page May 19, 2023 · 2 revisions

Tealer allows printing contract's information through its printers.

Num Printer Description
1 cfg Export the CFG of entire contract
2 subroutine-cfg Export the CFG of each subroutine.
3 call-graph Export the subroutine call-graph to a dot file
4 human-summary Print a human-readable summary of the contract
5 transaction-context Output possible values of transaction fields: GroupSize, GroupIndex

Majority of the printers use dot format to represent graphs.

Use this instructions to install xdot and dot.

To vizualize a graph:

$ xdot graph.dot

To convert the file to svg:

$ dot graph.dot -Tpng -o graph.dot.png

CFG edge colors

Printers generating CFG use colors to differentiate graph edges.

  • Green: if the jump is taken. The condition to jump is satisfied.
  • Red: if the jump is not taken.
  • Orange: Call to a subroutine.
  • Black: A normal edge

CFG

$ tealer program.teal --print cfg

Export the CFG of entire contract.

Tealer adds additional information to the basic blocks and instructions in the output CFG.

Information of basic blocks:

  • block_id: Block Id is used to identify a basic block in the contract. Having this information makes it easy to understand and filter detector's results.
  • cost: Opcode cost of executing the basic block.

Information of instructions:

  • method-selector: 4-byte method selector for each method instruction.
  • ApplicationID: Application ID is 0 in Creation Txn.

Example

$ tealer examples/printers/cfg.teal --print cfg

Subroutine CFG

$ tealer program.teal --print subroutine-cfg

Export the CFG of each subroutine.

Printer emits multiple dot files. One for the contract(without subroutines) and one for each of the subroutine.

Example

$ tealer examples/printers/subroutine-cfg.teal --print subroutine-cfg

Full contract CFG

foo_bar subroutine CFG

Call Graph

$ tealer program.teal --print call-graph

Export the subroutine call-graph to a dot file.

__entry__ represents the entry point of the contract.

Examples

$ tealer examples/printers/call-graph.teal --print call-graph

Human Summary

$ tealer program.teal --print human-summary

Print a human-readable summary of the contract.

Example

$ tealer examples/printers/human-summary.teal --print human-summary

Program version: 7
Mode: stateful
Number of basic blocks: 22
Number of instructions: 87
Number of subroutines: 6
Subroutines:
	hello_5
	deleteapplication_3
	updateapplication_2
	create_1
	iscreator_0
	greet_4

Number of optimization issues: 0
Number of informational issues: 0
Number of low issues: 0
Number of medium issues: 0
Number of high issues: 9
is_complex: Yes

Transaction context

$ tealer program.teal --print transaction-context

Output possible values of transaction fields: GroupSize, GroupIndex.

Tealer adds possible values for each of the field on top of the basic block.

Understanding possible values(S) of a field F for a basic block B:

  • F should be one of values in S for the execution to reach block B and finish successfully.

Example

$ tealer examples/printers/transaction-context.teal --print transaction-context