diem_types/
validator_config.rs1use crate::{
9 account_address::AccountAddress,
10 network_address::{encrypted::EncNetworkAddress, NetworkAddress},
11};
12use diem_crypto::{
13 bls::{BLSPrivateKey, BLSPublicKey, BLSSignature},
14 ec_vrf::{EcVrfPrivateKey, EcVrfProof, EcVrfPublicKey},
15 multi_bls::{MultiBLSPrivateKey, MultiBLSPublicKey, MultiBLSSignature},
16};
17use move_core_types::move_resource::MoveResource;
18#[cfg(any(test, feature = "fuzzing"))]
19use proptest_derive::Arbitrary;
20use serde::{Deserialize, Serialize};
21
22#[derive(Debug, Deserialize, Serialize, Clone, Eq, PartialEq, Default)]
23pub struct ValidatorConfigResource {
24 pub validator_config: Option<ValidatorConfig>,
25 pub delegated_account: Option<AccountAddress>,
26 pub human_name: Vec<u8>,
27}
28
29impl MoveResource for ValidatorConfigResource {
30 const MODULE_NAME: &'static str = "ValidatorConfig";
31 const STRUCT_NAME: &'static str = "ValidatorConfig";
32}
33
34#[derive(Debug, Deserialize, Serialize, Clone, Eq, PartialEq, Default)]
35pub struct ValidatorOperatorConfigResource {
36 pub human_name: Vec<u8>,
37}
38
39impl MoveResource for ValidatorOperatorConfigResource {
40 const MODULE_NAME: &'static str = "ValidatorOperatorConfig";
41 const STRUCT_NAME: &'static str = "ValidatorOperatorConfig";
42}
43
44#[derive(Clone, Debug, Eq, PartialEq, Deserialize, Serialize)]
45#[cfg_attr(any(test, feature = "fuzzing"), derive(Arbitrary))]
46pub struct ValidatorConfig {
47 pub consensus_public_key: ConsensusPublicKey,
48 pub vrf_public_key: Option<ConsensusVRFPublicKey>,
50 pub validator_network_addresses: Vec<u8>,
52 pub fullnode_network_addresses: Vec<u8>,
54}
55
56impl ValidatorConfig {
57 pub fn new(
58 consensus_public_key: ConsensusPublicKey,
59 vrf_public_key: Option<ConsensusVRFPublicKey>,
60 validator_network_addresses: Vec<u8>,
61 fullnode_network_addresses: Vec<u8>,
62 ) -> Self {
63 ValidatorConfig {
64 consensus_public_key,
65 vrf_public_key,
66 validator_network_addresses,
67 fullnode_network_addresses,
68 }
69 }
70
71 pub fn fullnode_network_addresses(
72 &self,
73 ) -> Result<Vec<NetworkAddress>, bcs::Error> {
74 bcs::from_bytes(&self.fullnode_network_addresses)
75 }
76
77 pub fn validator_network_addresses(
78 &self,
79 ) -> Result<Vec<EncNetworkAddress>, bcs::Error> {
80 bcs::from_bytes(&self.validator_network_addresses)
81 }
82}
83
84pub type ConsensusPublicKey = BLSPublicKey;
86pub type ConsensusPrivateKey = BLSPrivateKey;
87pub type ConsensusSignature = BLSSignature;
88pub type ConsensusVRFPublicKey = EcVrfPublicKey;
89pub type ConsensusVRFPrivateKey = EcVrfPrivateKey;
90pub type ConsensusVRFProof = EcVrfProof;
91pub type MultiConsensusPublicKey = MultiBLSPublicKey;
92pub type MultiConsensusPrivateKey = MultiBLSPrivateKey;
93pub type MultiConsensusSignature = MultiBLSSignature;