Skip to content

Commit

Permalink
fix: module whitelist settings parse (#572)
Browse files Browse the repository at this point in the history
* fix how we parse module whitelist

* changelog update
  • Loading branch information
czarcas7ic committed May 9, 2024
1 parent 715f321 commit 7bc2cfc
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,8 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) {
)
}

fastNodeModuleWhitelist := ParseModuleWhitelist(appOpts)

return []func(*baseapp.BaseApp){
baseapp.SetPruning(pruningOpts),
baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(FlagMinGasPrices))),
Expand All @@ -555,7 +557,7 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) {
baseapp.SetSnapshot(snapshotStore, snapshotOptions),
baseapp.SetIAVLCacheSize(cast.ToInt(appOpts.Get(FlagIAVLCacheSize))),
baseapp.SetIAVLDisableFastNode(cast.ToBool(appOpts.Get(FlagDisableIAVLFastNode))),
baseapp.SetIAVLFastNodeModuleWhitelist(cast.ToStringSlice(appOpts.Get(FlagIAVLFastNodeModuleWhitelist))),
baseapp.SetIAVLFastNodeModuleWhitelist(fastNodeModuleWhitelist),
defaultMempool,
baseapp.SetChainID(chainID),
baseapp.SetQueryGasLimit(cast.ToUint64(appOpts.Get(FlagQueryGasLimit))),
Expand All @@ -580,3 +582,21 @@ func GetSnapshotStore(appOpts types.AppOptions) (*snapshots.Store, error) {

return snapshotStore, nil
}

func ParseModuleWhitelist(appOpts types.AppOptions) []string {
var whitelist []string
if wl, ok := appOpts.Get(FlagIAVLFastNodeModuleWhitelist).([]string); ok {
// Trim the brackets from the string
trimmed := strings.Trim(wl[0], "[]")
// If the trimmed string is not empty, split it into a slice of strings
if trimmed != "" {
// Split the string into a slice of strings using space and comma as the separators
whitelist = strings.FieldsFunc(trimmed, func(c rune) bool {
return c == ' ' || c == ','
})
}
} else {
whitelist = cast.ToStringSlice(appOpts.Get(FlagIAVLFastNodeModuleWhitelist))
}
return whitelist
}

0 comments on commit 7bc2cfc

Please sign in to comment.