Keeper activation and deactivation in PPAgentV2RANDAO
Removal of keepers is performed by their elimination from the active (i.e. eligible for execution) keeper pool.
Deactivating the keeper
When a keeper admin desires to disable his keeper, he invokes the function disableKeeper(uint256 keeperId_)
.
Arguments
uint256 keeperId_
: the id of the keeper to disable
Assertions
_assertOnlyKeeperAdmin
ensures that only the keeper admin can disable a keeper_ensureCanReleaseKeeper
asserts that the keeper to be disabled is not currently assigned to any pending jobIt is also asserted that the keeper to be disabled is not already inactive.
After the checks are performed, the keeperId is removed from the EnumerableSet.UintSet internal activeKeepers
where all active keepers are stored, and the keeper (stored in the mapping mapping(uint256 => Keeper) internal keepers
at the index of keeperId
) has its activation status set to False
.
Keeper disabling event
Having disabled the specified keeper, the function emits the event DisableKeeper(keeperId_)
Activating the keeper
Keeper activation is done with a delay, much like the CVP token withdrawal. This is done to curb the possibility of the active keeper pool oscillating violently.
Initialising
When the admin of an inactive keeper deems it fit to reactivate the keeper once again, he invokes the function initiateKeeperActivation(uint256 keeperId_)
.
Arguments
uint256 keeperId_
: the id of the keeper to activate
Assertions
_assertOnlyKeeperAdmin
ensures that only the keeper admin may invoke this functionAn additional assertion is made, checking that the keeper with this ID is not active already.
When all assertions have been satisfied, the finalisation time uint256 canBeFinalizedAt
is calculated by adding to the current block timestamp the keeper activation finalisation delay in hours uint8 keeperActivationTimeoutHours
. This variable is a parameter of the instance of PPAgentV2RANDAO and is set by the agent owner. It can never exceed 255 hours due to the datatype employed. The calculated finalisation time is stored in the mapping mapping(uint256 => uint256) public keeperActivationCanBeFinalizedAt
, with the key being the keeperId
.
Activation initialisation event
Having computed and stored the activation time, the function emits the event InitiateKeeperActivation(keeperId_, canBeFinalizedAt)
.
Finalising
When the admin of an inactive keeper, having initialised the activation process before, desires to finalise it, he invokes the function finalizeKeeperActivation(uint256 keeperId_)
.
Arguments
uint256 keeperId_
: the id of the keeper to activate
Assertions
_assertOnlyKeeperAdmin
ensures that only the keeper admin may invoke this functionAn additional assertion is made, checking that the current block timestamp is not exceeded by the finalisation permission time, stored beforehand at activation initialisation in the mapping
mapping(uint256 => uint256) public keeperActivationCanBeFinalizedAt
, with the key being thekeeperId
.
When all assertions have been satisfied, the keeperId
is added back to the active keeper set EnumerableSet.UintSet internal activeKeepers
whence it was removed at deactivation, the finalisation time stored in the mapping mapping(uint256 => uint256) public keeperActivationCanBeFinalizedAt
, with the key being the keeperId
, is zeroed, and the keeper stored in the mapping mapping(uint256 => Keeper) internal keepers
at the index of keeperId
) has its activation status set to True
.
Activation finalisation event
Having reactivated the keeper, the function emits the event FinalizeKeeperActivation(keeperId_)
.
Last updated