BaseConsumer
Git Source (opens in a new tab)
Handles receiving container compute responses from Infernet coordinator
Handles exposing container inputs to Infernet nodes via getContainerInputs()
Declares internal INBOX
reference to allow downstream consumers to read from Inbox
Contains a single public entrypoint rawReceiveCompute
callable only by the Infernet coordinator. Once
msg.sender is verified, parameters are proxied to internal function _receiveCompute
Does not inherit Coordinated
for rawReceiveCompute
coordinator-permissioned check to keep error scope localized
State Variables
COORDINATOR
Coordinator
Internal visibility since COORDINATOR is consumed by inheriting contracts
Coordinator internal immutable COORDINATOR;
INBOX
Inbox
Internal visibility since INBOX can be consumed by inheriting readers
Inbox internal immutable INBOX;
Functions
constructor
Initialize new BaseConsumer
constructor(address registry);
Parameters
Name | Type | Description |
---|---|---|
registry | address | registry address |
_receiveCompute
Callback entrypoint to receive container compute responses from validated Coordinator source
Called by rawReceiveCompute
once validated that msg.sender == address(COORDINATOR)
Same function parameters as rawReceiveCompute
function _receiveCompute(
uint32 subscriptionId,
uint32 interval,
uint16 redundancy,
address node,
bytes calldata input,
bytes calldata output,
bytes calldata proof,
bytes32 containerId,
uint256 index
) internal virtual;
Parameters
Name | Type | Description |
---|---|---|
subscriptionId | uint32 | id of subscription being responded to |
interval | uint32 | subscription interval |
redundancy | uint16 | after this call succeeds, how many nodes will have delivered a response for this interval |
node | address | address of responding Infernet node |
input | bytes | optional off-chain container input recorded by Infernet node (empty, hashed input, processed input, or both), empty for lazy subscriptions |
output | bytes | optional off-chain container output (empty, hashed output, processed output, both, or fallback: all encodeable data), empty for lazy subscriptions |
proof | bytes | optional off-chain container execution proof (or arbitrary metadata), empty for lazy subscriptions |
containerId | bytes32 | if lazy subscription, subscription compute container ID, else empty |
index | uint256 | if lazy subscription, Inbox lazy store index, else empty |
getContainerInputs
View function to broadcast dynamic container inputs to off-chain Infernet nodes
Developers can modify this function to return dynamic inputs
function getContainerInputs(uint32 subscriptionId, uint32 interval, uint32 timestamp, address caller)
external
view
virtual
returns (bytes memory);
Parameters
Name | Type | Description |
---|---|---|
subscriptionId | uint32 | subscription ID to collect container inputs for |
interval | uint32 | subscription interval to collect container inputs for |
timestamp | uint32 | timestamp at which container inputs are collected |
caller | address | calling address |
rawReceiveCompute
Callback entrypoint called by Infernet Coordinator to return container compute responses
Callable only by address(COORDINATOR)
, else throws NotCoordinator()
error
function rawReceiveCompute(
uint32 subscriptionId,
uint32 interval,
uint16 redundancy,
address node,
bytes calldata input,
bytes calldata output,
bytes calldata proof,
bytes32 containerId,
uint256 index
) external;
Parameters
Name | Type | Description |
---|---|---|
subscriptionId | uint32 | id of subscription being responded to |
interval | uint32 | subscription interval |
redundancy | uint16 | after this call succeeds, how many nodes will have delivered a response for this interval |
node | address | address of responding Infernet node |
input | bytes | optional off-chain container input recorded by Infernet node (empty, hashed input, processed input, or both), empty for lazy subscriptions |
output | bytes | optional off-chain container output (empty, hashed output, processed output, both, or fallback: all encodeable data), empty for lazy subscriptions |
proof | bytes | optional off-chain container execution proof (or arbitrary metadata), empty for lazy subscriptions |
containerId | bytes32 | if lazy subscription, subscription compute container ID, else empty |
index | uint256 | if lazy subscription, Inbox lazy store index, else empty |
Errors
NotCoordinator
Thrown if attempting to call rawReceiveCompute
from a msg.sender != address(COORDINATOR)
4-byte signature: 0x9ec853e6
error NotCoordinator();