Commit Graph

33 Commits

Author SHA1 Message Date
Dmitri Makarov 791cc8a776
Use target_os instead of target_arch for Solana conditional compilation (#3148) 2022-05-17 12:25:24 -07:00
Dmitri Makarov f1c1d440e9
Bump solana to v1.10.15 (#3176) 2022-05-17 11:27:30 -07:00
Sebastian Bor 3d3b32dcf6
Governance: Veto vote (#3156)
* chore: remove #[repr(C)]

* wip: resolve proposal governing token mint

* fix: remove optionality from veto vote

* feat: implement tipping for veto vote

* fix: move vote_threshold to the end of Proposal struct

* chore: remove use super

* chore: make clippy happy

* chore: add change log

* feat: add council_veto_vote_threshold

* fix: resolve vote threshold for voting token mint

* chore: revert old function name

* fix: calculate max veto in coerce_max_voter_weight

* chore: make clippy happy

* chore: make clippy happy

* feat: Implement RelinquishVote for Veto

* chore: update comments

* chore: rename with_cast_vote to with_cast_yes_no_vote

* chore: rename with_cast_multi_option_vote to with_cast_vote

* chore: create use_veto_vote test scenario

* chore: Add veto vote disabled tests

* chore: Add partial Veto vote tests

* chore: update comments

* chore: test_cast_veto_vote_with_no_council_error

* chore: test_relinquish_veto_vote

* chore: rename with_token_owner_record to with_community_token_owner_record

* chore: test_relinquish_veto_vote_with_vote_record_for_different_voting_mint_error

* chore: test_cast_veto_vote_with_invalid_voting_mint_error

* chore: fix chat build

* chore: test_cast_veto_vote_with_council_only_allowed_to_veto

* fix: Use VoteKind to distinguish between Veto and Electorate votes

* chore: make clippy happy

* Update change log

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* chore: rename voting_token_mint to vote_governing_token_mint

* chore: test_cast_yes_and_veto_votes_with_yes_as_winning_vote

* fix: throw error for Community veto

* chore: Update comments

* chore: Update names and commnents

* chore: split try_get_tipped_vote_state into Electorate and Veto cases

* chore: Update comments

* chore: remove #[allow(clippy::float_cmp)]

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2022-05-17 16:37:43 +01:00
Sebastian Bor 219b6a1b78
Governance: Council Vote Threshold (#3135)
* wip: Replace proposal_cool_off_time with council_vote_threshold

* wip: serialise governance vec

* wip: cool off time

* chore: create test to deserialize legacy config

* wip: default council_vote_threshold from community_vote_threshold for legacy accounts

* chore: fix chat compilation

* feat: use community_vote_threshold for voting

* feat: assert all voting thresholds are not disabled

* chore: simplify tests without config mutation

* feat: assert proposal is created for valid vote threshold

* chore: update test name

* chore: test_finalize_council_vote

* chore: test_cast_council_vote

* chore: test for disabled voter threshold

* feat: Ensure GovernanceConfig reserved buffer is always empty

* chore: change error name to AtLeastOneVoteThresholdRequired

* chore: add comments

* chore: Add VoteThreshold.Any comments
2022-05-06 17:24:46 +01:00
Sebastian Bor 3db53e278b
Governance: Rename vote_threshold_percentage to community_vote_threshold (#3132) 2022-05-02 16:15:08 +01:00
Tyera Eulberg b3fe5b6d5d
Bump token-2022 (#3113)
* Bump token-2022

* Bump solana dependencies
2022-04-26 12:15:26 -06:00
Jon Cinque 1d1c2b178b
Upgrade crates to 1.10.8 (#3076) 2022-04-11 22:25:27 +02:00
Sebastian Bor 762c584dfe
Governance: Update addin account discriminators to Anchor compatible (#3026) 2022-03-24 18:28:47 +00:00
Tyera Eulberg f4c5fdcfcf
Bump solana to v1.9.9 (#2902) 2022-02-23 16:20:55 -07:00
Sebastian Bor 11d9952937
Governance: Use correct max size for multiple instruction transaction (#2891)
* fix: use correct max size for multiple instruction transaction

* chore: add instruction to serialisation tests
2022-02-09 12:32:06 +00:00
Sebastian Bor fa1da606a7
Governance: Update release version to v2.2.2 (#2878)
* chore: Update release version to v2.2.2

* chore: Update chat version
2022-02-07 14:39:46 +00:00
Sebastian Bor 1573319244
Governance: Fix Realm deserialisation and bump create versions for V2 (#2863)
* fix: realm deserialisation

* chore: update spl-gov version for chat

* chore: update spl-governance-tools version to 0.1.2

* chore: upgrade Anchor to 0.20.1

* chore: update addin-api version

* chore: update spl-governance-test-sdk version
2022-02-04 15:42:30 +00:00
Sebastian Bor 4c0bc4c968
Governance V2 cleanup (#2855)
* chore: use exhaustive check for governance account type

* fix: realm v1 deserialisation

* chore: use exhaustive check for multiple account types

* chore:  use exhaustive check for seeds

* chore: update comments
2022-02-01 19:56:03 +00:00
Sebastian Bor ebc91e871a
Governance: add v2 account padding (#2842)
* chore: create RealmV2 account type

* feat: add padding to Realm account

* chore: move RealmConfigArgsV1 and GovernanceInstructionV1 to tests

* chore: Add RealmV2 comments

* chore: rename TokenOwnerRecord to V2 and add reserved space

* feat: translate TokenOwnerRecordV1

* chore: rename Governance to GovernanceV2

* feat: add reserved_v2 to Governance

* chore: make clippy happy

* feat: translate GovernanceV1 accounts

* chore: fix chat build

* fix: update seeds logic for governance V1 accounts

* fix: add check for RealmV1 and GovernanceV1

* chore: add padding to ProposalTransaction

* chore: add padding to VoteRecordV2

* chore: add padding to SignatoryRecord V2

* feat: translate SignatoryRecordV1 account
2022-01-31 03:58:28 +00:00
Sebastian Bor 0e85d2e3e0
Governance: Rename tokens_to_create to weight_to_create (#2839)
* chore: assert options length when serialising ProposalV1

* chore: rename tokens_to_create to weight_to_create

* fix: use saturating_sub for voting_proposal_count

* chore: update voting_proposal_count comments

* Revert "chore: update voting_proposal_count comments"

This reverts commit 3e2eb9d90afdd4f6001d17b14f9579fb72ebb895.

* Revert "fix: use saturating_sub for voting_proposal_count"

This reverts commit 5d357049b7bbc12d8ec9d46caefe3b740967fae3.
2022-01-30 22:23:11 +00:00
Sebastian Bor 851efed467
Governance: Rename AccountGovernance to Governance (#2836)
* chore: rename AccountGovernance to Governance

* chore: make governed_account optional

* chore: rename account_governance to governance
2022-01-29 18:14:27 +00:00
Christian Kamm 5850973d97
Governance: Add VoteTipping option (#2826)
* spl-governance: Add VoteTipping option

This allows two new tipping styles in addition to the previous "Strict"
mode:
- Early: Where a yes majority above the yes vote threshold will
  complete the vote, even if below 50% of total possible votes.
- Disabled: Where votes never complete early.

* address review nits
2022-01-29 18:13:18 +00:00
Sebastian Bor aefbebe3ae
Governance: Multiple instructions per proposal transaction (#2833)
* feat: support multiple instructions per proposal instruction

* chore: rename instruction to transaction

* chore: rename ProposalInstruction to ProposalTransaction

* chore: rename instruction to transaction

* chore: rename InstructionExecutionStatus to TransactionExecutionStatus

* chore: rename proposal instruction to proposal transaction

* chore: make clippy happy

* chore: update instruction names to transactions

* chore: fix compilation

* chore: rename instruction to transaction

* chore: rename instruction to transaction

* chore rename instruction to transaction

Co-authored-by: Jon Cinque jon.cinque@gmail.com
2022-01-29 12:43:22 +00:00
Sebastian Bor 0094255292
Governance: Max voter weight addin (#2815)
* chore: change voter-weight-addin to mock

* chore: fix tests

* chore: add action, target and expiry validation tests

* chore: add full target test checks

* feat: add max community voter weight adding structures

* chore: move payer to last account position

* wip: update max_community_voter_weight_addin

* chore: simplify logic to update realm config

* wip: setup addins when realm is created

* wip: setup voter weights accounts

* chore: make clippy happy

* core: fix merge

* chore: remove old readme

* chore: add SetupMaxVoterWeightRecord to addin mock

* chore: test_create_realm_with_max_voter_weight_addin test

* chore: add SetRealmConfigArgs and refactor tests

* chore: update max voter weight tests

* chore: setup cast_vote_with_max_voter_weight_addin test

* wip: get max voter weight from plugin

* chore: update comments and make clippy happy

* wip: use max voter weight to tip proposals

* chore: rename get_max_voter_weight

* chore: load addins using different ids

* chore: add tests with all addins

* fix: coerce max vote weight when cast votes are higher

* chore: add tests with all adins being used

* chore: add test for expired max voter weight record

* chore: simplify addin mock

* wip: Create addin api crate

* chore: use native build order and dependency

* chore: fix build

* feat: add reserved space to addin records

* chore: bump versions

* fix: use [u8; 8] discriminator for addin account types

* chore: update instruction comments

* chore: use saturating_sub instead of checked_sub

Co-authored-by: Jon Cinque
2022-01-29 02:08:21 +00:00
Sebastian Bor 5d330d1a74
Governance: Voter weight action & target (#2803)
* feat: add weight action and target to VoterWeightRecord

* chore: update comments

* chore: change voter-weight-addin to mock

* chore: fix tests

* chore: add action, target and expiry validation tests

* chore: add full target test checks

* chore: update comments

* chore: rename addin to addin-mock

* chore: rename voter-weight-addin to addin

* chore: fix tests
2022-01-26 17:00:00 +00:00
Sebastian Bor 56953b2286
Governance: Transfer freeze and close authorities (#2799)
* fix: transfer mint freeze authority for mint governance

* chore: update transfer_mint_authorities comments

* feat: transfer close_authority when creating token account governance

* chore: update spl-token function names

* chore: remove redundant set_spl_token_mint_authority
2022-01-25 11:02:43 +00:00
Sebastian Bor 2ae2f5f067
Governance Chat: Voter weight (#2778)
* chore: update governance chat program version to 0.2.0

* feat: support voter weight for chat

* chore: move ensure_voter_weight_addin_is_built to test sdk

* chore: add program version to logs

* fix: workaround for logs

* chore: add test for chat message using voter weight addin

* chore: remove logger overrides

Co-authored-by: Jon Cinque
2022-01-24 17:59:21 +00:00
Tyera Eulberg 83c3ffad25
Bump solana crates to v1.9.5 (#2780)
* Bump solana crates to v1.9.5

* Update sol_set_return_data type signature and un-ignore test
2022-01-21 22:52:10 -07:00
Jon Cinque 81f50127f1
token: Bump version to 3.3.0 (#2765) 2022-01-21 01:47:02 +01:00
Jon Cinque 6ee008d256
Update SDK to 1.9.2, fix warnings (#2674)
* Update SDK to 1.9.2, fix warnings

* Upgrade honggfuzz

* Use `get_latest_blockhash` correctly
2021-12-28 23:02:47 -05:00
Jon Cinque d5581dbd62
governance: Remove dependency on ProcessInstructionWithContext (#2589) 2021-11-17 15:48:01 +01:00
Sebastian Bor bf7ad18f41
Governance: vote options (#2544)
* feat: use VoteChoice instead of VoteWeight

* chore: make clippy happy

* feat: use options for ye/no vote

* feat: use choices for CastVote instruction

* chore: move Vote enum to tests

* fix: iterate overall choices for withdrawal

* chore: split ProposalOption and ProposalOptionVote

* fix: calculate multi option proposal size

* chore: split weighted and fractional vote choices

* feat: add proposal type

* feat: add reject option flag

* feat: calculate final state for proposal using options results

* chore: make clippy happy

* fix: generalise max vote weight calculation for multiple options

* feat: gate vote tipping for yes/no proposals only

* chore: make clippy happy

* feat: add option_index to instruction

* feat: move instructions to options

* chore: advance clock

* chore: add await

* chore: add multi option proposal tests

* chore: move governing_mint to account list

* feat: assert valid proposal options

* feat: assert proposal is executable when instruction is added

* chore: make clippy happy

* chore: add tests to insert instructions into multi option proposal

* chore: make clippy happy

* feat: use explicit reject_option_vote_weight

* feat: use Vote struct for vote results

* feat: validate vote

* feat: reject empty proposal options

* chore: update comments

* fix: allow execute only successful options

* chore: add assertions for option statuses

* chore: add partial success test

* chore: add full success execution test

* chore: add test for instructions execution for fully denied proposal

* feat: finalise none executable proposals into completed state

* chore: fix chat

* feat: add vote_record v1 v2 roundtrip serialization

* eat: add proposal_instruction v1 v2 roundtrip serialisation

* chore: use VoteRecordV1

* chore: use legacy structs instead of legacy crate version

* chore: rename proposal to V2

* feat: translate Proposal v1 v2 versions

* chore: make clippy happy

* chore: make clippy happy

* chore: remove unnecessary clone for match

* chore: rename get_final_vote_state to resolve_final_vote_state

* fix proposal account name

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>

* chore: fix compilation

* chore: use borsh::maybestd::io::Write

* chore: consume self in serialise instructions to avoid cloning

* chore: update comments

* feat: add N limit placeholder to multi choice vote type

* feat: increase options size to u16

* fix: use checked math

Co-authored-by: Jon Cinque <jon.cinque@gmail.com>
2021-11-11 19:34:00 +00:00
Michael Vines 9acb082dc3 Upgrade to Solana v1.8.1 2021-10-20 22:52:19 -07:00
Sebastian Bor d6d0b92ae7
Governance: Voter-weight-addin cleanup (#2512)
* chore: Ensure voter-weight-addin is built for tests

fix: build addin during test run

fix: build voter weight addin for tests using the addin only

chore: use mutex to build addin only once

chore: move build guard to separate file

chore: update governance version for chat

* chore: create tools crate for common utility functions in governance ecosystem

* chore: add test-sdk and tools readme

* chore: rename reserved addins to specific names

* chore: remove todo comment

* chore: remove unnecessary var drop

* chore: move all account tools to shared crate

* chore: fix chat compilation

* chore: move program_id to first position
2021-10-19 11:43:01 +01:00
Sebastian Bor dc7f6be034
Governance: Add deposit amount (#2485)
* feat: add amount to Deposit instruction

* feat: use try_from_slice_unchecked to support forward compatibility

* chore: make clippy happy

* chore: update comments
2021-10-13 19:59:30 +01:00
Sebastian Bor c99f4195f1
Governance: Voters weights add-in (#2450)
* feat: setup and configure voter weight addin

feat: add use_voter_weight_add_in flag to realm config

chore: use spl-governance 1.1.1 version

chore: make clippy happy

chore: add test to deserialise v1 CreateRealm instruction from v2

feat: add voter-weight-addin skeleton project

chore: build voter-weight-addin before governance

fix: temp workaround to make spl_governance_voter_weight_addin available in CI

chore: add tests with voter-weight-addin

feat: implement deposit instruction for voter weight addin

feat: add voter_weight_expiry

fix: set voter_weight_expiry

chore: restore positive execute tests

chore: restore ignored tests

wip: pass voter weight accounts to create_account_governance2

wip: read voter weight account

chore: make clippy happy

wip: add realm and validation to voter_weight deposit

fix: update addin

chore: make clippy happy

chore: fix voter_weight_record names

feat: use voter weight provided by addin when governance created

chore: update addin

chore: remove governance stake pool program

feat: remove time offset from revise

chore: fix build

feat: create RealmAddins account when realm with addin is created

chore: make clippy happy

feat: set voter weight addin using SetRealmConfig instruction

chore: make clippy happy

chore: update comments

chore: reorder SetrealmConfig accounts

chore: infer use_community_voter_weight_addin

chore: infer use_community_voter_weight_addin

chore: update voter weight addin comments

feat: use voter weight addin id from RealmAddins account

* feat: use voter weight addin to create proposal

* feat: use voter weight addin to cast vote

* chore: make clippy happy

* feat: use voter weight addin to create token governance

* feat: use voter weight addin to create mint governance

* feat: use voter weight adding to create program governance

* chore: create assert_can_withdraw_governing_tokens() helper function

* chore: fix compilation

* fix: ensure governance authority signed transaction to create governance

* feat: implement CreateTokenOwnerRecord instruction

* chore: fix chat tests

* chore: update comments

* chore: rename RealmAddins account to RealmConfig account

* chore: add more reserved space to GovernanceConfig account

* chore: update instruction comments

* chore: update comments

* chore: fix compilation

* chore: remove ignore directive for tests

* feat: panic when depositing tokens into a realm with voter weight addin

* chore: rename community_voter_weight to community_voter_weight_addin

* feat: make payer account optional for SetRealmConfig
2021-10-13 13:15:22 +01:00
Michael Vines 12732f8d5a Upgrade to Solana 1.8.0 2021-10-12 09:40:06 -07:00
Sebastian Bor b3684bbfe9
Governance: Chat program (#2319)
* chore: create test-sdk crate

* chore: create test-sdk crate

* chore: use shred test bench to run tests

* chore: scaffold governance chat program

* chore: move process_transaction to bench

* chore: add with_proposal factory function

* chore: move token utility functions to bench

* chore: create test realm

* chore: move create_token_account_with_transfer_authority to bench

* chore: create test governance

* chore: create test proposal

* feat: implement process_post_message

* chore: move get_clock to bench

* chore: add clock and message author

* chore: move get_borsh_account and get_account to bench

* feat: add reaply_to

* chore: update comments

* chore: update comments and make clippy happy

* chore: add reply to test

* chore: assert is valid replyTo chat message

* chore: add error test cases

* chore: add not enough tokens error test

* chore: update Reaction comment

* feat: assert new account is not initialised

* chore: upgrade chat version

* chore: add license

* chore: update cargo lock

* chore: fix solana version

* chore: update cargo.lock

* chore: move chat program inside governance folder
2021-09-09 15:45:01 +01:00