Skip to content

Commit

Permalink
Move relayer batch sorting into latest batches query
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrit committed Aug 9, 2023
1 parent 5402aa8 commit dbb3f9c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 4 additions & 1 deletion orchestrator/cosmos_gravity/src/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions orchestrator/relayer/src/batch_relaying.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit dbb3f9c

Please sign in to comment.