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

Vesting contract #900

Merged
merged 26 commits into from
Dec 1, 2021
Merged

Vesting contract #900

merged 26 commits into from
Dec 1, 2021

Conversation

durch
Copy link
Contributor

@durch durch commented Nov 16, 2021

TODO:

  • Spec out interface
  • Special undelegation/unbonding handling due to rewards
  • Node bonding/unbonding
  • Unit tests
  • QAnet tests

@durch durch changed the title Initial interface spec Vesting contract Nov 16, 2021
@durch durch marked this pull request as ready for review November 17, 2021 12:41
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
contracts/vesting/src/contract.rs Outdated Show resolved Hide resolved
contracts/vesting/src/contract.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@jstuczyn jstuczyn left a comment

Choose a reason for hiding this comment

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

Thing that scares me the most is my arch nemesis - unbounded call for the delegations...

.gitignore Show resolved Hide resolved
common/mixnet-contract/src/msg.rs Outdated Show resolved Hide resolved
contracts/mixnet/src/contract.rs Outdated Show resolved Hide resolved
contracts/mixnet/src/transactions.rs Outdated Show resolved Hide resolved
contracts/mixnet/src/transactions.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
@durch durch changed the base branch from develop to release/1.0.0-pre1 November 29, 2021 10:42
contracts/mixnet/src/mixnodes/bonding_transactions.rs Outdated Show resolved Hide resolved
contracts/mixnet/src/mixnodes/storage.rs Outdated Show resolved Hide resolved
contracts/mixnet/src/mixnodes/storage.rs Outdated Show resolved Hide resolved
contracts/mixnet/src/mixnodes/delegation_transactions.rs Outdated Show resolved Hide resolved
contracts/vesting/src/support/tests.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
contracts/vesting/src/contract.rs Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
contracts/vesting/src/contract.rs Outdated Show resolved Hide resolved
contracts/vesting/src/contract.rs Show resolved Hide resolved
contracts/vesting/src/vesting.rs Outdated Show resolved Hide resolved
contracts/mixnet/src/mixnodes/storage.rs Outdated Show resolved Hide resolved
common/mixnet-contract/src/msg.rs Outdated Show resolved Hide resolved
@@ -42,6 +42,8 @@ pub const DEFAULT_SYBIL_RESISTANCE_PERCENT: u8 = 30;
// We'll be assuming a few more things, profit margin and cost function. Since we don't have reliable package measurement, we'll be using uptime. We'll also set the value of 1 Nym to 1 $, to be able to translate epoch costs to Nyms. We'll also assume a cost of 40$ per epoch(month), converting that to Nym at our 1$ rate translates to 40_000_000 uNyms
pub const DEFAULT_COST_PER_EPOCH: u32 = 40_000_000;

pub const VESTING_CONTRACT_ADDR: &str = "";
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you think about passing it in an InitMsg so that we wouldn't need to remember to update this constant before deployment?

Copy link
Contributor

Choose a reason for hiding this comment

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

But then... Isn't it a chicken and an egg problem? Vesting contract needs to know about mixnet contract and mixnet contract needs to know about the vesting contract...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I don't have a good take on here, we should probably do what ever feels more ergonomic, we can also put it in contract state, so that we can update it more easily

Copy link
Contributor Author

@durch durch Dec 1, 2021

Choose a reason for hiding this comment

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

I don't think we even need a vesting address here, since we control on the proxy, noone can undelegate/unbond except the proxy that did the original bonding/delegation, so there is no specific need to further gate on the vesting contract, as far as we care anyone can delegate on behalf of someone else, as long as they pay the bonding/delegation fee... This way we can have multiple vesting contracts, that implement the same interface...

contracts/mixnet/src/mixnodes/bonding_transactions.rs Outdated Show resolved Hide resolved
contracts/mixnet/src/mixnodes/bonding_transactions.rs Outdated Show resolved Hide resolved
contracts/mixnet/src/mixnodes/bonding_transactions.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting/account/vesting_account.rs Outdated Show resolved Hide resolved
contracts/vesting/src/vesting/account/vesting_account.rs Outdated Show resolved Hide resolved
@jstuczyn
Copy link
Contributor

After everything is merged, I'll definitely have another look at it all

@durch
Copy link
Contributor Author

durch commented Dec 1, 2021

I'm mostly happy here, we can probably optimize storage some more tough, although lets defer that until the testnet

@durch durch merged commit 7f8a111 into release/1.0.0-pre1 Dec 1, 2021
@durch durch deleted the vesting-staking-cointract branch December 1, 2021 14:42
durch added a commit that referenced this pull request Dec 1, 2021
* Upgraded code to be cosmwasm 1.0-beta.2 compatible (#923)

* Upgraded code to be cosmwasm 1.0-beta.2 compatible

* [ci skip] Generate TS types

Co-authored-by: jstuczyn <jstuczyn@users.noreply.github.com>

* Feature/cosmwasm plus storage (#924)

* Upgraded code to be cosmwasm 1.0-beta.2 compatible

* Added cw-storage-plus dependency

* Experimentally replaced storage for config and layers with cw plus Item

* The same for main mixnode storage

* Usingn IndexedMap for mixnodes

* Split delegations from mixnodes into separate module

* MixnodeIndex on Addr directly

* Moved namespace values to constants

* Outdated comment

* [ci skip] Generate TS types

* Removed redundant identity index on mixnodes

* IndexMap for gateways storage

* Moved total delegation into a Map

* Compiling contract code after delegation storage upgrades

Tests dont compile yet and neither, I would assume, the client code

* Delegation type cleanup

* Client fixes

* Migrated delegation tests + fixed them

* Moved Rewarding Status to rewards

* Reward pool

* Rewarding status migrated

* Made clippy happier

* Added explorer API to default workspace members

* Updated delegation types in explorer-api

* Fixed tauri wallet

Co-authored-by: jstuczyn <jstuczyn@users.noreply.github.com>

* Vesting contract (#900)

* Initial interface spec

* .gitignore

* Finalize implementation

* Correct assumptions, use wasm_execute

* Cleanup

* Track delegation balance

* Add delegation flow img

* Proper messaging from the vesting side

* Add proxy_address to RawDelegationData

* Wrap up (un)delegation

* Add proxy: Addr to MixNodeBond

* Stub in bonding/unbonding

* Migrate vesting to cosmwasm 1.0

* Rebase on top of 1.0.0-pre1

* Reimplement delegations tracking with a Map

* Migrate to cw-storage-plus

* Restructure code, add tests

* Streamline contract code, as per review

* Address review comments

* Pre-merge rebase

* Few more nits

* Few more nits

* Fix test

* cargo fmt

* Fix beta CI

Co-authored-by: Drazen Urch <durch@users.noreply.guthub.com>

Co-authored-by: Jędrzej Stuczyński <jedrzej.stuczynski@gmail.com>
Co-authored-by: jstuczyn <jstuczyn@users.noreply.github.com>
Co-authored-by: Drazen Urch <durch@users.noreply.guthub.com>
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.

None yet

3 participants