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

R4R: Distr-PR-5 Implement Distribution #2236

Merged
merged 121 commits into from
Oct 16, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
121 commits
Select commit Hold shift + click to select a range
b2eab0d
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Aug 31, 2018
469334d
Merge branch 'rigel/piggy-bank-fee-spec' into rigel/fee-distribution
rigelrozanski Sep 3, 2018
d7794b4
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 3, 2018
9a2aee8
working
rigelrozanski Sep 4, 2018
48aa9a6
working, moved WIP distribution spec to attic
rigelrozanski Sep 4, 2018
4ddf6ca
undo spec move for PR clarity
rigelrozanski Sep 4, 2018
43ab066
move WIP-lamborghini-distribution
rigelrozanski Sep 4, 2018
38c6090
Merge branch 'rigel/move-spec' into rigel/fee-distribution
rigelrozanski Sep 5, 2018
53253aa
working
rigelrozanski Sep 5, 2018
aebd36f
...
rigelrozanski Sep 5, 2018
8ab25fa
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 5, 2018
e2b5b9b
...
rigelrozanski Sep 5, 2018
b409099
update spec
rigelrozanski Sep 5, 2018
cbb5a50
work on allocate fees
rigelrozanski Sep 5, 2018
e498d43
dec coins, refactoring distr
rigelrozanski Sep 10, 2018
7d864fe
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 10, 2018
922eb5e
...
rigelrozanski Sep 11, 2018
a153088
...
rigelrozanski Sep 11, 2018
46db96b
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 13, 2018
dae32a3
...
rigelrozanski Sep 13, 2018
d60f620
working
rigelrozanski Sep 14, 2018
2eff69a
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 17, 2018
431fdb8
hook, genesis, and withdraw address
rigelrozanski Sep 18, 2018
24e43b9
hookwork
rigelrozanski Sep 18, 2018
bb9e647
add in basic commission stuff
rigelrozanski Sep 18, 2018
a18b895
handler, tags, msgs, codec
rigelrozanski Sep 19, 2018
e3cf4f6
cli transactions
rigelrozanski Sep 19, 2018
73c5fdf
more cli related
rigelrozanski Sep 19, 2018
de4071f
aliases, errors
rigelrozanski Sep 19, 2018
97f7dbc
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 19, 2018
7688299
alias work, working on compiling
rigelrozanski Sep 19, 2018
df9c8db
working through compile errors
rigelrozanski Sep 19, 2018
d9396ed
working compile errors
rigelrozanski Sep 19, 2018
7002438
compile debugging
rigelrozanski Sep 20, 2018
18fdccf
...
rigelrozanski Sep 20, 2018
5dabd1b
the errors never want to seem to end...
rigelrozanski Sep 20, 2018
5790f33
...
rigelrozanski Sep 20, 2018
251a81f
yay it compiles
rigelrozanski Sep 20, 2018
d360304
breakout use of GetValidatorByConsAddr
rigelrozanski Sep 20, 2018
0d9105c
...
rigelrozanski Sep 21, 2018
0867ce8
...
rigelrozanski Sep 21, 2018
4e4749d
pulling in stuff from fee-distr PR
rigelrozanski Sep 21, 2018
ab61695
PENDING
rigelrozanski Sep 21, 2018
0f903bd
finished pulling in, compiles
rigelrozanski Sep 21, 2018
9e2b8e4
revert some gov changes
rigelrozanski Sep 21, 2018
1243507
no more compile errors in tests
rigelrozanski Sep 21, 2018
787a2f9
fix using cons address, also remove old commented distr code
rigelrozanski Sep 21, 2018
72e3025
doc update
rigelrozanski Sep 21, 2018
b212470
revert some accidental stuff
rigelrozanski Sep 21, 2018
a2b2ef9
Merge remote-tracking branch 'origin/develop' into rigel/stake-cons-addr
rigelrozanski Sep 22, 2018
14792f2
val comments
rigelrozanski Sep 22, 2018
d428317
import decimal from fee-distr PR
rigelrozanski Sep 22, 2018
79cfee9
pending
rigelrozanski Sep 22, 2018
6012a25
...
rigelrozanski Sep 22, 2018
6f35822
import hook from fee-distr
rigelrozanski Sep 22, 2018
1b485bb
pending
rigelrozanski Sep 22, 2018
df0d582
add staking hooks to staking spec
rigelrozanski Sep 22, 2018
9dfeeb0
address bez comments
rigelrozanski Sep 24, 2018
afe179e
remove GetValidatorByConsPubKey
rigelrozanski Sep 25, 2018
16594f7
Merge remote-tracking branch 'origin/develop' into rigel/stake-cons-addr
rigelrozanski Sep 25, 2018
dad4253
merge fix
rigelrozanski Sep 25, 2018
ff8d748
Merge branch 'rigel/stake-cons-addr' into rigel/truncate-decimal
rigelrozanski Sep 25, 2018
f5116b9
Merge branch 'rigel/truncate-decimal' into rigel/new-hooks
rigelrozanski Sep 25, 2018
ca2fc77
update commission hook for new commission work
rigelrozanski Sep 25, 2018
5be5ea3
comment update
rigelrozanski Sep 25, 2018
380d3e1
pull a bunch from develop
rigelrozanski Sep 25, 2018
47e899b
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 25, 2018
d3146bf
...
rigelrozanski Sep 25, 2018
910af20
Merge commit '5be5ea3' into rigel/new-hooks
rigelrozanski Sep 25, 2018
9e9756a
Merge remote-tracking branch 'origin/develop' into rigel/new-hooks
rigelrozanski Sep 25, 2018
4929b02
mini-fix
rigelrozanski Sep 25, 2018
3846894
Merge branch 'rigel/new-hooks' into rigel/fee-distribution
rigelrozanski Sep 26, 2018
0436f50
...
rigelrozanski Sep 27, 2018
436d2a0
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Sep 28, 2018
956566d
proser
rigelrozanski Sep 28, 2018
60a3541
major debugs
rigelrozanski Sep 28, 2018
7ab02ae
lcd tests to include proposer
rigelrozanski Sep 28, 2018
733b616
disable endblock for lcd
rigelrozanski Sep 28, 2018
e223ead
types msg tests
rigelrozanski Sep 28, 2018
064f8b0
dec coin tests
rigelrozanski Sep 28, 2018
16f5d69
types fee pool test
rigelrozanski Sep 28, 2018
dcf0dda
...
rigelrozanski Sep 29, 2018
1e74da1
validator_info tests
rigelrozanski Oct 4, 2018
4d4de3a
delegator_dist_info tests
rigelrozanski Oct 4, 2018
3a9102e
fix
rigelrozanski Oct 4, 2018
eb01cb4
checkout distr types PR updates
rigelrozanski Oct 4, 2018
45f0dd0
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 4, 2018
20a51e5
fix compile errors
rigelrozanski Oct 4, 2018
17dc812
fix distribution endblocker issues
rigelrozanski Oct 5, 2018
81d0f5f
add wanted final test case functions
rigelrozanski Oct 5, 2018
83c2781
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 5, 2018
e304b9c
debugging simulation
rigelrozanski Oct 6, 2018
142f42e
...
rigelrozanski Oct 9, 2018
6005325
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 9, 2018
46fe52b
create test initialization for distr
rigelrozanski Oct 9, 2018
c973032
...
rigelrozanski Oct 9, 2018
6d4975e
R4R: Fix simulation proposer (#2460)
cwgoes Oct 9, 2018
fc9bafb
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 10, 2018
151a81e
staking changes test_cover fixes
rigelrozanski Oct 10, 2018
ace19d9
Merge branch 'rigel/fee-distribution' of https://github.com/cosmos/co…
rigelrozanski Oct 10, 2018
52316d9
fix initialization of the test
rigelrozanski Oct 10, 2018
22de856
fix distr initialization
rigelrozanski Oct 10, 2018
3b5e57b
ctx with proposer, working through allocation test
rigelrozanski Oct 10, 2018
900a5f4
keeper_test
rigelrozanski Oct 11, 2018
f4f39ae
allocation tests
rigelrozanski Oct 11, 2018
8e378e2
got basic delegation tests working
rigelrozanski Oct 11, 2018
8cb6d10
TestWithdrawDelegationRewardWithCommission
rigelrozanski Oct 11, 2018
f3c0496
TestWithdrawDelegationRewardsAll
rigelrozanski Oct 12, 2018
a60b91b
bugfix form TestWithdrawDelegationRewardTwoDelegatorsUneven
rigelrozanski Oct 12, 2018
94731a5
some validator dist tests
rigelrozanski Oct 12, 2018
7b1f4a8
finished off validator tests
rigelrozanski Oct 12, 2018
dba20d1
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 12, 2018
06fa518
address @cwgoes comments, add in precommit calculation
rigelrozanski Oct 12, 2018
2ece2ff
address @cwgoes comments
rigelrozanski Oct 15, 2018
5de0c9a
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 15, 2018
2f4a01b
address @ValarDragon comments, param store update
rigelrozanski Oct 15, 2018
43e4396
Merge remote-tracking branch 'origin/develop' into rigel/fee-distribu…
rigelrozanski Oct 15, 2018
076053d
proposer reward params to global param
rigelrozanski Oct 15, 2018
eaecde2
test_utils >:(
rigelrozanski Oct 15, 2018
03b9260
oh
rigelrozanski Oct 15, 2018
32e0f14
rework to correctly use previous vote info
rigelrozanski Oct 16, 2018
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
95 changes: 76 additions & 19 deletions cmd/gaia/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
"github.com/cosmos/cosmos-sdk/x/bank"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/params"
"github.com/cosmos/cosmos-sdk/x/slashing"
Expand Down Expand Up @@ -43,6 +44,8 @@ type GaiaApp struct {
keyStake *sdk.KVStoreKey
tkeyStake *sdk.TransientStoreKey
keySlashing *sdk.KVStoreKey
keyDistr *sdk.KVStoreKey
tkeyDistr *sdk.TransientStoreKey
keyGov *sdk.KVStoreKey
keyFeeCollection *sdk.KVStoreKey
keyParams *sdk.KVStoreKey
Expand All @@ -54,6 +57,7 @@ type GaiaApp struct {
bankKeeper bank.Keeper
stakeKeeper stake.Keeper
slashingKeeper slashing.Keeper
distrKeeper distr.Keeper
govKeeper gov.Keeper
paramsKeeper params.Keeper
}
Expand All @@ -72,6 +76,8 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
keyAccount: sdk.NewKVStoreKey("acc"),
keyStake: sdk.NewKVStoreKey("stake"),
tkeyStake: sdk.NewTransientStoreKey("transient_stake"),
keyDistr: sdk.NewKVStoreKey("distr"),
tkeyDistr: sdk.NewTransientStoreKey("transient_distr"),
keySlashing: sdk.NewKVStoreKey("slashing"),
keyGov: sdk.NewKVStoreKey("gov"),
keyFeeCollection: sdk.NewKVStoreKey("fee"),
Expand All @@ -88,46 +94,49 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio

// add handlers
app.bankKeeper = bank.NewBaseKeeper(app.accountMapper)

app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(
app.cdc,
app.keyFeeCollection,
)
app.paramsKeeper = params.NewKeeper(
app.cdc,
app.keyParams, app.tkeyParams,
)

app.stakeKeeper = stake.NewKeeper(
app.cdc,
app.keyStake, app.tkeyStake,
app.bankKeeper, app.paramsKeeper.Subspace(stake.DefaultParamspace),
app.RegisterCodespace(stake.DefaultCodespace),
)

app.distrKeeper = distr.NewKeeper(
app.cdc,
app.keyDistr,
app.paramsKeeper.Subspace(distr.DefaultParamspace),
app.bankKeeper, app.stakeKeeper, app.feeCollectionKeeper,
app.RegisterCodespace(stake.DefaultCodespace),
)
app.slashingKeeper = slashing.NewKeeper(
app.cdc,
app.keySlashing,
app.stakeKeeper, app.paramsKeeper.Subspace(slashing.DefaultParamspace),
app.RegisterCodespace(slashing.DefaultCodespace),
)

app.stakeKeeper = app.stakeKeeper.WithHooks(
app.slashingKeeper.Hooks(),
)

app.govKeeper = gov.NewKeeper(
app.cdc,
app.keyGov,
app.paramsKeeper, app.paramsKeeper.Subspace(gov.DefaultParamspace), app.bankKeeper, app.stakeKeeper,
app.RegisterCodespace(gov.DefaultCodespace),
)

app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(
app.cdc,
app.keyFeeCollection,
)
// register the staking hooks
app.stakeKeeper = app.stakeKeeper.WithHooks(
NewHooks(app.distrKeeper.Hooks(), app.slashingKeeper.Hooks()))

// register message routes
app.Router().
AddRoute("bank", bank.NewHandler(app.bankKeeper)).
AddRoute("stake", stake.NewHandler(app.stakeKeeper)).
AddRoute("distr", distr.NewHandler(app.distrKeeper)).
AddRoute("slashing", slashing.NewHandler(app.slashingKeeper)).
AddRoute("gov", gov.NewHandler(app.govKeeper))

Expand All @@ -138,11 +147,12 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
// initialize BaseApp
app.SetInitChainer(app.initChainer)
app.SetBeginBlocker(app.BeginBlocker)
app.SetEndBlocker(app.EndBlocker)
app.SetAnteHandler(auth.NewAnteHandler(app.accountMapper, app.feeCollectionKeeper))
app.MountStoresIAVL(app.keyMain, app.keyAccount, app.keyStake,
app.MountStoresIAVL(app.keyMain, app.keyAccount, app.keyStake, app.keyDistr,
app.keySlashing, app.keyGov, app.keyFeeCollection, app.keyParams)
app.MountStoresTransient(app.tkeyParams, app.tkeyStake)
app.MountStoresTransient(app.tkeyParams, app.tkeyStake, app.tkeyDistr)
app.SetEndBlocker(app.EndBlocker)

err := app.LoadLatestVersion(app.keyMain)
if err != nil {
cmn.Exit(err.Error())
Expand All @@ -156,6 +166,7 @@ func MakeCodec() *codec.Codec {
var cdc = codec.New()
bank.RegisterCodec(cdc)
stake.RegisterCodec(cdc)
distr.RegisterCodec(cdc)
slashing.RegisterCodec(cdc)
gov.RegisterCodec(cdc)
auth.RegisterCodec(cdc)
Expand All @@ -168,6 +179,9 @@ func MakeCodec() *codec.Codec {
func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
tags := slashing.BeginBlocker(ctx, req, app.slashingKeeper)

// distribute rewards from previous block
distr.BeginBlocker(ctx, req, app.distrKeeper)

return abci.ResponseBeginBlock{
Tags: tags.ToKVPairs(),
}
Expand All @@ -176,10 +190,13 @@ func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) ab
// application updates every end block
// nolint: unparam
func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {

tags := gov.EndBlocker(ctx, app.govKeeper)
validatorUpdates := stake.EndBlocker(ctx, app.stakeKeeper)

// Add these new validators to the addr -> pubkey map.
app.slashingKeeper.AddValidators(ctx, validatorUpdates)

return abci.ResponseEndBlock{
ValidatorUpdates: validatorUpdates,
Tags: tags,
Expand Down Expand Up @@ -208,18 +225,17 @@ func (app *GaiaApp) initChainer(ctx sdk.Context, req abci.RequestInitChain) abci
// load the initial stake information
validators, err := stake.InitGenesis(ctx, app.stakeKeeper, genesisState.StakeData)
if err != nil {
panic(err) // TODO https://github.com/cosmos/cosmos-sdk/issues/468
// return sdk.ErrGenesisParse("").TraceCause(err, "")
panic(err) // TODO find a way to do this w/o panics
}

// load the address to pubkey map
slashing.InitGenesis(ctx, app.slashingKeeper, genesisState.SlashingData, genesisState.StakeData)

gov.InitGenesis(ctx, app.govKeeper, genesisState.GovData)
distr.InitGenesis(ctx, app.distrKeeper, genesisState.DistrData)
err = GaiaValidateGenesisState(genesisState)
if err != nil {
// TODO find a way to do this w/o panics
panic(err)
panic(err) // TODO find a way to do this w/o panics
}

return abci.ResponseInitChain{
Expand All @@ -243,6 +259,7 @@ func (app *GaiaApp) ExportAppStateAndValidators() (appState json.RawMessage, val
genState := GenesisState{
Accounts: accounts,
StakeData: stake.WriteGenesis(ctx, app.stakeKeeper),
DistrData: distr.WriteGenesis(ctx, app.distrKeeper),
GovData: gov.WriteGenesis(ctx, app.govKeeper),
}
appState, err = codec.MarshalJSONIndent(app.cdc, genState)
Expand All @@ -252,3 +269,43 @@ func (app *GaiaApp) ExportAppStateAndValidators() (appState json.RawMessage, val
validators = stake.WriteValidators(ctx, app.stakeKeeper)
return appState, validators, nil
}

//______________________________________________________________________________________________

// Combined Staking Hooks
type Hooks struct {
dh distr.Hooks
sh slashing.Hooks
}

func NewHooks(dh distr.Hooks, sh slashing.Hooks) Hooks {
return Hooks{dh, sh}
}

var _ sdk.StakingHooks = Hooks{}

// nolint
func (h Hooks) OnValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {
h.dh.OnValidatorCreated(ctx, addr)
}
func (h Hooks) OnValidatorCommissionChange(ctx sdk.Context, addr sdk.ValAddress) {
h.dh.OnValidatorCommissionChange(ctx, addr)
}
func (h Hooks) OnValidatorRemoved(ctx sdk.Context, addr sdk.ValAddress) {
h.dh.OnValidatorRemoved(ctx, addr)
}
func (h Hooks) OnValidatorBonded(ctx sdk.Context, addr sdk.ConsAddress) {
h.sh.OnValidatorBonded(ctx, addr)
}
func (h Hooks) OnValidatorBeginUnbonding(ctx sdk.Context, addr sdk.ConsAddress) {
h.sh.OnValidatorBeginUnbonding(ctx, addr)
}
func (h Hooks) OnDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
h.dh.OnDelegationCreated(ctx, delAddr, valAddr)
}
func (h Hooks) OnDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
h.dh.OnDelegationSharesModified(ctx, delAddr, valAddr)
}
func (h Hooks) OnDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) {
h.dh.OnDelegationRemoved(ctx, delAddr, valAddr)
}
2 changes: 2 additions & 0 deletions cmd/gaia/app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/x/auth"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake"
"github.com/stretchr/testify/require"
Expand All @@ -24,6 +25,7 @@ func setGenesis(gapp *GaiaApp, accs ...*auth.BaseAccount) error {
genesisState := GenesisState{
Accounts: genaccs,
StakeData: stake.DefaultGenesisState(),
DistrData: distr.DefaultGenesisState(),
SlashingData: slashing.DefaultGenesisState(),
}

Expand Down
3 changes: 3 additions & 0 deletions cmd/gaia/app/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/cosmos/cosmos-sdk/server/config"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/auth"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake"
Expand All @@ -34,6 +35,7 @@ var (
type GenesisState struct {
Accounts []GenesisAccount `json:"accounts"`
StakeData stake.GenesisState `json:"stake"`
DistrData distr.GenesisState `json:"distr"`
GovData gov.GenesisState `json:"gov"`
SlashingData slashing.GenesisState `json:"slashing"`
}
Expand Down Expand Up @@ -196,6 +198,7 @@ func GaiaAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (genesisStat
genesisState = GenesisState{
Accounts: genaccs,
StakeData: stakeData,
DistrData: distr.DefaultGenesisState(),
GovData: gov.DefaultGenesisState(),
SlashingData: slashingData,
}
Expand Down
12 changes: 10 additions & 2 deletions cmd/gaia/app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"
banksim "github.com/cosmos/cosmos-sdk/x/bank/simulation"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/gov"
govsim "github.com/cosmos/cosmos-sdk/x/gov/simulation"
"github.com/cosmos/cosmos-sdk/x/mock/simulation"
Expand Down Expand Up @@ -60,13 +61,18 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
slashingGenesis := slashing.DefaultGenesisState()
var validators []stake.Validator
var delegations []stake.Delegation

// XXX Try different numbers of initially bonded validators
numInitiallyBonded := int64(50)
valAddrs := make([]sdk.ValAddress, numInitiallyBonded)
for i := 0; i < int(numInitiallyBonded); i++ {
validator := stake.NewValidator(sdk.ValAddress(accs[i].Address), accs[i].PubKey, stake.Description{})
valAddr := sdk.ValAddress(accs[i].Address)
valAddrs[i] = valAddr

validator := stake.NewValidator(valAddr, accs[i].PubKey, stake.Description{})
validator.Tokens = sdk.NewDec(100)
validator.DelegatorShares = sdk.NewDec(100)
delegation := stake.Delegation{accs[i].Address, sdk.ValAddress(accs[i].Address), sdk.NewDec(100), 0}
delegation := stake.Delegation{accs[i].Address, valAddr, sdk.NewDec(100), 0}
validators = append(validators, validator)
delegations = append(delegations, delegation)
}
Expand All @@ -76,9 +82,11 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
// No inflation, for now
stakeGenesis.Params.InflationMax = sdk.NewDec(0)
stakeGenesis.Params.InflationMin = sdk.NewDec(0)

genesis := GenesisState{
Accounts: genesisAccounts,
StakeData: stakeGenesis,
DistrData: distr.DefaultGenesisWithValidators(valAddrs),
SlashingData: slashingGenesis,
GovData: govGenesis,
}
Expand Down
2 changes: 2 additions & 0 deletions cmd/gaia/app/test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

"github.com/cosmos/cosmos-sdk/codec"
sdk "github.com/cosmos/cosmos-sdk/types"
distr "github.com/cosmos/cosmos-sdk/x/distribution"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/slashing"
"github.com/cosmos/cosmos-sdk/x/stake"
Expand Down Expand Up @@ -72,6 +73,7 @@ func NewTestGaiaAppGenState(
return GenesisState{
Accounts: genAccs,
StakeData: stakeData,
DistrData: distr.DefaultGenesisState(),
SlashingData: slashing.DefaultGenesisState(),
GovData: gov.DefaultGenesisState(),
}, nil
Expand Down
17 changes: 11 additions & 6 deletions cmd/gaia/cmd/gaiacli/main.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
package main

import (
"os"
"path"

"github.com/spf13/cobra"
"github.com/spf13/viper"

"github.com/tendermint/tendermint/libs/cli"

Expand All @@ -10,18 +14,17 @@ import (
"github.com/cosmos/cosmos-sdk/client/lcd"
"github.com/cosmos/cosmos-sdk/client/rpc"
"github.com/cosmos/cosmos-sdk/client/tx"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/cosmos/cosmos-sdk/version"

authcmd "github.com/cosmos/cosmos-sdk/x/auth/client/cli"
bankcmd "github.com/cosmos/cosmos-sdk/x/bank/client/cli"
distrcmd "github.com/cosmos/cosmos-sdk/x/distribution/client/cli"
govcmd "github.com/cosmos/cosmos-sdk/x/gov/client/cli"
slashingcmd "github.com/cosmos/cosmos-sdk/x/slashing/client/cli"
stakecmd "github.com/cosmos/cosmos-sdk/x/stake/client/cli"

_ "github.com/cosmos/cosmos-sdk/client/lcd/statik"
"github.com/cosmos/cosmos-sdk/cmd/gaia/app"
"github.com/spf13/viper"
"os"
"path"
)

const (
Expand Down Expand Up @@ -101,11 +104,13 @@ func main() {
stakecmd.GetCmdCreateValidator(cdc),
stakecmd.GetCmdEditValidator(cdc),
stakecmd.GetCmdDelegate(cdc),
govcmd.GetCmdDeposit(cdc),
stakecmd.GetCmdRedelegate(storeStake, cdc),
stakecmd.GetCmdUnbond(storeStake, cdc),
distrcmd.GetCmdWithdrawRewards(cdc),
distrcmd.GetCmdSetWithdrawAddr(cdc),
govcmd.GetCmdDeposit(cdc),
bankcmd.SendTxCmd(cdc),
govcmd.GetCmdSubmitProposal(cdc),
stakecmd.GetCmdUnbond(storeStake, cdc),
slashingcmd.GetCmdUnjail(cdc),
govcmd.GetCmdVote(cdc),
)...)
Expand Down
10 changes: 4 additions & 6 deletions docs/spec/distribution/end_block.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ pool which validator holds individually
(`ValidatorDistribution.ProvisionsRewardPool`).

```
func AllocateFees(feesCollected sdk.Coins, global Global, proposer ValidatorDistribution,
func AllocateFees(feesCollected sdk.Coins, feePool FeePool, proposer ValidatorDistribution,
sumPowerPrecommitValidators, totalBondedTokens, communityTax,
proposerCommissionRate sdk.Dec)

Expand All @@ -28,13 +28,11 @@ func AllocateFees(feesCollected sdk.Coins, global Global, proposer ValidatorDist
proposer.Pool += proposerReward - commission

communityFunding = feesCollectedDec * communityTax
global.CommunityFund += communityFunding
feePool.CommunityFund += communityFunding

poolReceived = feesCollectedDec - proposerReward - communityFunding
global.Pool += poolReceived
global.EverReceivedPool += poolReceived
global.LastReceivedPool = poolReceived
feePool.Pool += poolReceived

SetValidatorDistribution(proposer)
SetGlobal(global)
SetFeePool(feePool)
```
2 changes: 1 addition & 1 deletion docs/spec/distribution/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

The pool of a new delegator bond will be 0 for the height at which the bond was
added, or the withdrawal has taken place. This is achieved by setting
`DelegatorDistInfo.WithdrawalHeight` to the height of the triggering transaction.
`DelegationDistInfo.WithdrawalHeight` to the height of the triggering transaction.

## Commission rate change

Expand Down
Loading