From cf09bb59fa0ba3c5d96f3018dbd74131fccef57c Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Wed, 13 Mar 2024 18:08:38 -0500 Subject: [PATCH] fix: module whitelist settings parse (#572) * fix how we parse module whitelist * changelog update --- CHANGELOG.md | 8 ++++++++ server/util.go | 22 +++++++++++++++++++++- 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 36c579bc624a..ccff25c0d0b6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased IAVL v1] +## [v0.47.5-v23-osmo-5-iavl-v1](https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-v23-osmo-5-iavl-v1) + +* (config) [#572](https://github.com/osmosis-labs/cosmos-sdk/pull/572) Fix module whitelist parsing + ## [v0.47.5-v23-osmo-4-iavl-v1](https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-v23-osmo-4-iavl-v1) * (config) [#563](https://github.com/osmosis-labs/cosmos-sdk/pull/563) Set lockup as the default whitelisted fast nodes module @@ -70,6 +74,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased IAVL v0] +## [v0.47.5-v23-osmo-4](https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-v23-osmo-4) + +* (config) [#572](https://github.com/osmosis-labs/cosmos-sdk/pull/572) Fix module whitelist parsing + ## [v0.47.5-v23-osmo-3](https://github.com/osmosis-labs/cosmos-sdk/releases/tag/v0.47.5-v23-osmo-3) * (config) [#563](https://github.com/osmosis-labs/cosmos-sdk/pull/563) Set lockup as the default whitelisted fast nodes module diff --git a/server/util.go b/server/util.go index 7a1bc19db83c..0c96aabdb5b5 100644 --- a/server/util.go +++ b/server/util.go @@ -483,6 +483,8 @@ func DefaultBaseappOptions(appOpts types.AppOptions) []func(*baseapp.BaseApp) { cast.ToUint32(appOpts.Get(FlagStateSyncSnapshotKeepRecent)), ) + fastNodeModuleWhitelist := ParseModuleWhitelist(appOpts) + return []func(*baseapp.BaseApp){ baseapp.SetPruning(pruningOpts), baseapp.SetMinGasPrices(cast.ToString(appOpts.Get(FlagMinGasPrices))), @@ -495,7 +497,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), baseapp.SetMempool( mempool.NewSenderNonceMempool( mempool.SenderNonceMaxTxOpt(cast.ToInt(appOpts.Get(FlagMempoolMaxTxs))), @@ -523,3 +525,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 +}