From 4fbe195491255754e425c9951a0863f1db64889e Mon Sep 17 00:00:00 2001 From: elizabeth Date: Wed, 11 Sep 2024 13:40:09 -0400 Subject: [PATCH 1/3] insert height into query_packet_receipt and query_packet_acknowledgement grpc metadata --- .../src/applications/transfer/msgs/mod.rs | 1 + crates/relayer/src/chain/astria/endpoint.rs | 34 ++++++++++++++----- 2 files changed, 27 insertions(+), 8 deletions(-) diff --git a/crates/relayer-types/src/applications/transfer/msgs/mod.rs b/crates/relayer-types/src/applications/transfer/msgs/mod.rs index 5b07d46f18..c4252593c5 100644 --- a/crates/relayer-types/src/applications/transfer/msgs/mod.rs +++ b/crates/relayer-types/src/applications/transfer/msgs/mod.rs @@ -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"; diff --git a/crates/relayer/src/chain/astria/endpoint.rs b/crates/relayer/src/chain/astria/endpoint.rs index 994327235a..a316b17363 100644 --- a/crates/relayer/src/chain/astria/endpoint.rs +++ b/crates/relayer/src/chain/astria/endpoint.rs @@ -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 = Vec::with_capacity(msg_len); @@ -731,12 +731,12 @@ impl ChainEndpoint for AstriaEndpoint { } .into_request(); - let map = req.metadata_mut(); - let height_str: String = match request.height { - QueryHeight::Latest => 0.to_string(), - QueryHeight::Specific(h) => h.to_string(), + let height = match request.height { + QueryHeight::Latest => 0, + QueryHeight::Specific(h) => h.revision_height(), }; - map.insert("height", height_str.parse().expect("valid ascii string")); + req.metadata_mut() + .insert("height", height.to_string().parse().expect("valid ascii")); let response = self .block_on(client.client_state(req)) @@ -1176,7 +1176,16 @@ impl ChainEndpoint for AstriaEndpoint { // TODO: height is ignored }; - let request = tonic::Request::new(req); + let height = match request.height { + QueryHeight::Latest => 0, + QueryHeight::Specific(h) => h.revision_height(), + }; + + let mut request = tonic::Request::new(req); + request + .metadata_mut() + .insert("height", height.to_string().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()))? @@ -1238,7 +1247,16 @@ impl ChainEndpoint for AstriaEndpoint { // TODO: height is ignored }; - let request = tonic::Request::new(req); + let height = match request.height { + QueryHeight::Latest => 0, + QueryHeight::Specific(h) => h.revision_height(), + }; + + let mut request = tonic::Request::new(req); + request + .metadata_mut() + .insert("height", height.to_string().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()))? From 903bac5d188950189547cdb1ebeaf3d8b0bfbe9e Mon Sep 17 00:00:00 2001 From: elizabeth Date: Wed, 11 Sep 2024 13:58:58 -0400 Subject: [PATCH 2/3] put full height string --- crates/relayer/src/chain/astria/endpoint.rs | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/crates/relayer/src/chain/astria/endpoint.rs b/crates/relayer/src/chain/astria/endpoint.rs index a316b17363..8f76e72ef3 100644 --- a/crates/relayer/src/chain/astria/endpoint.rs +++ b/crates/relayer/src/chain/astria/endpoint.rs @@ -732,11 +732,12 @@ impl ChainEndpoint for AstriaEndpoint { .into_request(); let height = match request.height { - QueryHeight::Latest => 0, - QueryHeight::Specific(h) => h.revision_height(), + QueryHeight::Latest => 0.to_string(), + QueryHeight::Specific(h) => h.to_string(), }; + req.metadata_mut() - .insert("height", height.to_string().parse().expect("valid ascii")); + .insert("height", height.parse().expect("valid ascii")); let response = self .block_on(client.client_state(req)) @@ -1177,14 +1178,14 @@ impl ChainEndpoint for AstriaEndpoint { }; let height = match request.height { - QueryHeight::Latest => 0, - QueryHeight::Specific(h) => h.revision_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.to_string().parse().expect("valid ascii")); + .insert("height", height.parse().expect("valid ascii")); let response = self .block_on(client.packet_receipt(request)) @@ -1248,14 +1249,14 @@ impl ChainEndpoint for AstriaEndpoint { }; let height = match request.height { - QueryHeight::Latest => 0, - QueryHeight::Specific(h) => h.revision_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.to_string().parse().expect("valid ascii")); + .insert("height", height.parse().expect("valid ascii")); let response = self .block_on(client.packet_acknowledgement(request)) From 450f84884a61688e375140dae6b14d3e41e3a9b2 Mon Sep 17 00:00:00 2001 From: elizabeth Date: Mon, 16 Sep 2024 17:59:16 -0400 Subject: [PATCH 3/3] add height to packet_commitment req --- crates/relayer/src/chain/astria/endpoint.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/crates/relayer/src/chain/astria/endpoint.rs b/crates/relayer/src/chain/astria/endpoint.rs index 8f76e72ef3..e4bebbde63 100644 --- a/crates/relayer/src/chain/astria/endpoint.rs +++ b/crates/relayer/src/chain/astria/endpoint.rs @@ -1115,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()))?