Skip to content

Commit

Permalink
Make improvements to ValidatorRegistry contract
Browse files Browse the repository at this point in the history
  • Loading branch information
evercoinx committed Sep 16, 2024
1 parent fb5107a commit 1fb4937
Show file tree
Hide file tree
Showing 3 changed files with 435 additions and 47 deletions.
2 changes: 1 addition & 1 deletion contracts/MaticX.sol
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ contract MaticX is
reentrancyGuardStatus = NOT_ENTERED;
}

/// -------------------------- initialize ----------------------------------
/// -------------------------- Initialize ----------------------------------

/// @notice Initializes the current contract.
/// @param _validatorRegistry - Address of the validator registry
Expand Down
9 changes: 5 additions & 4 deletions contracts/ValidatorRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ contract ValidatorRegistry is
_;
}

/// -------------------------- initialize ----------------------------------
/// -------------------------- Initialize ----------------------------------

/// @notice Initialize the ValidatorRegistry contract.
/// @param _stakeManager address of the polygon stake manager.
Expand Down Expand Up @@ -124,12 +124,12 @@ contract ValidatorRegistry is

require(
smValidator.contractAddress != address(0),
"Validator has no ValidatorShare"
"Validator has no validator share"
);
require(
(smValidator.status == IStakeManager.Status.Active) &&
smValidator.deactivationEpoch == 0,
"Validator isn't ACTIVE"
"Validator isn't active"
);

validators.push(_validatorId);
Expand Down Expand Up @@ -175,8 +175,8 @@ contract ValidatorRegistry is
++i;
}
}
validators.pop();

validators.pop();
delete validatorIdExists[_validatorId];

emit RemoveValidator(_validatorId);
Expand Down Expand Up @@ -272,6 +272,7 @@ contract ValidatorRegistry is
function getValidatorId(
uint256 _index
) external view override returns (uint256) {
require(_index < validators.length, "Invalid validator index");
return validators[_index];
}

Expand Down
Loading

0 comments on commit 1fb4937

Please sign in to comment.