Copy of Task Reward and Gas Compensation
All payment is carried out by the Agent contract. Herein we specify the modes of interaction with it for such purposes.
Flashbots realisation
Reward amount cases and computation
In Flashbots realisation, all compensation and reward computation is handled by one internal function _calculateCompensation
sharing functionality with a public pure function calculateCompensationPure
.
_calculateCompensation arguments and logic
Function signature:
Function logic in Flashbots implementation:
Compensation computation usage cases
The function _calculateCompensation
is invoked in the payout block of the execute_44g58pv
, immediately after the execution part proper. Do note that the call of this function is in no way conditioned on the success of execution of the job being automated: there are no conditionals involved in either the function itself or the parameters of its call, and it is always invoked, irrespectively of the ok
result which indicates the success of the call to the desired function.
For this reason, do note that all executions that are posted to the blockchain and do not revert the main function in Flashbots realisation are rewarded in full. In fact, no partial reward (e..g gas compensation) exists in Flashbots realisation; since the _afterExecutionReverted
function in Flashbots realisation always produces and propagates a revert (unlike in RanDAO realisation, where it only produces a revert when the function is of a Resolver type, but has no slashing initiated: since for Resolver type functions we do not known the executability status a priori, we use slashing initiation as an indicator thereof, judging the slashers to be optimal actors; for interval jobs, checks are performed by considering the interval proper earlier in the function), no unsuccessful attempts to execute the underlying job may receive any compensation (it would be reverted by this hook). This is justified because Flashbots provide costless reversion, and there is no gas expenditure to compensate. CHECK THE CORRECTNESS OF THIS INTERPRETATION OF LOGIC WITH KOLYAN
Reward payment options
Having computed the reward by invoking _calculateCompensation
, execute_44g58pv
either directly transfers the rewards in native chain tokens to the worker address or increases the corresponding value in the appropriate mapping.
The first option is whether job or job owner credits are employed to disburse rewards. This is controlled on a per-job basis by means of the job config byte, wherein the penultimate bit corresponds to the flag switching the reward source between the two listed here. The flag assuming the value of True
makes the rewards be disbursed from the job owner account, which may be advantageous for those who desire to automate a great amount of jobs, particularly inexpensive ones, since it affords superior convenience. Greater detail on this is afforded on pages Flags, Job (Old), and Job Registration & Update.
Job/Job owner payment code snippet
The second option is whether to increment the keeper's compensation value stored in the eponymous mapping with his ID as a key or pass the tokens directly to the message sender's address, i.e., the Keeper's worker address. The former option may afford superior efficiency, since it allows to transfer all accured compensation in one transaction, saving on gas. This option is configured by the Keeper himself in the execution config byte: the penultimate bit value thereof toggles this behaviour.
Accrue/send payment code snippet
Accrued compensation may be withdrawn by a special function. Do refer to Keeper (Old) and Flags for superior clarity.
RanDAO realisation
In RanDAO realisation, only hooks and compensation computations are overloaded, and the main function execute_44g58pv
is retained exactly as it is in the Flashbots realisation, as it is not virtual
.
Reward amount cases and computation
The function calculateCompensationPure
is no longer used; all computation are done directly within _calculateCompensation
, since calculateCompensationPure
was not made virtual and thus remains specific to the Flashbots realisation.
_calculateCompensation arguments and logic
Function signature:
Function logic in RanDAO implementation:
Compensation computation usage cases
RanDAO implementation shares the main execution function with the Flashbots implementation, and the hooks have no bearing on computing rewards (instead, they deal with the matters of slashing). Therefore, the cases are entirely similar to the Flashbots implementation, with the primary difference being that now the amount compensated is actually conditioned on the success of execution of the job in a different way: if the job succeeds, the full reward is paid, but reverted jobs pay only the gas cost as recompense. This can be seen as a generalisation of Flashbots realisation model, with the latter simply always having gas usage of reverted transactions be zero.
Reward payment options
Since the payout block is shared together with the execution function, these are entirely coincident with those of the Flashbots implementation.
Last updated