## Tracer - The tracer binary makes use of goblin, capstone and rustc-demangle to disassemble the riscV ELF and build a symbol table - The execution trace for the rollup ELF is generated by running the `demo-prover` with the `ROLLUP_TRACE` environment variable set to the desired path ```bash cd examples/demo-prover/host ROLLUP_TRACE=rollup.trace cargo bench --bench prover_bench --features bench ``` - `rollup.trace` now contains the program counter values for the run of the demo-prover (how many ever blocks, blobs and transactions we configured it for) - The corresponding ELF used for the trace is found at ```bash $ file target/riscv-guest/riscv32im-risc0-zkvm-elf/release/rollup target/riscv-guest/riscv32im-risc0-zkvm-elf/release/rollup: ELF 32-bit LSB executable, UCB RISC-V, soft-float ABI, version 1 (SYSV), statically linked, with debug_info, not stripped ``` - Both the above files are passed as input to the tracer ```bash % cargo run -- --rollup-elf ../../../examples/demo-prover/target/riscv-guest/riscv32im-risc0-zkvm-elf/release/rollup --rollup-trace ../../../examples/demo-prover/rollup.trace Finished dev [unoptimized + debuginfo] target(s) in 0.11s Running `target/debug/tracer --rollup-elf ../../../examples/demo-prover/target/riscv-guest/riscv32im-risc0-zkvm-elf/release/rollup --rollup-trace ../../../examples/demo-prover/rollup.trace` [00:01:04] [########################################] 16154861/16154861 (0s) Total instructions in trace: 16154861 Instruction counts considering call graph +--------------------------------------------------------------------------------------------+-------------------+ | Function Name | Instruction Count | +============================================================================================+===================+ | __start | 16154854 | +--------------------------------------------------------------------------------------------+-------------------+ | main | 16153565 | +--------------------------------------------------------------------------------------------+-------------------+ | rollup::main::h089e03181dac539a | 16153559 | +--------------------------------------------------------------------------------------------+-------------------+ | sov_modules_stf_template:: for | | | sov_modules_stf_template::app_template::AppTemplate>::apply_slot::h820293d | | | c8d744201 | | +--------------------------------------------------------------------------------------------+-------------------+ | ed25519_dalek::public::PublicKey::verify_strict::hfad17f99efbd2cd0 | 13528566 | +--------------------------------------------------------------------------------------------+-------------------+ | <&curve25519_dalek::backend::serial::u64::field::FieldElement51 as | 8295218 | | core::ops::arith::Mul<&curve25519_dalek::backend::serial::u64::field::FieldElement51>>::mu | | | l::h39351372a97422dd | | . . . +--------------------------------------------------------------------------------------------+-------------------+ ``` - The tracer also generates a pure count of instructions without considering the stack - There are other options that can be passed which are self documented in the cli ```bash Usage: tracer [OPTIONS] --rollup-elf --rollup-trace Options: -t, --top Include the "top" number of functions [default: 30] --no-stack-counts Don't print stack aware instruction counts --no-raw-counts Don't print raw (stack un-aware) instruction counts --rollup-elf Path to the riscv32 elf --rollup-trace Path to the rollup trace. File must be one u64 program counter per line -s, --strip-hashes Strip the hashes from the function name while printing -h, --help Print help -V, --version Print version ```