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
constructor
registerMigratedScannerPool
function registerMigratedScannerPool(address scannerPoolAddress, uint256 chainId) external returns (uint256 scannerPoolId)
registerMigratedScannerNode
function registerMigratedScannerNode(struct ScannerPoolRegistryCore.ScannerNodeRegistration req, bool disabled) external
_canSetEnableState
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
Helper to get either msg msg.sender if not a meta transaction, signer of forwarder metatx if it is.
_msgData
Helper to get msg.data if not a meta transaction, forwarder data in metatx if it is.
__gap
ScannerPoolRegistryManaged
ManagerEnabled
SenderNotManager
onlyManagerOf
Checks sender (or metatx signer) is manager of the scanner pool token.
Name | Type | Description |
---|---|---|
scannerPoolId | uint256 | ERC721 token id of the ScannerPool |
isManager
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
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
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
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
ScannerPoolRegistryCore
ScannerUpdated
ManagedStakeThresholdChanged
RegistrationDelaySet
ScannerEnabled
EnabledScannersChanged
ScannerPoolRegistered
ScannerPoolNotRegistered
ScannerExists
ScannerNotRegistered
PublicRegistrationDisabled
RegisteringTooLate
SignatureDoesNotMatch
CannotSetScannerActivation
SenderNotScannerPool
ChainIdMismatch
ActionShutsDownPool
ScannerPreviouslyEnabled
ScannerPreviouslyDisabled
constructor
__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
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
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
isScannerRegistered
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
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
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
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
Converts scanner address to uint256 for FortaStaking Token Id.
scannerIdToAddress
Converts FortaStaking uint256 id to address.
isScannerDisabled
Gets if the disabled flag has been set for a Scanner Node Address
isScannerOperational
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
returns true if one more enabled scanner (or one registration) would put ALL scanners under min threshold, (not operational)
enableScanner
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
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
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
Total scanners registered to a ScannerPool
setRegistrationDelay
Sets maximum delay between execution of forta auth in Scan Node CLI and execution of registerScanner() in this contract
_msgSender
Helper to get either msg msg.sender if not a meta transaction, signer of forwarder metatx if it is.
_msgData
Helper to get msg.data if not a meta transaction, forwarder data in metatx if it is.
ownerOf
disambiguation of ownerOf.
See {IERC721-ownerOf}.