-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathIValidatorConfig.sol
More file actions
108 lines (92 loc) · 5.21 KB
/
IValidatorConfig.sol
File metadata and controls
108 lines (92 loc) · 5.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
// SPDX-License-Identifier: MIT OR Apache-2.0
pragma solidity >=0.8.13 <0.9.0;
/// @title IValidatorConfig - Validator Config Precompile Interface
/// @notice Interface for managing consensus validators
/// @dev This precompile manages the set of validators that participate in consensus.
/// Validators can update their own information, rotate their identity to a new address,
/// and the owner can manage validator status.
interface IValidatorConfig {
/// @notice Thrown when caller lacks authorization to perform the requested action
error Unauthorized();
/// @notice Thrown when trying to add a validator that already exists
error ValidatorAlreadyExists();
/// @notice Thrown when validator is not found
error ValidatorNotFound();
/// @notice Thrown when public key is invalid (zero)
error InvalidPublicKey();
/// @notice Thrown when inbound address is not in valid host:port format
/// @param field The field name that failed validation
/// @param input The invalid input that was provided
/// @param backtrace Additional error context
error NotHostPort(string field, string input, string backtrace);
/// @notice Thrown when outbound address is not in valid ip:port format
/// @param field The field name that failed validation
/// @param input The invalid input that was provided
/// @param backtrace Additional error context
error NotIpPort(string field, string input, string backtrace);
/// @notice Validator information
/// @param publicKey The validator's communication public key
/// @param active Whether the validator is active in consensus
/// @param index The validator's index in the validators array
/// @param validatorAddress The validator's address
/// @param inboundAddress Address where other validators can connect to this validator (format: `<hostname|ip>:<port>`)
/// @param outboundAddress IP address for firewall whitelisting by other validators (format: `<ip>:<port>`)
struct Validator {
bytes32 publicKey;
bool active;
uint64 index;
address validatorAddress;
string inboundAddress;
string outboundAddress;
}
/// @notice Get the complete set of validators
/// @return validators Array of all validators with their information
function getValidators() external view returns (Validator[] memory validators);
/// @notice Add a new validator (owner only)
/// @param newValidatorAddress The address of the new validator
/// @param publicKey The validator's communication public key
/// @param active Whether the validator should be active
/// @param inboundAddress The validator's inbound address `<hostname|ip>:<port>` for incoming connections
/// @param outboundAddress The validator's outbound IP address `<ip>:<port>` for firewall whitelisting (IP only, no hostnames)
function addValidator(
address newValidatorAddress,
bytes32 publicKey,
bool active,
string calldata inboundAddress,
string calldata outboundAddress
) external;
/// @notice Update validator information (only validator)
/// @param newValidatorAddress The new address for this validator
/// @param publicKey The validator's new communication public key
/// @param inboundAddress The validator's inbound address `<hostname|ip>:<port>` for incoming connections
/// @param outboundAddress The validator's outbound IP address `<ip>:<port>` for firewall whitelisting (IP only, no hostnames)
function updateValidator(
address newValidatorAddress,
bytes32 publicKey,
string calldata inboundAddress,
string calldata outboundAddress
) external;
/// @notice Change validator active status (owner only)
/// @param validator The validator address
/// @param active Whether the validator should be active
/// @dev Deprecated: Use changeValidatorStatusByIndex to prevent front-running attacks
function changeValidatorStatus(address validator, bool active) external;
/// @notice Change validator active status by index (owner only) - T1+
/// @param index The validator index in the validators array
/// @param active Whether the validator should be active
/// @dev Added in T1 to prevent front-running attacks where a validator changes its address
function changeValidatorStatusByIndex(uint64 index, bool active) external;
/// @notice Get the owner of the precompile
/// @return The owner address
function owner() external view returns (address);
/// @notice Change owner
/// @param newOwner The new owner address
function changeOwner(address newOwner) external;
/// @notice Get the epoch at which a fresh DKG ceremony will be triggered
///
/// @return The epoch number, or 0 if no fresh DKG is scheduled. The fresh DKG ceremony runs in epoch N, and epoch N+1 uses the new DKG polynomial.
function getNextFullDkgCeremony() external view returns (uint64);
/// @notice Set the epoch at which a fresh DKG ceremony will be triggered (owner only)
/// @param epoch The epoch in which to run the fresh DKG ceremony. Epoch N runs the ceremony, and epoch N+1 uses the new DKG polynomial.
function setNextFullDkgCeremony(uint64 epoch) external;
}