Skip to content

Scanner Pool Registry

ScannerPoolRegistry

ERC721 Registry of Scanner Pools. Each scanner ScannerPool EOA controls a number of Scanner Nodes through the ownership of this NFT, represented by their EOA address. The Scanner Pool must register themselves, then register scanner addresses to be controlled by their scannerPoolId (incremental uint). Registered Scanner Pools can also assign managers to manage the scanners. Each Scanner Pool has a single "chainId" for all the scanners, and each scanner has metadata (string that can point to a URL, IPFS…). Scanner Pool owners and managers can update said metadata. Scanner Nodes can be enabled or disabled by: - the Scanner itself, - the ScannerPool owner - any of the scanner managers

If the scannerId is staked under the minimum stake, it can’t be enabled() and isEnabled() will return false, regardless of the disabled flag. If the scanner is not registered, isEnabled() will return false. A Scanner Node that is not enabled will not receive work (bot assignments)

version

string version

constructor

constructor(address forwarder, address stakeAllocator) public

registerMigratedScannerPool

function registerMigratedScannerPool(address scannerPoolAddress, uint256 chainId) external returns (uint256 scannerPoolId)

registerMigratedScannerNode

function registerMigratedScannerNode(struct ScannerPoolRegistryCore.ScannerNodeRegistration req, bool disabled) external

_canSetEnableState

function _canSetEnableState(address scanner) internal view virtual returns (bool)

disambiguation of _canSetEnableState, adding SCANNER_2_SCANNER_POOL_MIGRATOR_ROLE to the allowed setters.

Name Type Description
scanner address address
Name Type Description
[0] bool true if _msgSender() is the ScannerPool owning the Scanner or the Scanner Node itself

_msgSender

function _msgSender() internal view virtual returns (address sender)

Helper to get either msg msg.sender if not a meta transaction, signer of forwarder metatx if it is.

_msgData

function _msgData() internal view virtual returns (bytes)

Helper to get msg.data if not a meta transaction, forwarder data in metatx if it is.

__gap

uint256[50] __gap

ScannerPoolRegistryManaged

ManagerEnabled

event ManagerEnabled(uint256 scannerPoolId, address manager, bool enabled)

SenderNotManager

error SenderNotManager(address sender, uint256 scannerPoolId)

onlyManagerOf

modifier onlyManagerOf(uint256 scannerPoolId)

Checks sender (or metatx signer) is manager of the scanner pool token.

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool

isManager

function isManager(uint256 scannerPoolId, address manager) public view returns (bool)

Checks if address is defined as a manager for a ScannerPool's registered Scanner Nodes.

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool
manager address address to check.
Name Type Description
[0] bool true if defined as manager for ScannerPool, false otherwise.

getManagerCount

function getManagerCount(uint256 scannerPoolId) public view virtual returns (uint256)

Gets total managers defined for a ScannerPool's registered Scanner Nodes.

helper for external iteration.

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool
Name Type Description
[0] uint256 total managers defined for a ScannerPool.

getManagerAt

function getManagerAt(uint256 scannerPoolId, uint256 index) public view virtual returns (address)

Gets manager address at certain position of the ScannerPool's registered Scanner Nodes.

helper for external iteration.

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool
index uint256 position in the set.
Name Type Description
[0] address address of the manager at index.

setManager

function setManager(uint256 scannerPoolId, address manager, bool enable) public

Adds or removes a manager to a certain ScannerPool's registered Scanner Nodes. Restricted to ScannerPoolRegistry owner.

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool
manager address address to be added or removed from manager list for the ScannerPool.
enable bool true for adding, false for removing.

__gap

uint256[49] __gap

ScannerPoolRegistryCore

ScannerUpdated

event ScannerUpdated(uint256 scannerId, uint256 chainId, string metadata, uint256 scannerPool)

ManagedStakeThresholdChanged

event ManagedStakeThresholdChanged(uint256 chainId, uint256 min, uint256 max, bool activated)

RegistrationDelaySet

event RegistrationDelaySet(uint256 delay)

ScannerEnabled

event ScannerEnabled(uint256 scannerId, bool enabled, address sender, bool disableFlag)

EnabledScannersChanged

event EnabledScannersChanged(uint256 scannerPoolId, uint256 enabledScanners)

ScannerPoolRegistered

event ScannerPoolRegistered(uint256 scannerPoolId, uint256 chainId)

ScannerPoolNotRegistered

error ScannerPoolNotRegistered(uint256 scannerPoolId)

ScannerExists

error ScannerExists(address scanner)

ScannerNotRegistered

error ScannerNotRegistered(address scanner)

PublicRegistrationDisabled

error PublicRegistrationDisabled(uint256 chainId)

RegisteringTooLate

error RegisteringTooLate()

SignatureDoesNotMatch

error SignatureDoesNotMatch()

CannotSetScannerActivation

error CannotSetScannerActivation()

SenderNotScannerPool

error SenderNotScannerPool(address sender, uint256 scannerPoolId)

ChainIdMismatch

error ChainIdMismatch(uint256 expected, uint256 provided)

ActionShutsDownPool

error ActionShutsDownPool()

ScannerPreviouslyEnabled

error ScannerPreviouslyEnabled(address scanner)

ScannerPreviouslyDisabled

error ScannerPreviouslyDisabled(address scanner)

constructor

constructor(address __stakeAllocator) internal

__ScannerPoolRegistryCore_init

function __ScannerPoolRegistryCore_init(string __name, string __symbol, address __stakeSubjectGateway, uint256 __registrationDelay) internal

Initializer method

Name Type Description
__name string ERC721 token name.
__symbol string ERC721 token symbol.
__stakeSubjectGateway address address of StakeSubjectGateway
__registrationDelay uint256 amount of time allowed from scanner signing a ScannerNodeRegistration and it's execution by ScannerPool

isRegistered

function isRegistered(uint256 scannerPoolId) public view returns (bool)

Checks if scannerPoolId has been registered (minted).

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool.
Name Type Description
[0] bool true if scannerPoolId exists, false otherwise.

registerScannerPool

function registerScannerPool(uint256 chainId) external returns (uint256 scannerPoolId)

mints a ScannerPoolRegistry ERC721 NFT to sender Transferring ownership of a ScannerPoolRegistry NFT will transfer ownership of all its registered Scanner Node addresses

Name Type Description
scannerPoolId uint256 (autoincremented uint)

monitoredChainId

function monitoredChainId(uint256 scannerPoolId) public view returns (uint256)

isScannerRegistered

function isScannerRegistered(address scanner) public view returns (bool)

Checks if scanner address has been registered

Name Type Description
scanner address address.
Name Type Description
[0] bool true if scanner is registered, false otherwise.

isScannerRegisteredTo

function isScannerRegisteredTo(address scanner, uint256 scannerPoolId) public view returns (bool)

Checks if scanner address has been registered to a specific scannerPoolId

Name Type Description
scanner address address.
scannerPoolId uint256 ERC721 token id of the ScannerPool.
Name Type Description
[0] bool true if scanner is registered to scannerPoolId, false otherwise.

registerScannerNode

function registerScannerNode(struct ScannerPoolRegistryCore.ScannerNodeRegistration req, bytes signature) external

Method to register a Scanner Node and associate it with a scannerPoolId. Before executing this method, make sure to have enough FORT staked by the owner of the Scanner Pool to be allocated to the new scanner, then register a scanner with Forta Scan Node CLI and obtain the parameters for this methods by executing forta auth. Follow the instructions here https://docs.forta.network/en/latest/scan-node/introduction/ This method will try to allocate stake from unallocated stake if necessary. Individual ownership of a scaner node is not transferrable. A scanner node can be disabled, but not unregistered

Name Type Description
req struct ScannerPoolRegistryCore.ScannerNodeRegistration ScannerNodeRegistration struct with the Scanner Node data.
signature bytes ERC712 signature, result from signed req by the scanner.

updateScannerMetadata

function updateScannerMetadata(address scanner, string metadata) external

Method to update a registered Scanner Node metadata string. Only the ScannerPool that owns the scanner can update.

Name Type Description
scanner address address.
metadata string IPFS string pointing to Scanner Node metadata.

totalScannersRegistered

function totalScannersRegistered(uint256 scannerPoolId) public view returns (uint256)

gets the amount of Scanner Nodes ever registered to a ScannerPool Id. Useful for external iteration.

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool.

registeredScannerAtIndex

function registeredScannerAtIndex(uint256 scannerPoolId, uint256 index) external view returns (struct ScannerPoolRegistryCore.ScannerNode)

gets the Scanner Node address at index registered to scannerPoolId Useful for external iteration.

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool.
index uint256 of the registered Scanner Node. Must be lower than totalScannersRegistered(scannerPoolId)

registeredScannerAddressAtIndex

function registeredScannerAddressAtIndex(uint256 scannerPoolId, uint256 index) external view returns (address)

gets the Scanner Node data struct at index registered to scannerPoolId Useful for external iteration.

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool.
index uint256 of the registered Scanner Node. Must be lower than totalScannersRegistered(scannerPoolId)

scannerAddressToId

function scannerAddressToId(address scanner) public pure returns (uint256)

Converts scanner address to uint256 for FortaStaking Token Id.

scannerIdToAddress

function scannerIdToAddress(uint256 scannerId) public pure returns (address)

Converts FortaStaking uint256 id to address.

isScannerDisabled

function isScannerDisabled(address scanner) public view returns (bool)

Gets if the disabled flag has been set for a Scanner Node Address

isScannerOperational

function isScannerOperational(address scanner) public view returns (bool)

Checks if the Scanner Node is considered operational by the Forta Network, and is thus eligible for bot (Agent) assignment.

Name Type Description
scanner address address
Name Type Description
[0] bool true if: - Scanner Node is registered AND - Scanner Node's disabled flag is not set (is false) AND - (Scanner Node has more than minimum stake allocated to it OR staking is not activated for the Scanner Node's chain)

willNewScannerShutdownPool

function willNewScannerShutdownPool(uint256 scannerPoolId) public view returns (bool)

returns true if one more enabled scanner (or one registration) would put ALL scanners under min threshold, (not operational)

enableScanner

function enableScanner(address scanner) public

Sets Scanner Node disabled flag to false. It's not possible to re-enable a Scanner Node if allocatedStake / enabled scanners < min. If there is enough unallocated stake, this method will allocate it. If not, it will revert.

Name Type Description
scanner address address

disableScanner

function disableScanner(address scanner) public

Sets Scanner Node disabled flag to true. This will result in the scanner unlinking from assigned bots (process happens off-chain in Assigner software) and not being able to be linked to any bot until re-enabled.

Name Type Description
scanner address address

updateEnabledScanners

function updateEnabledScanners(uint256 scannerPoolId, uint256 count) external

Updates enabled scanner count of a pool

Name Type Description
scannerPoolId uint256 ERC721 token id of the ScannerPool
count uint256

getScanner

function getScanner(address scanner) public view returns (struct ScannerPoolRegistryCore.ScannerNode)

Gets ScannerNode struct for address

getScannerState

function getScannerState(address scanner) external view returns (bool registered, address owner, uint256 chainId, string metadata, bool operational, bool disabled)

Gets ScannerNode data for address

setManagedStakeThreshold

function setManagedStakeThreshold(struct IStakeSubject.StakeThreshold newStakeThreshold, uint256 chainId) external

Sets stake parameters (min, max, activated) for scanners. Restricted to SCANNER_POOL_ADMIN_ROLE

Name Type Description
newStakeThreshold struct IStakeSubject.StakeThreshold struct with stake parameters.
chainId uint256 scanned chain the thresholds applies to.

getManagedStakeThreshold

function getManagedStakeThreshold(uint256 managedId) public view returns (struct IStakeSubject.StakeThreshold)

Getter for StakeThreshold for the scanner with id subject

getTotalManagedSubjects

function getTotalManagedSubjects(uint256 subject) public view virtual returns (uint256)

Total scanners registered to a ScannerPool

setRegistrationDelay

function setRegistrationDelay(uint256 delay) external

Sets maximum delay between execution of forta auth in Scan Node CLI and execution of registerScanner() in this contract

_msgSender

function _msgSender() internal view virtual returns (address sender)

Helper to get either msg msg.sender if not a meta transaction, signer of forwarder metatx if it is.

_msgData

function _msgData() internal view virtual returns (bytes)

Helper to get msg.data if not a meta transaction, forwarder data in metatx if it is.

ownerOf

function ownerOf(uint256 subject) public view virtual returns (address)

disambiguation of ownerOf.

See {IERC721-ownerOf}.

__gap

uint256[38] __gap