tempo_contracts/precompiles/validator_config.rs
1pub use IValidatorConfig::IValidatorConfigErrors as ValidatorConfigError;
2
3crate::sol! {
4 /// Validator config interface for managing consensus validators.
5 ///
6 /// This precompile manages the set of validators that participate in consensus.
7 /// Validators can update their own information, rotate their identity to a new address,
8 /// and the owner can manage validator status.
9 #[derive(Debug, PartialEq, Eq)]
10 #[sol(abi)]
11 interface IValidatorConfig {
12 /// Validator information
13 struct Validator {
14 bytes32 publicKey;
15 bool active;
16 uint64 index;
17 address validatorAddress;
18 /// Address where other validators can connect to this validator.
19 /// Format: `<hostname|ip>:<port>`
20 string inboundAddress;
21 /// IP address for firewall whitelisting by other validators.
22 /// Format: `<ip>:<port>` - must be an IP address, not a hostname.
23 string outboundAddress;
24 }
25
26 /// Get the complete set of validators
27 /// @return validators Array of all validators with their information
28 function getValidators() external view returns (Validator[] memory validators);
29
30 /// Add a new validator (owner only)
31 /// @param newValidatorAddress The address of the new validator
32 /// @param publicKey The validator's communication public publicKey
33 /// @param inboundAddress The validator's inbound address `<hostname|ip>:<port>` for incoming connections
34 /// @param outboundAddress The validator's outbound IP address `<ip>:<port>` for firewall whitelisting (IP only, no hostnames)
35 function addValidator(address newValidatorAddress, bytes32 publicKey, bool active, string calldata inboundAddress, string calldata outboundAddress) external;
36
37 /// Update validator information (only validator)
38 /// @param newValidatorAddress The new address for this validator
39 /// @param publicKey The validator's new communication public publicKey
40 /// @param inboundAddress The validator's inbound address `<hostname|ip>:<port>` for incoming connections
41 /// @param outboundAddress The validator's outbound IP address `<ip>:<port>` for firewall whitelisting (IP only, no hostnames)
42 function updateValidator(address newValidatorAddress, bytes32 publicKey, string calldata inboundAddress, string calldata outboundAddress) external;
43
44 /// Change validator active status (owner only)
45 /// @param validator The validator address
46 /// @param active Whether the validator should be active
47 /// @dev Deprecated: Use changeValidatorStatusByIndex to prevent front-running attacks
48 function changeValidatorStatus(address validator, bool active) external;
49
50 /// Change validator active status by index (owner only) - T1+
51 /// @param index The validator index in the validators array
52 /// @param active Whether the validator should be active
53 /// @dev Added in T1 to prevent front-running attacks where a validator changes its address
54 function changeValidatorStatusByIndex(uint64 index, bool active) external;
55
56 /// Get the owner of the precompile
57 /// @return owner The owner address
58 function owner() external view returns (address);
59
60 /// Change owner
61 /// @param newOwner The new owner address
62 function changeOwner(address newOwner) external;
63
64 /// Get the epoch at which a fresh DKG ceremony will be triggered
65 ///
66 /// @return The epoch number. The fresh DKG ceremony runs in epoch N, and epoch N+1 uses the new DKG polynomial.
67 function getNextFullDkgCeremony() external view returns (uint64);
68
69 /// Set the epoch at which a fresh DKG ceremony will be triggered (owner only)
70 ///
71 /// @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.
72 function setNextFullDkgCeremony(uint64 epoch) external;
73
74 /// Get validator address at a specific index in the validators array
75 /// @param index The index in the validators array
76 /// @return The validator address at the given index
77 function validatorsArray(uint256 index) external view returns (address);
78
79 /// Get validator information by address
80 /// @param validator The validator address to look up
81 /// @return The validator struct for the given address
82 function validators(address validator) external view returns (Validator memory);
83
84 /// Get the total number of validators
85 /// @return The count of validators
86 function validatorCount() external view returns (uint64);
87
88 // Errors
89 error Unauthorized();
90 error ValidatorAlreadyExists();
91 error ValidatorNotFound();
92 error InvalidPublicKey();
93
94 error NotHostPort(string field, string input, string backtrace);
95 error NotIpPort(string field, string input, string backtrace);
96 }
97}