Skip to content

Commit 58cb717

Browse files
committed
Fix checks
1 parent bed50a5 commit 58cb717

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

wormhole/example/src/main.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,9 @@ use wormhole_circuit::inputs::{
2323
BlockHeaderInputs, CircuitInputs, PrivateCircuitInputs, PublicCircuitInputs, DIGEST_LOGS_SIZE,
2424
};
2525
use wormhole_circuit::nullifier::Nullifier;
26-
use wormhole_circuit::storage_proof::ProcessedStorageProof;
2726
use wormhole_prover::WormholeProver;
2827
use zk_circuits_common::utils::{BytesDigest, Digest};
2928

30-
mod proof_processing;
3129
mod utils;
3230

3331
#[tokio::main]
@@ -131,8 +129,8 @@ async fn main() -> anyhow::Result<()> {
131129
wormhole_circuit::unspendable_account::UnspendableAccount::from_secret(&secret).account_id;
132130

133131
println!("Processing storage proof to generate ordered path and indices...");
134-
let processed_storage_proof = proof_processing::process_storage_proof::
135-
<qp_poseidon::PoseidonHasher>(header.state_root, &final_key, read_proof.proof)?;
132+
let processed_storage_proof =
133+
utils::prepare_proof_for_circuit(read_proof.proof, header.state_root, 0)?;
136134
let inputs = CircuitInputs {
137135
private: PrivateCircuitInputs {
138136
secret,

wormhole/example/src/utils.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
use anyhow::anyhow;
33
use hex;
44
use sp_core::{Hasher, H256};
5+
use subxt::backend::legacy::rpc_methods::Bytes;
56
use wormhole_circuit::storage_proof::ProcessedStorageProof;
67

7-
// Assuming PoseidonHasher is brought into scope from main.rs or lib.rs
8-
use crate::PoseidonHasher;
8+
use qp_poseidon::PoseidonHasher;
99

1010
/// Prepares the storage proof for circuit consumption.
1111
/// This function attempts to order the proof nodes based on finding child hashes
1212
/// within parent nodes using a string search.
1313
pub fn prepare_proof_for_circuit(
14-
proof: Vec<Vec<u8>>,
14+
proof: Vec<Bytes>,
1515
state_root: H256,
1616
last_idx: usize,
1717
) -> anyhow::Result<ProcessedStorageProof> {
@@ -20,12 +20,12 @@ pub fn prepare_proof_for_circuit(
2020
let mut storage_proof_hex = vec![];
2121

2222
for node_data in proof.iter() {
23-
let hash = <PoseidonHasher as Hasher>::hash(node_data);
23+
let hash = <PoseidonHasher as Hasher>::hash(&node_data.0);
2424
if hash == state_root {
25-
storage_proof_hex.push(hex::encode(node_data));
25+
storage_proof_hex.push(hex::encode(&node_data.0));
2626
} else {
2727
hashes.push(hash);
28-
bytes_hex.push(hex::encode(node_data));
28+
bytes_hex.push(hex::encode(&node_data.0));
2929
}
3030
}
3131

@@ -66,5 +66,5 @@ pub fn prepare_proof_for_circuit(
6666
.map(hex::decode)
6767
.collect::<Result<_, _>>()?;
6868

69-
Ok(ProcessedStorageProof::new(final_storage_proof, indices))
69+
ProcessedStorageProof::new(final_storage_proof, indices)
7070
}

wormhole/tests/test-helpers/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl TestInputs for CircuitInputs {
6363
block_number: 1,
6464
state_root: BytesDigest::try_from(root_hash).unwrap(),
6565
extrinsics_root: BytesDigest::try_from(root_hash).unwrap(), // TODO: use more sensible value
66-
digest_logs: [0u8; 110],
66+
digest_logs: [0u8; 72],
6767
},
6868
},
6969
}

0 commit comments

Comments
 (0)