From bf131150f1e1b22174ca2afd0631fd108509c18e Mon Sep 17 00:00:00 2001 From: Ava Howell Date: Wed, 6 Dec 2023 21:43:38 -0800 Subject: [PATCH] ibc: prepend ibc commitment prefix in client state and connection queries --- .../core/component/ibc/src/component/rpc/client_query.rs | 6 ++++-- .../component/ibc/src/component/rpc/connection_query.rs | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/crates/core/component/ibc/src/component/rpc/client_query.rs b/crates/core/component/ibc/src/component/rpc/client_query.rs index b391512efc..325be1d12f 100644 --- a/crates/core/component/ibc/src/component/rpc/client_query.rs +++ b/crates/core/component/ibc/src/component/rpc/client_query.rs @@ -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; @@ -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(), ) diff --git a/crates/core/component/ibc/src/component/rpc/connection_query.rs b/crates/core/component/ibc/src/component/rpc/connection_query.rs index 411d44cdc9..5ccb633761 100644 --- a/crates/core/component/ibc/src/component/rpc/connection_query.rs +++ b/crates/core/component/ibc/src/component/rpc/connection_query.rs @@ -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; @@ -27,14 +29,15 @@ impl ConnectionQuery for IbcQuery { &self, request: tonic::Request, ) -> std::result::Result, 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(), )