CoprocessorAdapter

Git Source

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

NameTypeDescription
_taskIssueraddressAddress of the coprocessor task issuer
_machineHashbytes32Initial machine hash

callCoprocessor

Issues a task to the coprocessor

function callCoprocessor(bytes memory input) internal;

Parameters

NameTypeDescription
inputbytesABI-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

NameTypeDescription
payloadHashbytes32This is a hash of the initial input whose response/resolution is being returned
noticebytesABI-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

NameTypeDescription
_machineHashbytes32The hash of the machine that processed the task
_payloadHashbytes32The hash of the input payload
outputsbytes[]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

NameTypeDescription
argumentsbytesABI-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

NameTypeDescription
argumentsbytesABI-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);