Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dao voting cw4 cleanup #691

Merged
merged 6 commits into from
Jun 14, 2023
Merged

Dao voting cw4 cleanup #691

merged 6 commits into from
Jun 14, 2023

Conversation

JakeHartnell
Copy link
Member

Closes #675

@codecov-commenter
Copy link

codecov-commenter commented Apr 3, 2023

Codecov Report

Patch coverage: 96.00% and project coverage change: +0.12 🎉

Comparison is base (9261bb3) 93.82% compared to head (ae9600a) 93.94%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #691      +/-   ##
==========================================
+ Coverage   93.82%   93.94%   +0.12%     
==========================================
  Files          60       60              
  Lines        5149     5189      +40     
==========================================
+ Hits         4831     4875      +44     
+ Misses        318      314       -4     
Impacted Files Coverage Δ
contracts/voting/dao-voting-cw4/src/contract.rs 94.18% <96.00%> (-1.31%) ⬇️

... and 21 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@github-actions
Copy link

github-actions bot commented Apr 3, 2023

Cosm-Orc Gas Usage

Contract Op Name Gas Used Old Gas Used Gas Diff File
cw721_base Instantiate__instantiate_cw721_base 166518 164837 +1.0198% ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:22
cw721_base Store__Store 3975657 3369402 +17.9930% ci/integration-tests/src/helpers/chain.rs:98
dao_voting_cw4 Store__Store 2613465 2684822 -2.6578% ci/integration-tests/src/helpers/chain.rs:98
Raw Report for ae9600a
Contract Op Name Gas Used Gas Wanted File
dao_core Instantiate__inst_admin_create_dao 1276299 1891644 ci/integration-tests/src/helpers/helper.rs:101
dao_core Instantiate__exc_stake_create_dao 1275225 1890033 ci/integration-tests/src/helpers/helper.rs:101
dao_core Execute__exc_admin_msgs_pause_dao 194613 269202 ci/integration-tests/src/tests/cw_core_test.rs:76
dao_core Instantiate__exc_admin_msgs_create_dao 1275249 1890069 ci/integration-tests/src/helpers/helper.rs:101
dao_core Instantiate__exc_admin_msgs_create_dao_with_admin 1276299 1891644 ci/integration-tests/src/helpers/helper.rs:101
dao_core Execute__exc_items_rm 192820 266513 ci/integration-tests/src/tests/cw_core_test.rs:171
dao_core Execute__exc_items_set 194487 269013 ci/integration-tests/src/tests/cw_core_test.rs:136
dao_core Instantiate__exc_items_create_dao 1276299 1891644 ci/integration-tests/src/helpers/helper.rs:101
dao_core Instantiate__create_dao 1275249 1890069 ci/integration-tests/src/helpers/helper.rs:101
dao_core Store__Store 6177688 9243743 ci/integration-tests/src/helpers/chain.rs:98
dao_core Instantiate__inst_dao_no_admin 1275249 1890069 ci/integration-tests/src/helpers/helper.rs:101
cw20_base Execute__exc_stake_stake_tokens 234536 320952 ci/integration-tests/src/tests/cw20_stake_test.rs:76
cw20_base Execute__cw20_base_increase_allowance 142201 190586 ci/integration-tests/src/helpers/helper.rs:216
cw20_base Execute__send_and_stake_cw20 234267 328683 ci/integration-tests/src/helpers/helper.rs:180
cw20_base Store__Store 4180849 6248484 ci/integration-tests/src/helpers/chain.rs:98
cw721_base Instantiate__instantiate_cw721_base 166518 227061 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:22
cw721_base Execute__mint_nft 140715 188355 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:93
cw721_base Execute__stake_nft 234591 329169 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:76
cw721_base Store__Store 3975657 5940696 ci/integration-tests/src/helpers/chain.rs:98
dao_pre_propose_single Execute__pre_propose_propose 1806420 2686818 ci/integration-tests/src/helpers/helper.rs:235
dao_pre_propose_single Store__Store 4168135 6229413 ci/integration-tests/src/helpers/chain.rs:98
dao_proposal_single Execute__dao_proposal_single_vote 5992046 8965184 ci/integration-tests/src/helpers/helper.rs:285
dao_proposal_single Store__Store 6674821 9989442 ci/integration-tests/src/helpers/chain.rs:98
cw_vesting Execute__delegate 206743 287399 ci/integration-tests/src/tests/cw_vesting_test.rs:103
cw_vesting Execute__undelegate 251835 332390 ci/integration-tests/src/tests/cw_vesting_test.rs:142
cw_vesting Execute__withdraw_reward 191362 264323 ci/integration-tests/src/tests/cw_vesting_test.rs:124
cw_vesting Instantiate__instantiate 227547 318603 ci/integration-tests/src/tests/cw_vesting_test.rs:59
cw_vesting Store__Store 4236619 6332139 ci/integration-tests/src/helpers/chain.rs:98
dao_voting_cw721_staked Execute__unstake_nfts 230319 322761 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:111
dao_voting_cw721_staked Instantiate__instantiate_dao_voting_cw721_staked 178857 245570 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:49
dao_voting_cw721_staked Store__Store 3346379 4996779 ci/integration-tests/src/helpers/chain.rs:98
dao_voting_cw721_staked Execute__claim_nfts 5710869 8543408 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:126
cw20_stake Store__Store 3956612 5912129 ci/integration-tests/src/helpers/chain.rs:98
cw20_stake_external_rewards Store__Store 3350045 5002278 ci/integration-tests/src/helpers/chain.rs:98
cw20_stake_reward_distributor Store__Store 2841017 4238736 ci/integration-tests/src/helpers/chain.rs:98
cw4_group Store__Store 2783570 4152566 ci/integration-tests/src/helpers/chain.rs:98
cw_admin_factory Store__Store 2019807 3006921 ci/integration-tests/src/helpers/chain.rs:98
cw_fund_distributor Store__Store 3365619 5025639 ci/integration-tests/src/helpers/chain.rs:98
cw_payroll_factory Store__Store 3696547 5522031 ci/integration-tests/src/helpers/chain.rs:98
cw_token_swap Store__Store 2382910 3551576 ci/integration-tests/src/helpers/chain.rs:98
dao_migrator Store__Store 5126339 7666719 ci/integration-tests/src/helpers/chain.rs:98
dao_pre_propose_approval_single Store__Store 4916480 7351931 ci/integration-tests/src/helpers/chain.rs:98
dao_pre_propose_approver Store__Store 3674720 5489291 ci/integration-tests/src/helpers/chain.rs:98
dao_pre_propose_multiple Store__Store 4246655 6347193 ci/integration-tests/src/helpers/chain.rs:98
dao_proposal_condorcet Store__Store 4635150 6929931 ci/integration-tests/src/helpers/chain.rs:98
dao_proposal_multiple Store__Store 6472801 9686412 ci/integration-tests/src/helpers/chain.rs:98
dao_voting_cw20_staked Store__Store 3626321 5416692 ci/integration-tests/src/helpers/chain.rs:98
dao_voting_cw4 Store__Store 2613465 3897408 ci/integration-tests/src/helpers/chain.rs:98
dao_voting_native_staked Store__Store 2988099 4459359 ci/integration-tests/src/helpers/chain.rs:98
multiple_contracts Execute__batch_cw721_stake_max_claims 4198001 6256577 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:257

}
GroupContract::Existing { address } => {
let group_contract = deps.api.addr_validate(&address)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could something go wrong here if the address is valid but does not point to a valid GroupContract?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. @0xekez, any ideas for validation here?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without providing any additional data, I guess you can query ListMembers with limit: 1, and verify the response is valid format (MemberListResponse { members }) and not empty?
This will:

  1. Verify the contract have ListMembers query with the right response format
  2. Verify the members list is not empty

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it would be nice to use a similar pattern as with UncheckedDepositInfo and CheckedDepositInfo in dao-voting module to validate the group contract

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the conclusion on this? I think some minimal verification is best to at least try and catch some obvious user errors

Copy link
Collaborator

@Art3miX Art3miX left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good! Just got 1 question

What about admin of existing cw4-group?
When creating new group you set it to be the DAO, maybe this contract should verify that the DAO is the admin or its not set?

}
GroupContract::Existing { address } => {
let group_contract = deps.api.addr_validate(&address)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without providing any additional data, I guess you can query ListMembers with limit: 1, and verify the response is valid format (MemberListResponse { members }) and not empty?
This will:

  1. Verify the contract have ListMembers query with the right response format
  2. Verify the members list is not empty

@JakeHartnell
Copy link
Member Author

What about admin of existing cw4-group?
When creating new group you set it to be the DAO, maybe this contract should verify that the DAO is the admin or its not set?

Good question! IMO this should not be enforced. What about things like SubDAOs where a certain groups contract may be used across multiple SubDAOs?

That said, folks should exercise caution when using existing contracts if they don't understand who controls them. Feel this should be more of a UX thing.

@JakeHartnell JakeHartnell force-pushed the dao-voting-cw4-cleanup branch from 732fb0a to 4f94ef8 Compare May 15, 2023 21:13
nightly broke a bunch of linting stuff, we should probably be using stable
@JakeHartnell JakeHartnell changed the base branch from main to development May 23, 2023 19:20
Comment on lines +94 to +100
pub fn execute(
_deps: DepsMut,
_env: Env,
_info: MessageInfo,
_msg: ExecuteMsg,
) -> Result<Response, ContractError> {
Err(ContractError::NoExecute {})
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Complains no tests, I guess you can just add a simple test that trying to execute something errors?
should be a good reminder in the future to add test if execute msgs are added as well

}
GroupContract::Existing { address } => {
let group_contract = deps.api.addr_validate(&address)?;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whats the conclusion on this? I think some minimal verification is best to at least try and catch some obvious user errors

Copy link
Contributor

@onewhiskeypls onewhiskeypls left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

untested ACK: lgtm.

just 2 things came up:

  1. note: I attempted to compile and test; however, I ran in to this error. It may be an environment issue on my machine, but I wanted to bring it up anyways:
error[E0658]: `let...else` statements are unstable
  --> /Users/whiskey/.cargo/registry/src/github.com-1ecc6299db9ec823/cw-ownable-derive-0.5.1/src/lib.rs:22:5
  1. thought: there's a test case that checks total vp at height (test_power_at_height) and it does modification of VP (see line 284 of tests.rs. If these are possible scenarios, I'd actually like to see another test that instantiates a dao with disproportionate vp -- a setup_test_case with VP's of 1, 1, 2, 0

@JakeHartnell
Copy link
Member Author

@JakeHartnell JakeHartnell merged commit ba3017b into development Jun 14, 2023
@JakeHartnell JakeHartnell deleted the dao-voting-cw4-cleanup branch June 14, 2023 19:12
JakeHartnell added a commit that referenced this pull request Jul 9, 2023
* Refactor cw4 voting

* Fix up tests and bugs

* Add test for using an existing group contract

* Update schema

* Fix clippy

* nightly -> stable for CI

nightly broke a bunch of linting stuff, we should probably be using stable
@NoahSaso NoahSaso mentioned this pull request Jul 31, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

dao-voting-cw4 maintains duplicate state, does not allow use of existing group
5 participants