Skip to content

Commit

Permalink
Additional debug output
Browse files Browse the repository at this point in the history
  • Loading branch information
zbuc committed Aug 16, 2024
1 parent bd2d9f3 commit 5edb29e
Showing 1 changed file with 59 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ use ibc_types::{
State as ConnectionState,
},
};
use penumbra_proto::DomainType;
use sha2::Digest;

use crate::component::{
client::StateReadExt as _,
Expand Down Expand Up @@ -99,6 +101,63 @@ impl MsgHandler for MsgConnectionOpenTry {
// PROOF VERIFICATION
// 1. verify that the counterparty chain committed the expected_conn to its state
let proof_conn_end_on_a = self.proof_conn_end_on_a.clone();

let existence_proofs: Vec<(Vec<u8>, Vec<u8>)> = proof_conn_end_on_a
.proofs
.iter()
.map(|proof| {
let p = proof.proof.clone().unwrap();
match p {
ics23::commitment_proof::Proof::Exist(p) => (p.key, p.value),
_ => (vec![], vec![]),
}
})
.inspect(|(k, v)| {
println!(
"proof_conn_end_on_a: k {} v {}",
hex::encode(k),
hex::encode(v)
);
})
.collect();

{
// TODO: change this into a different test after the bug is understood
assert_eq!(
hex::encode(&existence_proofs[0].0),
"636f6e6e656374696f6e732f636f6e6e656374696f6e2d30"
);
assert_eq!(hex::encode(&existence_proofs[0].1), "0a0f30372d74656e6465726d696e742d3012230a0131120d4f524445525f4f524445524544120f4f524445525f554e4f5244455245441801221d0a0f30372d74656e6465726d696e742d301a0a0a086962632d64617461288094ebdc03");
assert_eq!(hex::encode(&existence_proofs[1].0), "6962632d64617461");
assert_eq!(
hex::encode(&existence_proofs[1].1),
"e421a1ef4acacb331f598197adb7d3250f2b4f84a3e30721190fd00bfe914de3"
);
}

println!("trusted_client_state: {:?}", trusted_client_state);
println!("proofs_height_on_a: {:?}", self.proofs_height_on_a);
println!(
"counterparty.prefix: {}",
hex::encode(self.counterparty.prefix.key_prefix.clone())
);
println!(
"trusted_consensus_state.root.hash: {}",
hex::encode(trusted_consensus_state.root.hash.clone())
);
assert_eq!(
hex::encode(trusted_consensus_state.root.hash.clone()),
"d01e8818de18fb050c7aff28a59d430db07802f91c14c4370cf8be785381d4c7".to_string()
);
println!("expected_conn: {:?}", expected_conn);

let hashed_client_state = sha2::Sha256::digest(trusted_client_state.encode_to_vec());
println!("hashed_client_state: {}", hex::encode(hashed_client_state));
assert_eq!(
hex::encode(hashed_client_state),
"41e997cf572ca0d333e9a35d571d34cc2e67939dda4bd1a8a356aa35fa17dbb2"
);

proof_verification::verify_connection_state(
&trusted_client_state,
self.proofs_height_on_a,
Expand Down

0 comments on commit 5edb29e

Please sign in to comment.