Nodes

This contract contains all logic to manage SKALE Network nodes states, space availability, stake requirement checks, and exit functions.

Nodes may be in one of several states:

  • Active: Node is registered and is in network operation.

  • Leaving: Node has begun exiting from the network.

  • Left: Node has left the network.

  • In_Maintenance: Node is temporarily offline or undergoing infrastructure maintenance

Note: Online nodes contain both Active and Leaving states.

checkNodeExists checkNodeExists(uint256 nodeIndex) modifier

onlyNodeOrNodeManager onlyNodeOrNodeManager(uint256 nodeIndex) modifier

onlyCompliance onlyCompliance() modifier

nonZeroIP nonZeroIP(bytes4 ip) modifier

removeSpaceFromNode removeSpaceFromNode(uint256 nodeIndex, uint8 space) → bool external

Allows Schains and SchainsInternal contracts to occupy available space on a node.

Returns whether operation is successful.

addSpaceToNode addSpaceToNode(uint256 nodeIndex, uint8 space) external

Allows Schains contract to occupy free space on a node.

Returns whether operation is successful.

changeNodeLastRewardDate changeNodeLastRewardDate(uint256 nodeIndex) external

Allows SkaleManager to change a node’s last reward date.

changeNodeFinishTime changeNodeFinishTime(uint256 nodeIndex, uint256 time) external

Allows SkaleManager to change a node’s finish time.

createNode createNode(address from, struct Nodes.NodeCreationParams params) external

Allows SkaleManager contract to create new node and add it to the Nodes contract.

Emits a NodeCreated event.

Requirements:

  • Node IP must be non-zero.

  • Node IP must be available.

  • Node name must not already be registered.

  • Node port must be greater than zero.

initExit initExit(uint256 nodeIndex) → bool external

Allows SkaleManager contract to initiate a node exit procedure.

Returns whether the operation is successful.

Emits an ExitInitialized event.

completeExit completeExit(uint256 nodeIndex) → bool external

Allows SkaleManager contract to complete a node exit procedure.

Returns whether the operation is successful.

Emits an ExitCompleted event.

Requirements:

  • Node must have already initialized a node exit procedure.

deleteNodeForValidator deleteNodeForValidator(uint256 validatorId, uint256 nodeIndex) external

Allows SkaleManager contract to delete a validator’s node.

Requirements:

  • Validator ID must exist.

checkPossibilityCreatingNode checkPossibilityCreatingNode(address nodeAddress) external

Allows SkaleManager contract to check whether a validator has sufficient stake to create another node.

Requirements:

  • Validator must be included on trusted list if trusted list is enabled.

  • Validator must have sufficient stake to operate an additional node.

checkPossibilityToMaintainNode checkPossibilityToMaintainNode(uint256 validatorId, uint256 nodeIndex) → bool external

Allows SkaleManager contract to check whether a validator has sufficient stake to maintain a node.

Returns whether validator can maintain node with current stake.

Requirements:

  • Validator ID and nodeIndex must both exist.

setNodeInMaintenance setNodeInMaintenance(uint256 nodeIndex) external

Allows Node to set In_Maintenance status.

Requirements:

  • Node must already be Active.

  • msg.sender must be owner of Node, validator, or SkaleManager.

removeNodeFromInMaintenance removeNodeFromInMaintenance(uint256 nodeIndex) external

Allows Node to remove In_Maintenance status.

Requirements:

  • Node must already be In Maintenance.

  • msg.sender must be owner of Node, validator, or SkaleManager.

setNodeIncompliant setNodeIncompliant(uint256 nodeIndex) external

Marks the node as incompliant

setNodeCompliant setNodeCompliant(uint256 nodeIndex) external

Marks the node as compliant

setDomainName setDomainName(uint256 nodeIndex, string domainName) external

makeNodeVisible makeNodeVisible(uint256 nodeIndex) external

makeNodeInvisible makeNodeInvisible(uint256 nodeIndex) external

changeIP changeIP(uint256 nodeIndex, bytes4 newIP, bytes4 newPublicIP) external

getRandomNodeWithFreeSpace getRandomNodeWithFreeSpace(uint8 freeSpace, struct Random.RandomGenerator randomGenerator) → uint256 external

isTimeForReward isTimeForReward(uint256 nodeIndex) → bool external

Checks whether it is time for a node’s reward.

getNodeIP getNodeIP(uint256 nodeIndex) → bytes4 external

Returns IP address of a given node.

Requirements:

  • Node must exist.

getNodeDomainName getNodeDomainName(uint256 nodeIndex) → string external

Returns domain name of a given node.

Requirements:

  • Node must exist.

getNodePort getNodePort(uint256 nodeIndex) → uint16 external

Returns the port of a given node.

Requirements:

  • Node must exist.

getNodePublicKey getNodePublicKey(uint256 nodeIndex) → bytes32[2] external

Returns the public key of a given node.

getNodeAddress getNodeAddress(uint256 nodeIndex) → address external

Returns an address of a given node.

getNodeFinishTime getNodeFinishTime(uint256 nodeIndex) → uint256 external

Returns the finish exit time of a given node.

isNodeLeft isNodeLeft(uint256 nodeIndex) → bool external

Checks whether a node has left the network.

isNodeInMaintenance isNodeInMaintenance(uint256 nodeIndex) → bool external

getNodeLastRewardDate getNodeLastRewardDate(uint256 nodeIndex) → uint256 external

Returns a given node’s last reward date.

getNodeNextRewardDate getNodeNextRewardDate(uint256 nodeIndex) → uint256 external

Returns a given node’s next reward date.

getNumberOfNodes getNumberOfNodes() → uint256 external

Returns the total number of registered nodes.

getNumberOnlineNodes getNumberOnlineNodes() → uint256 external

Returns the total number of online nodes.

Note: Online nodes are equal to the number of active plus leaving nodes.

getActiveNodeIds getActiveNodeIds() → uint256[] activeNodeIds external

Return active node IDs.

getNodeStatus getNodeStatus(uint256 nodeIndex) → enum Nodes.NodeStatus external

Return a given node’s current status.

getValidatorNodeIndexes getValidatorNodeIndexes(uint256 validatorId) → uint256[] external

Return a validator’s linked nodes.

Requirements:

  • Validator ID must exist.

countNodesWithFreeSpace countNodesWithFreeSpace(uint8 freeSpace) → uint256 count external

Returns number of nodes with available space.

initialize initialize(address contractsAddress) public

constructor in Permissions approach.

getValidatorId getValidatorId(uint256 nodeIndex) → uint256 public

Returns the Validator ID for a given node.

isNodeExist isNodeExist(address from, uint256 nodeIndex) → bool public

Checks whether a node exists for a given address.

isNodeActive isNodeActive(uint256 nodeIndex) → bool public

Checks whether a node’s status is Active.

isNodeLeaving isNodeLeaving(uint256 nodeIndex) → bool public

Checks whether a node’s status is Leaving.

_removeNodeFromSpaceToNodes _removeNodeFromSpaceToNodes(uint256 nodeIndex, uint8 space) internal

NodeCreated NodeCreated(uint256 nodeIndex, address owner, string name, bytes4 ip, bytes4 publicIP, uint16 port, uint16 nonce, string domainName, uint256 time, uint256 gasSpend) event

Emitted when a node is created.

ExitCompleted ExitCompleted(uint256 nodeIndex, uint256 time, uint256 gasSpend) event

Emitted when a node completes a network exit.

ExitInitialized ExitInitialized(uint256 nodeIndex, uint256 startLeavingPeriod, uint256 time, uint256 gasSpend) event

Emitted when a node begins to exit from the network.