Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getters to validator manager #655

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion contracts/validator-manager/PoSValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,12 @@ abstract contract PoSValidatorManager is
error InvalidUptimeBlockchainID(bytes32 uptimeBlockchainID);

// solhint-disable ordering
/**
* @dev This storage is visible to child contracts for convenience.
* Child contracts should probably never write to this storage.
*/
function _getPoSValidatorManagerStorage()
private
internal
pure
returns (PoSValidatorManagerStorage storage $)
{
Expand Down
14 changes: 5 additions & 9 deletions contracts/validator-manager/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ abstract contract ValidatorManager is Initializable, ContextUpgradeable, IValida
error PChainOwnerAddressesNotSorted();

// solhint-disable ordering
/**
* @dev This storage is visible to child contracts for convenience.
* Child contracts should probably never write to this storage.
*/
function _getValidatorManagerStorage()
private
internal
pure
returns (ValidatorManagerStorage storage $)
{
Expand Down Expand Up @@ -469,14 +473,6 @@ abstract contract ValidatorManager is Initializable, ContextUpgradeable, IValida
return (validationID, validator);
}

/**
* @notice Returns the validator's weight. This weight is not guaranteed to be known by the P-Chain
* @return Weight of the validator. If the validation ID does not exist, the weight will be 0.
*/
function getWeight(bytes32 validationID) external view returns (uint64) {
return getValidator(validationID).weight;
}

Comment on lines -472 to -479
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is redundant, we have an external getting for the Validator object

function _incrementAndGetNonce(bytes32 validationID) internal returns (uint64) {
ValidatorManagerStorage storage $ = _getValidatorManagerStorage();
return ++$._validationPeriods[validationID].messageNonce;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2365,7 +2365,7 @@ abstract contract PoSValidatorManagerTest is ValidatorManagerTest {

_completeEndDelegation(delegationID, weightUpdateMessage);

assertEq(posValidatorManager.getWeight(validationID), expectedValidatorWeight);
assertEq(posValidatorManager.getValidator(validationID).weight, expectedValidatorWeight);

if (rewardRecipient == delegator) {
assertEq(
Expand Down