Skip to content

Commit c71bc7f

Browse files
committed
fix: use string type for legacy rpc-servers TOML field
Tendermint writes rpc-servers as a comma-separated string in config.toml, not a TOML array. The legacy struct now uses string and conversion functions handle split/join with the internal []string representation.
1 parent 94e6904 commit c71bc7f

2 files changed

Lines changed: 25 additions & 6 deletions

File tree

legacy.go

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package seiconfig
22

3+
import "strings"
4+
35
// Legacy types match the existing config.toml (Tendermint) and app.toml
46
// (Cosmos SDK + Sei) TOML schemas exactly. These are used during Phase 2
57
// for reading/writing the two-file layout and will be removed when the
@@ -103,9 +105,9 @@ type legacyMempool struct {
103105
}
104106

105107
type legacyStateSync struct {
106-
Enable bool `toml:"enable"`
107-
UseP2P bool `toml:"use-p2p"`
108-
RPCServers []string `toml:"rpc-servers"`
108+
Enable bool `toml:"enable"`
109+
UseP2P bool `toml:"use-p2p"`
110+
RPCServers string `toml:"rpc-servers"`
109111
TrustHeight int64 `toml:"trust-height"`
110112
TrustHash string `toml:"trust-hash"`
111113
TrustPeriod Duration `toml:"trust-period"`
@@ -441,7 +443,7 @@ func (cfg *SeiConfig) toLegacyTendermint() legacyTendermintConfig {
441443
StateSync: legacyStateSync{
442444
Enable: cfg.StateSync.Enable,
443445
UseP2P: cfg.StateSync.UseP2P,
444-
RPCServers: cfg.StateSync.RPCServers,
446+
RPCServers: strings.Join(cfg.StateSync.RPCServers, ","),
445447
TrustHeight: cfg.StateSync.TrustHeight,
446448
TrustHash: cfg.StateSync.TrustHash,
447449
TrustPeriod: cfg.StateSync.TrustPeriod,
@@ -783,7 +785,7 @@ func fromLegacy(tm legacyTendermintConfig, app legacyAppConfig) *SeiConfig {
783785
StateSync: StateSyncConfig{
784786
Enable: tm.StateSync.Enable,
785787
UseP2P: tm.StateSync.UseP2P,
786-
RPCServers: tm.StateSync.RPCServers,
788+
RPCServers: splitRPCServers(tm.StateSync.RPCServers),
787789
TrustHeight: tm.StateSync.TrustHeight,
788790
TrustHash: tm.StateSync.TrustHash,
789791
TrustPeriod: tm.StateSync.TrustPeriod,
@@ -967,3 +969,20 @@ func fromLegacy(tm legacyTendermintConfig, app legacyAppConfig) *SeiConfig {
967969
},
968970
}
969971
}
972+
973+
// splitRPCServers converts a Tendermint-style comma-separated rpc-servers
974+
// string into the []string used by SeiConfig. Returns nil for empty input.
975+
func splitRPCServers(s string) []string {
976+
s = strings.TrimSpace(s)
977+
if s == "" {
978+
return nil
979+
}
980+
parts := strings.Split(s, ",")
981+
out := make([]string, 0, len(parts))
982+
for _, p := range parts {
983+
if t := strings.TrimSpace(p); t != "" {
984+
out = append(out, t)
985+
}
986+
}
987+
return out
988+
}

version.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"version": "v0.0.4"
2+
"version": "v0.0.5"
33
}

0 commit comments

Comments
 (0)