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 #2092

Merged
merged 5 commits into from
Mar 17, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
}