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

Merged
merged 8 commits into from
Dec 4, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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.

2 changes: 1 addition & 1 deletion contracts/validator-manager/PoSValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ abstract contract PoSValidatorManager is

// solhint-disable ordering
function _getPoSValidatorManagerStorage()
private
internal
pure
returns (PoSValidatorManagerStorage storage $)
{
Expand Down
10 changes: 1 addition & 9 deletions contracts/validator-manager/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ abstract contract ValidatorManager is Initializable, ContextUpgradeable, IValida

// solhint-disable ordering
function _getValidatorManagerStorage()
private
internal
pure
returns (ValidatorManagerStorage storage $)
{
Expand Down Expand Up @@ -469,14 +469,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

@geoff-vball geoff-vball Nov 29, 2024

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 getter 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
Loading