From 2e58240c37b0830cb312e26c83779e878e72feeb Mon Sep 17 00:00:00 2001 From: brentstone Date: Wed, 18 Oct 2023 23:40:11 -0400 Subject: [PATCH] process_slashes: fix critical bug --- proof_of_stake/src/lib.rs | 4 +--- proof_of_stake/src/tests/state_machine.rs | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/proof_of_stake/src/lib.rs b/proof_of_stake/src/lib.rs index 35ea602aba..65f8e83996 100644 --- a/proof_of_stake/src/lib.rs +++ b/proof_of_stake/src/lib.rs @@ -4554,9 +4554,7 @@ where // `updatedSlashedAmountMap` let validator_slashes = slashed_amount_map.entry(validator.clone()).or_default(); - for (epoch, slash) in result_slash { - *validator_slashes.entry(epoch).or_default() += slash; - } + *validator_slashes = result_slash; // `outgoingRedelegation` let outgoing_redelegations = diff --git a/proof_of_stake/src/tests/state_machine.rs b/proof_of_stake/src/tests/state_machine.rs index e9c4db1b3a..ce941abbbd 100644 --- a/proof_of_stake/src/tests/state_machine.rs +++ b/proof_of_stake/src/tests/state_machine.rs @@ -3929,9 +3929,7 @@ impl AbstractPosState { // `updatedSlashedAmountMap` let validator_slashes = val_slash_amounts.entry(validator.clone()).or_default(); - for (epoch, slash) in result_slash { - *validator_slashes.entry(epoch).or_default() += slash; - } + *validator_slashes = result_slash; let dest_validators = self .outgoing_redelegations