Skip to content

Commit

Permalink
Merge branch 'main' into JeancarloBarrios/migrate-staking-away-from-p…
Browse files Browse the repository at this point in the history
…arams
  • Loading branch information
JeancarloBarrios committed Jul 17, 2022
2 parents beffda2 + 0a3c597 commit 06bb7ce
Show file tree
Hide file tree
Showing 23 changed files with 39 additions and 48 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### Improvements

* [#12589](https://github.com/cosmos/cosmos-sdk/pull/12589) Allow zero gas in simulation mode.
* [#12576](https://github.com/cosmos/cosmos-sdk/pull/12576) Remove dependency on cosmos/keyring and upgrade to 99designs/keyring v1.2.1
* [#12089](https://github.com/cosmos/cosmos-sdk/pull/12089) Mark the `TipDecorator` as beta, don't include it in simapp by default.
* [#12153](https://github.com/cosmos/cosmos-sdk/pull/12153) Add a new `NewSimulationManagerFromAppModules` constructor, to simplify simulation wiring.
Expand Down
1 change: 0 additions & 1 deletion core/appconfig/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,5 +118,4 @@ modules:
"@type": testpb.TestNoGoImportModule
`))
expectContainerErrorContains(t, opt, "module should have ModuleDescriptor.go_import specified")

}
2 changes: 1 addition & 1 deletion core/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (
golang.org/x/sys v0.0.0-20211019181941-9d821ace8654 // indirect
golang.org/x/text v0.3.5 // indirect
google.golang.org/genproto v0.0.0-20211223182754-3ac035c7e7cb // indirect
google.golang.org/grpc v1.47.0 // indirect
google.golang.org/grpc v1.48.0 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)
Expand Down
4 changes: 2 additions & 2 deletions core/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8
google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0=
google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU=
google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34=
google.golang.org/grpc v1.47.0 h1:9n77onPX5F3qfFCqjy9dhn8PbNQsIKeVU04J9G7umt8=
google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/grpc v1.48.0 h1:rQOsyJ/8+ufEDJd/Gdsz7HG220Mh9HAhFHRGnIjda0w=
google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk=
google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8=
google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0=
google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM=
Expand Down
6 changes: 4 additions & 2 deletions cosmovisor/cmd/cosmovisor/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,10 @@ func (s *InitTestSuite) setEnv(t *testing.T, env *cosmovisorInitEnv) {
}
}

var _ io.Reader = BufferedPipe{}
var _ io.Writer = BufferedPipe{}
var (
_ io.Reader = BufferedPipe{}
_ io.Writer = BufferedPipe{}
)

// BufferedPipe contains a connected read/write pair of files (a pipe),
// and a buffer of what goes through it that is populated in the background.
Expand Down
1 change: 0 additions & 1 deletion simapp/app_legacy.go
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,6 @@ func (app *SimApp) setAnteHandler(txConfig client.TxConfig) {
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
)

if err != nil {
panic(err)
}
Expand Down
6 changes: 2 additions & 4 deletions types/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import (
dbm "github.com/tendermint/tm-db"
)

var (
// This is set at compile time. Could be cleveldb, defaults is goleveldb.
backend = dbm.GoLevelDBBackend
)
// This is set at compile time. Could be cleveldb, defaults is goleveldb.
var backend = dbm.GoLevelDBBackend

// SortedJSON takes any JSON and returns it sorted by keys. Also, all white-spaces
// are removed.
Expand Down
16 changes: 12 additions & 4 deletions x/auth/ante/fee.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,21 @@ func (dfd DeductFeeDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bo
return ctx, sdkerrors.Wrap(sdkerrors.ErrTxDecode, "Tx must be a FeeTx")
}

if ctx.BlockHeight() > 0 && feeTx.GetGas() == 0 {
if !simulate && ctx.BlockHeight() > 0 && feeTx.GetGas() == 0 {
return ctx, sdkerrors.Wrap(sdkerrors.ErrInvalidGasLimit, "must provide positive gas")
}

fee, priority, err := dfd.txFeeChecker(ctx, tx)
if err != nil {
return ctx, err
var (
priority int64
err error
)

fee := feeTx.GetFee()
if !simulate {
fee, priority, err = dfd.txFeeChecker(ctx, tx)
if err != nil {
return ctx, err
}
}
if err := dfd.checkDeductFee(ctx, tx, fee); err != nil {
return ctx, err
Expand Down
9 changes: 9 additions & 0 deletions x/auth/ante/fee_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ func (s *AnteTestSuite) TestDeductFeeDecorator_ZeroGas() {

_, err = antehandler(s.ctx, tx, false)
s.Require().Error(err)

// zero gas is accepted in simulation mode
_, err = antehandler(s.ctx, tx, true)
s.Require().NoError(err)
}

func (s *AnteTestSuite) TestEnsureMempoolFees() {
Expand Down Expand Up @@ -74,6 +78,11 @@ func (s *AnteTestSuite) TestEnsureMempoolFees() {
_, err = antehandler(s.ctx, tx, false)
s.Require().NotNil(err, "Decorator should have errored on too low fee for local gasPrice")

// antehandler should not error since we do not check minGasPrice in simulation mode
cacheCtx, _ := s.ctx.CacheContext()
_, err = antehandler(cacheCtx, tx, true)
s.Require().Nil(err, "Decorator should not have errored in simulation mode")

// Set IsCheckTx to false
s.ctx = s.ctx.WithIsCheckTx(false)

Expand Down
1 change: 0 additions & 1 deletion x/auth/ante/sigverify_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func (suite *AnteTestSuite) TestSigVerification() {
// In the meantime, we want to make double-sure amino compatibility works.
// ref: https://github.com/cosmos/cosmos-sdk/issues/7229
func (suite *AnteTestSuite) TestSigVerification_ExplicitAmino() {

// Set up TxConfig.
aminoCdc := codec.NewLegacyAmino()
// We're using TestMsg amino encoding in some tests, so register it here.
Expand Down
1 change: 0 additions & 1 deletion x/auth/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ func NewAccountKeeper(
cdc codec.BinaryCodec, storeKey storetypes.StoreKey, proto func() types.AccountI,
maccPerms map[string][]string, bech32Prefix string, authority string,
) AccountKeeper {

permAddrs := make(map[string]types.PermissionsForAddress)
for name, perms := range maccPerms {
permAddrs[name] = types.NewPermissionsForAddress(name, perms)
Expand Down
1 change: 0 additions & 1 deletion x/auth/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ func (suite *KeeperTestSuite) TestGetSetParams() {
}

func (suite *KeeperTestSuite) TestSupply_ValidatePermissions() {

err := suite.accountKeeper.ValidatePermissions(multiPermAcc)
suite.Require().NoError(err)

Expand Down
5 changes: 0 additions & 5 deletions x/auth/migrations/v043/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ func TestMigrateVestingAccounts(t *testing.T) {
{
"delayed vesting has vested, multiple delegations less than the total account balance",
func(ctx sdk.Context, validator stakingtypes.Validator, delegatorAddr sdk.AccAddress) {

baseAccount := authtypes.NewBaseAccountWithAddress(delegatorAddr)
vestedCoins := sdk.NewCoins(sdk.NewCoin(stakingKeeper.BondDenom(ctx), sdk.NewInt(200)))
delayedAccount := types.NewDelayedVestingAccount(baseAccount, vestedCoins, ctx.BlockTime().Unix())
Expand Down Expand Up @@ -590,7 +589,6 @@ func TestMigrateVestingAccounts(t *testing.T) {
for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {

err := accountKeeper.SetParams(ctx, authtypes.DefaultParams())
require.NoError(t, err)

Expand Down Expand Up @@ -652,7 +650,6 @@ func trackingCorrected(ctx sdk.Context, t *testing.T, ak keeper.AccountKeeper, a
}

func cleartTrackingFields(ctx sdk.Context, vesting exported.VestingAccount, accountKeeper keeper.AccountKeeper) error {

switch t := vesting.(type) {
case *types.DelayedVestingAccount:
t.DelegatedFree = nil
Expand All @@ -674,7 +671,6 @@ func cleartTrackingFields(ctx sdk.Context, vesting exported.VestingAccount, acco
}

func dirtyTrackingFields(ctx sdk.Context, vesting exported.VestingAccount, accountKeeper keeper.AccountKeeper) error {

dirt := sdk.NewCoins(sdk.NewInt64Coin("stake", 42))

switch t := vesting.(type) {
Expand All @@ -698,7 +694,6 @@ func dirtyTrackingFields(ctx sdk.Context, vesting exported.VestingAccount, accou
}

func createValidator(t *testing.T, ctx sdk.Context, bankKeeper bankkeeper.Keeper, stakingKeeper *stakingkeeper.Keeper, powers int64) (sdk.AccAddress, sdk.ValAddress) {

valTokens := sdk.TokensFromConsensusPower(powers, sdk.DefaultPowerReduction)
addrs := simtestutil.AddTestAddrsIncremental(bankKeeper, stakingKeeper, ctx, 1, valTokens)
valAddrs := simtestutil.ConvertAddrsToValAddrs(addrs)
Expand Down
4 changes: 1 addition & 3 deletions x/auth/migrations/v046/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,7 @@ func TestMigrateMapAccAddressToAccNumberKey(t *testing.T) {
ctx := testutil.DefaultContext(storeKey, tKey)
store := ctx.KVStore(storeKey)

var (
accountKeeper keeper.AccountKeeper
)
var accountKeeper keeper.AccountKeeper

app, err := simtestutil.Setup(
authtestutil.AppConfig,
Expand Down
5 changes: 1 addition & 4 deletions x/auth/migrations/v4/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const (
ModuleName = "auth"
)

var (
ParamsKey = []byte{0x01}
)
var ParamsKey = []byte{0x01}

// Migrate migrates the x/auth module state from the consensus version 3 to
// version 4. Specifically, it takes the parameters that are currently stored
Expand All @@ -31,5 +29,4 @@ func Migrate(ctx sdk.Context, store sdk.KVStore, legacySubspace exported.Subspac
store.Set(ParamsKey, bz)

return nil

}
1 change: 0 additions & 1 deletion x/crisis/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ func NewKeeper(
cdc codec.BinaryCodec, storeKey storetypes.StoreKey, invCheckPeriod uint,
supplyKeeper types.SupplyKeeper, feeCollectorName string, authority string,
) *Keeper {

return &Keeper{
storeKey: storeKey,
cdc: cdc,
Expand Down
4 changes: 1 addition & 3 deletions x/crisis/types/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ const (
StoreKey = ModuleName
)

var (
ConstantFeeKey = []byte{0x01}
)
var ConstantFeeKey = []byte{0x01}
4 changes: 1 addition & 3 deletions x/distribution/migrations/v3/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ const (
ModuleName = "distribution"
)

var (
ParamsKey = []byte{0x09}
)
var ParamsKey = []byte{0x09}

// MigrateStore migrates the x/distribution module state from the consensus version 2 to
// version 3. Specifically, it takes the parameters that are currently stored
Expand Down
4 changes: 1 addition & 3 deletions x/feegrant/testutil/app_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,4 @@ import (
//go:embed app.yaml
var appConfig []byte

var (
AppConfig = appconfig.LoadYAML(appConfig)
)
var AppConfig = appconfig.LoadYAML(appConfig)
4 changes: 1 addition & 3 deletions x/mint/migrations/v2/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const (
ModuleName = "mint"
)

var (
ParamsKey = []byte{0x01}
)
var ParamsKey = []byte{0x01}

// Migrate migrates the x/mint module state from the consensus version 1 to
// version 2. Specifically, it takes the parameters that are currently stored
Expand Down
2 changes: 1 addition & 1 deletion x/params/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ type subspaceInputs struct {

func provideSubspace(in subspaceInputs) types.Subspace {
moduleName := in.Key.Name()
var kt, exists = in.KeyTables[moduleName]
kt, exists := in.KeyTables[moduleName]
if !exists {
return in.Keeper.Subspace(moduleName)
} else {
Expand Down
1 change: 0 additions & 1 deletion x/slashing/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ type Keeper struct {

// NewKeeper creates a slashing keeper
func NewKeeper(cdc codec.BinaryCodec, legacyAmino *codec.LegacyAmino, key storetypes.StoreKey, sk types.StakingKeeper, authority string) Keeper {

return Keeper{
storeKey: key,
cdc: cdc,
Expand Down
4 changes: 1 addition & 3 deletions x/slashing/migrations/v3/migrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const (
ModuleName = "slashing"
)

var (
ParamsKey = []byte{0x00}
)
var ParamsKey = []byte{0x00}

// Migrate migrates the x/slashing module state from the consensus version 2 to
// version 3. Specifically, it takes the parameters that are currently stored
Expand Down

0 comments on commit 06bb7ce

Please sign in to comment.