major debugs
This commit is contained in:
parent
956566d5d1
commit
60a3541380
|
@ -168,7 +168,7 @@ func (app *GaiaApp) EndBlocker(ctx sdk.Context, req abci.RequestEndBlock) abci.R
|
|||
validatorUpdates := stake.EndBlocker(ctx, app.stakeKeeper)
|
||||
|
||||
// distribute rewards
|
||||
distr.EndBlocker(ctx, app.distrKeeper)
|
||||
//distr.EndBlocker(ctx, app.distrKeeper)
|
||||
|
||||
// Add these new validators to the addr -> pubkey map.
|
||||
app.slashingKeeper.AddValidators(ctx, validatorUpdates)
|
||||
|
|
|
@ -75,7 +75,7 @@ func GetCmdWithdrawRewards(cdc *codec.Codec) *cobra.Command {
|
|||
}
|
||||
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
return utils.CompleteAndBroadcastTxCli(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
cmd.Flags().String(flagOnlyFromValidator, "", "only withdraw from this validator address (in bech)")
|
||||
|
@ -110,7 +110,7 @@ func GetCmdSetWithdrawAddr(cdc *codec.Codec) *cobra.Command {
|
|||
msg := types.NewMsgSetWithdrawAddress(delAddr, withdrawAddr)
|
||||
|
||||
// build and sign the transaction, then broadcast to Tendermint
|
||||
return utils.SendTx(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
return utils.CompleteAndBroadcastTxCli(txBldr, cliCtx, []sdk.Msg{msg})
|
||||
},
|
||||
}
|
||||
return cmd
|
||||
|
|
|
@ -1,22 +1,27 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
||||
// Allocate fees handles distribution of the collected fees
|
||||
func (k Keeper) AllocateFees(ctx sdk.Context) {
|
||||
fmt.Println("wackydebugoutput AllocateFees 0")
|
||||
|
||||
// get the proposer of this block
|
||||
proposerConsAddr := k.GetProposerConsAddr(ctx)
|
||||
proposerValidator := k.stakeKeeper.ValidatorByConsAddr(ctx, proposerConsAddr)
|
||||
proposerDist := k.GetValidatorDistInfo(ctx, proposerValidator.GetOperator())
|
||||
fmt.Println("wackydebugoutput AllocateFees 1")
|
||||
|
||||
// get the fees which have been getting collected through all the
|
||||
// transactions in the block
|
||||
feesCollected := k.feeCollectionKeeper.GetCollectedFees(ctx)
|
||||
feesCollectedDec := types.NewDecCoins(feesCollected)
|
||||
fmt.Println("wackydebugoutput AllocateFees 2")
|
||||
|
||||
// allocated rewards to proposer
|
||||
bondedTokens := k.stakeKeeper.TotalPower(ctx)
|
||||
|
@ -24,25 +29,30 @@ func (k Keeper) AllocateFees(ctx sdk.Context) {
|
|||
proposerMultiplier := sdk.NewDecWithPrec(1, 2).Add(sdk.NewDecWithPrec(4, 2).Mul(
|
||||
sumPowerPrecommitValidators).Quo(bondedTokens))
|
||||
proposerReward := feesCollectedDec.Mul(proposerMultiplier)
|
||||
fmt.Println("wackydebugoutput AllocateFees 3")
|
||||
|
||||
// apply commission
|
||||
commission := proposerReward.Mul(proposerValidator.GetCommission())
|
||||
remaining := proposerReward.Mul(sdk.OneDec().Sub(proposerValidator.GetCommission()))
|
||||
proposerDist.PoolCommission = proposerDist.PoolCommission.Plus(commission)
|
||||
proposerDist.Pool = proposerDist.Pool.Plus(remaining)
|
||||
fmt.Println("wackydebugoutput AllocateFees 4")
|
||||
|
||||
// allocate community funding
|
||||
communityTax := k.GetCommunityTax(ctx)
|
||||
communityFunding := feesCollectedDec.Mul(communityTax)
|
||||
feePool := k.GetFeePool(ctx)
|
||||
feePool.CommunityPool = feePool.CommunityPool.Plus(communityFunding)
|
||||
fmt.Println("wackydebugoutput AllocateFees 5")
|
||||
|
||||
// set the global pool within the distribution module
|
||||
poolReceived := feesCollectedDec.Mul(sdk.OneDec().Sub(proposerMultiplier).Sub(communityTax))
|
||||
feePool.Pool = feePool.Pool.Plus(poolReceived)
|
||||
fmt.Println("wackydebugoutput AllocateFees 0")
|
||||
|
||||
k.SetValidatorDistInfo(ctx, proposerDist)
|
||||
k.SetFeePool(ctx, feePool)
|
||||
fmt.Println("wackydebugoutput AllocateFees 6")
|
||||
|
||||
// clear the now distributed fees
|
||||
k.feeCollectionKeeper.ClearCollectedFees(ctx)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
)
|
||||
|
@ -41,6 +43,7 @@ func (k Keeper) onDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress,
|
|||
WithdrawalHeight: ctx.BlockHeight(),
|
||||
}
|
||||
k.SetDelegatorDistInfo(ctx, ddi)
|
||||
ctx.Logger().With("module", "x/distribution").Error(fmt.Sprintf("ddi created: %v", ddi))
|
||||
}
|
||||
|
||||
// Withdrawal all validator rewards
|
||||
|
|
|
@ -46,12 +46,10 @@ func NewKeeper(cdc *codec.Codec, key, tkey sdk.StoreKey, ps params.Setter, ck ty
|
|||
// get the global fee pool distribution info
|
||||
func (k Keeper) GetFeePool(ctx sdk.Context) (feePool types.FeePool) {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
b := store.Get(FeePoolKey)
|
||||
if b == nil {
|
||||
panic("Stored fee pool should not have been nil")
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshalBinary(b, &feePool)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -6,10 +6,10 @@ import (
|
|||
|
||||
// keys/key-prefixes
|
||||
var (
|
||||
FeePoolKey = []byte{0x00} // key for global distribution state
|
||||
ValidatorDistInfoKey = []byte{0x01} // prefix for each key to a validator distribution
|
||||
DelegatorDistInfoKey = []byte{0x02} // prefix for each key to a delegation distribution
|
||||
DelegatorWithdrawInfoKey = []byte{0x03} // prefix for each key to a delegator withdraw info
|
||||
FeePoolKey = []byte{0x01} // key for global distribution state
|
||||
ValidatorDistInfoKey = []byte{0x02} // prefix for each key to a validator distribution
|
||||
DelegatorDistInfoKey = []byte{0x03} // prefix for each key to a delegation distribution
|
||||
DelegatorWithdrawInfoKey = []byte{0x04} // prefix for each key to a delegator withdraw info
|
||||
|
||||
// transient
|
||||
ProposerKey = []byte{0x00} // key for storing the proposer operator address
|
||||
|
|
|
@ -13,7 +13,7 @@ func (k Keeper) GetValidatorDistInfo(ctx sdk.Context,
|
|||
|
||||
b := store.Get(GetValidatorDistInfoKey(operatorAddr))
|
||||
if b == nil {
|
||||
panic("Stored delegation-distribution info should not have been nil")
|
||||
panic("Stored validator-distribution info should not have been nil")
|
||||
}
|
||||
|
||||
k.cdc.MustUnmarshalBinary(b, &vdi)
|
||||
|
|
|
@ -14,6 +14,10 @@ func (di DelegatorDistInfo) WithdrawRewards(fp FeePool, vi ValidatorDistInfo,
|
|||
height int64, totalBonded, vdTokens, totalDelShares, delegatorShares,
|
||||
commissionRate sdk.Dec) (DelegatorDistInfo, FeePool, DecCoins) {
|
||||
|
||||
if vi.DelAccum.Accum.IsZero() {
|
||||
return di, fp, DecCoins{}
|
||||
}
|
||||
|
||||
vi.UpdateTotalDelAccum(height, totalDelShares)
|
||||
vi, fp = vi.TakeFeePoolRewards(fp, height, totalBonded, vdTokens, commissionRate)
|
||||
|
||||
|
|
|
@ -26,6 +26,10 @@ func (vi ValidatorDistInfo) TakeFeePoolRewards(fp FeePool, height int64, totalBo
|
|||
|
||||
fp.UpdateTotalValAccum(height, totalBonded)
|
||||
|
||||
if fp.ValAccum.Accum.IsZero() {
|
||||
return vi, fp
|
||||
}
|
||||
|
||||
// update the validators pool
|
||||
blocks := height - vi.FeePoolWithdrawalHeight
|
||||
vi.FeePoolWithdrawalHeight = height
|
||||
|
|
|
@ -38,10 +38,13 @@ func InitGenesis(ctx sdk.Context, keeper Keeper, data types.GenesisState) (res [
|
|||
if validator.Status == sdk.Bonded {
|
||||
keeper.SetValidatorBondedIndex(ctx, validator)
|
||||
}
|
||||
|
||||
keeper.OnValidatorCreated(ctx, validator.OperatorAddr)
|
||||
}
|
||||
|
||||
for _, bond := range data.Bonds {
|
||||
keeper.SetDelegation(ctx, bond)
|
||||
for _, delegation := range data.Bonds {
|
||||
keeper.SetDelegation(ctx, delegation)
|
||||
keeper.OnDelegationCreated(ctx, delegation.DelegatorAddr, delegation.ValidatorAddr)
|
||||
}
|
||||
|
||||
keeper.UpdateBondedValidatorsFull(ctx)
|
||||
|
|
|
@ -336,7 +336,6 @@ func (k Keeper) unbond(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValA
|
|||
k.RemoveValidator(ctx, validator.OperatorAddr)
|
||||
}
|
||||
|
||||
k.OnDelegationSharesModified(ctx, delegation.DelegatorAddr, validator.OperatorAddr)
|
||||
return amount, nil
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue