Comment on page
To prepare and finish the execution of the task by PowerAgent, helper functions are called. They may be changed in different realizations of PowerAgent.
A slasher can try to execute the task if the assigned keeper has failed to do so.
function beforeExecute(bytes32 jobKey, uint256 actualKeeperId_, uint256 binJob_)is the first statement in the execute function of the PowerAgent. It contains a set of checks for the slasher and reverts at any step with failed check, interrupting the execution function of the PowerAgent.
- Slasher idIf the caller is the currently assigned keeper, the checks are skipped, and the execution continues. Otherwise, all checks are performed. If the caller is neither a keeper nor a slasher, the function reverts.
- Only next keeperFor interval tasks, if the slasher has called the execution too early.
- Slashing not initiatedThis job is not configured for slashing.
- Too early for slashingFor resolver jobs a certain block can be specified after which a negligent keeper can be slashed.
- Only reserved slasherA reserved slasher can be assigned to the job. If so, only this slasher can execute the failed task.
If all checks have been passed, the execution continues.
function afterExecute(bytes32 jobKey, uint256 actualKeeperId_, uint256 binJob_) internal overrideis called after the execution has succeeded. If the caller was not a slasher, it simply releases the previous keeper and assigns a new keeper (see Keeper Selection).
If the caller was a slasher, the negligent keeper is slashed by the following formula:
uint256 dynamicSlashAmount = eKeeper.cvpStake * uint256(rdConfig.slashingFeeBps) / 10000
uint256 fixedSlashAmount = uint256(rdConfig.slashingFeeFixedCVP) * 1 ether
uint88 totalSlashAmount = uint88(fixedSlashAmount + dynamicSlashAmount)
The CVP stake of the failed keeper is reduced by this amount, and the CVP stake of the slasher which successfully executed the task is increased by this amount.