Skip to content

Commit

Permalink
ibc: prepend ibc commitment prefix in client state and connection que…
Browse files Browse the repository at this point in the history
…ries
  • Loading branch information
avahowell authored and erwanor committed Dec 7, 2023
1 parent 7deba33 commit bf13115
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
6 changes: 4 additions & 2 deletions crates/core/component/ibc/src/component/rpc/client_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ use std::str::FromStr;
use tonic::{Response, Status};

use crate::component::ClientStateReadExt;
use crate::prefix::MerklePrefixExt;
use crate::IBC_COMMITMENT_PREFIX;

use super::IbcQuery;

Expand All @@ -45,8 +47,8 @@ impl ClientQuery for IbcQuery {
// Query for client_state and associated proof.
let (cs_opt, proof) = snapshot
.get_with_proof(
ClientStatePath(client_id.clone())
.to_string()
IBC_COMMITMENT_PREFIX
.apply_string(ClientStatePath(client_id.clone()).to_string())
.as_bytes()
.to_vec(),
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ use prost::Message;
use std::str::FromStr;

use crate::component::ConnectionStateReadExt;
use crate::prefix::MerklePrefixExt;
use crate::IBC_COMMITMENT_PREFIX;

use super::IbcQuery;

Expand All @@ -27,14 +29,15 @@ impl ConnectionQuery for IbcQuery {
&self,
request: tonic::Request<QueryConnectionRequest>,
) -> std::result::Result<tonic::Response<QueryConnectionResponse>, tonic::Status> {
tracing::debug!("querying connection {:?}", request);
let snapshot = self.0.latest_snapshot();
let connection_id = &ConnectionId::from_str(&request.get_ref().connection_id)
.map_err(|e| tonic::Status::aborted(format!("invalid connection id: {e}")))?;

let (conn, proof) = snapshot
.get_with_proof(
ConnectionPath::new(connection_id)
.to_string()
IBC_COMMITMENT_PREFIX
.apply_string(ConnectionPath::new(connection_id).to_string())
.as_bytes()
.to_vec(),
)
Expand Down

0 comments on commit bf13115

Please sign in to comment.