ā„¹ļøScenarios

Different aspects of PowerAgent network operation

User operations

Scenarios related to users interacting with PowerAgent.

Keeper registration

This scenario covers the registration and activation of a keeper.

  1. The noderunner allows spending and stakes CVP, registering a Worker address in the Agent contract.

  2. The noderunner configures and launches the node software.

  3. The noderunner sends activation transaction into the Agent contract, enabling the node to execute tasks.

Job submission

This scenario covers the submission of automated task into the PowerAgent network.

0. (optional) The job owner deploys a smart-contract (which may contain a resolver function, which may also be in a separate contract).

  1. The job owner selects the implementation of the Agent contract.

  2. The job owner configures and registers the task in the Agent contract, accompanied by native token deposit.

  3. The job owner provides the address and the function of the target smart contract.

  4. The job owner sets the stake range.

  5. The job owner sets the execution interval.

  6. The job owner provides the native token to be used as rewards for execution.

  7. The job owner submits the job into the Agent contract.

  8. The Agent contract randomly assigns a keeper to the job.

  9. The job is available for execution immediately.

Staking and withdrawing

TBA


Node operations

Scenarios which are related to the operation of the PowerAgent node and do not include user interactions.

Keeper selection

Keeper selection occurs immediately after the job submission, as well as after every job execution.

  1. The job is submitted or executed.

  2. In the same transaction, the Agent contract randomly assigns a keeper from a set of viable keepers.

  3. The node updates the information about the job.

  4. All keeper nodes set up a timer (for interval tasks) or immediately start static calls to the resolver function in each block (resolver tasks).

The set of viable keepers is determined by the keepers' stake and the job-specific stake range. The range is set by the job owner. See more about job configuration.

Interval task execution

The interval task is an automation task which requires execution once in a given period of time.

  1. Time comes for the task to be executed.

  2. The timer set by every node also expires.

  3. The node assigned to this task sends execution transaction to the Agent contract.

    1. If the node does not send the execution transaction in time, slashing occurs (if there is at least one non-malicious node in operation).

    2. If the node sends the execution transaction in time, the Agent contract checks:

      1. The sender is the assigned keeper OR both the sender is the current slasher AND the grace period is over.

      2. Whether the keeper has sufficient CVP stake globally and for this particular job.

      3. Whether the time is correct, and the task should be executed.

      4. The block base fee is not greater than the maximal base fee set by the job owner (OR exceeding the max base fee is permitted by the job owner).

      And several more checks.

  4. In case all checks pass, the Agent relays the execution transaction to the target contract address.

  5. In case checks do not pass, the Agent reverts the transaction.

  6. In case the execution is successful, the reward is calculated and paid out to the keeeper.

  7. In case the execution is unsuccessful, the gas compensation is paid out to the keeper and the keeper is released.

  8. The job information inside the Agent contract is updated. The job is disabled IF there is insufficient job balance.

  9. Keeper selection is performed.

Diagram

Resolver task execution

The resolver task requires a special (resolver) function to return (executabilityFlag, calldata) in order to determine whether the task should be executed. executabilityFlag can be either true (the task SHOULD be executed THIS BLOCK) or false (the task SHOULD NOT be executed THIS BLOCK).

  1. All PowerAgent nodes virtually execute the resolver function related to this task.

  2. When the resolver function returns (executabilityFlag, calldata), the assigned keeper sends the execution transaction to the Agent, passing the calldata received from the resolver execution.

  3. The Agent relays the transaction to the target function of the target contract, passing the calldata.

  4. The following steps are 7., 8., and 9. from Interval Task Execution.

Diagram

Reward Calculation

TBA

Slashing

Slashing is the process of partial keeper stake alienation in benefit of a slasher keeper.

Each keeper is given a certain time window, during which ONLY he can safely send an execution transaction. If a keeper fails to do so, another keeper (named slasher) will send its own transaction. In this transaction:

  1. The task is executed by the slasher (see Interval task execution or Resolver task execution).

  2. The negligent keeper is slashed for a following amount:

SA=dSA+fSAdSA=KSā‹…FS10000fSA=FSfixedā‹…1etherSA = dSA + fSA\\ \hspace{1mm}\\ dSA = K_S \cdot \frac{F_S}{10000}\\ \hspace{1mm}\\ fSA = F_{S_{fixed}}\cdot 1\hspace{1mm}ether

Where:

  • SA,dSA,fSASA, dSA, fSA - Slashed Amount, dynamic Slashed Amount, fixed Slashed Amount

  • KSK_S - keeper's stake.

  • FSF_S - slashing fee (bps).

  • FSfixedF_{S_{fixed}} - fixed slashing fee.

  1. The slashed amount is immediately added to the slasher keeper's stake.

Resolver Guidelines

TBA

Last updated