Skip to content

Commit

Permalink
add penaltyRandomFactor as option to set by admin
Browse files Browse the repository at this point in the history
  • Loading branch information
0xCardinalError committed Feb 9, 2024
1 parent 91d50ef commit 8e6b737
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/Redistribution.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
}

/**
Expand Down

0 comments on commit 8e6b737

Please sign in to comment.