Skip to content

Commit

Permalink
Merge branch 'main' into facu/distr-mocks
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Aug 29, 2022
2 parents 2988b90 + 8436dc1 commit 0a84870
Show file tree
Hide file tree
Showing 26 changed files with 578 additions and 271 deletions.
30 changes: 30 additions & 0 deletions .github/ISSUE_TEMPLATE/epics.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
name: Epic
about: Create an epic/user

---

<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
v ✰ Thanks for opening an issue! ✰
v Before smashing the submit button please review the template.
v Word of caution: poorly thought-out proposals may be rejected
v without deliberation
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->

## Summary

<!-- Short, concise description of the proposed feature/changes to the repository
What are the user needs?
How could this solution fix the user facing problem? -->

## Problem Definition

<!-- Why do we need this feature?
What problems may be addressed by introducing this feature?
What benefits does the SDK stand to gain by including this feature?
Are there any disadvantages of including this feature? -->

## Work Breakdown

<!-- Break the work into many bullet points that will later be turned into issues that can be assigned to developers to work on
This work may been to be broken up into phases of work in order to better organize when and how things get done. -->
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (store) [#12945](https://github.com/cosmos/cosmos-sdk/pull/12945) Fix nil end semantics in store/cachekv/iterator when iterating a dirty cache.
* (export) [#13029](https://github.com/cosmos/cosmos-sdk/pull/13029) Fix exporting the blockParams regression.
* (x/gov) [#13051](https://github.com/cosmos/cosmos-sdk/pull/13051) In SubmitPropsal, when a legacy msg fails it's handler call, wrap the error as ErrInvalidProposalContent (instead of ErrNoProposalHandlerExists).
* (x/gov) [#13045](https://github.com/cosmos/cosmos-sdk/pull/13045) Fix gov migrations for v3(0.46).

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion cosmovisor/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ require (
github.com/cosmos/cosmos-sdk v0.46.1
github.com/hashicorp/go-getter v1.6.2
github.com/otiai10/copy v1.7.0
github.com/rs/zerolog v1.27.0
github.com/rs/zerolog v1.28.0
github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.8.0
)
Expand Down
6 changes: 3 additions & 3 deletions cosmovisor/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,9 @@ github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFR
github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XFkP+Eg=
github.com/rogpeppe/go-internal v1.8.1/go.mod h1:JeRgkft04UBgHMgCIwADu4Pn6Mtm5d4nPKWu0nJ5d+o=
github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs=
github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sasha-s/go-deadlock v0.2.1-0.20190427202633-1595213edefa h1:0U2s5loxrTy6/VgfVoLuVLFJcURKLH49ie0zSch7gh4=
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ require (
github.com/prometheus/common v0.37.0
github.com/rakyll/statik v0.1.7
github.com/regen-network/cosmos-proto v0.3.1
github.com/rs/zerolog v1.27.0
github.com/rs/zerolog v1.28.0
github.com/spf13/cast v1.5.0
github.com/spf13/cobra v1.5.0
github.com/spf13/pflag v1.0.5
Expand Down
6 changes: 3 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -932,9 +932,9 @@ github.com/rogpeppe/go-internal v1.8.1 h1:geMPLpDpQOgVyCg5z5GoRwLHepNdb71NXb67XF
github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/rs/cors v1.8.2 h1:KCooALfAYGs415Cwu5ABvv9n9509fSiG5SQJn/AQo4U=
github.com/rs/cors v1.8.2/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
github.com/rs/xid v1.3.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.27.0 h1:1T7qCieN22GVc8S4Q2yuexzBb1EqjbgjSH9RohbMjKs=
github.com/rs/zerolog v1.27.0/go.mod h1:7frBqO0oezxmnO7GF86FY++uy8I0Tk/If5ni1G9Qc0U=
github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
github.com/rs/zerolog v1.28.0 h1:MirSo27VyNi7RJYP3078AA1+Cyzd2GB66qy3aUHvsWY=
github.com/rs/zerolog v1.28.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
Expand Down
2 changes: 1 addition & 1 deletion orm/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
google.golang.org/grpc v1.49.0
google.golang.org/protobuf v1.28.1
gotest.tools/v3 v3.3.0
pgregory.net/rapid v0.4.8
pgregory.net/rapid v0.5.1
)

require (
Expand Down
4 changes: 2 additions & 2 deletions orm/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -257,5 +257,5 @@ gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gotest.tools/v3 v3.3.0 h1:MfDY1b1/0xN1CyMlQDac0ziEy9zJQd9CXBRRDHw2jJo=
gotest.tools/v3 v3.3.0/go.mod h1:Mcr9QNxkg0uMvy/YElmo4SpXgJKWgQvYrT7Kw5RzJ1A=
pgregory.net/rapid v0.4.7/go.mod h1:UYpPVyjFHzYBGHIxLFoupi8vwk6rXNzRY9OMvVxFIOU=
pgregory.net/rapid v0.4.8 h1:d+5SGZWUbJPbl3ss6tmPFqnNeQR6VDOFly+eTjwPiEw=
pgregory.net/rapid v0.4.8/go.mod h1:Z5PbWqjvWR1I3UGjvboUuan4fe4ZYEYNLNQLExzCoUs=
pgregory.net/rapid v0.5.1 h1:U7LVKOJavGH81G5buGiyztKCmpQLfepzitHEKDLQ8ug=
pgregory.net/rapid v0.5.1/go.mod h1:PY5XlDGj0+V1FCq0o192FdRhpKHGTRIWBgqjDBTrq04=
3 changes: 0 additions & 3 deletions simapp/params/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ package params
const (
DefaultWeightMsgSend int = 100
DefaultWeightMsgMultiSend int = 10
DefaultWeightMsgDeposit int = 100
DefaultWeightMsgVote int = 67
DefaultWeightMsgVoteWeighted int = 33
DefaultWeightMsgCreateValidator int = 100
DefaultWeightMsgEditValidator int = 5
DefaultWeightMsgDelegate int = 100
Expand Down
29 changes: 29 additions & 0 deletions tests/integration/gov/common_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package gov_test

import (
"testing"

"cosmossdk.io/math"
sdk "github.com/cosmos/cosmos-sdk/types"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
"github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
"github.com/stretchr/testify/require"
)

var (
valTokens = sdk.TokensFromConsensusPower(42, sdk.DefaultPowerReduction)
TestProposal = v1beta1.NewTextProposal("Test", "description")
TestDescription = stakingtypes.NewDescription("T", "E", "S", "T", "Z")
TestCommissionRates = stakingtypes.NewCommissionRates(math.LegacyZeroDec(), math.LegacyZeroDec(), math.LegacyZeroDec())
)

// mkTestLegacyContent creates a MsgExecLegacyContent for testing purposes.
func mkTestLegacyContent(t *testing.T) *v1.MsgExecLegacyContent {
msgContent, err := v1.NewLegacyContent(TestProposal, authtypes.NewModuleAddress(types.ModuleName).String())
require.NoError(t, err)

return msgContent
}
159 changes: 159 additions & 0 deletions tests/integration/gov/genesis_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
package gov_test

import (
"encoding/json"
"testing"

"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/codec"
"github.com/cosmos/cosmos-sdk/runtime"
"github.com/cosmos/cosmos-sdk/testutil/configurator"
simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims"
sdk "github.com/cosmos/cosmos-sdk/types"
_ "github.com/cosmos/cosmos-sdk/x/auth"
authkeeper "github.com/cosmos/cosmos-sdk/x/auth/keeper"
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
_ "github.com/cosmos/cosmos-sdk/x/bank"
bankkeeper "github.com/cosmos/cosmos-sdk/x/bank/keeper"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
_ "github.com/cosmos/cosmos-sdk/x/distribution"
distrkeeper "github.com/cosmos/cosmos-sdk/x/distribution/keeper"
distributiontypes "github.com/cosmos/cosmos-sdk/x/distribution/types"
"github.com/cosmos/cosmos-sdk/x/gov"
"github.com/cosmos/cosmos-sdk/x/gov/keeper"
"github.com/cosmos/cosmos-sdk/x/gov/types"
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
_ "github.com/cosmos/cosmos-sdk/x/params"
_ "github.com/cosmos/cosmos-sdk/x/staking"
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
)

type suite struct {
cdc codec.Codec
app *runtime.App
AccountKeeper authkeeper.AccountKeeper
BankKeeper bankkeeper.Keeper
DistrKeeper distrkeeper.Keeper
GovKeeper *keeper.Keeper
StakingKeeper *stakingkeeper.Keeper
appBuilder *runtime.AppBuilder
}

var appConfig = configurator.NewAppConfig(
configurator.ParamsModule(),
configurator.AuthModule(),
configurator.StakingModule(),
configurator.BankModule(),
configurator.GovModule(),
configurator.DistributionModule(),
configurator.MintModule(),
)

func TestImportExportQueues(t *testing.T) {
var err error

s1 := suite{}
s1.app, err = simtestutil.SetupWithConfiguration(
appConfig,
simtestutil.DefaultStartUpConfig(),
&s1.AccountKeeper, &s1.BankKeeper, &s1.DistrKeeper, &s1.GovKeeper, &s1.StakingKeeper, &s1.cdc, &s1.appBuilder,
)
require.NoError(t, err)

ctx := s1.app.BaseApp.NewContext(false, tmproto.Header{})
addrs := simtestutil.AddTestAddrs(s1.BankKeeper, s1.StakingKeeper, ctx, 1, valTokens)

header := tmproto.Header{Height: s1.app.LastBlockHeight() + 1}
s1.app.BeginBlock(abci.RequestBeginBlock{Header: header})

ctx = s1.app.BaseApp.NewContext(false, tmproto.Header{})
// Create two proposals, put the second into the voting period
proposal1, err := s1.GovKeeper.SubmitProposal(ctx, []sdk.Msg{mkTestLegacyContent(t)}, "")
require.NoError(t, err)
proposalID1 := proposal1.Id

proposal2, err := s1.GovKeeper.SubmitProposal(ctx, []sdk.Msg{mkTestLegacyContent(t)}, "")
require.NoError(t, err)
proposalID2 := proposal2.Id

votingStarted, err := s1.GovKeeper.AddDeposit(ctx, proposalID2, addrs[0], s1.GovKeeper.GetParams(ctx).MinDeposit)
require.NoError(t, err)
require.True(t, votingStarted)

proposal1, ok := s1.GovKeeper.GetProposal(ctx, proposalID1)
require.True(t, ok)
proposal2, ok = s1.GovKeeper.GetProposal(ctx, proposalID2)
require.True(t, ok)
require.True(t, proposal1.Status == v1.StatusDepositPeriod)
require.True(t, proposal2.Status == v1.StatusVotingPeriod)

authGenState := s1.AccountKeeper.ExportGenesis(ctx)
bankGenState := s1.BankKeeper.ExportGenesis(ctx)
stakingGenState := s1.StakingKeeper.ExportGenesis(ctx)
distributionGenState := s1.DistrKeeper.ExportGenesis(ctx)

// export the state and import it into a new app
govGenState := gov.ExportGenesis(ctx, s1.GovKeeper)
genesisState := s1.appBuilder.DefaultGenesis()

genesisState[authtypes.ModuleName] = s1.cdc.MustMarshalJSON(authGenState)
genesisState[banktypes.ModuleName] = s1.cdc.MustMarshalJSON(bankGenState)
genesisState[types.ModuleName] = s1.cdc.MustMarshalJSON(govGenState)
genesisState[stakingtypes.ModuleName] = s1.cdc.MustMarshalJSON(stakingGenState)
genesisState[distributiontypes.ModuleName] = s1.cdc.MustMarshalJSON(distributionGenState)

stateBytes, err := json.MarshalIndent(genesisState, "", " ")
require.NoError(t, err)

s2 := suite{}
s2.app, err = simtestutil.SetupWithConfiguration(
appConfig,
simtestutil.DefaultStartUpConfig(),
&s2.AccountKeeper, &s2.BankKeeper, &s2.DistrKeeper, &s2.GovKeeper, &s2.StakingKeeper, &s2.cdc, &s2.appBuilder,
)
require.NoError(t, err)

s2.app.InitChain(
abci.RequestInitChain{
Validators: []abci.ValidatorUpdate{},
ConsensusParams: simtestutil.DefaultConsensusParams,
AppStateBytes: stateBytes,
},
)

s2.app.Commit()
s2.app.BeginBlock(abci.RequestBeginBlock{Header: tmproto.Header{Height: s2.app.LastBlockHeight() + 1}})

header = tmproto.Header{Height: s2.app.LastBlockHeight() + 1}
s2.app.BeginBlock(abci.RequestBeginBlock{Header: header})

ctx2 := s2.app.BaseApp.NewContext(false, tmproto.Header{})

// Jump the time forward past the DepositPeriod and VotingPeriod
ctx2 = ctx2.WithBlockTime(ctx2.BlockHeader().Time.Add(*s2.GovKeeper.GetParams(ctx2).MaxDepositPeriod).Add(*s2.GovKeeper.GetParams(ctx2).VotingPeriod))

// Make sure that they are still in the DepositPeriod and VotingPeriod respectively
proposal1, ok = s2.GovKeeper.GetProposal(ctx2, proposalID1)
require.True(t, ok)
proposal2, ok = s2.GovKeeper.GetProposal(ctx2, proposalID2)
require.True(t, ok)
require.True(t, proposal1.Status == v1.StatusDepositPeriod)
require.True(t, proposal2.Status == v1.StatusVotingPeriod)

macc := s2.GovKeeper.GetGovernanceAccount(ctx2)
require.Equal(t, sdk.Coins(s2.GovKeeper.GetParams(ctx2).MinDeposit), s2.BankKeeper.GetAllBalances(ctx2, macc.GetAddress()))

// Run the endblocker. Check to make sure that proposal1 is removed from state, and proposal2 is finished VotingPeriod.
gov.EndBlocker(ctx2, s2.GovKeeper)

proposal1, ok = s2.GovKeeper.GetProposal(ctx2, proposalID1)
require.False(t, ok)

proposal2, ok = s2.GovKeeper.GetProposal(ctx2, proposalID2)
require.True(t, ok)
require.True(t, proposal2.Status == v1.StatusRejected)
}
File renamed without changes.
16 changes: 16 additions & 0 deletions testutil/configurator/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
feegrantmodulev1 "cosmossdk.io/api/cosmos/feegrant/module/v1"
genutilmodulev1 "cosmossdk.io/api/cosmos/genutil/module/v1"
govmodulev1 "cosmossdk.io/api/cosmos/gov/module/v1"
mintmodulev1 "cosmossdk.io/api/cosmos/mint/module/v1"
paramsmodulev1 "cosmossdk.io/api/cosmos/params/module/v1"
slashingmodulev1 "cosmossdk.io/api/cosmos/slashing/module/v1"
stakingmodulev1 "cosmossdk.io/api/cosmos/staking/module/v1"
Expand Down Expand Up @@ -197,6 +198,21 @@ func GovModule() ModuleOption {
}
}

func MintModule() ModuleOption {
return func(config *appConfig) {
config.moduleConfigs["mint"] = &appv1alpha1.ModuleConfig{
Name: "mint",
Config: appconfig.WrapAny(&mintmodulev1.Module{}),
GolangBindings: []*appv1alpha1.GolangBinding{
{
InterfaceType: "github.com/cosmos/cosmos-sdk/x/mint/types/types.StakingKeeper",
Implementation: "github.com/cosmos/cosmos-sdk/x/staking/keeper/*keeper.Keeper",
},
},
}
}
}

func OmitInitGenesis() ModuleOption {
return func(config *appConfig) {
config.setInitGenesis = false
Expand Down
3 changes: 0 additions & 3 deletions testutil/sims/weights.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ const (
DefaultWeightMsgWithdrawDelegationReward int = 50
DefaultWeightMsgWithdrawValidatorCommission int = 50
DefaultWeightMsgFundCommunityPool int = 50
DefaultWeightMsgDeposit int = 100
DefaultWeightMsgVote int = 67
DefaultWeightMsgVoteWeighted int = 33
DefaultWeightMsgUnjail int = 100
DefaultWeightMsgCreateValidator int = 100
DefaultWeightMsgEditValidator int = 5
Expand Down
3 changes: 0 additions & 3 deletions x/auth/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -1566,10 +1566,7 @@ func (s *IntegrationTestSuite) TestSignWithMultiSignersAminoJSON() {
require.Equal(sdk.NewCoins(val0Coin, val1Coin), queryRes.Balances)
}

// TODO to re-enable in #12274
func (s *IntegrationTestSuite) TestAuxSigner() {
s.T().Skip()

require := s.Require()
val := s.network.Validators[0]
val0Coin := sdk.NewCoin(fmt.Sprintf("%stoken", val.Moniker), sdk.NewInt(10))
Expand Down
4 changes: 0 additions & 4 deletions x/feegrant/client/testutil/suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,8 +713,6 @@ func (s *IntegrationTestSuite) TestNewCmdRevokeFeegrant() {
}

func (s *IntegrationTestSuite) TestTxWithFeeGrant() {
s.T().Skip() // TODO to re-enable in #12274

val := s.network.Validators[0]
clientCtx := val.ClientCtx
granter := val.Address
Expand Down Expand Up @@ -804,8 +802,6 @@ func (s *IntegrationTestSuite) TestTxWithFeeGrant() {
}

func (s *IntegrationTestSuite) TestFilteredFeeAllowance() {
s.T().Skip() // TODO to re-enable in #12274

val := s.network.Validators[0]

granter := val.Address
Expand Down
Loading

0 comments on commit 0a84870

Please sign in to comment.