CoprocessorAdapter
Inherits: ICoprocessorCallback
A base contract, which should be inherited for interacting with the Coprocessor
State Variables
machineHash
bytes32 public machineHash;
taskIssuer
ITaskIssuer public taskIssuer;
computationSent
mapping(bytes32 => bool) public computationSent;
Functions
constructor
Initializes the contract with the coprocessor address and machine hash
constructor(address _taskIssuer, bytes32 _machineHash);
Parameters
Name | Type | Description |
---|---|---|
_taskIssuer | address | Address of the coprocessor task issuer |
_machineHash | bytes32 | Initial machine hash |
callCoprocessor
Issues a task to the coprocessor
function callCoprocessor(bytes memory input) internal;
Parameters
Name | Type | Description |
---|---|---|
input | bytes | ABI-encoded input data for the coprocessor |
handleNotice
Handles notices sent back from the coprocessor
This function should be overridden by child contracts to define specific behavior
function handleNotice(bytes32 payloadHash, bytes memory notice) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
payloadHash | bytes32 | This is a hash of the initial input whose response/resolution is being returned |
notice | bytes | ABI-encoded notice data |
coprocessorCallbackOutputsOnly
Callback function invoked by the coprocessor with computation outputs
function coprocessorCallbackOutputsOnly(bytes32 _machineHash, bytes32 _payloadHash, bytes[] calldata outputs)
external
override;
Parameters
Name | Type | Description |
---|---|---|
_machineHash | bytes32 | The hash of the machine that processed the task |
_payloadHash | bytes32 | The hash of the input payload |
outputs | bytes[] | Array of ABI-encoded outputs from the coprocessor |
_executeVoucher
Executes a voucher
This function decodes and executes a voucher with the specified parameters
function _executeVoucher(bytes calldata arguments) internal;
Parameters
Name | Type | Description |
---|---|---|
arguments | bytes | ABI-encoded arguments containing the destination, value, and payload |
_executeDelegateCallVoucher
Executes a delegatecall voucher
This function decodes and executes a delegatecall voucher with the specified parameters
function _executeDelegateCallVoucher(bytes calldata arguments) internal;
Parameters
Name | Type | Description |
---|---|---|
arguments | bytes | ABI-encoded arguments |
Errors
UnauthorizedCaller
error UnauthorizedCaller(address caller);
InvalidOutputLength
error InvalidOutputLength(uint256 length);
ComputationNotFound
error ComputationNotFound(bytes32 payloadHash);
InsufficientFunds
error InsufficientFunds(uint256 value, uint256 balance);
MachineHashMismatch
error MachineHashMismatch(bytes32 current, bytes32 expected);
InvalidOutputSelector
error InvalidOutputSelector(bytes4 selector, bytes4 expected);