Handle compute node join request (#34)
This commit is contained in:
commit
7c1d3e1e2b
5 changed files with 26 additions and 21 deletions
|
@ -22,8 +22,8 @@ use crate::{
|
|||
pub struct CwProof<K = Vec<u8>, V = Vec<u8>> {
|
||||
proof: ProofOps,
|
||||
// TODO(hu55a1n1): replace `K` with `CwAbciKey`
|
||||
key: PrefixedKey<PrefixWasm, K>,
|
||||
value: V,
|
||||
pub key: PrefixedKey<PrefixWasm, K>,
|
||||
pub value: V,
|
||||
}
|
||||
|
||||
/// ABCI query response doesn't contain proof
|
||||
|
|
1
utils/tm-prover/Cargo.lock
generated
1
utils/tm-prover/Cargo.lock
generated
|
@ -2130,7 +2130,6 @@ dependencies = [
|
|||
"futures",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"serde_with",
|
||||
"tendermint",
|
||||
"tendermint-light-client",
|
||||
"tendermint-light-client-detector",
|
||||
|
|
|
@ -9,9 +9,9 @@ block height and trusted height/hash.
|
|||
cargo run -- --chain-id osmosis-1 \
|
||||
--primary "http://127.0.0.1:26657" \
|
||||
--witnesses "http://127.0.0.1:26657" \
|
||||
--trusted-height 400 \
|
||||
--trusted-hash "DEA1738C2AEE72E935E39CE6EB8765B8782B791038789AC2FEA446526FDE8638" \
|
||||
--contract-address "wasm17p9rzwnnfxcjp32un9ug7yhhzgtkhvl9jfksztgw5uh69wac2pgsm0v070" \
|
||||
--trusted-height 1 \
|
||||
--trusted-hash "798E237C6FDF39EDA8BA7AB8E8F5DC71F24BC7138BE31882338022F8F88086EE" \
|
||||
--contract-address "wasm14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9s0phg4d" \
|
||||
--storage-key "requests" \
|
||||
--trace-file light-client-proof.json
|
||||
```
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -180,22 +180,23 @@ async fn main() -> Result<()> {
|
|||
.latest_trusted()
|
||||
.ok_or_else(|| eyre!("No trusted state found for primary"))?;
|
||||
|
||||
let primary_block = {
|
||||
info!("Verifying to latest height on primary...");
|
||||
let status = client.status().await?;
|
||||
let latest_height = status.sync_info.latest_block_height;
|
||||
|
||||
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")
|
||||
};
|
||||
// `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");
|
||||
|
||||
primary.verify_to_height(proof_height)
|
||||
}?;
|
||||
info!("Verifying to latest height on primary...");
|
||||
|
||||
let primary_block = primary.verify_to_height(latest_height)?;
|
||||
|
||||
info!("Verified to height {} on primary", primary_block.height());
|
||||
let primary_trace = primary.get_trace(primary_block.height());
|
||||
let mut primary_trace = primary.get_trace(primary_block.height());
|
||||
|
||||
let witnesses = join_all(args.witnesses.0.into_iter().map(|addr| {
|
||||
make_provider(
|
||||
|
@ -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);
|
||||
|
@ -241,6 +241,12 @@ async fn main() -> Result<()> {
|
|||
.map_err(|e: ProofError| eyre!(e))?;
|
||||
|
||||
if let Some(trace_file) = args.trace_file {
|
||||
// replace the last block in the trace (i.e. the (latest - 1) block) with the latest block
|
||||
// we don't actually verify the latest block because it will be verified on the other side
|
||||
let latest_block = primary.fetch_light_block(status.sync_info.latest_block_height)?;
|
||||
let _ = primary_trace.pop();
|
||||
primary_trace.push(latest_block);
|
||||
|
||||
let output = ProofOutput {
|
||||
light_client_proof: primary_trace,
|
||||
merkle_proof: proof.into(),
|
||||
|
|
Loading…
Reference in a new issue