Skip to content

Commit

Permalink
feat!: bypass-min-fee migration (#2352)
Browse files Browse the repository at this point in the history
* feat: update proto files

* feat: update proto-docs

* refactor: update query request and response

* refactor: add bypass-min-fee-msg-types and max_total_bypass_minFee_msg_gas_usage to globalfee params

* test: update test

* feat: add migration

* docs: update changelog

* add BypassMinFeeMsgTypes param to store

* feat: add validateBypassMinFeeMsgTypes

* update fee decorator and global fee genesis

* merge main

* test: fix e2e test

* test: add migration_test

* chore: add comments

* remove bypass from config

* fix: proto typo

* skip bypass test

* save

* update ditrosless image url in Dockerfiles

* fix typo in makefil

* save

* update doc

* update params

* fix e2e bypass msg test

* save

* save

* update e2e bypass min fee test

* remove print

* update migrator test

* update CI upgrade tests

* make CI works running all contrib scripts in on step

* prepare merge

* nits

* update migration commment

* update CI tests

* update doc

* fix tiny update

* fix tiny update

* update changelog

* fix linter

* fix linter

* remove todos

* fix changelog

* revert package upgrade to v10

* Update changelog and merge with main

* Update CI to query migrate globalfee params

* fix CI script

* clean e2e tests

* fix QueryParamsResponse

* chore: remove duplicates

* docs: update proto doc

* fix: globalfee params query

* fix: e2e test, query globalfee params

* update module to v10

* fix lint

* docs: update changelog

* docs: update changelog links

* update according to comments

* test: upgrade fromVersion v9.1.0

* Update contrib/single-node.sh

Fix nitpick

Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>

* docs: update changelog about API endpoint change

---------

Co-authored-by: Simon Noetzlin <simon.ntz@gmail.com>
Co-authored-by: MSalopek <matija.salopek994@gmail.com>
Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com>
  • Loading branch information
4 people authored May 17, 2023
1 parent 9ee42c8 commit d425834
Show file tree
Hide file tree
Showing 57 changed files with 563 additions and 397 deletions.
21 changes: 12 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
name: Test

on:
workflow_call:
pull_request:
Expand Down Expand Up @@ -126,35 +125,39 @@ jobs:
- uses: actions/setup-go@v4
with:
go-version: 1.18
- name: Install GaiaV8
- name: Install GaiaV9
run: |
git checkout v8.0.0
git checkout v9.1.0
make build
cp ./build/gaiad ./build/gaiad8
cp ./build/gaiad ./build/gaiad9
go clean -modcache
if: env.GIT_DIFF
- uses: actions/setup-go@v4
with:
go-version: 1.20.x
- name: Install GaiaV9
- name: Install GaiaV10
run: |
git checkout -
make build
cp ./build/gaiad ./build/gaiad9
cp ./build/gaiad ./build/gaiad10
if: env.GIT_DIFF
- name: Install Cosmovisor
run: |
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@latest
if: env.GIT_DIFF
- name: Start GaiaV8
- name: Start GaiaV9
run: |
./contrib/scripts/run-gaia-v8.sh > v8.out 2>&1 &
go env GOPATH
./contrib/scripts/run-gaia-v9.sh
if: env.GIT_DIFF
- name: Submit Upgrade Commands
run: |
./contrib/scripts/run-upgrade-commands.sh 15
./contrib/scripts/run-upgrade-commands-v10.sh 15
if: env.GIT_DIFF
- name: Check for successful upgrade
run: |
./contrib/scripts/test_upgrade.sh 20 5 16 localhost
if: env.GIT_DIFF
- name: Check for successful migration
run: |
./contrib/scripts/test_migration.sh localhost
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ Ref: https://keepachangelog.com/en/1.0.0/
* (gaia) [#2442](https://github.com/cosmos/gaia/pull/2442) Bump [Interchain-Security](https://github.com/cosmos/interchain-security) to [v1.1.1](https://github.com/cosmos/interchain-security/tree/v1.1.1).

### State Machine Breaking
* (feat!) [#2424] Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params. Note that this change is both state breaking and API breaking.
* (gaia) Bump Golang prerequisite from 1.18 to 1.20 see (https://go.dev/blog/go1.20) for details.
* (feat!) [#2447] Update Global Fee's AnteHandler to check tx fees against the network min gas prices in DeliverTx mode.

* (feat!) [#2424](https://github.com/cosmos/gaia/pull/2424) Add `bypass-min-fee-msg-types` and `maxTotalBypassMinFeeMsgGagUsage` to globalfee params. Note that this change is both state breaking and API breaking. The previous API endpoint was "/gaia/globalfee/v1beta1/minimum_gas_prices," and the new API endpoint is "/gaia/globalfee/v1beta1/params."
* (feat!) [#2352](https://github.com/cosmos/gaia/pull/2352) Create the upgrade handler and params migration for the new Gloabal Fee module parameters introduced in [#2424](https://github.com/cosmos/gaia/pull/2424).
Update the CI upgrade tests from v9 to the v10 and check that the parameters are successfully migrated.
* (feat!) [#2447](https://github.com/cosmos/gaia/pull/2447) Update Global Fee's AnteHandler to check tx fees against the network min gas prices in DeliverTx mode.

## [v9.0.3] - 2023-04-19
* (deps) [#2399](https://github.com/cosmos/gaia/pull/2399) Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to [v0.45.15-ics](https://github.com/cosmos/cosmos
Expand Down
13 changes: 6 additions & 7 deletions ante/ante.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ import (
ibcante "github.com/cosmos/ibc-go/v4/modules/core/ante"
ibckeeper "github.com/cosmos/ibc-go/v4/modules/core/keeper"

gaiafeeante "github.com/cosmos/gaia/v9/x/globalfee/ante"
gaiafeeante "github.com/cosmos/gaia/v10/x/globalfee/ante"
)

// HandlerOptions extend the SDK's AnteHandler options by requiring the IBC
// channel keeper.
type HandlerOptions struct {
ante.HandlerOptions
Codec codec.BinaryCodec
GovKeeper *govkeeper.Keeper
IBCkeeper *ibckeeper.Keeper
BypassMinFeeMsgTypes []string
GlobalFeeSubspace paramtypes.Subspace
StakingSubspace paramtypes.Subspace
Codec codec.BinaryCodec
GovKeeper *govkeeper.Keeper
IBCkeeper *ibckeeper.Keeper
GlobalFeeSubspace paramtypes.Subspace
StakingSubspace paramtypes.Subspace
}

func NewAnteHandler(opts HandlerOptions) (sdk.AnteHandler, error) {
Expand Down
7 changes: 4 additions & 3 deletions ante/gov_ante_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,13 @@ import (

"github.com/cosmos/cosmos-sdk/client"
"github.com/cosmos/cosmos-sdk/testutil/testdata"
"github.com/cosmos/gaia/v9/ante"
gaiahelpers "github.com/cosmos/gaia/v9/app/helpers"
tmrand "github.com/tendermint/tendermint/libs/rand"
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"

gaiaapp "github.com/cosmos/gaia/v9/app"
"github.com/cosmos/gaia/v10/ante"
gaiahelpers "github.com/cosmos/gaia/v10/app/helpers"

gaiaapp "github.com/cosmos/gaia/v10/app"
)

var (
Expand Down
61 changes: 12 additions & 49 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ import (
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
ibcclienttypes "github.com/cosmos/ibc-go/v4/modules/core/02-client/types"
ibcchanneltypes "github.com/cosmos/ibc-go/v4/modules/core/04-channel/types"
ibctesting "github.com/cosmos/interchain-security/legacy_ibc_testing/testing"
"github.com/gorilla/mux"
"github.com/rakyll/statik/fs"
Expand All @@ -40,12 +38,12 @@ import (
tmos "github.com/tendermint/tendermint/libs/os"
dbm "github.com/tendermint/tm-db"

gaiaante "github.com/cosmos/gaia/v9/ante"
"github.com/cosmos/gaia/v9/app/keepers"
gaiaappparams "github.com/cosmos/gaia/v9/app/params"
"github.com/cosmos/gaia/v9/app/upgrades"
v9 "github.com/cosmos/gaia/v9/app/upgrades/v9"
"github.com/cosmos/gaia/v9/x/globalfee"
gaiaante "github.com/cosmos/gaia/v10/ante"
"github.com/cosmos/gaia/v10/app/keepers"
gaiaappparams "github.com/cosmos/gaia/v10/app/params"
"github.com/cosmos/gaia/v10/app/upgrades"
v10 "github.com/cosmos/gaia/v10/app/upgrades/v10"
"github.com/cosmos/gaia/v10/x/globalfee"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
Expand All @@ -55,7 +53,7 @@ var (
// DefaultNodeHome default home directories for the application daemon
DefaultNodeHome string

Upgrades = []upgrades.Upgrade{v9.Upgrade}
Upgrades = []upgrades.Upgrade{v10.Upgrade}
)

var (
Expand Down Expand Up @@ -188,19 +186,6 @@ func NewGaiaApp(
app.MountTransientStores(app.GetTransientStoreKey())
app.MountMemoryStores(app.GetMemoryStoreKey())

var bypassMinFeeMsgTypes []string
bypassMinFeeMsgTypesOptions := appOpts.Get(gaiaappparams.BypassMinFeeMsgTypesKey)
if bypassMinFeeMsgTypesOptions == nil {
bypassMinFeeMsgTypes = GetDefaultBypassFeeMessages()
} else {
bypassMinFeeMsgTypes = cast.ToStringSlice(bypassMinFeeMsgTypesOptions)
}

if err := app.ValidateBypassFeeMsgTypes(bypassMinFeeMsgTypes); err != nil {
app.Logger().Error("invalid 'bypass-min-fee-msg-types' config option", "error", err)
panic(fmt.Sprintf("invalid 'bypass-min-fee-msg-types' config option: %s", err))
}

anteHandler, err := gaiaante.NewAnteHandler(
gaiaante.HandlerOptions{
HandlerOptions: ante.HandlerOptions{
Expand All @@ -210,12 +195,11 @@ func NewGaiaApp(
SignModeHandler: encodingConfig.TxConfig.SignModeHandler(),
SigGasConsumer: ante.DefaultSigVerificationGasConsumer,
},
Codec: appCodec,
IBCkeeper: app.IBCKeeper,
GovKeeper: &app.GovKeeper,
BypassMinFeeMsgTypes: bypassMinFeeMsgTypes,
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
StakingSubspace: app.GetSubspace(stakingtypes.ModuleName),
Codec: appCodec,
IBCkeeper: app.IBCKeeper,
GovKeeper: &app.GovKeeper,
GlobalFeeSubspace: app.GetSubspace(globalfee.ModuleName),
StakingSubspace: app.GetSubspace(stakingtypes.ModuleName),
},
)
if err != nil {
Expand All @@ -239,27 +223,6 @@ func NewGaiaApp(
return app
}

func GetDefaultBypassFeeMessages() []string {
return []string{
sdk.MsgTypeURL(&ibcchanneltypes.MsgRecvPacket{}),
sdk.MsgTypeURL(&ibcchanneltypes.MsgAcknowledgement{}),
sdk.MsgTypeURL(&ibcclienttypes.MsgUpdateClient{}),
sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeout{}),
sdk.MsgTypeURL(&ibcchanneltypes.MsgTimeoutOnClose{}),
}
}

// ValidateBypassFeeMsgTypes checks that a proto message type exists for all MsgTypes in bypassMinFeeMsgTypes
// An error is returned for the first msgType that cannot be resolved
func (app *GaiaApp) ValidateBypassFeeMsgTypes(bypassMinFeeMsgTypes []string) error {
for _, msgType := range bypassMinFeeMsgTypes {
if _, err := app.interfaceRegistry.Resolve(msgType); err != nil {
return err
}
}
return nil
}

// Name returns the name of the App
func (app *GaiaApp) Name() string { return app.BaseApp.Name() }

Expand Down
5 changes: 3 additions & 2 deletions app/app_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (

authtypes "github.com/cosmos/cosmos-sdk/x/auth/types"
govtypes "github.com/cosmos/cosmos-sdk/x/gov/types"
gaia "github.com/cosmos/gaia/v9/app"
gaiahelpers "github.com/cosmos/gaia/v9/app/helpers"
"github.com/stretchr/testify/require"
"github.com/tendermint/tendermint/libs/log"
db "github.com/tendermint/tm-db"

gaia "github.com/cosmos/gaia/v10/app"
gaiahelpers "github.com/cosmos/gaia/v10/app/helpers"
)

type EmptyAppOptions struct{}
Expand Down
2 changes: 1 addition & 1 deletion app/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package gaia
import (
"github.com/cosmos/cosmos-sdk/std"

"github.com/cosmos/gaia/v9/app/params"
"github.com/cosmos/gaia/v10/app/params"
)

// MakeTestEncodingConfig creates an EncodingConfig for testing. This function
Expand Down
2 changes: 1 addition & 1 deletion app/helpers/test_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
tmtypes "github.com/tendermint/tendermint/types"
dbm "github.com/tendermint/tm-db"

gaiaapp "github.com/cosmos/gaia/v9/app"
gaiaapp "github.com/cosmos/gaia/v10/app"
)

// SimAppChainID hardcoded chainID for simulation
Expand Down
3 changes: 2 additions & 1 deletion app/keepers/keepers.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
"github.com/cosmos/cosmos-sdk/x/upgrade"
upgradekeeper "github.com/cosmos/cosmos-sdk/x/upgrade/keeper"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"
"github.com/cosmos/gaia/v9/x/globalfee"
ica "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts"
icahost "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host"
icahostkeeper "github.com/cosmos/ibc-go/v4/modules/apps/27-interchain-accounts/host/keeper"
Expand All @@ -62,6 +61,8 @@ import (
routerkeeper "github.com/strangelove-ventures/packet-forward-middleware/v4/router/keeper"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"

"github.com/cosmos/gaia/v10/x/globalfee"

// unnamed import of statik for swagger UI support
_ "github.com/cosmos/cosmos-sdk/client/docs/statik"
)
Expand Down
4 changes: 2 additions & 2 deletions app/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ import (
"github.com/strangelove-ventures/packet-forward-middleware/v4/router"
routertypes "github.com/strangelove-ventures/packet-forward-middleware/v4/router/types"

gaiaappparams "github.com/cosmos/gaia/v9/app/params"
"github.com/cosmos/gaia/v9/x/globalfee"
gaiaappparams "github.com/cosmos/gaia/v10/app/params"
"github.com/cosmos/gaia/v10/x/globalfee"
)

var maccPerms = map[string][]string{
Expand Down
55 changes: 0 additions & 55 deletions app/params/config.go

This file was deleted.

4 changes: 2 additions & 2 deletions app/sim/sim_state.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ import (
"os"
"time"

"github.com/cosmos/gaia/v9/app"

tmjson "github.com/tendermint/tendermint/libs/json"
tmtypes "github.com/tendermint/tendermint/types"

gaia "github.com/cosmos/gaia/v10/app"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1"
simappparams "github.com/cosmos/cosmos-sdk/simapp/params"
Expand Down
4 changes: 2 additions & 2 deletions app/sim/sim_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import (
"fmt"
"os"

"github.com/cosmos/gaia/v9/app"

"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

gaia "github.com/cosmos/gaia/v10/app"

"github.com/cosmos/cosmos-sdk/codec"
"github.com/cosmos/cosmos-sdk/simapp/helpers"
sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down
8 changes: 4 additions & 4 deletions app/sim_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ import (
"github.com/tendermint/tendermint/libs/log"
dbm "github.com/tendermint/tm-db"

gaia "github.com/cosmos/gaia/v9/app"
"github.com/cosmos/gaia/v9/app/helpers"
"github.com/cosmos/gaia/v9/app/params"
"github.com/cosmos/gaia/v9/app/sim"
gaia "github.com/cosmos/gaia/v10/app"
"github.com/cosmos/gaia/v10/app/helpers"
"github.com/cosmos/gaia/v10/app/params"
"github.com/cosmos/gaia/v10/app/sim"
)

func init() {
Expand Down
2 changes: 1 addition & 1 deletion app/upgrades/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/cosmos/cosmos-sdk/types/module"
upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types"

"github.com/cosmos/gaia/v9/app/keepers"
"github.com/cosmos/gaia/v10/app/keepers"
)

// Upgrade defines a struct containing necessary fields that a SoftwareUpgradeProposal
Expand Down
15 changes: 15 additions & 0 deletions app/upgrades/v10/constants.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package v10

import (
"github.com/cosmos/gaia/v10/app/upgrades"
)

const (
// UpgradeName defines the on-chain upgrade name.
UpgradeName = "v10"
)

var Upgrade = upgrades.Upgrade{
UpgradeName: UpgradeName,
CreateUpgradeHandler: CreateUpgradeHandler,
}
Loading

0 comments on commit d425834

Please sign in to comment.