Skip to content

Commit c68f987

Browse files
github-actions[bot]blindchasermasih
authored
Backport release/v6.3: fix: support iavl.* pruning config keys with legacy fallback (#2769)
Backport of #2767 to `release/v6.3`. --------- Co-authored-by: yirenz <blindchaser@users.noreply.github.com> Co-authored-by: Masih H. Derkani <m@derkani.org>
1 parent 2adbd97 commit c68f987

4 files changed

Lines changed: 73 additions & 9 deletions

File tree

‎README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Sei is the fastest general purpose L1 blockchain and the first parallelized EVM.
88
**Sei** is a high-performance, low-fee, delegated proof-of-stake blockchain designed for developers. It supports optimistic parallel execution of both EVM and CosmWasm, opening up new design possibilities. With unique optimizations like twin turbo consensus and SeiDB, Sei ensures consistent 400ms block times and a transaction throughput that’s orders of magnitude higher than Ethereum. This means faster, more cost-effective operations. Plus, Sei’s seamless interoperability between EVM and CosmWasm gives developers native access to the entire Cosmos ecosystem, including IBC tokens, multi-sig accounts, fee grants, and more.
99

1010
# Documentation
11-
For the most up to date documentation please visit https://www.docs.sei.io/
11+
For the most up-to-date documentation please visit https://www.docs.sei.io/
1212

1313
# Sei Optimizations
1414
Sei introduces four major innovations:

‎sei-cosmos/server/pruning.go‎

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,35 @@ import (
1515
// PruningOptions. If a pruning strategy is provided, that will be parsed and
1616
// returned, otherwise, it is assumed custom pruning options are provided.
1717
func GetPruningOptionsFromFlags(appOpts types.AppOptions) (storetypes.PruningOptions, error) {
18-
strategy := strings.ToLower(cast.ToString(appOpts.Get(FlagPruning)))
18+
// New format (iavl.*) takes priority, fallback to legacy top-level keys for backward compatibility
19+
strategy := cast.ToString(appOpts.Get(FlagIAVLPruning))
20+
if strategy == "" {
21+
strategy = cast.ToString(appOpts.Get(FlagPruning))
22+
}
23+
strategy = strings.ToLower(strategy)
1924

2025
switch strategy {
2126
case storetypes.PruningOptionDefault, storetypes.PruningOptionNothing, storetypes.PruningOptionEverything:
2227
return storetypes.NewPruningOptionsFromString(strategy), nil
2328

2429
case storetypes.PruningOptionCustom:
30+
keepRecent := appOpts.Get(FlagIAVLPruningKeepRecent)
31+
if keepRecent == nil {
32+
keepRecent = appOpts.Get(FlagPruningKeepRecent)
33+
}
34+
keepEvery := appOpts.Get(FlagIAVLPruningKeepEvery)
35+
if keepEvery == nil {
36+
keepEvery = appOpts.Get(FlagPruningKeepEvery)
37+
}
38+
interval := appOpts.Get(FlagIAVLPruningInterval)
39+
if interval == nil {
40+
interval = appOpts.Get(FlagPruningInterval)
41+
}
42+
2543
opts := storetypes.NewPruningOptions(
26-
cast.ToUint64(appOpts.Get(FlagPruningKeepRecent)),
27-
cast.ToUint64(appOpts.Get(FlagPruningKeepEvery)),
28-
cast.ToUint64(appOpts.Get(FlagPruningInterval)),
44+
cast.ToUint64(keepRecent),
45+
cast.ToUint64(keepEvery),
46+
cast.ToUint64(interval),
2947
)
3048

3149
if err := opts.Validate(); err != nil {

‎sei-cosmos/server/pruning_test.go‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ func TestGetPruningOptionsFromFlags(t *testing.T) {
2525
},
2626
expectedOptions: types.PruneNothing,
2727
},
28+
{
29+
name: FlagIAVLPruning,
30+
initParams: func() *viper.Viper {
31+
v := viper.New()
32+
v.Set(FlagIAVLPruning, types.PruningOptionNothing)
33+
return v
34+
},
35+
expectedOptions: types.PruneNothing,
36+
},
2837
{
2938
name: "custom pruning options",
3039
initParams: func() *viper.Viper {
@@ -42,6 +51,23 @@ func TestGetPruningOptionsFromFlags(t *testing.T) {
4251
Interval: 10,
4352
},
4453
},
54+
{
55+
name: "custom pruning options iavl",
56+
initParams: func() *viper.Viper {
57+
v := viper.New()
58+
v.Set(FlagIAVLPruning, types.PruningOptionCustom)
59+
v.Set(FlagIAVLPruningKeepRecent, 1234)
60+
v.Set(FlagIAVLPruningKeepEvery, 4321)
61+
v.Set(FlagIAVLPruningInterval, 10)
62+
63+
return v
64+
},
65+
expectedOptions: types.PruningOptions{
66+
KeepRecent: 1234,
67+
KeepEvery: 4321,
68+
Interval: 10,
69+
},
70+
},
4571
{
4672
name: types.PruningOptionDefault,
4773
initParams: func() *viper.Viper {
@@ -51,6 +77,17 @@ func TestGetPruningOptionsFromFlags(t *testing.T) {
5177
},
5278
expectedOptions: types.PruneDefault,
5379
},
80+
{
81+
name: "new format takes priority over legacy",
82+
initParams: func() *viper.Viper {
83+
v := viper.New()
84+
// Both old and new format present - new format should win
85+
v.Set(FlagPruning, types.PruningOptionNothing)
86+
v.Set(FlagIAVLPruning, types.PruningOptionEverything)
87+
return v
88+
},
89+
expectedOptions: types.PruneEverything,
90+
},
5491
}
5592

5693
for _, tt := range tests {

‎sei-cosmos/server/start.go‎

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,19 @@ const (
5454
FlagProfile = "profile"
5555
FlagInvCheckPeriod = "inv-check-period"
5656

57-
FlagPruning = "pruning"
58-
FlagPruningKeepRecent = "pruning-keep-recent"
59-
FlagPruningKeepEvery = "pruning-keep-every"
60-
FlagPruningInterval = "pruning-interval"
57+
// Legacy pruning flags (kept for backward compatibility)
58+
FlagPruning = "pruning"
59+
FlagPruningKeepRecent = "pruning-keep-recent"
60+
FlagPruningKeepEvery = "pruning-keep-every"
61+
FlagPruningInterval = "pruning-interval"
62+
63+
// New pruning config keys under [iavl] section (v6.3.0+)
64+
// TODO: Remove legacy fallback once all nodes have migrated to v6.3.0+
65+
FlagIAVLPruning = "iavl.pruning"
66+
FlagIAVLPruningKeepRecent = "iavl.pruning-keep-recent"
67+
FlagIAVLPruningKeepEvery = "iavl.pruning-keep-every"
68+
FlagIAVLPruningInterval = "iavl.pruning-interval"
69+
6170
FlagIndexEvents = "index-events"
6271
FlagMinRetainBlocks = "min-retain-blocks"
6372
FlagIAVLCacheSize = "iavl-cache-size"

0 commit comments

Comments
 (0)