Skip to main content

ValidationRules

ValidationRules

Responsible for reviewing and voting to invalidate users and resources.

Manage validators rules and data. This contract is responsible for reviewing and voting to invalidate wrong or corrupted actions across different user types and resources.

POINTS_PER_LEVEL

uint256 POINTS_PER_LEVEL

Validation points required for one pool level.

userValidations

mapping(address => mapping(uint256 => uint256)) userValidations

The relationship between address and validations received by era.

validatorLastVoteAt

mapping(address => uint256) validatorLastVoteAt

Relationship between validator and last vote block.number.

hunterVoter

mapping(address => mapping(uint256 => address)) hunterVoter

Tracks the first user who voted to invalidate a specific user in a given era.

hunterPools

mapping(address => struct Pool) hunterPools

Mapping from a validators's address directly to their pool data.

validationPoints

mapping(address => uint256) validationPoints

Tracks the accumulated, unspent validation points for each voter.

totalValidationLevels

mapping(address => uint256) totalValidationLevels

Tracks the total number of validation levels a user has ever earned.

communityRules

contract ICommunityRules communityRules

CommunityRules contract interface.

regeneratorRules

contract IRegeneratorRules regeneratorRules

RegeneratorRules contract interface.

inspectorRules

contract IInspectorRules inspectorRules

InspectorRules contract interface.

developerRules

contract IDeveloperRules developerRules

DeveloperRules contract interface.

researcherRules

contract IResearcherRules researcherRules

ResearcherRules contract interface.

contributorRules

contract IContributorRules contributorRules

ContributorRules contract interface.

activistRules

contract IActivistRules activistRules

ActivistRules contract interface.

voteRules

contract IVoteRules voteRules

VoteRules contract interface.

validationPool

contract IValidationPool validationPool

The interface of the ValidationPool contract, responsible for managing and distributing token rewards to validators.

timeBetweenVotes

uint256 timeBetweenVotes

Amount of blocks between votes.

constructor

constructor(uint256 timeBetweenVotes_) public

Initializes the ValidationRules contract with a minimum time between votes.

Sets the immutable timeBetweenVotes which dictates how many blocks a validator must wait between votes.

Parameters

NameTypeDescription
timeBetweenVotes_uint256The number of blocks a validator must wait between consecutive votes.

setContractInterfaces

function setContractInterfaces(struct ContractsDependency contractDependency) external

onlyOwner function to set contract interfaces. This function must be called only once after the contract deploy and ownership must be renounced.

Parameters

NameTypeDescription
contractDependencystruct ContractsDependencyAddresses of system contracts used.

addUserValidation

function addUserValidation(address userAddress, string justification) external

Allows users to attempt to vote to invalidate an user.

_Votes to invalidate users with unwanted behavior.

Requirements:

  • The caller must be a registered voter user (verified by VoteRules).
  • Caller level must be above average (verified by VoteRules.canVote implicitly).
  • Caller must have waited timeBetweenVotes since their last vote.
  • Caller must vote only once per user per era.
  • The target user must be registered and not already denied.
  • If the target user is a Regenerator, they must have fewer than 4 completed inspections to be eligible for invalidation._

Parameters

NameTypeDescription
userAddressaddressInvalidation user address.
justificationstringInvalidation justification (Max characters).

exchangePointsForLevel

function exchangePointsForLevel() external

Allows a voter to exchange their accumulated validation points for a single level.

_This function implements a fixed exchange rate where a voter can trade a specific amount of points (POINTS_PER_LEVEL) for one level, which contributes to their standing and potential rewards in the Validation Pool.

Requirements:

  • The caller (msg.sender) must be a registered voter (e.g., Researcher, Developer, Contributor).
  • The caller must have accumulated at least POINTS_PER_LEVEL points to be eligible for the exchange._

withdraw

function withdraw() external

Validators can claim tokens for their hunt and investigation service.

Allows a validator to initiate a withdrawal of Regeneration Credits for the malicious/fake users hunt service. Rewards will be based on their hunting level and current era.

updateValidatorLastVoteBlock

function updateValidatorLastVoteBlock(address validatorAddress) external

Called only by authorized callers.

Update last validator vote block.number.

Parameters

NameTypeDescription
validatorAddressaddressThe validator wallet address.

addValidationPoint

function addValidationPoint(address voter) external

Grants a single validation point to a voter for a voting action.

This is a function intended to be called by the resources contract after a validation vote.

Parameters

NameTypeDescription
voteraddressThe address of the voter who is earning the point.

getUserValidations

function getUserValidations(address userAddress, uint256 currentEra) public view returns (uint256)

Get user validations count for a specific user in a given era.

Retrieves the total number of validation votes received for a specified user and era.

Parameters

NameTypeDescription
userAddressaddressThe address of the user.
currentErauint256The era to check for validations.

Return Values

NameTypeDescription
[0]uint256uint256 The number of received invalidation votes.

votesToInvalidate

function votesToInvalidate() public view returns (uint256)

Get how many validations is necessary to invalidate a user or resource.

Calculates the required number of votes for invalidation based on the total number of registered voters in the system. Calculation is based on the votersCount which includes researchers, developers, and contributors.

Return Values

NameTypeDescription
[0]uint256count Number of votes required for invalidation.

waitedTimeBetweenVotes

function waitedTimeBetweenVotes(address validatorAddress) public view returns (bool)

Check if a validator can vote based on their last vote block number and timeBetweenVotes.

Returns true if the current block number is past validatorLastVoteAt + timeBetweenVotes, or if the validator has never voted before.

Parameters

NameTypeDescription
validatorAddressaddressThe address of the validator.

Return Values

NameTypeDescription
[0]boolbool True if the validator can vote, false otherwise.

UserValidation

event UserValidation(address _validatorAddress, address _userAddress, string _justification, uint256 _currentEra)

Emitted

Parameters

NameTypeDescription
_validatorAddressaddressThe address of the validator.
_userAddressaddressThe wallet of the user receiving the vote.
_justificationstringThe justification provided for the vote.
_currentErauint256User validation currentEra.