Fix proof gen and verify

This commit is contained in:
hu55a1n1 2024-01-04 03:26:51 -08:00
parent 6c70969814
commit 8c0c871666
2 changed files with 14 additions and 14 deletions

File diff suppressed because one or more lines are too long

View file

@ -180,19 +180,20 @@ async fn main() -> Result<()> {
.latest_trusted()
.ok_or_else(|| eyre!("No trusted state found for primary"))?;
let primary_block = {
let status = client.status().await?;
let latest_height = status.sync_info.latest_block_height;
// `proof_height` is the height at which we want to query the blockchain's state
// This is one less than than the `latest_height` because we want to verify the merkle-proof for
// the state against the `app_hash` at `latest_height`.
// (because Tendermint commits to the latest `app_hash` in the subsequent block)
let proof_height = (latest_height.value() - 1)
.try_into()
.expect("infallible conversion");
info!("Verifying to latest height on primary...");
let status = client.status().await?;
let proof_height = {
let latest_height = status.sync_info.latest_block_height;
(latest_height.value() - 1)
.try_into()
.expect("infallible conversion")
};
primary.verify_to_height(proof_height)
}?;
let primary_block = primary.verify_to_height(latest_height)?;
info!("Verified to height {} on primary", primary_block.height());
let mut primary_trace = primary.get_trace(primary_block.height());
@ -223,8 +224,7 @@ async fn main() -> Result<()> {
.await?;
let status = client.status().await?;
let (proof_height, latest_app_hash) =
(primary_block.height(), status.sync_info.latest_app_hash);
let latest_app_hash = status.sync_info.latest_app_hash;
let path = WASM_STORE_KEY.to_owned();
let data = CwAbciKey::new(args.contract_address, args.storage_key, None);