-
Notifications
You must be signed in to change notification settings - Fork 13
Printer documentation
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
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
$ 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 eachmethodinstruction. -
ApplicationID: Application ID is 0 in Creation Txn.
$ tealer examples/printers/cfg.teal --print 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.
$ tealer examples/printers/subroutine-cfg.teal --print subroutine-cfg
$ tealer program.teal --print call-graph
Export the subroutine call-graph to a dot file.
__entry__ represents the entry point of the contract.
$ tealer examples/printers/call-graph.teal --print call-graph
$ tealer program.teal --print human-summary
Print a human-readable summary of the contract.
$ 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
$ 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:
-
Fshould be one of values inSfor the execution to reach blockBand finish successfully.
$ tealer examples/printers/transaction-context.teal --print transaction-context