Skip to content

Map cosmos-sdk pruning config to ev-node format and remove sonic dependency#345

Merged
julienrbrt merged 7 commits intopierrick/prunningfrom
copilot/remove-pruning-key-clearing
Feb 17, 2026
Merged

Map cosmos-sdk pruning config to ev-node format and remove sonic dependency#345
julienrbrt merged 7 commits intopierrick/prunningfrom
copilot/remove-pruning-key-clearing

Conversation

Copy link
Contributor

Copilot AI commented Feb 17, 2026

Implementation Plan

1. Update pruning configuration mapping in server/start.go

  • Rename clearConflictingViperKeys to mapCosmosPruningToEvNode
  • Implement proper mapping from cosmos-sdk pruning keys to ev-node format:
    • Map pruningevnode.pruning.pruning_mode with value conversion:
      • "default" → "all"
      • "nothing" → "disabled"
      • "everything" → "all"
      • "custom" → "all"
      • unknown → "metadata"
    • Map pruning-keep-recentevnode.pruning.pruning_keep_recent
    • Map pruning-intervalevnode.pruning.pruning_interval (with block-to-duration conversion)
  • Use cosmos-sdk server flag constants (FlagPruning, FlagPruningKeepRecent, FlagPruningInterval) instead of hardcoded strings
  • Add tests for the mapping function
  • Address all code review feedback

2. Remove sonic dependency from Dockerfiles

  • Remove sonic installation from Dockerfile (line 31)
  • Remove sonic installation from Dockerfile.cosmos-sdk (line 32)
  • Remove sonic installation from tests/integration/docker/Dockerfile.gm (line 37)

3. Testing and Validation

  • Run unit tests for server package - All pass ✅
  • Verify builds work correctly - Build successful ✅
  • Address all PR review comments ✅

Technical Details

The implementation now uses the official cosmos-sdk server flag constants to ensure consistency with the SDK's configuration system. Unknown pruning mode values are mapped to "metadata" mode, which provides a conservative middle-ground that prunes block data but preserves metadata.

The cosmos-sdk import is qualified as sdkserver throughout the server package to avoid name collisions with the local server package.

Original prompt

Problem Statement

Update PR #332 to:

  1. Remove pruning key clearing in server/start.go and instead map the cosmos-sdk default pruning configuration keys to ev-node/pkg/config/PruningConfig

Currently, in server/start.go lines 727-736, there's a clearConflictingViperKeys function that clears pruning-related keys:

func clearConflictingViperKeys(v *viper.Viper) {
	conflictingKeys := []string{"pruning", "pruning-keep-recent", "pruning-interval"}
	for _, k := range conflictingKeys {
		val := v.Get(k)
		if _, isString := val.(string); isString {
			v.Set(k, map[string]interface{}{})
		}
	}
}

Replace this approach with proper mapping that converts cosmos-sdk pruning config keys to ev-node's PruningConfig format:

  • Cosmos SDK uses: pruning, pruning-keep-recent, pruning-interval
  • ev-node expects: evnode.pruning.pruning_mode, evnode.pruning.pruning_keep_recent, evnode.pruning.pruning_interval

The mapping should:

  • Convert cosmos-sdk pruning string values (like "default", "nothing", "everything", "custom") to ev-node's pruning_mode (one of: "disabled", "all", "metadata")
  • Map pruning-keep-recent to evnode.pruning.pruning_keep_recent
  • Map pruning-interval to evnode.pruning.pruning_interval
  • Handle the conversion properly in the clearConflictingViperKeys function (rename it to something like mapCosmosPruningToEvNode)

Refer to ev-node's PruningConfig structure:

type PruningConfig struct {
	Mode       string          `mapstructure:"pruning_mode"`
	KeepRecent uint64          `mapstructure:"pruning_keep_recent"`
	Interval   DurationWrapper `mapstructure:"pruning_interval"`
}

Valid modes: "disabled", "all", "metadata"

  1. Remove sonic replaces from all Dockerfiles

Remove the lines that install/get the github.com/bytedance/sonic package:

  • In Dockerfile (line 28): Remove go get github.com/bytedance/sonic@v1.15.0 && \
  • In Dockerfile.cosmos-sdk (line 35): Remove go get github.com/bytedance/sonic@v1.15.0 && go mod tidy
  • In tests/integration/docker/Dockerfile.gm (line 39): Remove && go get github.com/bytedance/sonic@v1.15.0 \

Implementation Details

For the pruning config mapping:

  1. Rename clearConflictingViperKeys to mapCosmosPruningToEvNode
  2. Read the cosmos-sdk pruning config values
  3. Convert them to ev-node format:
    • "default" → "all" (or appropriate mapping)
    • "nothing" → "disabled"
    • "everything" → "all"
    • "custom" → "all" or "metadata" (depending on context)
  4. Set the converted values in viper with the ev-node key prefixes

For the dockerfile changes:

  1. Simply remove the sonic installation lines
  2. Ensure the remaining go mod operations work correctly

Expected Outcome

After this change:

  • The pruning configuration from cosmos-sdk's app.toml should be properly mapped to ev-node's configuration
  • Docker builds should no longer include the sonic dependency
  • The PR should be ready for review with these updates applied

This pull request was created from Copilot chat.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits February 17, 2026 09:41
- Rename clearConflictingViperKeys to mapCosmosPruningToEvNode
- Map cosmos-sdk pruning keys to ev-node format with proper value conversion
- Add comprehensive tests for pruning mapping function
- Remove sonic installation from all Dockerfiles

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
- Simplify switch statement logic in mapCosmosPruningToEvNode
- Add test case for verifying cosmos settings override existing evnode settings

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove pruning key clearing and map to ev-node config Map cosmos-sdk pruning config to ev-node format and remove sonic dependency Feb 17, 2026
Copilot AI requested a review from julienrbrt February 17, 2026 09:48
server/start.go Outdated
case "default", "everything", "custom":
evnodePruningMode = "all"
default:
// Unknown non-empty values default to "all", empty values remain empty
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unknown values default to disabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 387da22. Unknown pruning values now default to "disabled" instead of "all".

server/start.go Outdated
v.Set("evnode.pruning.pruning_keep_recent", cosmosKeepRecent)
}
if cosmosInterval != "" {
v.Set("evnode.pruning.pruning_interval", cosmosInterval)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure we can set the interval like this. In ev-node intervals are time, while in the SDK I believe it is number of block. If that's the case, make sure to do nblock * blockTime

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 387da22. The interval is now properly converted from blocks to time duration by multiplying the block count by the block time (from evnode.node.block_time, defaulting to 1s if not set).

for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
v := viper.New()
v.Set("pruning", tc.cosmosPruning)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Improve the test by using server DefaultConfig() and read it to viper, to make sure this works.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 387da22. Added a new test TestMapCosmosPruningToEvNode_WithDefaultConfig that uses serverconfig.DefaultConfig() to test with realistic cosmos-sdk configuration values.

@julienrbrt
Copy link
Member

@copilot check my comments

- Change unknown pruning values to default to "disabled" instead of "all"
- Convert cosmos-sdk pruning-interval from blocks to time duration
- Add evnode.node.block_time to tests and use DefaultConfig for realistic testing
- Update all test expectations to match the block-to-duration conversion

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
evnodePruningMode = "disabled"
case "default", "everything", "custom":
evnodePruningMode = "all"
default:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make default case to do metadatas only @copilot

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3608be4. The default case now maps unknown pruning values to "metadata" instead of "disabled".

server/start.go Outdated
func mapCosmosPruningToEvNode(v *viper.Viper) {
// Get cosmos-sdk pruning configuration
cosmosPruning := v.GetString("pruning")
cosmosKeepRecent := v.GetString("pruning-keep-recent")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use the flags from the SDK package instead of directly putting them here (client/flags or server most likely)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 3608be4. Now using cosmos-sdk server flag constants (sdkserver.FlagPruning, sdkserver.FlagPruningKeepRecent, sdkserver.FlagPruningInterval) instead of hardcoded string literals.

- Change default case to map unknown pruning values to "metadata" instead of "disabled"
- Use cosmos-sdk server flag constants (FlagPruning, FlagPruningKeepRecent, FlagPruningInterval) instead of hardcoded strings
- Update imports across server package to use qualified sdkserver import to avoid name collision
- Update all tests to use the SDK flag constants
- Update test expectations for unknown value mapping to metadata

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
Copilot AI requested a review from julienrbrt February 17, 2026 11:44
@julienrbrt julienrbrt marked this pull request as ready for review February 17, 2026 11:56
@julienrbrt julienrbrt requested a review from a team as a code owner February 17, 2026 11:56
@julienrbrt julienrbrt merged commit 4d7ceb5 into pierrick/prunning Feb 17, 2026
@julienrbrt julienrbrt deleted the copilot/remove-pruning-key-clearing branch February 17, 2026 11:56
julienrbrt added a commit that referenced this pull request Feb 17, 2026
* prunning

* changed to batch delete

* Map cosmos-sdk pruning config to ev-node format and remove sonic dependency (#345)

* Initial plan

* Implement pruning config mapping and remove sonic dependency

- Rename clearConflictingViperKeys to mapCosmosPruningToEvNode
- Map cosmos-sdk pruning keys to ev-node format with proper value conversion
- Add comprehensive tests for pruning mapping function
- Remove sonic installation from all Dockerfiles

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>

* Fix comment clarity in mapCosmosPruningToEvNode

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>

* Simplify logic and add test for override behavior

- Simplify switch statement logic in mapCosmosPruningToEvNode
- Add test case for verifying cosmos settings override existing evnode settings

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>

* Remove redundant empty string case in switch statement

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>

* Address PR review feedback on pruning mapping

- Change unknown pruning values to default to "disabled" instead of "all"
- Convert cosmos-sdk pruning-interval from blocks to time duration
- Add evnode.node.block_time to tests and use DefaultConfig for realistic testing
- Update all test expectations to match the block-to-duration conversion

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>

* Address PR review: use SDK flag constants and map unknown to metadata

- Change default case to map unknown pruning values to "metadata" instead of "disabled"
- Use cosmos-sdk server flag constants (FlagPruning, FlagPruningKeepRecent, FlagPruningInterval) instead of hardcoded strings
- Update imports across server package to use qualified sdkserver import to avoid name collision
- Update all tests to use the SDK flag constants
- Update test expectations for unknown value mapping to metadata

Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>

* fixes

* updates

---------

Co-authored-by: julienrbrt <julien@rbrt.fr>
Co-authored-by: Copilot <198982749+Copilot@users.noreply.github.com>
Co-authored-by: julienrbrt <29894366+julienrbrt@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants