Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

insert height into query_packet_receipt and query_packet_acknowledgement grpc metadata #12

Merged
merged 3 commits into from
Oct 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading