From 2d01871aee1f9b5799943930ca9a99e28dfa0f06 Mon Sep 17 00:00:00 2001 From: Julien Robert Date: Wed, 17 Aug 2022 16:54:29 +0200 Subject: [PATCH] chore: add proposer removal changelog (#12941) --- CHANGELOG.md | 1 + x/distribution/abci_test.go | 134 ------------------------------------ 2 files changed, 1 insertion(+), 134 deletions(-) delete mode 100644 x/distribution/abci_test.go diff --git a/CHANGELOG.md b/CHANGELOG.md index b35c1791a6..b18fa3384b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/x/distribution/abci_test.go b/x/distribution/abci_test.go deleted file mode 100644 index c83f5189f3..0000000000 --- a/x/distribution/abci_test.go +++ /dev/null @@ -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) -}