Infernet
SDK
Reference
Patterns
Allowlist

Allowlist

Git Source (opens in a new tab)

Exposes an onlyAllowedNode modifier that restricts unallowed nodes from calling permissioned contract functions

To be used with BaseConsumer._receiveCompute to restrict responding nodes

In the future, this list can be abstracted out to a contract that enables dynamic list declarations (registry)

State Variables

allowedNodes

node address => is allowed node

Access list applied via onlyAllowedNode modifier

Forced private visibility to disallow modifications outside of _updateAllowlist

Read getter exposed via isAllowedNode()

mapping(address => bool) private allowedNodes;

Functions

onlyAllowedNode

Allow only nodes in the allowedNodes set

modifier onlyAllowedNode(address node);

Parameters

NameTypeDescription
nodeaddresscalling node to checkin allowedNodes set

constructor

Initializes new Allowlist

constructor(address[] memory initialAllowed);

Parameters

NameTypeDescription
initialAllowedaddress[]array of initially-allowed node addresses

_updateAllowlist

Update allowedNodes

Does not validate nodes.length == status.length

function _updateAllowlist(address[] memory nodes, bool[] memory statuses) internal;

Parameters

NameTypeDescription
nodesaddress[]array of node addresses to update
statusesbool[]array of status(es) to update where index corresponds to index in nodes array

isAllowedNode

Check whether a node is allowed

function isAllowedNode(address node) external view returns (bool);

Parameters

NameTypeDescription
nodeaddressaddress to check for set inclusion

Returns

NameTypeDescription
<none>booltrue if node is in Allowlist & its status is set to true (allowed), else false

Errors

NodeNotAllowed

Thrown by onlyAllowedNode() if node address is not in allowedNodes set

4-byte signature: 0x42764946

error NodeNotAllowed();