Skip to content

Commit

Permalink
abci query: support nonexistence proofs
Browse files Browse the repository at this point in the history
  • Loading branch information
avahowell committed Oct 6, 2023
1 parent 8dc50e6 commit a212094
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
5 changes: 2 additions & 3 deletions crates/bin/pd/src/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,8 @@ impl Info {
format!("failed to get key {}", String::from_utf8_lossy(&key))
})?;

let Some((value, proof_ops)) = rsp else {
anyhow::bail!("key not found")
};
let (value, proof_ops) = rsp;
let value = value.unwrap_or_else(Vec::new);

Ok(response::Query {
code: 0.into(),
Expand Down
10 changes: 4 additions & 6 deletions crates/core/component/chain/src/component/app_hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub trait AppHashRead {
async fn get_with_proof_to_apphash_tm(
&self,
key: Vec<u8>,
) -> anyhow::Result<Option<(Vec<u8>, tendermint::merkle::proof::ProofOps)>>;
) -> anyhow::Result<(Option<Vec<u8>>, tendermint::merkle::proof::ProofOps)>;

async fn app_hash(&self) -> anyhow::Result<AppHash>;
}
Expand Down Expand Up @@ -126,10 +126,8 @@ impl AppHashRead for Snapshot {
async fn get_with_proof_to_apphash_tm(
&self,
key: Vec<u8>,
) -> Result<Option<(Vec<u8>, TendermintMerkleProof)>> {
let (Some(value), ics23_proof) = self.get_with_proof_to_apphash(key.to_vec()).await? else {
return Ok(None);
};
) -> Result<(Option<Vec<u8>>, TendermintMerkleProof)> {
let (value, ics23_proof) = self.get_with_proof_to_apphash(key.to_vec()).await?;

let jmt_op = tendermint::merkle::proof::ProofOp {
field_type: "jmt:v".to_string(),
Expand All @@ -146,7 +144,7 @@ impl AppHashRead for Snapshot {
ops: vec![jmt_op, root_op],
};

Ok(Some((value, proof)))
Ok((value, proof))
}
}

Expand Down

0 comments on commit a212094

Please sign in to comment.