Skip to content

Commit

Permalink
IACP99ValidatorManager interface
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-schultz committed Dec 3, 2024
1 parent d5b5b93 commit c77a480
Show file tree
Hide file tree
Showing 12 changed files with 84 additions and 190 deletions.
12 changes: 8 additions & 4 deletions contracts/validator-manager/ACP99ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

import {IACP99SecurityModule} from "./interfaces/IACP99SecurityModule.sol";
import {ValidatorManager} from "./ValidatorManager.sol";
import {ConversionData,ValidatorRegistrationInput} from "./interfaces/IValidatorManager.sol";
import {IACP99ValidatorManager, ConversionData, ValidatorRegistrationInput} from "./interfaces/IACP99ValidatorManager.sol";

pragma solidity 0.8.25;

abstract contract ACP99ValidatorManager is ValidatorManager {
abstract contract ACP99ValidatorManager is IACP99ValidatorManager, ValidatorManager {
IACP99SecurityModule public securityModule;

// TODO: calling this should be restricted to...who?
Expand Down Expand Up @@ -49,7 +49,11 @@ abstract contract ACP99ValidatorManager is ValidatorManager {
securityModule.handleCompleteEndValidation(validationID);
}

function initializeValidatorWeightChange() external{}
function initializeValidatorWeightChange(bytes32 validationID, uint64 weight, bytes calldata args) external{
securityModule.handleInitializeValidatorWeightChange(validationID, weight, args);
}

function completeValidatorWeightChange() external{}
function completeValidatorWeightChange(bytes32 validationID, bytes calldata args) external{
securityModule.handleCompleteValidatorWeightChange(validationID, args);
}
}
2 changes: 0 additions & 2 deletions contracts/validator-manager/ERC20TokenStakingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ pragma solidity 0.8.25;

import {PoSValidatorManager} from "./PoSValidatorManager.sol";
import {PoSValidatorManagerSettings} from "./interfaces/IPoSValidatorManager.sol";
import {ValidatorRegistrationInput} from "./interfaces/IValidatorManager.sol";
import {IERC20TokenStakingManager} from "./interfaces/IERC20TokenStakingManager.sol";
import {IERC20Mintable} from "./interfaces/IERC20Mintable.sol";
import {ICMInitializable} from "@utilities/ICMInitializable.sol";
import {SafeERC20TransferFrom} from "@utilities/SafeERC20TransferFrom.sol";
Expand Down
2 changes: 0 additions & 2 deletions contracts/validator-manager/NativeTokenStakingManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ pragma solidity 0.8.25;

import {PoSValidatorManager} from "./PoSValidatorManager.sol";
import {PoSValidatorManagerSettings} from "./interfaces/IPoSValidatorManager.sol";
import {ValidatorRegistrationInput} from "./interfaces/IValidatorManager.sol";
import {INativeTokenStakingManager} from "./interfaces/INativeTokenStakingManager.sol";
import {INativeMinter} from
"@avalabs/[email protected]/contracts/interfaces/INativeMinter.sol";
import {ICMInitializable} from "@utilities/ICMInitializable.sol";
Expand Down
4 changes: 1 addition & 3 deletions contracts/validator-manager/PoAValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
pragma solidity 0.8.25;

import {
ValidatorManagerSettings,
ValidatorRegistrationInput
ValidatorManagerSettings
} from "./interfaces/IValidatorManager.sol";
import {IPoAValidatorManager} from "./interfaces/IPoAValidatorManager.sol";
import {ICMInitializable} from "@utilities/ICMInitializable.sol";
import {OwnableUpgradeable} from
"@openzeppelin/[email protected]/access/OwnableUpgradeable.sol";
Expand Down
1 change: 0 additions & 1 deletion contracts/validator-manager/PoSValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {
} from "./interfaces/IPoSValidatorManager.sol";
import {
Validator,
ValidatorRegistrationInput,
ValidatorStatus
} from "./interfaces/IValidatorManager.sol";
import {IRewardCalculator} from "./interfaces/IRewardCalculator.sol";
Expand Down
5 changes: 1 addition & 4 deletions contracts/validator-manager/ValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,10 @@ pragma solidity 0.8.25;

import {ValidatorMessages} from "./ValidatorMessages.sol";
import {
InitialValidator,
IValidatorManager,
PChainOwner,
ConversionData,
Validator,
ValidatorChurnPeriod,
ValidatorManagerSettings,
ValidatorRegistrationInput,
ValidatorStatus
} from "./interfaces/IValidatorManager.sol";
import {
Expand All @@ -26,6 +22,7 @@ import {ContextUpgradeable} from
import {Initializable} from
"@openzeppelin/[email protected]/proxy/utils/Initializable.sol";
import {IACP99SecurityModule} from "./interfaces/IACP99SecurityModule.sol";
import {ValidatorRegistrationInput, ConversionData, PChainOwner, InitialValidator} from "./interfaces/IACP99ValidatorManager.sol";

/**
* @dev Implementation of the {IValidatorManager} interface.
Expand Down
2 changes: 1 addition & 1 deletion contracts/validator-manager/ValidatorMessages.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
// SPDX-License-Identifier: Ecosystem
pragma solidity 0.8.25;

import {PChainOwner, ConversionData} from "./interfaces/IValidatorManager.sol";
import {PChainOwner, ConversionData} from "./interfaces/IACP99ValidatorManager.sol";

/**
* @dev Packing utilities for the Warp message types used by the Validator Manager contracts, as specified in ACP-77:
Expand Down
71 changes: 71 additions & 0 deletions contracts/validator-manager/interfaces/IACP99ValidatorManager.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
// (c) 2024, Ava Labs, Inc. All rights reserved.
// See the file LICENSE for licensing terms.

// SPDX-License-Identifier: Ecosystem

pragma solidity 0.8.25;

/**
* @dev Specifies the owner of a validator's remaining balance or disable owner on the P-Chain.
* P-Chain addresses are also 20-bytes, so we use the address type to represent them.
*/
struct PChainOwner {
uint32 threshold;
address[] addresses;
}

/**
* @dev Specifies an initial validator, used in the conversion data.
*/
struct InitialValidator {
bytes nodeID;
bytes blsPublicKey;
uint64 weight;
}

/**
* @dev Description of the conversion data used to convert
* a subnet to an L1 on the P-Chain.
* This data is the pre-image of a hash that is authenticated by the P-Chain
* and verified by the Validator Manager.
*/
struct ConversionData {
bytes32 subnetID;
bytes32 validatorManagerBlockchainID;
address validatorManagerAddress;
InitialValidator[] initialValidators;
}

/**
* @dev Specifies a validator to register.
*/
struct ValidatorRegistrationInput {
bytes nodeID;
bytes blsPublicKey;
uint64 registrationExpiry;
PChainOwner remainingBalanceOwner;
PChainOwner disableOwner;
}

interface IACP99ValidatorManager {
function initializeValidatorSet(
ConversionData calldata conversionData,
uint32 messageIndex
) external;

function initializeValidatorRegistration(
ValidatorRegistrationInput calldata input,
uint64 weight,
bytes calldata args
) external returns (bytes32);

function completeValidatorRegistration(uint32 messageIndex) external;

function initializeEndValidation(bytes32 validationID, bytes calldata args) external;

function completeEndValidation(uint32 messageIndex) external;

function initializeValidatorWeightChange(bytes32 validationID, uint64 weight, bytes calldata args) external;

function completeValidatorWeightChange(bytes32 validationID, bytes calldata args) external;
}

This file was deleted.

This file was deleted.

30 changes: 0 additions & 30 deletions contracts/validator-manager/interfaces/IPoAValidatorManager.sol

This file was deleted.

72 changes: 2 additions & 70 deletions contracts/validator-manager/interfaces/IValidatorManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

pragma solidity 0.8.25;

import {ConversionData} from "./IACP99ValidatorManager.sol";

/**
* @dev Validator status
*/
Expand All @@ -17,15 +19,6 @@ enum ValidatorStatus {
Invalidated
}

/**
* @dev Specifies the owner of a validator's remaining balance or disable owner on the P-Chain.
* P-Chain addresses are also 20-bytes, so we use the address type to represent them.
*/
struct PChainOwner {
uint32 threshold;
address[] addresses;
}

/**
* @dev Contains the active state of a Validator
*/
Expand Down Expand Up @@ -61,39 +54,6 @@ struct ValidatorManagerSettings {
uint8 maximumChurnPercentage;
}

/**
* @dev Description of the conversion data used to convert
* a subnet to an L1 on the P-Chain.
* This data is the pre-image of a hash that is authenticated by the P-Chain
* and verified by the Validator Manager.
*/
struct ConversionData {
bytes32 subnetID;
bytes32 validatorManagerBlockchainID;
address validatorManagerAddress;
InitialValidator[] initialValidators;
}

/**
* @dev Specifies an initial validator, used in the conversion data.
*/
struct InitialValidator {
bytes nodeID;
bytes blsPublicKey;
uint64 weight;
}

/**
* @dev Specifies a validator to register.
*/
struct ValidatorRegistrationInput {
bytes nodeID;
bytes blsPublicKey;
uint64 registrationExpiry;
PChainOwner remainingBalanceOwner;
PChainOwner disableOwner;
}

/**
* @notice Interface for Validator Manager contracts that implement Subnet-only Validator management.
*/
Expand Down Expand Up @@ -171,45 +131,17 @@ interface IValidatorManager {
bytes32 setWeightMessageID
);

/**
* @notice Verifies and sets the initial validator set for the chain through a P-Chain SubnetToL1ConversionMessage.
* @param conversionData The subnet conversion message data used to recompute and verify against the conversionID.
* @param messsageIndex The index that contains the SubnetToL1ConversionMessage Warp message containing the conversionID to be verified against the provided {ConversionData}
*/
function initializeValidatorSet(
ConversionData calldata conversionData,
uint32 messsageIndex
) external;

/**
* @notice Resubmits a validator registration message to be sent to the P-Chain.
* Only necessary if the original message can't be delivered due to validator churn.
* @param validationID The ID of the validation period being registered.
*/
function resendRegisterValidatorMessage(bytes32 validationID) external;

/**
* @notice Completes the validator registration process by returning an acknowledgement of the registration of a
* validationID from the P-Chain.
* @param messageIndex The index of the Warp message to be received providing the acknowledgement.
*/
function completeValidatorRegistration(uint32 messageIndex) external;

/**
* @notice Resubmits a validator end message to be sent to the P-Chain.
* Only necessary if the original message can't be delivered due to validator churn.
* @param validationID The ID of the validation period being ended.
*/
function resendEndValidatorMessage(bytes32 validationID) external;

/**
* @notice Completes the process of ending a validation period by receiving an acknowledgement from the P-Chain
* that the validation ID is not active and will never be active in the future. Returns the the stake associated
* with the validation.
* Note: This function can be used for successful validation periods that have been explicitly ended by calling
* {initializeEndValidation} or for validation periods that never began on the P-Chain due to the {registrationExpiry} being reached.
* @param messageIndex The index of the Warp message to be received providing the proof the validation is not active
* and never will be active on the P-Chain.
*/
function completeEndValidation(uint32 messageIndex) external;
}

0 comments on commit c77a480

Please sign in to comment.