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

Add support for permanent locked vesting accounts #8520

Merged
merged 19 commits into from
Apr 21, 2021

Conversation

clevinson
Copy link
Contributor

@clevinson clevinson commented Feb 5, 2021

Description

closes: #8283

While the SDK currently supports 3 different types of vesting accounts (delayed, continuous, periodic), it only exposes one Msg for creating vesting accounts, parameterized by a delayed boolean, which either creates a "delayed" or "continuous" vesting account.

After speaking with @aaronc about this today, I've realized that we don't actually need sdk.Msg support for creation of PermanentLockedVestingAccount. We discussed a bit the issues with the current vesting logic (as described in #8528), and as a result, i'd like to proceed with the most minimal solution in this PR.

This simply adds support for a new PermanentLockedVestingAccount type. There shouldn't really be any need for creating these accounts after genesis (as @aaronc noted below). In Regen's own use case, we will setup these accounts to hold locked funds of a Group account (for our Community Staking DAOs), and even with these DAOs not fully realized at genesis, we can instantiate the relevant group accounts and correpsonding PermanentLockedVestingAccounts at genesis.


Before we can merge this PR, please make sure that all the following items have been
checked off. If any of the checklist items are not applicable, please leave them but
write a little note why.

  • Targeted PR against correct branch (see CONTRIBUTING.md)
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
  • Code follows the module structure standards.
  • Wrote unit and integration tests
  • Updated relevant documentation (docs/) or specification (x/<module>/spec/)
  • Added relevant godoc comments.
  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md
  • Re-reviewed Files changed in the Github PR explorer
  • Review Codecov Report in the comment section below once CI passes

@aaronc
Copy link
Member

aaronc commented Feb 5, 2021

Not sure we even need to create this sort of thing after genesis, but maybe... Also I'd like to see a more generic way to deal with vesting eventually but that's out of scope.

@clevinson
Copy link
Contributor Author

@aaronc As it currently stands (on the Regen side atleast), we will not have our Community Staking DAOs setup prior to genesis. It's been my understanding that Regen Foundation would hold all tokens for community staking dao's, and distribute them as the organizations are brought onboard (after mainnet).

@clevinson
Copy link
Contributor Author

@aaronc I've updated this to remove the Msg support. Let's just stick with setting these up with Group accounts for now. I've updated the description in this PR accordingly.

@clevinson clevinson marked this pull request as ready for review February 6, 2021 03:12
@codecov
Copy link

codecov bot commented Feb 9, 2021

Codecov Report

Merging #8520 (1755c6f) into master (9fd866e) will increase coverage by 0.01%.
The diff coverage is 90.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #8520      +/-   ##
==========================================
+ Coverage   58.80%   58.82%   +0.01%     
==========================================
  Files         583      583              
  Lines       32749    32769      +20     
==========================================
+ Hits        19258    19275      +17     
- Misses      11214    11216       +2     
- Partials     2277     2278       +1     
Impacted Files Coverage Δ
x/auth/vesting/types/vesting_account.go 88.23% <87.50%> (-0.60%) ⬇️
x/auth/vesting/types/codec.go 100.00% <100.00%> (ø)

@clevinson clevinson requested a review from amaury1093 February 17, 2021 17:31
proto/cosmos/vesting/v1beta1/tx.proto Outdated Show resolved Hide resolved
x/auth/vesting/types/vesting_account.go Outdated Show resolved Hide resolved
x/auth/vesting/types/vesting_account_test.go Outdated Show resolved Hide resolved
x/auth/vesting/types/vesting_account_test.go Outdated Show resolved Hide resolved
x/auth/vesting/types/vesting_account.go Outdated Show resolved Hide resolved
x/auth/vesting/types/vesting_account.go Outdated Show resolved Hide resolved
x/auth/vesting/types/vesting_account.go Outdated Show resolved Hide resolved
x/auth/vesting/types/vesting_account.go Outdated Show resolved Hide resolved

// require that all vested coins (50%) are spendable plus any received
lockedCoins = cva.LockedCoins(now.Add(12 * time.Hour))
require.Equal(t, sdk.Coins{sdk.NewInt64Coin(feeDenom, 500), sdk.NewInt64Coin(stakeDenom, 50)}, lockedCoins)
}
Copy link
Member

Choose a reason for hiding this comment

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

Why were these deleted?

Copy link
Contributor

@amaury1093 amaury1093 Apr 13, 2021

Choose a reason for hiding this comment

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

They are copy-pasted from 4 lines above.

x/auth/vesting/types/vesting_account_test.go Show resolved Hide resolved
x/auth/vesting/types/vesting_account_test.go Show resolved Hide resolved
x/auth/vesting/types/vesting_account_test.go Outdated Show resolved Hide resolved
x/auth/vesting/types/vesting_account_test.go Outdated Show resolved Hide resolved
amaury1093 and others added 7 commits April 13, 2021 14:21
Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Aaron Craelius <aaron@regen.network>
Co-authored-by: Aaron Craelius <aaron@regen.network>
…m/cosmos/cosmos-sdk into clevinson/permanent-vesting-account
@@ -5,6 +5,5 @@ import (
)

var (
app = simapp.Setup(false)
appCodec = simapp.MakeTestEncodingConfig().Marshaler
Copy link
Contributor

Choose a reason for hiding this comment

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

unused var

@amaury1093
Copy link
Contributor

amaury1093 commented Apr 13, 2021

This PR is r4r again. Would appreciate if @clevinson, @aaronc and @alexanderbez could have a look 🙏

proto/cosmos/vesting/v1beta1/vesting.proto Outdated Show resolved Hide resolved
option (gogoproto.goproto_getters) = false;
option (gogoproto.goproto_stringer) = false;

BaseVestingAccount base_vesting_account = 1 [(gogoproto.embed) = true];
Copy link
Collaborator

Choose a reason for hiding this comment

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

we don't need to repeat type name in the attribute name. How about base_account?

Copy link
Contributor

Choose a reason for hiding this comment

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

I changed PermanentLockedVestingAccount to PermanentLockedAccount, but I disagree with this one: BaseVestingAccount has a field BaseAccount. I dont want to do permanentAccount.BaseAccount.BaseAccount.*

x/auth/vesting/types/vesting_account.go Show resolved Hide resolved
x/auth/vesting/types/vesting_account.go Outdated Show resolved Hide resolved
@amaury1093
Copy link
Contributor

In the latest commits, I changed:

  • the semantics of EndTime: 0 means no end time, not -1
  • rename PermanentLockedVestingAccount to PermanentLockedAccount

@robert-zaremba lmk if that lgty.

@amaury1093 amaury1093 added the A:automerge Automatically merge PR once all prerequisites pass. label Apr 21, 2021
@mergify mergify bot merged commit 603e895 into master Apr 21, 2021
@mergify mergify bot deleted the clevinson/permanent-vesting-account branch April 21, 2021 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A:automerge Automatically merge PR once all prerequisites pass.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Permanently Locked Vesting Accounts
6 participants