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 authored Mar 13, 2024
1 parent 9345069 commit cf09bb5
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
22 changes: 21 additions & 1 deletion server/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
Expand All @@ -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))),
Expand Down Expand Up @@ -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
}

0 comments on commit cf09bb5

Please sign in to comment.