Skip to content

Commit

Permalink
insert height into query_packet_receipt and `query_packet_acknowled…
Browse files Browse the repository at this point in the history
…gement` grpc metadata (#12)

* insert height into query_packet_receipt and query_packet_acknowledgement grpc metadata

* put full height string

* add height to packet_commitment req
  • Loading branch information
noot authored Oct 3, 2024
1 parent f4ac139 commit 31fca38
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 7 deletions.
1 change: 1 addition & 0 deletions crates/relayer-types/src/applications/transfer/msgs/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
pub mod send;
pub mod transfer;

// TODO: does this need to be updated?
pub const ASTRIA_WITHDRAWAL_TYPE_URL: &str = "/astria.sequencer.v1.Ics20Withdrawal";
43 changes: 36 additions & 7 deletions crates/relayer/src/chain/astria/endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,12 +243,12 @@ impl AstriaEndpoint {
TransactionParams,
UnsignedTransaction,
},
Protobuf as _,
};
use astria_sequencer_client::SequencerClientExt as _;
use ibc_relayer_types::applications::transfer::msgs::ASTRIA_WITHDRAWAL_TYPE_URL;
use penumbra_ibc::IbcRelay;
use penumbra_proto::core::component::ibc::v1::IbcRelay as RawIbcRelay;
use astria_core::Protobuf as _;

let msg_len = tracked_msgs.msgs.len();
let mut actions: Vec<Action> = Vec::with_capacity(msg_len);
Expand Down Expand Up @@ -731,12 +731,13 @@ impl ChainEndpoint for AstriaEndpoint {
}
.into_request();

let map = req.metadata_mut();
let height_str: String = match request.height {
let height = match request.height {
QueryHeight::Latest => 0.to_string(),
QueryHeight::Specific(h) => h.to_string(),
};
map.insert("height", height_str.parse().expect("valid ascii string"));

req.metadata_mut()
.insert("height", height.parse().expect("valid ascii"));

let response = self
.block_on(client.client_state(req))
Expand Down Expand Up @@ -1114,9 +1115,19 @@ impl ChainEndpoint for AstriaEndpoint {
port_id: request.port_id.to_string(),
channel_id: request.channel_id.to_string(),
sequence: request.sequence.into(),
// TODO: height is ignored
};

let request = tonic::Request::new(req);
let height = match request.height {
QueryHeight::Latest => 0.to_string(),
QueryHeight::Specific(h) => h.to_string(),
};

let mut request = tonic::Request::new(req);
request
.metadata_mut()
.insert("height", height.parse().expect("valid ascii"));

let response = self
.block_on(client.packet_commitment(request))
.map_err(|e| Error::grpc_status(e, "query_packet_commitment".to_owned()))?
Expand Down Expand Up @@ -1176,7 +1187,16 @@ impl ChainEndpoint for AstriaEndpoint {
// TODO: height is ignored
};

let request = tonic::Request::new(req);
let height = match request.height {
QueryHeight::Latest => 0.to_string(),
QueryHeight::Specific(h) => h.to_string(),
};

let mut request = tonic::Request::new(req);
request
.metadata_mut()
.insert("height", height.parse().expect("valid ascii"));

let response = self
.block_on(client.packet_receipt(request))
.map_err(|e| Error::grpc_status(e, "query_packet_receipt".to_owned()))?
Expand Down Expand Up @@ -1238,7 +1258,16 @@ impl ChainEndpoint for AstriaEndpoint {
// TODO: height is ignored
};

let request = tonic::Request::new(req);
let height = match request.height {
QueryHeight::Latest => 0.to_string(),
QueryHeight::Specific(h) => h.to_string(),
};

let mut request = tonic::Request::new(req);
request
.metadata_mut()
.insert("height", height.parse().expect("valid ascii"));

let response = self
.block_on(client.packet_acknowledgement(request))
.map_err(|e| Error::grpc_status(e, "query_packet_acknowledgement".to_owned()))?
Expand Down

0 comments on commit 31fca38

Please sign in to comment.