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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
40ed336
ADR 11: Generalize Gen Accounts implementation
fedekunze Sep 9, 2019
90a3882
move CLI cmd to auth
fedekunze Sep 10, 2019
8e92e02
delete genaccount module
fedekunze Sep 10, 2019
e1e4993
add some tests
fedekunze Sep 10, 2019
84f92dd
more fixes
fedekunze Sep 10, 2019
19fd7c8
register codec
fedekunze Sep 10, 2019
7085b9c
Merge branch 'master' of https://github.com/cosmos/cosmos-sdk into fe…
fedekunze Sep 10, 2019
0b6bbb5
Apply suggestions from code review
fedekunze Sep 11, 2019
e6bf7c4
address comments from review
fedekunze Sep 11, 2019
ac7aaef
Merge branch 'fedekunze/ADR-11-generalize-gen-accs' of https://github…
fedekunze Sep 11, 2019
e9d215a
remove genaccounts command
fedekunze Sep 11, 2019
5a69363
keep legacy genaccount migrations
fedekunze Sep 11, 2019
6c4b702
update genutil migration
fedekunze Sep 11, 2019
4e5e1a2
format
fedekunze Sep 11, 2019
6288793
migrate
fedekunze Sep 12, 2019
fe125bf
iterator
fedekunze Sep 12, 2019
e905853
feat: separate vesting from auth
karzak Sep 12, 2019
fb0e13d
fix: lint
karzak Sep 12, 2019
1198733
Update godoc
alexanderbez Sep 12, 2019
f07fabc
Update godoc
alexanderbez Sep 12, 2019
2979564
Remove RegisterAccountTypeCodec call from supply
alexanderbez Sep 12, 2019
3636574
Merge branch 'master' into fedekunze/ADR-11-generalize-gen-accs
alexanderbez Sep 12, 2019
da91323
re-add RegisterAccountTypeCodec
alexanderbez Sep 12, 2019
42b04ee
Update godoc
alexanderbez Sep 12, 2019
a65b323
Merge branch 'origin/fedekunze/ADR-11-generalize-gen-accs' into kd-se…
karzak Sep 12, 2019
4a53d93
apply changes from code review
karzak Sep 12, 2019
47b44d4
Merge remote-tracking branch 'origin/master' into kd-separate-vesting
karzak Sep 12, 2019
97b7a05
Merge remote-tracking branch 'origin/master' into kd-separate-vesting
karzak Sep 16, 2019
9dfd712
Merge remote-tracking branch 'origin/master' into kd-separate-vesting
karzak Sep 16, 2019
1de8470
fix: lint
karzak Sep 16, 2019
d7cf2ce
Merge remote-tracking branch 'origin/master' into kd-separate-vesting
karzak Sep 17, 2019
a69a107
feat: add periodic vesting account to spec
karzak Sep 17, 2019
ab06e07
address code review comments
karzak Sep 17, 2019
0e17f46
fix: lint
karzak Sep 17, 2019
f7b3feb
fix coin denoms in benchmark test
karzak Sep 18, 2019
385d4e4
fix validation of vesting periods
karzak Sep 22, 2019
88121bd
remove private methods from BaseVestingAccount
karzak Sep 22, 2019
076adae
Merge remote-tracking branch 'origin' into kd-separate-vesting
karzak Sep 22, 2019
2c35f8c
add simulation account generator function
karzak Sep 24, 2019
836f66d
lint
karzak Sep 24, 2019
29752ed
address review comments
karzak Sep 29, 2019
9054871
lint
karzak Sep 29, 2019
70940d0
lint
karzak Sep 29, 2019
3619dd5
address review comments
karzak Sep 30, 2019
655b0c1
address review comments
karzak Sep 30, 2019
fc06172
autogen alias file
karzak Sep 30, 2019
1f72304
Merge branch 'master' into kd-separate-vesting
fedekunze Sep 30, 2019
d78dba5
Merge branch 'master' into kd-separate-vesting
fedekunze Oct 1, 2019
c40ce3b
address review comments
karzak Oct 1, 2019
56a9220
lint spec
karzak Oct 1, 2019
e856664
address review comments
karzak Oct 3, 2019
914981b
Merge branch 'master' into kd-separate-vesting
alexanderbez Oct 3, 2019
9eebfb9
address review comments
karzak Oct 3, 2019
3f482d4
update spec to reflect changes
karzak Oct 3, 2019
f2ffb05
separate vesting codec from auth
karzak Oct 3, 2019
6b0629d
Merge branch 'master' into kd-separate-vesting
fedekunze Oct 7, 2019
4392ae1
address review comments
karzak Oct 7, 2019
3fe741e
Merge branch 'kd-separate-vesting' of github.com:Kava-Labs/cosmos-sdk…
karzak Oct 7, 2019
cc6fdd0
address review comments
karzak Oct 7, 2019
1e6c27c
update spendable coins name for vesting accounts
karzak Oct 7, 2019
432fdca
move vesting amount validation to contructor
karzak Oct 8, 2019
dd905b0
Update changelog
karzak Oct 8, 2019
e1f67c9
Merge branch 'master' into kd-separate-vesting
fedekunze Oct 8, 2019
a374f5f
Merge remote-tracking branch 'origin' into kd-separate-vesting
karzak Oct 10, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ have this method perform a no-op.
* Update gov keys to use big endian encoding instead of little endian
* (modules) [\#5017](https://github.com/cosmos/cosmos-sdk/pull/5017) The `x/genaccounts` module has been
deprecated and all components removed except the `legacy/` package.
* [\#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.
* (x/auth) [\#5006](https://github.com/cosmos/cosmos-sdk/pull/5006) Modular `AnteHandler` via composable decorators:
* The `AnteHandler` interface now returns `(newCtx Context, err error)` instead of `(newCtx Context, result sdk.Result, abort bool)`
* The `NewAnteHandler` function returns an `AnteHandler` function that returns the new `AnteHandler`
Expand Down Expand Up @@ -92,6 +97,8 @@ upgrade via: `sudo rm -rf /Library/Developer/CommandLineTools; xcode-select --in
correct version via: `pkgutil --pkg-info=com.apple.pkg.CLTools_Executables`.
* (keys) [\#5097](https://github.com/cosmos/cosmos-sdk/pull/5097) New `keys migrate` command to assist users migrate their keys
to the new keyring.
* [\#4486](https://github.com/cosmos/cosmos-sdk/issues/4486) Introduce new `PeriodicVestingAccount` vesting account type
that allows for arbitrary vesting periods.
* (x/auth) [\#5006](https://github.com/cosmos/cosmos-sdk/pull/5006) Modular `AnteHandler` via composable decorators:
* The `AnteDecorator` interface has been introduced to allow users to implement modular `AnteHandler`
functionality that can be composed together to create a single `AnteHandler` rather than implementing
Expand Down
2 changes: 2 additions & 0 deletions simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/version"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/auth/vesting"
"github.com/cosmos/cosmos-sdk/x/bank"
"github.com/cosmos/cosmos-sdk/x/crisis"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
Expand Down Expand Up @@ -71,6 +72,7 @@ var (
func MakeCodec() *codec.Codec {
var cdc = codec.New()
ModuleBasics.RegisterCodec(cdc)
vesting.RegisterCodec(cdc)
karzak marked this conversation as resolved.
Show resolved Hide resolved
sdk.RegisterCodec(cdc)
codec.RegisterCrypto(cdc)
return cdc
Expand Down
12 changes: 1 addition & 11 deletions x/auth/alias.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ package auth

import (
"github.com/cosmos/cosmos-sdk/x/auth/ante"
"github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/keeper"
"github.com/cosmos/cosmos-sdk/x/auth/types"
)
Expand Down Expand Up @@ -39,11 +38,6 @@ var (
NewBaseAccount = types.NewBaseAccount
ProtoBaseAccount = types.ProtoBaseAccount
NewBaseAccountWithAddress = types.NewBaseAccountWithAddress
NewBaseVestingAccount = types.NewBaseVestingAccount
NewContinuousVestingAccountRaw = types.NewContinuousVestingAccountRaw
NewContinuousVestingAccount = types.NewContinuousVestingAccount
NewDelayedVestingAccountRaw = types.NewDelayedVestingAccountRaw
NewDelayedVestingAccount = types.NewDelayedVestingAccount
NewAccountRetriever = types.NewAccountRetriever
RegisterCodec = types.RegisterCodec
RegisterAccountTypeCodec = types.RegisterAccountTypeCodec
Expand All @@ -65,6 +59,7 @@ var (
NewTxBuilder = types.NewTxBuilder
NewTxBuilderFromCLI = types.NewTxBuilderFromCLI
MakeSignature = types.MakeSignature
ValidateGenAccounts = types.ValidateGenAccounts
GetGenesisStateFromAppState = types.GetGenesisStateFromAppState

// variable aliases
Expand All @@ -80,13 +75,8 @@ var (

type (
SignatureVerificationGasConsumer = ante.SignatureVerificationGasConsumer
Account = exported.Account
VestingAccount = exported.VestingAccount
AccountKeeper = keeper.AccountKeeper
BaseAccount = types.BaseAccount
BaseVestingAccount = types.BaseVestingAccount
ContinuousVestingAccount = types.ContinuousVestingAccount
DelayedVestingAccount = types.DelayedVestingAccount
NodeQuerier = types.NodeQuerier
AccountRetriever = types.AccountRetriever
GenesisState = types.GenesisState
Expand Down
2 changes: 1 addition & 1 deletion x/auth/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const (
flagLimit = "limit"
)

// GetTxCmd returns the transaction commands for this module
// GetQueryCmd returns the transaction commands for this module
func GetQueryCmd(cdc *codec.Codec) *cobra.Command {
cmd := &cobra.Command{
Use: types.ModuleName,
Expand Down
20 changes: 0 additions & 20 deletions x/auth/exported/exported.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,6 @@ type Account interface {
String() string
}

// VestingAccount defines an account type that vests coins via a vesting schedule.
type VestingAccount interface {
Account

// Delegation and undelegation accounting that returns the resulting base
// coins amount.
TrackDelegation(blockTime time.Time, amount sdk.Coins)
TrackUndelegation(amount sdk.Coins)

GetVestedCoins(blockTime time.Time) sdk.Coins
GetVestingCoins(blockTime time.Time) sdk.Coins

GetStartTime() int64
GetEndTime() int64

GetOriginalVesting() sdk.Coins
GetDelegatedFree() sdk.Coins
GetDelegatedVesting() sdk.Coins
}

// GenesisAccounts defines a slice of GenesisAccount objects
type GenesisAccounts []GenesisAccount

Expand Down
24 changes: 12 additions & 12 deletions x/auth/keeper/keeper_bench_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ func BenchmarkAccountMapperGetAccountFoundWithCoins(b *testing.B) {
app, ctx := createTestApp(false)

coins := sdk.Coins{
sdk.NewCoin("LTC", sdk.NewInt(1000)),
sdk.NewCoin("BTC", sdk.NewInt(1000)),
sdk.NewCoin("ETH", sdk.NewInt(1000)),
sdk.NewCoin("XRP", sdk.NewInt(1000)),
sdk.NewCoin("BCH", sdk.NewInt(1000)),
sdk.NewCoin("EOS", sdk.NewInt(1000)),
sdk.NewCoin("ltc", sdk.NewInt(1000)),
sdk.NewCoin("btc", sdk.NewInt(1000)),
sdk.NewCoin("eth", sdk.NewInt(1000)),
sdk.NewCoin("xrp", sdk.NewInt(1000)),
sdk.NewCoin("bch", sdk.NewInt(1000)),
sdk.NewCoin("eos", sdk.NewInt(1000)),
}

// assumes b.N < 2**24
Expand Down Expand Up @@ -70,12 +70,12 @@ func BenchmarkAccountMapperSetAccountWithCoins(b *testing.B) {
app, ctx := createTestApp(false)

coins := sdk.Coins{
sdk.NewCoin("LTC", sdk.NewInt(1000)),
sdk.NewCoin("BTC", sdk.NewInt(1000)),
sdk.NewCoin("ETH", sdk.NewInt(1000)),
sdk.NewCoin("XRP", sdk.NewInt(1000)),
sdk.NewCoin("BCH", sdk.NewInt(1000)),
sdk.NewCoin("EOS", sdk.NewInt(1000)),
sdk.NewCoin("ltc", sdk.NewInt(1000)),
sdk.NewCoin("btc", sdk.NewInt(1000)),
sdk.NewCoin("eth", sdk.NewInt(1000)),
sdk.NewCoin("xrp", sdk.NewInt(1000)),
sdk.NewCoin("bch", sdk.NewInt(1000)),
sdk.NewCoin("eos", sdk.NewInt(1000)),
}

b.ResetTimer()
Expand Down
5 changes: 3 additions & 2 deletions x/auth/simulation/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
"github.com/cosmos/cosmos-sdk/x/auth/exported"
"github.com/cosmos/cosmos-sdk/x/auth/types"
vestingtypes "github.com/cosmos/cosmos-sdk/x/auth/vesting/types"
"github.com/cosmos/cosmos-sdk/x/simulation"
)

Expand Down Expand Up @@ -116,9 +117,9 @@ func RandomGenesisAccounts(simState *module.SimulationState) (genesisAccs export
}

if simState.Rand.Intn(100) < 50 {
gacc = types.NewContinuousVestingAccount(&bacc, startTime, endTime)
karzak marked this conversation as resolved.
Show resolved Hide resolved
gacc = vestingtypes.NewContinuousVestingAccount(&bacc, startTime, endTime)
} else {
gacc = types.NewDelayedVestingAccount(&bacc, endTime)
gacc = vestingtypes.NewDelayedVestingAccount(&bacc, endTime)
}
}
genesisAccs = append(genesisAccs, gacc)
Expand Down
Loading