From 6b25d9d21ac787e7de0239e3eb4ebdc15376ac38 Mon Sep 17 00:00:00 2001 From: airdrop-monster <102794667+airdrop-monster@users.noreply.github.com> Date: Sun, 24 Dec 2023 09:27:46 +0300 Subject: [PATCH] feat(proposer): improved shuffle function to preserve original prover endpoints slice (#475) Co-authored-by: David --- proposer/prover_selector/eth_fee_eoa_selector.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/proposer/prover_selector/eth_fee_eoa_selector.go b/proposer/prover_selector/eth_fee_eoa_selector.go index afa8cecab..80df4e5f0 100644 --- a/proposer/prover_selector/eth_fee_eoa_selector.go +++ b/proposer/prover_selector/eth_fee_eoa_selector.go @@ -161,10 +161,14 @@ func (s *ETHFeeEOASelector) AssignProver( // shuffleProverEndpoints shuffles the current selector's prover endpoints. func (s *ETHFeeEOASelector) shuffleProverEndpoints() []*url.URL { - rand.Shuffle(len(s.proverEndpoints), func(i, j int) { - s.proverEndpoints[i], s.proverEndpoints[j] = s.proverEndpoints[j], s.proverEndpoints[i] + // Clone the slice to avoid modifying the original proverEndpoints + shuffledEndpoints := make([]*url.URL, len(s.proverEndpoints)) + copy(shuffledEndpoints, s.proverEndpoints) + + rand.Shuffle(len(shuffledEndpoints), func(i, j int) { + shuffledEndpoints[i], shuffledEndpoints[j] = shuffledEndpoints[j], shuffledEndpoints[i] }) - return s.proverEndpoints + return shuffledEndpoints } // assignProver tries to assign a proof generation task to the given prover by HTTP API.