diff --git a/cosmos/scripts/cometbft-common.sh b/cosmos/scripts/cometbft-common.sh index 52f6c5a9..ceb8ae45 100644 --- a/cosmos/scripts/cometbft-common.sh +++ b/cosmos/scripts/cometbft-common.sh @@ -179,9 +179,13 @@ ct_configure_statesync() { # second server defaults to the first (cometbft wants >=2 for light-client cross-check) echo "$_rpc" | grep -q ',' || _rpc="$_rpc,$_rpc" ct_log "statesync: enable trust_height=$_trust_h trust_hash=$_trust_hash" - sed -i.bak -E "s|^(enable[[:space:]]*=[[:space:]]*).*$|\1true| ; \ - s|^(rpc-servers[[:space:]]*=[[:space:]]*).*$|\1\"$_rpc\"| ; \ - s|^(trust-height[[:space:]]*=[[:space:]]*).*$|\1$_trust_h| ; \ - s|^(trust-hash[[:space:]]*=[[:space:]]*).*$|\1\"$_trust_hash\"|" "$_cfg" + # Patch ONLY the [statesync] section. CometBFT config.toml uses underscore keys + # (rpc_servers/trust_height/trust_hash); tolerate hyphen variants with [_-]. + sed -i.bak -E "/^\[statesync\]/,/^\[/{ + s|^([[:space:]]*enable[[:space:]]*=[[:space:]]*).*|\1true| + s|^([[:space:]]*rpc[_-]servers[[:space:]]*=[[:space:]]*).*|\1\"$_rpc\"| + s|^([[:space:]]*trust[_-]height[[:space:]]*=[[:space:]]*).*|\1$_trust_h| + s|^([[:space:]]*trust[_-]hash[[:space:]]*=[[:space:]]*).*|\1\"$_trust_hash\"| + }" "$_cfg" return 0 } diff --git a/scripts/cometbft-common.sh b/scripts/cometbft-common.sh index 52f6c5a9..ceb8ae45 100644 --- a/scripts/cometbft-common.sh +++ b/scripts/cometbft-common.sh @@ -179,9 +179,13 @@ ct_configure_statesync() { # second server defaults to the first (cometbft wants >=2 for light-client cross-check) echo "$_rpc" | grep -q ',' || _rpc="$_rpc,$_rpc" ct_log "statesync: enable trust_height=$_trust_h trust_hash=$_trust_hash" - sed -i.bak -E "s|^(enable[[:space:]]*=[[:space:]]*).*$|\1true| ; \ - s|^(rpc-servers[[:space:]]*=[[:space:]]*).*$|\1\"$_rpc\"| ; \ - s|^(trust-height[[:space:]]*=[[:space:]]*).*$|\1$_trust_h| ; \ - s|^(trust-hash[[:space:]]*=[[:space:]]*).*$|\1\"$_trust_hash\"|" "$_cfg" + # Patch ONLY the [statesync] section. CometBFT config.toml uses underscore keys + # (rpc_servers/trust_height/trust_hash); tolerate hyphen variants with [_-]. + sed -i.bak -E "/^\[statesync\]/,/^\[/{ + s|^([[:space:]]*enable[[:space:]]*=[[:space:]]*).*|\1true| + s|^([[:space:]]*rpc[_-]servers[[:space:]]*=[[:space:]]*).*|\1\"$_rpc\"| + s|^([[:space:]]*trust[_-]height[[:space:]]*=[[:space:]]*).*|\1$_trust_h| + s|^([[:space:]]*trust[_-]hash[[:space:]]*=[[:space:]]*).*|\1\"$_trust_hash\"| + }" "$_cfg" return 0 }