2 unstable releases

0.3.0 Oct 20, 2023
0.2.0 Sep 14, 2023

#37 in #rollup

Download history 3/week @ 2024-06-22 6/week @ 2024-07-13 2/week @ 2024-07-20 18/week @ 2024-07-27 2/week @ 2024-08-03 18/week @ 2024-09-21 30/week @ 2024-09-28 4/week @ 2024-10-05

52 downloads per month
Used in 3 crates

MIT/Apache

8KB

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
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
$ 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
% 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::<impl                                                            | 15350436          |
| sov_rollup_interface::state_machine::stf::StateTransitionFunction<Vm,B> for                |                   |
| sov_modules_stf_template::app_template::AppTemplate<C,Cond,Vm,RT,B>>::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
Usage: tracer [OPTIONS] --rollup-elf <ROLLUP_ELF> --rollup-trace <ROLLUP_TRACE>

Options:
  -t, --top <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 <ROLLUP_ELF>      Path to the riscv32 elf
      --rollup-trace <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

Dependencies

~10–25MB
~333K SLoC