Skip to content

Commit

Permalink
use HostInterface for all block height reads in ibc server
Browse files Browse the repository at this point in the history
  • Loading branch information
noot committed Sep 17, 2024
1 parent 43f6e93 commit 0ffda9b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 23 deletions.
4 changes: 2 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 @@ -60,7 +60,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ClientQuery for IbcQuery<HI> {
client_state,
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot.get_block_height().await.map_err(|e| {
revision_height: HI::get_block_height(&snapshot).await.map_err(|e| {
tonic::Status::aborted(format!("couldn't decode height: {e}"))
})? + 1,
revision_number: HI::get_revision_number(&snapshot).await.map_err(|e| {
Expand Down Expand Up @@ -144,7 +144,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ClientQuery for IbcQuery<HI> {
consensus_state,
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot.get_block_height().await.map_err(|e| {
revision_height: HI::get_block_height(&snapshot).await.map_err(|e| {
tonic::Status::aborted(format!("couldn't decode height: {e}"))
})? + 1,
revision_number: HI::get_revision_number(&snapshot).await.map_err(|e| {
Expand Down
10 changes: 4 additions & 6 deletions crates/core/component/ibc/src/component/rpc/connection_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConnectionQuery for IbcQuery<HI>
connection: conn,
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot.get_block_height().await.map_err(|e| {
revision_height: HI::get_block_height(&snapshot).await.map_err(|e| {
tonic::Status::aborted(format!("couldn't decode height: {e}"))
})? + 1,
revision_number: HI::get_revision_number(&snapshot).await.map_err(|e| {
Expand Down Expand Up @@ -168,8 +168,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConnectionQuery for IbcQuery<HI>
connection_paths,
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot
.get_block_height()
revision_height: HI::get_block_height(&snapshot)
.await
.map_err(|e| tonic::Status::aborted(format!("couldn't decode height: {e}")))?
+ 1,
Expand Down Expand Up @@ -222,8 +221,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConnectionQuery for IbcQuery<HI>
identified_client_state: Some(identified_client_state),
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot
.get_block_height()
revision_height: HI::get_block_height(&snapshot)
.await
.map_err(|e| tonic::Status::aborted(format!("couldn't decode height: {e}")))?
+ 1,
Expand Down Expand Up @@ -280,7 +278,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConnectionQuery for IbcQuery<HI>
client_id: client_id.to_string(),
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot.get_block_height().await.map_err(|e| {
revision_height: HI::get_block_height(&snapshot).await.map_err(|e| {
tonic::Status::aborted(format!("couldn't decode height: {e}"))
})? + 1,
revision_number: HI::get_revision_number(&snapshot).await.map_err(|e| {
Expand Down
23 changes: 8 additions & 15 deletions crates/core/component/ibc/src/component/rpc/consensus_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConsensusQuery for IbcQuery<HI>
channel,
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot.get_block_height().await.map_err(|e| {
revision_height: HI::get_block_height(&snapshot).await.map_err(|e| {
tonic::Status::aborted(format!("couldn't decode height: {e}"))
})? + 1,
revision_number: HI::get_revision_number(&snapshot).await.map_err(|e| {
Expand Down Expand Up @@ -258,8 +258,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConsensusQuery for IbcQuery<HI>
identified_client_state: Some(identified_client_state),
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot
.get_block_height()
revision_height: HI::get_block_height(&snapshot)
.await
.map_err(|e| tonic::Status::aborted(format!("couldn't decode height: {e}")))?
+ 1,
Expand Down Expand Up @@ -351,8 +350,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConsensusQuery for IbcQuery<HI>
client_id: connection.client_id.clone().to_string(),
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot
.get_block_height()
revision_height: HI::get_block_height(&snapshot)
.await
.map_err(|e| tonic::Status::aborted(format!("couldn't decode height: {e}")))?
+ 1,
Expand Down Expand Up @@ -398,8 +396,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConsensusQuery for IbcQuery<HI>
commitment,
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot
.get_block_height()
revision_height: HI::get_block_height(&snapshot)
.await
.map_err(|e| tonic::Status::aborted(format!("couldn't decode height: {e}")))?
+ 1,
Expand Down Expand Up @@ -501,8 +498,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConsensusQuery for IbcQuery<HI>
received: receipt.is_some(),
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot
.get_block_height()
revision_height: HI::get_block_height(&snapshot)
.await
.map_err(|e| tonic::Status::aborted(format!("couldn't decode height: {e}")))?
+ 1,
Expand Down Expand Up @@ -546,8 +542,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConsensusQuery for IbcQuery<HI>
acknowledgement,
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot
.get_block_height()
revision_height: HI::get_block_height(&snapshot)
.await
.map_err(|e| tonic::Status::aborted(format!("couldn't decode height: {e}")))?
+ 1,
Expand Down Expand Up @@ -745,8 +740,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConsensusQuery for IbcQuery<HI>
next_sequence_receive: next_recv_sequence,
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot
.get_block_height()
revision_height: HI::get_block_height(&snapshot)
.await
.map_err(|e| tonic::Status::aborted(format!("couldn't decode height: {e}")))?
+ 1,
Expand Down Expand Up @@ -787,8 +781,7 @@ impl<HI: HostInterface + Send + Sync + 'static> ConsensusQuery for IbcQuery<HI>
next_sequence_send: next_send_sequence,
proof: proof.encode_to_vec(),
proof_height: Some(ibc_proto::ibc::core::client::v1::Height {
revision_height: snapshot
.get_block_height()
revision_height: HI::get_block_height(&snapshot)
.await
.map_err(|e| tonic::Status::aborted(format!("couldn't decode height: {e}")))?
+ 1,
Expand Down

0 comments on commit 0ffda9b

Please sign in to comment.