diff --git a/orchestrator/cosmos_gravity/src/query.rs b/orchestrator/cosmos_gravity/src/query.rs index 6643eade0..9624f7e1f 100644 --- a/orchestrator/cosmos_gravity/src/query.rs +++ b/orchestrator/cosmos_gravity/src/query.rs @@ -98,7 +98,10 @@ pub async fn get_latest_transaction_batches( let request = client .batch_txs(BatchTxsRequest { pagination: None }) .await?; - Ok(extract_valid_batches(request.into_inner().batches)) + let mut batches = request.into_inner().batches; + batches.sort_by(|a, b| a.batch_nonce.cmp(&b.batch_nonce)); + + Ok(extract_valid_batches(batches)) } // If we can't serialize a batch from a proto, but it was committed to the chain, diff --git a/orchestrator/relayer/src/batch_relaying.rs b/orchestrator/relayer/src/batch_relaying.rs index 6b246e5f9..698dea9cb 100644 --- a/orchestrator/relayer/src/batch_relaying.rs +++ b/orchestrator/relayer/src/batch_relaying.rs @@ -107,11 +107,7 @@ async fn get_batches_and_signatures( ); } } - // sort the batches by nonce in ascending order, we want to submit - // older batches first so that we don't invalidate newer batches - possible_batches.par_iter_mut().for_each(|(_key, value)| { - value.sort_by(|a, b| a.batch.nonce.cmp(&b.batch.nonce)); - }); + possible_batches }