Skip to content

Slashing Controller

SlashingController

UNDEFINED

enum StateMachines.State UNDEFINED

CREATED

enum StateMachines.State CREATED

REJECTED

enum StateMachines.State REJECTED

DISMISSED

enum StateMachines.State DISMISSED

IN_REVIEW

enum StateMachines.State IN_REVIEW

REVIEWED

enum StateMachines.State REVIEWED

EXECUTED

enum StateMachines.State EXECUTED

REVERTED

enum StateMachines.State REVERTED

PenaltyMode

enum PenaltyMode {
  UNDEFINED,
  MIN_STAKE,
  CURRENT_STAKE
}

SlashPenalty

struct SlashPenalty {
  uint256 percentSlashed;
  enum SlashingController.PenaltyMode mode;
}

Deposit

struct Deposit {
  address proposer;
  uint256 amount;
}

Proposal

struct Proposal {
  uint256 subjectId;
  address proposer;
  bytes32 penaltyId;
  uint8 subjectType;
}

_proposalIds

struct Counters.Counter _proposalIds

proposals

mapping(uint256 => struct SlashingController.Proposal) proposals

deposits

mapping(uint256 => uint256) deposits

penalties

mapping(bytes32 => struct SlashingController.SlashPenalty) penalties

slashingExecutor

contract ISlashingExecutor slashingExecutor

subjectGateway

contract StakeSubjectGateway subjectGateway

depositAmount

uint256 depositAmount

slashPercentToProposer

uint256 slashPercentToProposer

depositToken

contract IERC20 depositToken

_transitionTable

StateMachines.Machine _transitionTable

version

string version

MAX_EVIDENCE_LENGTH

uint256 MAX_EVIDENCE_LENGTH

MAX_CHAR_LENGTH

uint256 MAX_CHAR_LENGTH

HUNDRED_PERCENT

uint256 HUNDRED_PERCENT

SlashProposalUpdated

event SlashProposalUpdated(address updater, uint256 proposalId, enum StateMachines.State stateId, address proposer, uint256 subjectId, uint8 subjectType, bytes32 penaltyId)

EvidenceSubmitted

event EvidenceSubmitted(uint256 proposalId, enum StateMachines.State stateId, string[] evidence)

DepositAmountChanged

event DepositAmountChanged(uint256 amount)

SlashPercentToProposerChanged

event SlashPercentToProposerChanged(uint256 amount)

DepositSubmitted

event DepositSubmitted(uint256 proposalId, address proposer, uint256 amount)

DepositReturned

event DepositReturned(uint256 proposalId, address proposer, uint256 amount)

DepositSlashed

event DepositSlashed(uint256 proposalId, address proposer, uint256 amount)

SlashPenaltyAdded

event SlashPenaltyAdded(bytes32 penaltyId, uint256 percentSlashed, enum SlashingController.PenaltyMode mode)

SlashPenaltyRemoved

event SlashPenaltyRemoved(bytes32 penaltyId, uint256 percentSlashed, enum SlashingController.PenaltyMode mode)

WrongSlashPenaltyId

error WrongSlashPenaltyId(bytes32 penaltyId)

NonRegisteredSubject

error NonRegisteredSubject(uint8 subjectType, uint256 subjectId)

WrongPercentValue

error WrongPercentValue(uint256 value)

onlyValidSlashPenaltyId

modifier onlyValidSlashPenaltyId(bytes32 penaltyId)

onlyValidPercent

modifier onlyValidPercent(uint256 percent)

constructor

constructor(address _forwarder, address _depositToken) public

initialize

function initialize(address __manager, contract ISlashingExecutor __executor, contract StakeSubjectGateway __subjectGateway, uint256 __depositAmount, uint256 __slashPercentToProposer, bytes32[] __slashPenaltyIds, struct SlashingController.SlashPenalty[] __slashPenalties) public

Initializer method, access point to initialize inheritance tree.

Name Type Description
__manager address address of AccessManager.
__executor contract ISlashingExecutor
__subjectGateway contract StakeSubjectGateway
__depositAmount uint256
__slashPercentToProposer uint256
__slashPenaltyIds bytes32[]
__slashPenalties struct SlashingController.SlashPenalty[]

proposeSlash

function proposeSlash(uint8 _subjectType, uint256 _subjectId, bytes32 _penaltyId, string[] _evidence) external returns (uint256 proposalId)

Creates a slash proposal pointing to a slashable subject. To do so, the proposer must provide a FORT deposit and present evidence.

Name Type Description
_subjectType uint8 type of the subject.
_subjectId uint256 ERC721 registry id of the stake subject.
_penaltyId bytes32 if of the SlashPenalty to inflict upon the subject if the proposal goes through.
_evidence string[] IPFS hashes of the evidence files, proof of the subject being slash worthy.
Name Type Description
proposalId uint256 the proposal identifier.

dismissSlashProposal

function dismissSlashProposal(uint256 _proposalId, string[] _evidence) external

Arbiter dismisses a slash proposal (the proposal is legitimate, but after investigation, it is not a slashable offense) The deposit is returned to the proposer, and the stake of the subject is unfrozen

Name Type Description
_proposalId uint256 the proposal identifier.
_evidence string[] IPFS hashes of the evidence files, proof of the subject not being slashable.

rejectSlashProposal

function rejectSlashProposal(uint256 _proposalId, string[] _evidence) external

Arbiter rejects a slash proposal, slashing the deposit of the proposer (the proposal is deemed as spam, misconduct, or similar) and unfreezing the subject's stake.

Name Type Description
_proposalId uint256 the proposal identifier.
_evidence string[] IPFS hashes of the evidence files, justification for slashing the proposer's deposit.

markAsInReviewSlashProposal

function markAsInReviewSlashProposal(uint256 _proposalId) external

Arbiter recognizes the report as valid and procceeds to investigate. The deposit is returned to proposer, stake remains frozen.

Name Type Description
_proposalId uint256 the proposal identifier.

reviewSlashProposalParameters

function reviewSlashProposalParameters(uint256 _proposalId, uint8 _subjectType, uint256 _subjectId, bytes32 _penaltyId, string[] _evidence) external

After investigation, arbiter updates the proposal's incorrect assumptions. This can only be done if the proposal is IN_REVIEW, and presenting evidence for the changes. Changing the subject and subjectType will unfreeze the previous target and freeze the new. Changing the penalty will affect slashing amounts.

Name Type Description
_proposalId uint256 the proposal identifier.
_subjectType uint8 type of the subject.
_subjectId uint256 ERC721 registry id of the stake subject.
_penaltyId bytes32 if of the SlashPenalty to inflict upon the subject if the proposal goes through.
_evidence string[] IPFS hashes of the evidence files, proof of need for proposal changes.

_updateProposal

function _updateProposal(uint256 _proposalId, uint8 _subjectType, uint256 _subjectId, bytes32 _penaltyId) private

markAsReviewedSlashProposal

function markAsReviewedSlashProposal(uint256 _proposalId) external

Arbiter marks the proposal as reviewed, so the slasher can execute or revert.

Name Type Description
_proposalId uint256 the proposal identifier.

revertSlashProposal

function revertSlashProposal(uint256 _proposalId, string[] _evidence) external

The slashing proposal should not be executed. Stake is unfrozen. If the proposal is IN_REVIEW, this can be executed by the SLASHING_ARBITER_ROLE. If the proposal is REVIEWED, this can be executed by the SLASHER_ROLE.

Name Type Description
_proposalId uint256 the proposal identifier.
_evidence string[] IPFS hashes of the evidence files, proof of the slash being not valid.

executeSlashProposal

function executeSlashProposal(uint256 _proposalId) external

The slashing proposal is executed. Subject's stake is slashed and unfrozen. The proposer gets a % of the slashed stake as defined by slashPercentToProposer. Only executable by SLASHER_ROLE

Name Type Description
_proposalId uint256 the proposal identifier.

getSlashedStakeValue

function getSlashedStakeValue(uint256 _proposalId) public view returns (uint256)

gets the stake amount to be slashed. The amount depends on the StakePenalty. In all cases, the amount will be the minimum of the max slashable stake for the subject and: MIN_STAKE: a % of the subject's MIN_STAKE CURRENT_STAKE: a % of the subject's active + inactive stake.

getSubject

function getSubject(uint256 _proposalId) external view returns (uint8 subjectType, uint256 subject)

getProposer

function getProposer(uint256 _proposalId) external view returns (address)

setDepositAmount

function setDepositAmount(uint256 _amount) external

setSlashPercentToProposer

function setSlashPercentToProposer(uint256 _amount) external

setSlashPenalties

function setSlashPenalties(bytes32[] _slashReasons, struct SlashingController.SlashPenalty[] _slashPenalties) external

_authorizeRevertSlashProposal

function _authorizeRevertSlashProposal(uint256 _proposalId) private view

_unfreeze

function _unfreeze(uint256 _proposalId) private

_freeze

function _freeze(uint8 _subjectType, uint256 _subjectId) private

_setSlashingExecutor

function _setSlashingExecutor(contract ISlashingExecutor _executor) private

_setsubjectGateway

function _setsubjectGateway(contract StakeSubjectGateway _subjectGateway) private

_setDepositAmount

function _setDepositAmount(uint256 _amount) private

_setSlashPercentToProposer

function _setSlashPercentToProposer(uint256 _amount) private

_setSlashPenalties

function _setSlashPenalties(bytes32[] _slashReasons, struct SlashingController.SlashPenalty[] _slashPenalties) private

_submitEvidence

function _submitEvidence(uint256 _proposalId, enum StateMachines.State _stateId, string[] _evidence) private

_returnDeposit

function _returnDeposit(uint256 _proposalId) private

_slashDeposit

function _slashDeposit(uint256 _proposalId) private

transitionTable

function transitionTable() public view virtual returns (StateMachines.Machine)