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

Separate vesting from auth, add custom vesting schedules #5040

Merged
merged 64 commits into from
Oct 10, 2019

Conversation

karzak
Copy link
Contributor

@karzak karzak commented Sep 12, 2019

Fixes #4486

Features

  • Adds a new vesting account type, PeriodicVestingAccount, which allows for arbitrary vesting schedules.

  • 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.

  • Wrote tests

  • Updated relevant documentation (docs/)

  • Added a relevant changelog entry to the Unreleased section in CHANGELOG.md

  • Re-reviewed Files changed in the github PR explorer


For Admin Use:

  • Added appropriate labels to PR (ex. wip, ready-for-review, docs)
  • Reviewers Assigned
  • Squashed all commits, uses message "Merge pull request #XYZ: [title]" (coding standards)

@karzak
Copy link
Contributor Author

karzak commented Sep 12, 2019

This is R4R, but currently blocked by #5017

@codecov
Copy link

codecov bot commented Sep 12, 2019

Codecov Report

Merging #5040 into master will decrease coverage by 0.07%.
The diff coverage is 58.52%.

@@            Coverage Diff             @@
##           master    #5040      +/-   ##
==========================================
- Coverage   54.94%   54.87%   -0.08%     
==========================================
  Files         302      300       -2     
  Lines       18357    18362       +5     
==========================================
- Hits        10087    10076      -11     
- Misses       7517     7546      +29     
+ Partials      753      740      -13

x/auth/vesting/types/vesting_account.go Outdated Show resolved Hide resolved
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/bank/internal/keeper/keeper.go Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

Looking good @karzak, left some more feedback ⚡️

x/auth/module.go Outdated
@@ -36,6 +37,7 @@ func (AppModuleBasic) Name() string {
// RegisterCodec registers the auth module's types for the given codec.
func (AppModuleBasic) RegisterCodec(cdc *codec.Codec) {
types.RegisterCodec(cdc)
vestingtypes.RegisterCodec(cdc)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we avoid requiring auth to register anything related to vesting? Vesting should be completely opt-in if possible.

Copy link
Collaborator

Choose a reason for hiding this comment

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

how'd would you make it opt-in then. By defining a module.go in vesting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The two options I see are

  1. Define a module.go, which was rejected previously in e905853#r325162521
  2. Require vesting to call RegisterCodec outside the normal module manager pattern, as in ab06e07#r329289047

IMO, registering vesting types in auth doesn't makes sense, as a downstream consumer could build an app that doesn't want vesting, and would find the inclusion of vesting an anti-pattern. The tradeoff is that it needs to be clearly communicated that submodules have to be manually registered.

x/auth/vesting/types/codec.go Outdated Show resolved Hide resolved
x/auth/vesting/types/vesting_period.go Outdated Show resolved Hide resolved
x/bank/internal/keeper/keeper.go Show resolved Hide resolved
require.Equal(t, origCoins, vacc.GetCoins())
}

func TestPeriodicVestingAccountSend(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why should these move to auth/vesting? These tests are testing banking functionality with relation to vesting contraints.

x/auth/spec/05_vesting.md 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 Show resolved Hide resolved
x/auth/vesting/types/vesting_account.go Show resolved Hide resolved
x/auth/spec/05_vesting.md Outdated Show resolved Hide resolved
x/auth/spec/05_vesting.md Show resolved Hide resolved
x/auth/spec/05_vesting.md Outdated Show resolved Hide resolved
x/auth/spec/05_vesting.md Outdated Show resolved Hide resolved
x/auth/spec/05_vesting.md 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
x/auth/vesting/types/vesting_account.go Outdated Show resolved Hide resolved
Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

LGTM @karzak. Final piece missing is a changelog entries.

Under Features:

* [\#4486](https://github.com/cosmos/cosmos-sdk/issues/4486) Introduce new `PeriodicVestingAccount` vesting account type
that allows for arbitrary vesting periods.

Under API Breaking:

* [\#4486](https://github.com/cosmos/cosmos-sdk/issues/4486) Vesting account types decoupled from the `x/auth` module and
now live under `x/auth/vesting`. Applications wishing to use vesting account types must be sure to register types via
`RegisterCodec` under the new vesting package.
* [\#4486](https://github.com/cosmos/cosmos-sdk/issues/4486) The `NewBaseVestingAccount` constructor returns an error
if the provided arguments are invalid.

Copy link
Contributor

@alexanderbez alexanderbez left a comment

Choose a reason for hiding this comment

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

ACK 🎉

@alexanderbez alexanderbez merged commit 64a2741 into cosmos:master Oct 10, 2019
larry0x pushed a commit to larry0x/cosmos-sdk that referenced this pull request May 22, 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.

Decouple auth/vesting
5 participants