Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change bypass-min-fee-types parsing; change defaults (backport #2092) #2311

Merged
merged 17 commits into from
Mar 21, 2023
Merged
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ jobs:
if: env.GIT_DIFF
- name: Install Cosmovisor
run: |
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@v1.0.0
go install github.com/cosmos/cosmos-sdk/cosmovisor/cmd/cosmovisor@latest
if: env.GIT_DIFF
- name: Start GaiaV8
run: |
Expand Down
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Ref: https://keepachangelog.com/en/1.0.0/
# Changelog

## [Unreleased]
*
* (feat) Add two more msg types `/ibc.core.channel.v1.MsgTimeout` and `/ibc.core.channel.v1.MsgTimeoutOnClose` to default `bypass-min-fee-msg-types`.
* (feat) Change the bypassing gas usage criteria. Instead of requiring 200,000 gas per `bypass-min-fee-msg`, we will now allow a maximum total usage of 1,000,000 gas for all bypassed messages in a transaction. Note that all messages in the transaction must be the `bypass-min-fee-msg-types` for the bypass min fee to take effect, otherwise, fee payment will still apply.
* (fix) [#2087](https://github.com/cosmos/gaia/issues/2087) Fix `bypass-min-fee-msg-types` parsing in `app.toml`. Parsing of `bypass-min-fee-types` is changed to allow node operators to use empty bypass list. Removing the `bypass-min-fee-types` from `app.toml` applies the default message types. See [#2092](https://github.com/cosmos/gaia/pull/2092) for details.

## [v9.0.1] - 2023-03-09

Expand Down
25 changes: 23 additions & 2 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,11 +188,21 @@ func NewGaiaApp(
app.MountTransientStores(app.GetTransientStoreKey())
app.MountMemoryStores(app.GetMemoryStoreKey())

bypassMinFeeMsgTypes := cast.ToStringSlice(appOpts.Get(gaiaappparams.BypassMinFeeMsgTypesKey))
if bypassMinFeeMsgTypes == nil {
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))
}

app.Logger().Info("min fee bypass activated for message types", "types", bypassMinFeeMsgTypes)

anteHandler, err := gaiaante.NewAnteHandler(
gaiaante.HandlerOptions{
HandlerOptions: ante.HandlerOptions{
Expand Down Expand Up @@ -239,6 +249,17 @@ func GetDefaultBypassFeeMessages() []string {
}
}

// 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
11 changes: 10 additions & 1 deletion app/params/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,14 @@ var (
###############################################################################
# bypass-min-fee-msg-types defines custom message types the operator may set that
# will bypass minimum fee checks during CheckTx.
# NOTE:
# bypass-min-fee-msg-types = [] will deactivate the bypass - no messages will be allowed to bypass the minimum fee check
# bypass-min-fee-msg-types = [<MsgType>...] will allow messages of specified type to bypass the minimum fee check
# removing bypass-min-fee-msg-types from the config file will apply the default values:
# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient"]
#
# Example:
# ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", ...]
# bypass-min-fee-msg-types = ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient"]
bypass-min-fee-msg-types = [{{ range .BypassMinFeeMsgTypes }}{{ printf "%q, " . }}{{end}}]
`
)
Expand All @@ -42,5 +47,9 @@ type CustomAppConfig struct {

// BypassMinFeeMsgTypes defines custom message types the operator may set that
// will bypass minimum fee checks during CheckTx.
// NOTE:
// bypass-min-fee-msg-types = [] will deactivate the bypass - no messages will be allowed to bypass the minimum fee check
// bypass-min-fee-msg-types = [<some_msg_type>] will allow messages of specified type to bypass the minimum fee check
// omitting bypass-min-fee-msg-types from the config file will use the default values: ["/ibc.core.channel.v1.MsgRecvPacket", "/ibc.core.channel.v1.MsgAcknowledgement", "/ibc.core.client.v1.MsgUpdateClient"]
BypassMinFeeMsgTypes []string `mapstructure:"bypass-min-fee-msg-types"`
}
2 changes: 1 addition & 1 deletion contrib/scripts/run-gaia-v8.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,5 +67,5 @@ perl -i~ -0777 -pe 's/# Enable defines if the API server should be enabled.
enable = false/# Enable defines if the API server should be enabled.
enable = true/g' $NODE_HOME/config/app.toml

$COSMOVISOR start --home $NODE_HOME --x-crisis-skip-assert-invariants
$COSMOVISOR run start --home $NODE_HOME --x-crisis-skip-assert-invariants

3 changes: 2 additions & 1 deletion contrib/scripts/run-upgrade-commands.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ if test -f "$BINARY"; then


key=$($BINARY keys show val --home $NODE_HOME)
if [ key == "" ]; then

if [ -z "$key" ]; then
echo $USER_MNEMONIC | $BINARY --home $NODE_HOME keys add val --recover --keyring-backend=test
fi

Expand Down