From d27c860249ec907512bd9c002b243196709bd56e Mon Sep 17 00:00:00 2001 From: Brooks Date: Fri, 10 Feb 2023 09:56:11 -0500 Subject: [PATCH] Replaces stable sort with unstable sort (#30223) --- runtime/src/bank.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/runtime/src/bank.rs b/runtime/src/bank.rs index c038d54fbe..61654fa2c7 100644 --- a/runtime/src/bank.rs +++ b/runtime/src/bank.rs @@ -5007,8 +5007,10 @@ impl Bank { #[cfg(not(test))] assert!(!validator_stakes.is_empty()); - // Sort first by stake and then by validator identity pubkey for determinism - validator_stakes.sort_by(|(pubkey1, staked1), (pubkey2, staked2)| { + // Sort first by stake and then by validator identity pubkey for determinism. + // If two items are still equal, their relative order does not matter since + // both refer to the same validator. + validator_stakes.sort_unstable_by(|(pubkey1, staked1), (pubkey2, staked2)| { staked2.cmp(staked1).then(pubkey2.cmp(pubkey1)) });