chore: add proposer removal changelog (#12941)
This commit is contained in:
parent
6ed11b8f79
commit
2d01871aee
@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
|
||||
|
||||
### Improvements
|
||||
|
||||
* [#12876](https://github.com/cosmos/cosmos-sdk/pull/12876) Remove proposer-based rewards.
|
||||
* [#12892](https://github.com/cosmos/cosmos-sdk/pull/12892) `make format` now runs only gofumpt and golangci-lint run ./... --fix, replacing `goimports` `gofmt` and `misspell`
|
||||
* [#12846](https://github.com/cosmos/cosmos-sdk/pull/12846) Remove `RandomizedParams` from the `AppModuleSimulation` interface which is no longer needed.
|
||||
* (events) [#12850](https://github.com/cosmos/cosmos-sdk/pull/12850) Add a new `fee_payer` attribute to the `tx` event that is emitted from the `DeductFeeDecorator` AnteHandler decorator.
|
||||
|
||||
@ -1,134 +0,0 @@
|
||||
package distribution_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"cosmossdk.io/math"
|
||||
"github.com/stretchr/testify/require"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
|
||||
"github.com/cosmos/cosmos-sdk/crypto/keys/ed25519"
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/testutil"
|
||||
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
|
||||
"github.com/cosmos/cosmos-sdk/x/staking/teststaking"
|
||||
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
|
||||
)
|
||||
|
||||
const (
|
||||
totalValidators = 6
|
||||
lazyValidatorIdx = 2
|
||||
power = 100 / totalValidators
|
||||
)
|
||||
|
||||
var (
|
||||
valTokens = sdk.TokensFromConsensusPower(50, sdk.DefaultPowerReduction)
|
||||
validatorCommissionRates = stakingtypes.NewCommissionRates(math.LegacyOneDec(), math.LegacyOneDec(), math.LegacyOneDec())
|
||||
)
|
||||
|
||||
type validator struct {
|
||||
addr sdk.ValAddress
|
||||
pubkey cryptotypes.PubKey
|
||||
votes []abci.VoteInfo
|
||||
}
|
||||
|
||||
// Context in https://github.com/cosmos/cosmos-sdk/issues/9161
|
||||
func TestVerifyProposerRewardAssignement(t *testing.T) {
|
||||
var (
|
||||
bankKeeper bankkeeper.Keeper
|
||||
stakingKeeper *stakingkeeper.Keeper
|
||||
distrKeeper keeper.Keeper
|
||||
)
|
||||
|
||||
app, err := simtestutil.Setup(testutil.AppConfig,
|
||||
&bankKeeper,
|
||||
&stakingKeeper,
|
||||
&distrKeeper,
|
||||
)
|
||||
require.NoError(t, err)
|
||||
|
||||
ctx := app.BaseApp.NewContext(false, tmproto.Header{})
|
||||
addrs := simtestutil.AddTestAddrsIncremental(bankKeeper, stakingKeeper, ctx, totalValidators, valTokens)
|
||||
tstaking := teststaking.NewHelper(t, ctx, stakingKeeper)
|
||||
tstaking.Commission = validatorCommissionRates
|
||||
|
||||
// create validators
|
||||
validators := make([]validator, totalValidators-1)
|
||||
for i := range validators {
|
||||
validators[i].addr = sdk.ValAddress(addrs[i])
|
||||
validators[i].pubkey = ed25519.GenPrivKey().PubKey()
|
||||
validators[i].votes = make([]abci.VoteInfo, totalValidators)
|
||||
tstaking.CreateValidatorWithValPower(validators[i].addr, validators[i].pubkey, power, true)
|
||||
}
|
||||
app.EndBlock(abci.RequestEndBlock{})
|
||||
require.NotEmpty(t, app.Commit())
|
||||
|
||||
// verify validators lists
|
||||
require.Len(t, stakingKeeper.GetAllValidators(ctx), totalValidators)
|
||||
for i, val := range validators {
|
||||
// verify all validator exists
|
||||
require.NotNil(t, stakingKeeper.ValidatorByConsAddr(ctx, sdk.GetConsAddress(val.pubkey)))
|
||||
|
||||
// populate last commit info
|
||||
voteInfos := []abci.VoteInfo{}
|
||||
for _, val2 := range validators {
|
||||
voteInfos = append(voteInfos, abci.VoteInfo{
|
||||
Validator: abci.Validator{
|
||||
Address: sdk.GetConsAddress(val2.pubkey),
|
||||
Power: power,
|
||||
},
|
||||
SignedLastBlock: true,
|
||||
})
|
||||
}
|
||||
|
||||
// have this validator only submit the minimum amount of pre-commits
|
||||
if i == lazyValidatorIdx {
|
||||
for j := totalValidators * 2 / 3; j < len(voteInfos); j++ {
|
||||
voteInfos[j].SignedLastBlock = false
|
||||
}
|
||||
}
|
||||
|
||||
validators[i].votes = voteInfos
|
||||
}
|
||||
|
||||
// previous block submitted by validator n-1 (with 100% previous commits) and proposed by lazy validator
|
||||
app.BeginBlock(abci.RequestBeginBlock{
|
||||
Header: tmproto.Header{Height: app.LastBlockHeight() + 1, ProposerAddress: sdk.GetConsAddress(validators[lazyValidatorIdx].pubkey)},
|
||||
LastCommitInfo: abci.LastCommitInfo{Votes: validators[lazyValidatorIdx-1].votes},
|
||||
})
|
||||
require.NotEmpty(t, app.Commit())
|
||||
|
||||
// previous block submitted by lazy validator (with 67% previous commits) and proposed by validator n+1
|
||||
app.BeginBlock(abci.RequestBeginBlock{
|
||||
Header: tmproto.Header{Height: app.LastBlockHeight() + 1, ProposerAddress: sdk.GetConsAddress(validators[lazyValidatorIdx+1].pubkey)},
|
||||
LastCommitInfo: abci.LastCommitInfo{Votes: validators[lazyValidatorIdx].votes},
|
||||
})
|
||||
require.NotEmpty(t, app.Commit())
|
||||
|
||||
// previous block submitted by validator n+1 (with 100% previous commits) and proposed by validator n+2
|
||||
app.BeginBlock(abci.RequestBeginBlock{
|
||||
Header: tmproto.Header{Height: app.LastBlockHeight() + 1, ProposerAddress: sdk.GetConsAddress(validators[lazyValidatorIdx+2].pubkey)},
|
||||
LastCommitInfo: abci.LastCommitInfo{Votes: validators[lazyValidatorIdx+1].votes},
|
||||
})
|
||||
require.NotEmpty(t, app.Commit())
|
||||
|
||||
// Note, we used to ensure that the lazy validator's rewards are less than the
|
||||
// non-lazy validator, given the assumption that proposer-based rewards are
|
||||
// used. However, since proposer-based rewards are no longer used, the rewards
|
||||
// should be the same.
|
||||
//
|
||||
// We keep this (modified) assertion in case we'd like to augment the test
|
||||
// in the future.
|
||||
//
|
||||
// Ref: https://github.com/cosmos/cosmos-sdk/pull/12876
|
||||
rewardsValidatorBeforeLazyValidator := distrKeeper.GetValidatorOutstandingRewardsCoins(ctx, validators[lazyValidatorIdx+1].addr)
|
||||
rewardsLazyValidator := distrKeeper.GetValidatorOutstandingRewardsCoins(ctx, validators[lazyValidatorIdx].addr)
|
||||
rewardsValidatorAfterLazyValidator := distrKeeper.GetValidatorOutstandingRewardsCoins(ctx, validators[lazyValidatorIdx+1].addr)
|
||||
require.True(t, rewardsLazyValidator[0].Amount.Equal(rewardsValidatorAfterLazyValidator[0].Amount))
|
||||
require.Equal(t, rewardsValidatorBeforeLazyValidator, rewardsValidatorAfterLazyValidator)
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user