Skip to content

Commit

Permalink
Governance: v3.1 (#3915)
Browse files Browse the repository at this point in the history
* Governance: Remove proposal counter (#127)

* feat: Use proposal seed instead of index

* chore: Rename and reset legacy1 to reserved1

* chore: Make Clippy happy

* chore: Fix Chat tests compilation

* Governance: Remove Realm voting proposal count (#128)

* feat: Remove Realm.voting_proposal_count

* chore: Update comments

* chore: Add tests and explicit assertions for non existing accounts

* Governance: Remove TokenOwnerRecord total_votes_count (#130)

* feat: Extend unrelinquished_votes_count to u64

* chore: Update comments and names

* chore: Update asserts

* chore: Update comments

* chore: Use u32:MAX to trim unrelinquished_votes_count

* chore: Make Clippy happy

* chore: Update versioning cleanup comments

* Governance: Active proposal count (#131)

* feat: Add active_proposal_count to Governance

* feat: Reallocate GovernanceV1 to GovernanceV2

* chore: test_create_proposal_and_migrate_v1_governance_to_v2

* chore: Cleanup code

* chore: Update comments

* chore: Use assert_is_valid_realm instead of deserializing the account

* chore: Update comments

* chore: Update comments

* chore: Check for empty account first

* chore: Update comments

* fix: Assert new account size is greater than the existing one

* Governance: Proposal deposit (#135)

* feat: Add active_proposal_count to Governance

* feat: Reallocate GovernanceV1 to GovernanceV2

* chore: test_create_proposal_and_migrate_v1_governance_to_v2

* chore: Cleanup code

* chore: Update comments

* chore: Use assert_is_valid_realm instead of deserializing the account

* chore: Update comments

* chore: Update comments

* chore: Check for empty account first

* feat: Add extra_lamports to create_and_serialize_account

* chore: Make Clippy happy

* feat: Implement Proposal security deposit

* chore: Make Clippy happy

* chore: Add proposal deposit amount tests

* feat: Implement RefundProposalDeposit

* chore: test_refund_proposal_deposit

* chore: Make Clippy happy

* chore: test_refund_proposal_deposit_with_cannot_refund_draft_proposal_error

* chore: test_refund_proposal_deposit_with_invalid_proposal_owner_record_error

* chore: test_refund_proposal_deposit_with_invalid_proposal_owner_error

* fix: Return deposit to deposit payer

* chore: Cleanup

* chore: test_refund_proposal_deposit_with_invalid_proposal_deposit_account_error

* fix: Remove unnecessary max(1) for account lamports

* Governance: Review feedback (#139)

* chore: Update active_proposal_count comment

* chore: Update account indices in process_create_proposal

* fix: Disallow u8::MAX for deposit_exempt_proposal_count

* chore: Use u64 without option for extra_lamports

* fix: Use explicit version 1 for TokenOwnerRecord migration

* chore: Update math for RealmConfigAccount::get_max_size

* fix: Flag ProposalCoolOffTimeNotSupported as legacy instead of reusing it

* Governance: Add proposal and payer to ProposalDeposit account (#141)

* feat: Add proposal and payer to ProposalDeposit account

* chore: Update tests

* feat: Use referential fields to check ProposalDeposit

* chore: Make Clippy happy

* chore: Update Proposal deposit amount comments

* chore: Update deposit amount comment

* chore: Update versions (#142)
  • Loading branch information
SebastianBor committed Dec 15, 2022
1 parent 1f58b75 commit c750e03
Show file tree
Hide file tree
Showing 62 changed files with 1,959 additions and 365 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions governance/addin-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spl-governance-addin-api"
version = "0.1.2"
version = "0.1.3"
description = "Solana Program Library Governance Addin Api"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana-program-library"
Expand All @@ -9,6 +9,6 @@ edition = "2021"

[dependencies]
borsh = "0.9.1"
spl-governance-tools= { version = "0.1.2", path ="../tools"}
spl-governance-tools= { version = "0.1.3", path ="../tools"}
solana-program = "1.14.10"

8 changes: 4 additions & 4 deletions governance/addin-mock/program/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spl-governance-addin-mock"
version = "0.1.2"
version = "0.1.3"
description = "Solana Program Library Governance Voter Weight Addin Program"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana-program-library"
Expand All @@ -21,8 +21,8 @@ serde = "1.0.127"
serde_derive = "1.0.103"
solana-program = "1.14.10"
spl-token = { version = "3.5", path = "../../../token/program", features = [ "no-entrypoint" ] }
spl-governance-addin-api= { version = "0.1.2", path ="../../addin-api"}
spl-governance-tools= { version = "0.1.2", path ="../../tools"}
spl-governance-addin-api= { version = "0.1.3", path ="../../addin-api"}
spl-governance-tools= { version = "0.1.3", path ="../../tools"}
thiserror = "1.0"


Expand All @@ -32,7 +32,7 @@ base64 = "0.13"
proptest = "1.0"
solana-program-test = "1.14.10"
solana-sdk = "1.14.10"
spl-governance-test-sdk = { version = "0.1.2", path ="../../test-sdk"}
spl-governance-test-sdk = { version = "0.1.3", path ="../../test-sdk"}


[lib]
Expand Down
12 changes: 6 additions & 6 deletions governance/chat/program/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spl-governance-chat"
version = "0.2.6"
version = "0.2.7"
description = "Solana Program Library Governance Chat Program"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana-program-library"
Expand All @@ -21,9 +21,9 @@ serde = "1.0.127"
serde_derive = "1.0.103"
solana-program = "1.14.10"
spl-token = { version = "3.5", path = "../../../token/program", features = [ "no-entrypoint" ] }
spl-governance= { version = "3.0.0", path ="../../program", features = [ "no-entrypoint" ]}
spl-governance-tools= { version = "0.1.2", path ="../../tools"}
spl-governance-addin-api= { version = "0.1.2", path ="../../addin-api"}
spl-governance= { version = "3.1.0", path ="../../program", features = [ "no-entrypoint" ]}
spl-governance-tools= { version = "0.1.3", path ="../../tools"}
spl-governance-addin-api= { version = "0.1.3", path ="../../addin-api"}
thiserror = "1.0"


Expand All @@ -33,8 +33,8 @@ base64 = "0.13"
proptest = "1.0"
solana-program-test = "1.14.10"
solana-sdk = "1.14.10"
spl-governance-test-sdk = { version = "0.1.2", path ="../../test-sdk"}
spl-governance-addin-mock = { version = "0.1.2", path ="../../addin-mock/program"}
spl-governance-test-sdk = { version = "0.1.3", path ="../../test-sdk"}
spl-governance-addin-mock = { version = "0.1.3", path ="../../addin-mock/program"}


[lib]
Expand Down
13 changes: 8 additions & 5 deletions governance/chat/program/tests/program_test/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ use spl_governance::{
},
state::{
enums::{MintMaxVoterWeightSource, VoteThreshold},
governance::{get_governance_address, GovernanceConfig},
governance::{
get_governance_address, GovernanceConfig, DEFAULT_DEPOSIT_EXEMPT_PROPOSAL_COUNT,
},
proposal::{get_proposal_address, VoteType},
realm::{get_realm_address, GoverningTokenConfigAccountArgs},
realm_config::GoverningTokenType,
Expand Down Expand Up @@ -197,7 +199,7 @@ impl GovernanceChatProgramTest {
council_vote_tipping: spl_governance::state::enums::VoteTipping::Strict,
community_veto_vote_threshold: VoteThreshold::YesVotePercentage(55),
voting_cool_off_time: 1,
reserved: 0,
deposit_exempt_proposal_count: DEFAULT_DEPOSIT_EXEMPT_PROPOSAL_COUNT,
};

let token_owner_record_address = get_token_owner_record_address(
Expand Down Expand Up @@ -259,8 +261,9 @@ impl GovernanceChatProgramTest {
let proposal_name = "Proposal #1".to_string();
let description_link = "Proposal Description".to_string();
let options = vec!["Yes".to_string()];
let proposal_index: u32 = 0;

let use_deny_option = true;
let proposal_seed = Pubkey::new_unique();

let create_proposal_ix = create_proposal(
&self.governance_program_id,
Expand All @@ -276,7 +279,7 @@ impl GovernanceChatProgramTest {
VoteType::SingleChoice,
options,
use_deny_option,
proposal_index,
&proposal_seed,
);

self.bench
Expand All @@ -288,7 +291,7 @@ impl GovernanceChatProgramTest {
&self.governance_program_id,
&governance_address,
&governing_token_mint_keypair.pubkey(),
&proposal_index.to_le_bytes(),
&proposal_seed,
);

ProposalCookie {
Expand Down
10 changes: 5 additions & 5 deletions governance/program/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spl-governance"
version = "3.0.0"
version = "3.1.0"
description = "Solana Program Library Governance Program"
authors = ["Solana Maintainers <maintainers@solana.foundation>"]
repository = "https://github.com/solana-labs/solana-program-library"
Expand All @@ -21,8 +21,8 @@ serde = "1.0.130"
serde_derive = "1.0.103"
solana-program = "1.14.10"
spl-token = { version = "3.5", path = "../../token/program", features = [ "no-entrypoint" ] }
spl-governance-tools= { version = "0.1.2", path ="../tools"}
spl-governance-addin-api= { version = "0.1.2", path ="../addin-api"}
spl-governance-tools= { version = "0.1.3", path ="../tools"}
spl-governance-addin-api= { version = "0.1.3", path ="../addin-api"}
thiserror = "1.0"

[dev-dependencies]
Expand All @@ -31,8 +31,8 @@ base64 = "0.13"
proptest = "1.0"
solana-program-test = "1.14.10"
solana-sdk = "1.14.10"
spl-governance-test-sdk = { version = "0.1.2", path ="../test-sdk"}
spl-governance-addin-mock = { version = "0.1.2", path ="../addin-mock/program"}
spl-governance-test-sdk = { version = "0.1.3", path ="../test-sdk"}
spl-governance-addin-mock = { version = "0.1.3", path ="../addin-mock/program"}


[lib]
Expand Down
26 changes: 23 additions & 3 deletions governance/program/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,9 +255,9 @@ pub enum GovernanceError {
#[error("Given VoteWeightSource is not supported")]
VoteWeightSourceNotSupported, // 559

/// GoverningTokenMint not allowed to vote
#[error("GoverningTokenMint not allowed to vote")]
GoverningTokenMintNotAllowedToVote, // 560
/// Legacy1
#[error("Legacy1")]
Legacy1, // 560

/// Governance PDA must sign
#[error("Governance PDA must sign")]
Expand Down Expand Up @@ -442,6 +442,26 @@ pub enum GovernanceError {
/// Vote not allowed in cool off time
#[error("Vote not allowed in cool off time")]
VoteNotAllowedInCoolOffTime, // 606

/// Cannot refund ProposalDeposit
#[error("Cannot refund ProposalDeposit")]
CannotRefundProposalDeposit, // 607

///Invalid Proposal for ProposalDeposit
#[error("Invalid Proposal for ProposalDeposit")]
InvalidProposalForProposalDeposit, // 608

/// Invalid deposit_exempt_proposal_count
#[error("Invalid deposit_exempt_proposal_count")]
InvalidDepositExemptProposalCount, // 609

/// GoverningTokenMint not allowed to vote
#[error("GoverningTokenMint not allowed to vote")]
GoverningTokenMintNotAllowedToVote, // 610

///Invalid deposit Payer for ProposalDeposit
#[error("Invalid deposit Payer for ProposalDeposit")]
InvalidDepositPayerForProposalDeposit, // 611
}

impl PrintProgramError for GovernanceError {
Expand Down

0 comments on commit c750e03

Please sign in to comment.