Skip to content

Commit

Permalink
adapter better print
Browse files Browse the repository at this point in the history
  • Loading branch information
ohad-starkware committed Jan 8, 2025
1 parent 4a9e8f6 commit ad04851
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
6 changes: 4 additions & 2 deletions stwo_cairo_prover/crates/adapted_prover/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,10 @@ fn run(args: impl Iterator<Item = String>) -> Result<(), Error> {
.display_components(args.display_components)
.build();

let casm_states_by_opcode_count = &vm_output.state_transitions.casm_states_by_opcode.counts();
log::info!("Casm states by opcode count: {casm_states_by_opcode_count:?}");
log::info!(
"Casm states by opcode:\n {},",
vm_output.state_transitions.casm_states_by_opcode
);

// TODO(Ohad): Propagate hash from CLI args.
let proof = prove_cairo::<Blake2sMerkleChannel>(vm_output, prover_config)?;
Expand Down
13 changes: 13 additions & 0 deletions stwo_cairo_prover/crates/prover/src/input/state_transitions.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::collections::HashMap;
use std::fmt::Display;

use prover_types::cpu::CasmState;
use stwo_prover::core::fields::m31::M31;
Expand Down Expand Up @@ -158,6 +159,18 @@ impl CasmStatesByOpcode {
}
}

impl Display for CasmStatesByOpcode {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let counts = self.counts();
let total_steps = counts.iter().map(|(_, count)| count).sum::<usize>();
writeln!(f, "Total steps: {total_steps}")?;
for (name, count) in &counts {
writeln!(f, "{name}: {count}")?;
}
Ok(())
}
}

impl From<TraceEntry> for CasmState {
fn from(entry: TraceEntry) -> Self {
Self {
Expand Down

0 comments on commit ad04851

Please sign in to comment.