Skip to content

Commit

Permalink
Merge PR cosmos#5040: Separate vesting from auth, add custom vesting …
Browse files Browse the repository at this point in the history
…schedules
  • Loading branch information
karzak authored and alexanderbez committed Oct 10, 2019
1 parent c0223a4 commit 64a2741
Show file tree
Hide file tree
Showing 27 changed files with 1,848 additions and 938 deletions.
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)
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)
gacc = vestingtypes.NewContinuousVestingAccount(&bacc, startTime, endTime)
} else {
gacc = types.NewDelayedVestingAccount(&bacc, endTime)
gacc = vestingtypes.NewDelayedVestingAccount(&bacc, endTime)
}
}
genesisAccs = append(genesisAccs, gacc)
Expand Down
Loading

0 comments on commit 64a2741

Please sign in to comment.