Skip to content

Commit

Permalink
chore: Added support for witness inputs and storage application to pr…
Browse files Browse the repository at this point in the history
…over cli (#3670)

## What ❔

* Allow prover_cli file-info to display more information about witness
inputs and storage applications.

## Why ❔

* Makes it easier to debug, if proof fails.


## Is this a breaking change?
- [ ] Yes
- [X] No

## Operational changes

No
  • Loading branch information
mm-zk authored Mar 9, 2025
1 parent 659edaa commit 06dc279
Show file tree
Hide file tree
Showing 2 changed files with 70 additions and 3 deletions.
2 changes: 1 addition & 1 deletion core/lib/prover_interface/src/inputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl StorageLogMetadata {
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct WitnessInputMerklePaths {
// Merkle paths and some auxiliary information for each read / write operation in a block.
merkle_paths: Vec<StorageLogMetadata>,
pub merkle_paths: Vec<StorageLogMetadata>,
next_enumeration_index: u64,
}

Expand Down
71 changes: 69 additions & 2 deletions prover/crates/bin/prover_cli/src/commands/get_file_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ use zksync_prover_fri_types::{
},
CircuitWrapper, FriProofWrapper,
};
use zksync_prover_interface::outputs::L1BatchProofForL1;
use zksync_prover_interface::{inputs::WitnessInputMerklePaths, outputs::L1BatchProofForL1};
use zksync_types::{u256_to_h256, H256};

#[derive(ClapArgs)]
pub struct Args {
Expand Down Expand Up @@ -95,7 +96,49 @@ fn pretty_print_circuit_wrapper(circuit: &CircuitWrapper) {
}
ZkSyncBaseLayerCircuit::RAMPermutation(_) => todo!(),
ZkSyncBaseLayerCircuit::StorageSorter(_) => todo!(),
ZkSyncBaseLayerCircuit::StorageApplication(circuit) => circuit.debug_witness(),
ZkSyncBaseLayerCircuit::StorageApplication(circuit) => {
let witness = circuit.clone_witness().unwrap();
println!(
"Initial root hash: {:?}",
H256::from_slice(
&witness.closed_form_input.observable_input.initial_root_hash
)
);
println!(
"Fsm input hash: {:?}",
H256::from_slice(
&witness.closed_form_input.hidden_fsm_input.current_root_hash
)
);
println!(
"Fsm output hash: {:?}",
H256::from_slice(
&witness
.closed_form_input
.hidden_fsm_output
.current_root_hash
)
);
println!(
"Final root hash: {:?}",
H256::from_slice(
&witness.closed_form_input.observable_output.new_root_hash
)
);

let storage_queue = witness.storage_queue_witness.elements;
println!("storage queue elements: {:?}", storage_queue.len());
for (i, x) in storage_queue.iter().enumerate() {
println!(
"{} element: rw:{:?} {:?} {:?} {:?}",
i,
x.0.rw_flag,
x.0.address,
u256_to_h256(x.0.key),
u256_to_h256(x.0.written_value)
);
}
}
ZkSyncBaseLayerCircuit::EventsSorter(_) => todo!(),
ZkSyncBaseLayerCircuit::L1MessagesSorter(_) => todo!(),
ZkSyncBaseLayerCircuit::L1MessagesHasher(_) => todo!(),
Expand Down Expand Up @@ -229,5 +272,29 @@ pub(crate) async fn run(args: Args) -> anyhow::Result<()> {
} else {
println!(" NOT a L1BatchProof.");
}

let maybe_witness_input: Option<WitnessInputMerklePaths> = bincode::deserialize(&bytes).ok();
if let Some(witness_input) = maybe_witness_input {
println!(" Parsing file as WitnessInputMerklePaths.");
println!(
" Next enumeration index: {}",
witness_input.next_enumeration_index()
);
println!(" merkle paths: {:?}", witness_input.merkle_paths.len());
let merkle_path = witness_input.merkle_paths[0].clone();
println!(
"first root hash: {:?}",
H256::from_slice(&merkle_path.root_hash)
);

let merkle_path = witness_input.merkle_paths.last().unwrap().clone();
println!(
"last root hash: {:?}",
H256::from_slice(&merkle_path.root_hash)
);
} else {
println!(" NOT a WitnessInputMerklePaths.");
}

Ok(())
}

0 comments on commit 06dc279

Please sign in to comment.