Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit dc18878

Browse files
authored
Governance: Maintenance update (#3832)
* chore: Add comment to unused Governance account * chore: fix typos * chore: Update comments
1 parent e0dd05f commit dc18878

File tree

7 files changed

+24
-21
lines changed

7 files changed

+24
-21
lines changed

governance/program/src/processor/process_create_realm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ pub fn process_create_realm(
8888
None
8989
};
9090

91-
// Create and serialzie RealmConfig
91+
// Create and serialize RealmConfig
9292
let realm_config_info = next_account_info(account_info_iter)?; // 10
9393

9494
// 11, 12

governance/program/src/processor/process_set_governance_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub fn process_set_governance_config(
3030

3131
let mut governance_data = get_governance_data(program_id, governance_info)?;
3232

33-
// Until we have Veto implemented it's better to allow config change as the defence of last resort against governance attacks
33+
// Until we have Veto implemented it's better to allow config change as the defense of last resort against governance attacks
3434
// Note: Config change leaves voting proposals in unpredictable state and it's DAOs responsibility
3535
// to ensure the changes are made when there are no proposals in voting state
3636
// For example changing approval quorum could accidentally make proposals to succeed which would otherwise be defeated

governance/program/src/processor/process_set_realm_config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn process_set_realm_config(
3939
return Err(GovernanceError::RealmAuthorityMustSign.into());
4040
}
4141

42-
// Until we have Veto implemented it's better to allow config change as the defence of last resort against governance attacks
42+
// Until we have Veto implemented it's better to allow config change as the defense of last resort against governance attacks
4343
// Note: Config change leaves voting proposals in unpredictable state and it's DAOs responsibility
4444
// to ensure the changes are made when there are no proposals in voting state
4545
// For example changing voter-weight or max-voter-weight addin could accidentally make proposals to succeed which would otherwise be defeated

governance/program/src/processor/process_sign_off_proposal.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ pub fn process_sign_off_proposal(program_id: &Pubkey, accounts: &[AccountInfo])
2929

3030
let mut realm_data = get_realm_data(program_id, realm_info)?;
3131

32+
// Governance account data is no longer used in the current version but we still have to load it to validate Realm -> Governance -> Proposal relationship
33+
// It could be replaced with PDA check but the account is going to be needed in future versions once we support mandatory signatories
34+
// and hence keeping it as it is
3235
let _governance_data =
3336
get_governance_data_for_realm(program_id, governance_info, realm_info.key)?;
3437

governance/program/src/state/realm.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ pub struct GoverningTokenConfigArgs {
6565
pub token_type: GoverningTokenType,
6666
}
6767

68-
/// Realm Config instruction args with account parametres
68+
/// Realm Config instruction args with account parameters
6969
#[derive(Clone, Debug, PartialEq, Eq, BorshDeserialize, BorshSerialize, BorshSchema, Default)]
7070
pub struct GoverningTokenConfigAccountArgs {
7171
/// Specifies an external plugin program which should be used to provide voters weights
72-
/// for the given goventing token
72+
/// for the given governing token
7373
pub voter_weight_addin: Option<Pubkey>,
7474

7575
/// Specifies an external an external plugin program should be used to provide max voters weight
76-
/// for the given goventing token
76+
/// for the given governing token
7777
pub max_voter_weight_addin: Option<Pubkey>,
7878

7979
/// Governing token type defines how the token is used for governance power
@@ -99,12 +99,12 @@ pub enum SetRealmAuthorityAction {
9999
/// Realm Config defining Realm parameters.
100100
#[derive(Clone, Debug, PartialEq, Eq, BorshDeserialize, BorshSerialize, BorshSchema)]
101101
pub struct RealmConfig {
102-
/// Legacy field introdcued and used in V2 as use_community_voter_weight_addin: bool
102+
/// Legacy field introduced and used in V2 as use_community_voter_weight_addin: bool
103103
/// If the field is going to be reused in future version it must be taken under consideration
104104
/// that for some Realms it might be already set to 1
105105
pub legacy1: u8,
106106

107-
/// Legacy field introdcued and used in V2 as use_max_community_voter_weight_addin: bool
107+
/// Legacy field introduced and used in V2 as use_max_community_voter_weight_addin: bool
108108
/// If the field is going to be reused in future version it must be taken under consideration
109109
/// that for some Realms it might be already set to 1
110110
pub legacy2: u8,

governance/program/src/state/realm_config.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,15 +30,15 @@ pub enum GoverningTokenType {
3030

3131
/// Membership token is a token controlled by Realm authority
3232
/// Deposit - Yes, membership tokens can be deposited to gain governance power
33-
/// The membership tokens are conventionally minted into the holding account to keep them out of members possesion
33+
/// The membership tokens are conventionally minted into the holding account to keep them out of members possession
3434
/// Withdraw - No, after membership tokens are deposited they are no longer transferable and can't be withdrawn
3535
/// Revoke - Yes, Realm authority can Revoke (burn) membership tokens
3636
Membership,
3737

3838
/// Dormant token is a token which is only a placeholder and its deposits are not accepted and not used for governance power within the Realm
3939
///
4040
/// The Dormant token type is used when only a single voting population is operational. For example a Multisig starter DAO uses Council only
41-
/// and sets Community as Dormant to indicate its not utilised for any governance power.
41+
/// and sets Community as Dormant to indicate its not utilized for any governance power.
4242
/// Once the starter DAO decides to decentralise then it can change the Community token to Liquid
4343
///
4444
/// Note: When an external voter weight plugin which takes deposits of the token is used then the type should be set to Dormant
@@ -162,7 +162,7 @@ impl RealmConfigAccount {
162162
}
163163
}
164164

165-
/// Assertes the given governing token can be deposited
165+
/// Asserts the given governing token can be deposited
166166
pub fn assert_can_deposit_governing_token(
167167
&self,
168168
realm_data: &RealmV2,
@@ -175,12 +175,12 @@ impl RealmConfigAccount {
175175
match governing_token_type {
176176
GoverningTokenType::Membership | GoverningTokenType::Liquid => Ok(()),
177177
// Note: Preventing deposits of the Dormant type tokens is not a direct security concern
178-
// It only makes the intention of not using deposited tokens as governnace power stronger
178+
// It only makes the intention of not using deposited tokens as governance power stronger
179179
GoverningTokenType::Dormant => Err(GovernanceError::CannotDepositDormantTokens.into()),
180180
}
181181
}
182182

183-
/// Assertes the given governing token can be withdrawn
183+
/// Asserts the given governing token can be withdrawn
184184
pub fn assert_can_withdraw_governing_token(
185185
&self,
186186
realm_data: &RealmV2,
@@ -198,15 +198,15 @@ impl RealmConfigAccount {
198198
}
199199
}
200200

201-
/// Asserts the given RealmConfigArgs represent a valid Realm configuraiton change
201+
/// Asserts the given RealmConfigArgs represent a valid Realm configuration change
202202
pub fn assert_can_change_config(
203203
&self,
204204
realm_config_args: &RealmConfigArgs,
205205
) -> Result<(), ProgramError> {
206206
// Existing community token type can't be changed to Membership because it would
207207
// give the Realm authority the right to burn members tokens which should not be the case because the tokens belong to the members
208-
// On the other had for the Council token it's acceptable and in fact desired change becuase council tokens denote memebership
209-
// which should be controled by the Realm
208+
// On the other had for the Council token it's acceptable and in fact desired change because council tokens denote membership
209+
// which should be controlled by the Realm
210210
if self.community_token_config.token_type != GoverningTokenType::Membership
211211
&& realm_config_args.community_token_config_args.token_type
212212
== GoverningTokenType::Membership
@@ -226,8 +226,8 @@ pub fn get_realm_config_data(
226226
get_account_data::<RealmConfigAccount>(program_id, realm_config_info)
227227
}
228228

229-
/// If the account exists then desrialises it into RealmConfigAccount struct and checks the owner program and the Realm it belongs to
230-
/// If the accoutn doesn't exist then it checks its address is derived from the given owner program and Realm and returns default RealmConfigAccount
229+
/// If the account exists then deserializes it into RealmConfigAccount struct and checks the owner program and the Realm it belongs to
230+
/// If the account doesn't exist then it checks its address is derived from the given owner program and Realm and returns default RealmConfigAccount
231231
pub fn get_realm_config_data_for_realm(
232232
program_id: &Pubkey,
233233
realm_config_info: &AccountInfo,
@@ -236,7 +236,7 @@ pub fn get_realm_config_data_for_realm(
236236
let realm_config_data = if realm_config_info.data_is_empty() {
237237
// If RealmConfigAccount doesn't exist yet then validate its PDA
238238
// PDA validation is required because RealmConfigAccount might not exist for legacy Realms
239-
// and then its absense is used as default RealmConfigAccount value with no plugins and Liquid governance tokens
239+
// and then its absence is used as default RealmConfigAccount value with no plugins and Liquid governance tokens
240240
let realm_config_address = get_realm_config_address(program_id, realm);
241241

242242
if realm_config_address != *realm_config_info.key {

governance/program/src/state/token_owner_record.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ impl TokenOwnerRecordV2 {
125125
};
126126

127127
// If the weight threshold is set to u64::MAX then it indicates explicitly Disabled value
128-
// which should prevent any possiblity of using it
128+
// which should prevent any possibility of using it
129129
if min_weight_to_create_proposal == u64::MAX {
130130
return Err(GovernanceError::VoterWeightThresholdDisabled.into());
131131
}
@@ -160,7 +160,7 @@ impl TokenOwnerRecordV2 {
160160
};
161161

162162
// If the weight threshold is set to u64::MAX then it indicates explicitly Disabled value
163-
// which should prevent any possiblity of using it
163+
// which should prevent any possibility of using it
164164
if min_weight_to_create_governance == u64::MAX {
165165
return Err(GovernanceError::VoterWeightThresholdDisabled.into());
166166
}

0 commit comments

Comments
 (0)