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

Improve speed of tx_search query by using single query clause on sequence number #4191

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
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
16 changes: 0 additions & 16 deletions crates/relayer/src/chain/cosmos/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,22 +34,6 @@ pub struct QueryResponse {

pub fn packet_query(request: &QueryPacketEventDataRequest, seq: Sequence) -> Query {
Query::eq(
format!("{}.packet_src_channel", request.event_id.as_str()),
request.source_channel_id.to_string(),
)
.and_eq(
format!("{}.packet_src_port", request.event_id.as_str()),
request.source_port_id.to_string(),
)
.and_eq(
format!("{}.packet_dst_channel", request.event_id.as_str()),
request.destination_channel_id.to_string(),
)
.and_eq(
format!("{}.packet_dst_port", request.event_id.as_str()),
request.destination_port_id.to_string(),
)
.and_eq(
format!("{}.packet_sequence", request.event_id.as_str()),
seq.to_string(),
)
Expand Down
10 changes: 8 additions & 2 deletions crates/relayer/src/chain/cosmos/query/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,9 +129,15 @@ pub async fn query_packets_from_txs(
let mut result: Vec<IbcEventWithHeight> = vec![];

for seq in &request.sequences {
// Query the latest 10 txs which include the event specified in the query request
// Query the latest 100 txs which include the event specified in the query request
let response = rpc_client
.tx_search(packet_query(request, *seq), false, 1, 10, Order::Descending)
.tx_search(
packet_query(request, *seq),
false,
1,
100,
Order::Descending,
)
.await
.map_err(|e| Error::rpc(rpc_address.clone(), e))?;

Expand Down
Loading