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

Two-step ownership transfer for staking contracts #597

Merged
merged 10 commits into from
Jan 2, 2023

Conversation

0xekez
Copy link
Contributor

@0xekez 0xekez commented Dec 29, 2022

this implements a two-step ownership transfer for all of our staking contracts using the cw_ownable crate.

for each contract in staking/*:

  1. the manager is removed
  2. cw_ownable integrated
  3. migration from version one to two is implemented

it is my opinion that having a contract-level owner and CosmWasm-level admin that is a DAO has approximately the same semantics as having an owner and a manager. assuming the admin is a DAO, and the owner an operations multisig:

the operations multisig has the ability to update unstaking durations, but does not have the ability to update the admin. the admin has the ability to remove the operations multisig and migrate the contract.

that sentence could be reused in a situation where there is an owner, manager, and admin and still be accurate.

@0xekez 0xekez force-pushed the zeke/reward-distributor-two-step branch from ba89423 to f7c7d0c Compare December 29, 2022 22:46
@codecov-commenter
Copy link

codecov-commenter commented Dec 29, 2022

Codecov Report

Base: 95.08% // Head: 95.31% // Increases project coverage by +0.22% 🎉

Coverage data is based on head (2488614) compared to base (1c15e58).
Patch coverage: 93.50% of modified lines in pull request are covered.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #597      +/-   ##
==========================================
+ Coverage   95.08%   95.31%   +0.22%     
==========================================
  Files          41       41              
  Lines        3782     3732      -50     
==========================================
- Hits         3596     3557      -39     
+ Misses        186      175      -11     
Impacted Files Coverage Δ
...acts/voting/dao-voting-cw20-staked/src/contract.rs 93.85% <ø> (ø)
contracts/staking/cw20-stake/src/contract.rs 90.30% <87.50%> (+2.19%) ⬆️
...taking/cw20-stake-external-rewards/src/contract.rs 98.06% <95.83%> (+1.41%) ⬆️
...king/cw20-stake-reward-distributor/src/contract.rs 99.15% <100.00%> (-0.01%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

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

@github-actions
Copy link

github-actions bot commented Dec 29, 2022

Cosm-Orc Gas Usage

Contract Op Name Gas Used Old Gas Used Gas Diff File
cw20_stake Store__Store 3918184 3693999 +6.0689% ci/integration-tests/src/helpers/chain.rs:97
Raw Report for 60b89b6
Contract Op Name Gas Used Gas Wanted File
cw20_base Store__Store 4180849 6248484 ci/integration-tests/src/helpers/chain.rs:97
cw20_base Execute__exc_stake_stake_tokens 234536 320952 ci/integration-tests/src/tests/cw20_stake_test.rs:76
cw20_stake Store__Store 3918184 5854487 ci/integration-tests/src/helpers/chain.rs:97
cw20_stake_external_rewards Store__Store 3332066 4975310 ci/integration-tests/src/helpers/chain.rs:97
cw20_stake_reward_distributor Store__Store 2816213 4201530 ci/integration-tests/src/helpers/chain.rs:97
cw4_group Store__Store 2783570 4152566 ci/integration-tests/src/helpers/chain.rs:97
cw721_base Store__Store 3369402 5031314 ci/integration-tests/src/helpers/chain.rs:97
cw721_base Instantiate__instantiate_cw721_base 164837 224540 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:22
cw721_base Execute__mint_nft 140542 188097 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:87
cw721_base Execute__stake_nft 234591 329168 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:70
cw_admin_factory Store__Store 2003453 2982390 ci/integration-tests/src/helpers/chain.rs:97
cw_token_swap Store__Store 2365061 3524802 ci/integration-tests/src/helpers/chain.rs:97
dao_core Store__Store 5668751 8480337 ci/integration-tests/src/helpers/chain.rs:97
dao_core Execute__exc_items_rm 192820 266513 ci/integration-tests/src/tests/cw_core_test.rs:171
dao_core Execute__exc_items_set 194488 269013 ci/integration-tests/src/tests/cw_core_test.rs:136
dao_core Instantiate__exc_items_create_dao 1277715 1893773 ci/integration-tests/src/helpers/helper.rs:98
dao_core Instantiate__inst_admin_create_dao 1277715 1893773 ci/integration-tests/src/helpers/helper.rs:98
dao_core Instantiate__inst_dao_no_admin 1276665 1892198 ci/integration-tests/src/helpers/helper.rs:98
dao_core Instantiate__exc_stake_create_dao 1276641 1892162 ci/integration-tests/src/helpers/helper.rs:98
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 1276665 1892198 ci/integration-tests/src/helpers/helper.rs:98
dao_core Instantiate__exc_admin_msgs_create_dao_with_admin 1277715 1893773 ci/integration-tests/src/helpers/helper.rs:98
dao_pre_propose_approval_single Store__Store 4903233 7332060 ci/integration-tests/src/helpers/chain.rs:97
dao_pre_propose_approver Store__Store 3659835 5466963 ci/integration-tests/src/helpers/chain.rs:97
dao_pre_propose_multiple Store__Store 4233291 6327147 ci/integration-tests/src/helpers/chain.rs:97
dao_pre_propose_single Store__Store 4154927 6209601 ci/integration-tests/src/helpers/chain.rs:97
dao_proposal_multiple Store__Store 6360832 9518459 ci/integration-tests/src/helpers/chain.rs:97
dao_proposal_single Store__Store 6661184 9968987 ci/integration-tests/src/helpers/chain.rs:97
dao_voting_cw20_staked Store__Store 3608407 5389821 ci/integration-tests/src/helpers/chain.rs:97
dao_voting_cw4 Store__Store 2670847 3983481 ci/integration-tests/src/helpers/chain.rs:97
dao_voting_cw721_staked Store__Store 3327711 4968777 ci/integration-tests/src/helpers/chain.rs:97
dao_voting_cw721_staked Execute__claim_nfts 5710869 8543393 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:120
dao_voting_cw721_staked Instantiate__instantiate_dao_voting_cw721_staked 178406 244893 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:49
dao_voting_cw721_staked Execute__unstake_nfts 230319 322760 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:105
dao_voting_native_staked Store__Store 2960295 4417649 ci/integration-tests/src/helpers/chain.rs:97
multiple_contracts Execute__batch_cw721_stake_max_claims 4196439 6254235 ci/integration-tests/src/tests/dao_voting_cw721_staked_test.rs:251

Copy link
Member

@JakeHartnell JakeHartnell left a comment

Choose a reason for hiding this comment

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

Nice to see @larry0x's cw-ownership in use. ❤️

@0xekez
Copy link
Contributor Author

0xekez commented Dec 30, 2022

let's wait for this before landing this PR as we'll have to update the initialization call: larry0x/cw-plus-plus#7

@larry0x
Copy link

larry0x commented Dec 30, 2022

@0xekez i’ve merged it. Will make a new release a bit later

@0xekez 0xekez force-pushed the zeke/reward-distributor-two-step branch from 6cf275c to 92b8be6 Compare January 1, 2023 18:47
@0xekez 0xekez changed the title cw20-stake-external-rewards two-step ownership transfer. Two-step ownership transfer for staking contracts Jan 1, 2023
@0xekez 0xekez force-pushed the zeke/reward-distributor-two-step branch from ac585d5 to 2e7980f Compare January 2, 2023 19:04
@0xekez
Copy link
Contributor Author

0xekez commented Jan 2, 2023

pre-empting some review: i understand that there is some less-than-dry code in these changes, specifically:

  1. execute_update_ownership
  2. tests for ownership transfers
  3. migration version checks

the code that is duplicated is so simple and brief, that imo it is more readable just written out each time instead of hiding it behind a level of indirection and an abstraction.

@0xekez 0xekez linked an issue Jan 2, 2023 that may be closed by this pull request
Copy link
Member

@JakeHartnell JakeHartnell left a comment

Choose a reason for hiding this comment

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

Really nice to clean this up. ❤️

@0xekez 0xekez merged commit 1673241 into main Jan 2, 2023
@0xekez 0xekez deleted the zeke/reward-distributor-two-step branch January 2, 2023 23:20
JakeHartnell pushed a commit that referenced this pull request Dec 13, 2023
Add context to multitest execution errors
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.

Implement two step ownership transfers for contracts with an admin
5 participants