alias work, working on compiling
This commit is contained in:
parent
97f7dbc5e6
commit
76882991a4
|
@ -414,6 +414,14 @@
|
||||||
revision = "a8328986c1608950fa5d3d1c0472cccc4f8fc02c"
|
revision = "a8328986c1608950fa5d3d1c0472cccc4f8fc02c"
|
||||||
version = "v0.12.0-rc0"
|
version = "v0.12.0-rc0"
|
||||||
|
|
||||||
|
[[projects]]
|
||||||
|
digest = "1:2c971a45c89ca2ccc735af50919cdee05fbdc54d4bf50625073693300e31ead8"
|
||||||
|
name = "github.com/tendermint/go-wire"
|
||||||
|
packages = ["."]
|
||||||
|
pruneopts = "UT"
|
||||||
|
revision = "faa6e731944e2b7b6a46ad202902851e8ce85bee"
|
||||||
|
version = "v0.12.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
digest = "1:53397098d6acb7613358683cc84ae59281a60c6033f0bff62fa8d3f279c6c430"
|
digest = "1:53397098d6acb7613358683cc84ae59281a60c6033f0bff62fa8d3f279c6c430"
|
||||||
name = "github.com/tendermint/iavl"
|
name = "github.com/tendermint/iavl"
|
||||||
|
@ -645,6 +653,7 @@
|
||||||
"github.com/stretchr/testify/assert",
|
"github.com/stretchr/testify/assert",
|
||||||
"github.com/stretchr/testify/require",
|
"github.com/stretchr/testify/require",
|
||||||
"github.com/tendermint/go-amino",
|
"github.com/tendermint/go-amino",
|
||||||
|
"github.com/tendermint/go-wire",
|
||||||
"github.com/tendermint/iavl",
|
"github.com/tendermint/iavl",
|
||||||
"github.com/tendermint/tendermint/abci/server",
|
"github.com/tendermint/tendermint/abci/server",
|
||||||
"github.com/tendermint/tendermint/abci/types",
|
"github.com/tendermint/tendermint/abci/types",
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
// nolint
|
// nolint
|
||||||
package stake
|
package distribution
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||||
"github.com/cosmos/cosmos-sdk/x/distribution/querier"
|
|
||||||
"github.com/cosmos/cosmos-sdk/x/distribution/tags"
|
"github.com/cosmos/cosmos-sdk/x/distribution/tags"
|
||||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||||
|
"github.com/cosmos/cosmos-sdk/x/stake/querier"
|
||||||
)
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
|
|
|
@ -10,12 +10,12 @@ type DelegatorDistInfo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// withdraw rewards from delegator
|
// withdraw rewards from delegator
|
||||||
func (di DelegatorDistInfo) WithdrawRewards(g Global, vi ValidatorDistInfo,
|
func (di DelegatorDistInfo) WithdrawRewards(fp FeePool, vi ValidatorDistInfo,
|
||||||
height int64, totalBonded, vdTokens, totalDelShares, delegatorShares,
|
height int64, totalBonded, vdTokens, totalDelShares, delegatorShares,
|
||||||
commissionRate Dec) (di DelegatorDistInfo, g Global, withdrawn DecCoins) {
|
commissionRate sdk.Dec) (DelegatorDistInfo, FeePool, DecCoins) {
|
||||||
|
|
||||||
vi.UpdateTotalDelAccum(height, totalDelShares)
|
vi.UpdateTotalDelAccum(height, totalDelShares)
|
||||||
g = vi.TakeGlobalRewards(g, height, totalBonded, vdTokens, commissionRate)
|
fp = vi.TakeFeePoolRewards(fp, height, totalBonded, vdTokens, commissionRate)
|
||||||
|
|
||||||
blocks = height - di.WithdrawalHeight
|
blocks = height - di.WithdrawalHeight
|
||||||
di.WithdrawalHeight = height
|
di.WithdrawalHeight = height
|
||||||
|
@ -25,7 +25,7 @@ func (di DelegatorDistInfo) WithdrawRewards(g Global, vi ValidatorDistInfo,
|
||||||
vi.Pool = vi.Pool.Sub(withdrawalTokens)
|
vi.Pool = vi.Pool.Sub(withdrawalTokens)
|
||||||
vi.TotalDelAccum = vi.TotalDelAccum.sub(accum)
|
vi.TotalDelAccum = vi.TotalDelAccum.sub(accum)
|
||||||
|
|
||||||
return di, g, withdrawalTokens
|
return di, fp, withdrawalTokens
|
||||||
}
|
}
|
||||||
|
|
||||||
//_____________________________________________________________________
|
//_____________________________________________________________________
|
||||||
|
|
|
@ -14,41 +14,41 @@ type ValidatorDistInfo struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// update total delegator accumululation
|
// update total delegator accumululation
|
||||||
func (vi ValidatorDistInfo) UpdateTotalDelAccum(height int64, totalDelShares Dec) ValidatorDistInfo {
|
func (vi ValidatorDistInfo) UpdateTotalDelAccum(height int64, totalDelShares sdk.Dec) ValidatorDistInfo {
|
||||||
vi.DelAccum = vi.DelAccum.Update(height, totalDelShares)
|
vi.DelAccum = vi.DelAccum.Update(height, totalDelShares)
|
||||||
return vi
|
return vi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// XXX TODO Update dec logic
|
||||||
// move any available accumulated fees in the Global to the validator's pool
|
// move any available accumulated fees in the Global to the validator's pool
|
||||||
func (vi ValidatorDistInfo) TakeGlobalRewards(g Global, height int64, totalBonded, vdTokens, commissionRate Dec) (
|
func (vi ValidatorDistInfo) TakeFeePoolRewards(fp FeePool, height int64, totalBonded, vdTokens,
|
||||||
vi ValidatorDistInfo, g Global) {
|
commissionRate sdk.Dec) (ValidatorDistInfo, FeePool) {
|
||||||
|
|
||||||
g.UpdateTotalValAccum(height, totalBondedShares)
|
fp.UpdateTotalValAccum(height, totalBondedShares)
|
||||||
|
|
||||||
// update the validators pool
|
// update the validators pool
|
||||||
blocks = height - vi.GlobalWithdrawalHeight
|
blocks = height - vi.GlobalWithdrawalHeight
|
||||||
vi.GlobalWithdrawalHeight = height
|
vi.GlobalWithdrawalHeight = height
|
||||||
accum = blocks * vdTokens
|
accum = sdk.NewDec(blocks).Mul(vdTokens)
|
||||||
withdrawalTokens := g.Pool * accum / g.TotalValAccum
|
withdrawalTokens := fp.Pool.Mul(accum).Quo(fp.TotalValAccum)
|
||||||
commission := withdrawalTokens * commissionRate
|
commission := withdrawalTokens.Mul(commissionRate)
|
||||||
|
|
||||||
g.TotalValAccum -= accumm
|
fp.TotalValAccum = fp.TotalValAccum.Sub(accum)
|
||||||
g.Pool -= withdrawalTokens
|
fp.Pool = fp.Pool.Sub(withdrawalTokens)
|
||||||
vi.PoolCommission += commission
|
vi.PoolCommission = vi.PoolCommission.Add(commission)
|
||||||
vi.PoolCommissionFree += withdrawalTokens - commission
|
vi.PoolCommissionFree = vi.PoolCommissionFree.Add(withdrawalTokens.Sub(commission))
|
||||||
|
|
||||||
return vi, g
|
return vi, fp
|
||||||
}
|
}
|
||||||
|
|
||||||
// withdraw commission rewards
|
// withdraw commission rewards
|
||||||
func (vi ValidatorDistInfo) WithdrawCommission(g Global, height int64,
|
func (vi ValidatorDistInfo) WithdrawCommission(g Global, height int64,
|
||||||
totalBonded, vdTokens, commissionRate Dec) (
|
totalBonded, vdTokens, commissionRate Dec) (vio ValidatorDistInfo, fpo FeePool, withdrawn DecCoins) {
|
||||||
vi ValidatorDistInfo, g Global, withdrawn DecCoins) {
|
|
||||||
|
|
||||||
g = vi.TakeGlobalRewards(g, height, totalBonded, vdTokens, commissionRate)
|
fp = vi.TakeFeePoolRewards(fp, height, totalBonded, vdTokens, commissionRate)
|
||||||
|
|
||||||
withdrawalTokens := vi.PoolCommission
|
withdrawalTokens := vi.PoolCommission
|
||||||
vi.PoolCommission = 0
|
vi.PoolCommission = 0
|
||||||
|
|
||||||
return vi, g, withdrawalTokens
|
return vi, fp, withdrawalTokens
|
||||||
}
|
}
|
||||||
|
|
|
@ -736,6 +736,7 @@ func ensureValidatorFound(found bool, ownerAddr []byte) {
|
||||||
|
|
||||||
//__________________________________________________________________________
|
//__________________________________________________________________________
|
||||||
|
|
||||||
|
// XXX remove this code - this is should be superceded by commission work that bez is doing
|
||||||
// get a single validator
|
// get a single validator
|
||||||
func (k Keeper) UpdateValidatorCommission(ctx sdk.Context, addr sdk.ValAddress, newCommission sdk.Dec) sdk.Error {
|
func (k Keeper) UpdateValidatorCommission(ctx sdk.Context, addr sdk.ValAddress, newCommission sdk.Dec) sdk.Error {
|
||||||
store := ctx.KVStore(k.storeKey)
|
store := ctx.KVStore(k.storeKey)
|
||||||
|
@ -753,8 +754,6 @@ func (k Keeper) UpdateValidatorCommission(ctx sdk.Context, addr sdk.ValAddress,
|
||||||
return types.ErrNoValidatorFound(k.Codespace())
|
return types.ErrNoValidatorFound(k.Codespace())
|
||||||
case newCommission.LT(sdk.ZeroDec()):
|
case newCommission.LT(sdk.ZeroDec()):
|
||||||
return types.ErrCommissionNegative(k.Codespace())
|
return types.ErrCommissionNegative(k.Codespace())
|
||||||
case newCommission.GT(sdk.OnedDec()):
|
|
||||||
return types.ErrCommissionHuge(k.Codespace())
|
|
||||||
case newCommission.GT(validator.CommissionMax):
|
case newCommission.GT(validator.CommissionMax):
|
||||||
return types.ErrCommissionBeyondMax(k.Codespace())
|
return types.ErrCommissionBeyondMax(k.Codespace())
|
||||||
//case rateChange(Commission) > CommissionMaxChange: // XXX XXX XXX TODO implementation
|
//case rateChange(Commission) > CommissionMaxChange: // XXX XXX XXX TODO implementation
|
||||||
|
|
Loading…
Reference in New Issue