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 107 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
86 changes: 74 additions & 12 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 @@ -87,18 +93,27 @@ func NewGaiaApp(logger log.Logger, db dbm.DB, traceStore io.Writer, baseAppOptio
)

// add handlers
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
app.bankKeeper = bank.NewBaseKeeper(app.accountMapper)
app.paramsKeeper = params.NewKeeper(app.cdc, app.keyParams)
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.tkeyStake, app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper, app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
app.stakeKeeper = app.stakeKeeper.WithHooks(app.slashingKeeper.Hooks())
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper.Setter(), app.bankKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))
app.feeCollectionKeeper = auth.NewFeeCollectionKeeper(app.cdc, app.keyFeeCollection)
app.stakeKeeper = stake.NewKeeper(app.cdc, app.keyStake, app.tkeyStake,
rigelrozanski marked this conversation as resolved.
Show resolved Hide resolved
app.bankKeeper, app.RegisterCodespace(stake.DefaultCodespace))
app.distrKeeper = distr.NewKeeper(app.cdc, app.keyDistr, app.tkeyDistr,
app.paramsKeeper.Setter(), app.bankKeeper, app.stakeKeeper,
app.feeCollectionKeeper, app.RegisterCodespace(stake.DefaultCodespace))
app.slashingKeeper = slashing.NewKeeper(app.cdc, app.keySlashing, app.stakeKeeper,
app.paramsKeeper.Getter(), app.RegisterCodespace(slashing.DefaultCodespace))
app.govKeeper = gov.NewKeeper(app.cdc, app.keyGov, app.paramsKeeper.Setter(),
app.bankKeeper, app.stakeKeeper, app.RegisterCodespace(gov.DefaultCodespace))

// 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 @@ -109,11 +124,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 @@ -127,6 +143,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 @@ -138,6 +155,7 @@ func MakeCodec() *codec.Codec {
// application updates every end block
func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) abci.ResponseBeginBlock {
tags := slashing.BeginBlocker(ctx, req, app.slashingKeeper)
distr.BeginBlocker(ctx, req, app.distrKeeper)

return abci.ResponseBeginBlock{
Tags: tags.ToKVPairs(),
Expand All @@ -149,6 +167,10 @@ func (app *GaiaApp) BeginBlocker(ctx sdk.Context, req abci.RequestBeginBlock) ab
func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.ResponseEndBlock {
tags := gov.EndBlocker(ctx, app.govKeeper)
validatorUpdates := stake.EndBlocker(ctx, app.stakeKeeper)

// distribute rewards
distr.EndBlocker(ctx, app.distrKeeper)
rigelrozanski marked this conversation as resolved.
Show resolved Hide resolved

// Add these new validators to the addr -> pubkey map.
app.slashingKeeper.AddValidators(ctx, validatorUpdates)
return abci.ResponseEndBlock{
Expand Down Expand Up @@ -179,18 +201,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.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 @@ -214,6 +235,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 @@ -223,3 +245,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)
}
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/stake"

Expand All @@ -33,6 +34,7 @@ var (
type GenesisState struct {
Accounts []GenesisAccount `json:"accounts"`
StakeData stake.GenesisState `json:"stake"`
DistrData distr.GenesisState `json:"distr_data"`
GovData gov.GenesisState `json:"gov"`
}

Expand Down Expand Up @@ -192,6 +194,7 @@ func GaiaAppGenState(cdc *codec.Codec, appGenTxs []json.RawMessage) (genesisStat
genesisState = GenesisState{
Accounts: genaccs,
StakeData: stakeData,
DistrData: distr.DefaultGenesisState(),
GovData: gov.DefaultGenesisState(),
}

Expand Down
16 changes: 12 additions & 4 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 @@ -52,18 +53,23 @@ func appStateFn(r *rand.Rand, accs []simulation.Account) json.RawMessage {
Coins: coins,
})
}
govGenesis := gov.DefaultGenesisState()

// Default genesis state
stakeGenesis := stake.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 @@ -73,10 +79,12 @@ 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,
GovData: govGenesis,
DistrData: distr.DefaultGenesisWithValidators(valAddrs),
GovData: gov.DefaultGenesisState(),
}

// Marshal genesis
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
12 changes: 5 additions & 7 deletions docs/spec/distribution/end_block.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# End Block

At each endblock, the fees received are allocated to the proposer, community fund,
and global pool. When the validator is the proposer of the round, that
and pool. When the validator is the proposer of the round, that
rigelrozanski marked this conversation as resolved.
Show resolved Hide resolved
validator (and their delegators) receives between 1% and 5% of fee rewards, the
reserve community tax is then charged, then the remainder is distributed
proportionally by voting power to all bonded validators independent of whether
Expand All @@ -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
2 changes: 1 addition & 1 deletion docs/spec/distribution/overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ to independently and lazily withdraw their rewards.

As a part of the lazy computations, each delegator holds an accumulation term
specific to each validator which is used to estimate what their approximate
fair portion of tokens held in the global pool is owed to them.
fair portion of tokens held in the global fee pool is owed to them.

```
entitlement = delegator-accumulation / all-delegators-accumulation
Expand Down
Loading