From 8e6b737556efcaa43624534db7f0b27d19da6130 Mon Sep 17 00:00:00 2001 From: Marko Date: Fri, 9 Feb 2024 15:10:14 +0100 Subject: [PATCH] add penaltyRandomFactor as option to set by admin --- src/Redistribution.sol | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Redistribution.sol b/src/Redistribution.sol index d784748b..9b9b9bdd 100644 --- a/src/Redistribution.sol +++ b/src/Redistribution.sol @@ -135,6 +135,7 @@ contract Redistribution is AccessControl, Pausable { // Settings for slashing and freezing uint8 private penaltyMultiplierDisagreement = 1; uint8 private penaltyMultiplierNonRevealed = 2; + uint8 private penaltyRandomFactor = 20; // alpha=0.097612 beta=0.0716570 k=16 uint256 private sampleMaxValue = 1284401000000000000000000000000000000000000000000000000000000000000000000; @@ -526,11 +527,11 @@ contract Redistribution is AccessControl, Pausable { redundancyCount++; } - // Freeze deposit if any truth is false, make it a 20% chance for this to happen + // Freeze deposit if any truth is false, make it a penaltyRandomFactor chance for this to happen if ( currentCommit.revealed && (truthRevealedHash != currentReveal.hash || truthRevealedDepth != currentReveal.depth) && - (block.prevrandao % 100 < 20) + (block.prevrandao % 100 < penaltyRandomFactor) ) { Stakes.freezeDeposit( currentReveal.overlay, @@ -618,13 +619,19 @@ contract Redistribution is AccessControl, Pausable { /** * @notice Set freezing parameters */ - function setFreezingParams(uint8 _penaltyMultiplierDisagreement, uint8 _penaltyMultiplierNonRevealed) external { + function setFreezingParams( + uint8 _penaltyMultiplierDisagreement, + uint8 _penaltyMultiplierNonRevealed, + uint8 _penaltyRandomFactor + ) external { if (!hasRole(DEFAULT_ADMIN_ROLE, msg.sender)) { revert NotAdmin(); } penaltyMultiplierDisagreement = _penaltyMultiplierDisagreement; penaltyMultiplierNonRevealed = _penaltyMultiplierNonRevealed; + // Use 100 as value to ignore random factor in freezing penalty + penaltyRandomFactor = _penaltyRandomFactor; } /**