Skip to content

Commit 1096466

Browse files
committed
fix: optimizations
1 parent e884528 commit 1096466

File tree

4 files changed

+43
-35
lines changed

4 files changed

+43
-35
lines changed

cmd/push-validator/root_cobra.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,8 +262,7 @@ func init() {
262262
Moniker: initMoniker,
263263
GenesisDomain: cfg.GenesisDomain,
264264
BinPath: findPchaind(),
265-
SnapshotRPCPrimary: initSnapshotRPC,
266-
SnapshotRPCSecondary: "https://donut.rpc.push.org",
265+
SnapshotRPC: initSnapshotRPC,
267266
Progress: progressCallback,
268267
}); err != nil {
269268
ui.PrintError(ui.ErrorMessage{
@@ -343,8 +342,7 @@ func init() {
343342
Moniker: getenvDefault("MONIKER", "push-validator"),
344343
GenesisDomain: cfg.GenesisDomain,
345344
BinPath: findPchaind(),
346-
SnapshotRPCPrimary: cfg.SnapshotRPC,
347-
SnapshotRPCSecondary: "https://donut.rpc.push.org",
345+
SnapshotRPC: cfg.SnapshotRPC,
348346
Progress: progressCallback,
349347
}); err != nil {
350348
ui.PrintError(ui.ErrorMessage{

install.sh

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,6 +1255,36 @@ if [[ "$AUTO_START" = "yes" ]]; then
12551255
--snapshot-rpc "$SNAPSHOT_RPC" \
12561256
--bin "${PCHAIND:-pchaind}" || { err "init failed"; exit 1; }
12571257
ok "Node initialized"
1258+
1259+
# Optimize config for faster state sync
1260+
step "Optimizing node configuration"
1261+
APP_TOML="$HOME_DIR/config/app.toml"
1262+
CONFIG_TOML="$HOME_DIR/config/config.toml"
1263+
1264+
if [[ -f "$APP_TOML" ]]; then
1265+
# Increase IAVL cache size for faster state sync (default: 781250 -> 2000000)
1266+
sed -i.bak 's/^iavl-cache-size = .*/iavl-cache-size = 2000000/' "$APP_TOML" 2>/dev/null || \
1267+
sed -i '' 's/^iavl-cache-size = .*/iavl-cache-size = 2000000/' "$APP_TOML" 2>/dev/null || true
1268+
rm -f "$APP_TOML.bak" 2>/dev/null || true
1269+
fi
1270+
1271+
if [[ -f "$CONFIG_TOML" ]]; then
1272+
# Increase peer limits for more chunk sources
1273+
sed -i.bak 's/^max_num_inbound_peers = .*/max_num_inbound_peers = 100/' "$CONFIG_TOML" 2>/dev/null || \
1274+
sed -i '' 's/^max_num_inbound_peers = .*/max_num_inbound_peers = 100/' "$CONFIG_TOML" 2>/dev/null || true
1275+
sed -i.bak 's/^max_num_outbound_peers = .*/max_num_outbound_peers = 50/' "$CONFIG_TOML" 2>/dev/null || \
1276+
sed -i '' 's/^max_num_outbound_peers = .*/max_num_outbound_peers = 50/' "$CONFIG_TOML" 2>/dev/null || true
1277+
# Increase transfer rates for faster data transfer
1278+
sed -i.bak 's/^send_rate = .*/send_rate = 10240000/' "$CONFIG_TOML" 2>/dev/null || \
1279+
sed -i '' 's/^send_rate = .*/send_rate = 10240000/' "$CONFIG_TOML" 2>/dev/null || true
1280+
sed -i.bak 's/^recv_rate = .*/recv_rate = 10240000/' "$CONFIG_TOML" 2>/dev/null || \
1281+
sed -i '' 's/^recv_rate = .*/recv_rate = 10240000/' "$CONFIG_TOML" 2>/dev/null || true
1282+
# Disable tx indexer during sync for less disk I/O
1283+
sed -i.bak 's/^indexer = .*/indexer = "null"/' "$CONFIG_TOML" 2>/dev/null || \
1284+
sed -i '' 's/^indexer = .*/indexer = "null"/' "$CONFIG_TOML" 2>/dev/null || true
1285+
rm -f "$CONFIG_TOML.bak" 2>/dev/null || true
1286+
fi
1287+
ok "Configuration optimized"
12581288
else
12591289
step "Configuration exists, skipping init"
12601290
fi

internal/bootstrap/bootstrap.go

Lines changed: 10 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ type Options struct {
3838
Denom string // e.g., upc
3939
GenesisDomain string // e.g., donut.rpc.push.org
4040
BinPath string // pchaind path
41-
SnapshotRPCPrimary string // e.g., https://donut.rpc.push.org
42-
SnapshotRPCSecondary string // optional; if empty uses primary
41+
SnapshotRPC string // e.g., https://donut.rpc.push.org
4342
Progress func(string) // optional callback for progress messages
4443
}
4544

@@ -154,10 +153,10 @@ func (s *svc) Init(ctx context.Context, opts Options) error {
154153
progress("Using fullnode peers for state sync...")
155154
peers := fullnodePeers
156155

157-
// Set snapshot RPC primary (use first fullnode)
158-
snapPrimary := opts.SnapshotRPCPrimary
159-
if snapPrimary == "" {
160-
snapPrimary = fullnodeRPCs[0]
156+
// Set snapshot RPC (use first fullnode if not specified)
157+
snapshotRPC := opts.SnapshotRPC
158+
if snapshotRPC == "" {
159+
snapshotRPC = fullnodeRPCs[0]
161160
}
162161

163162
// Configure peers via config store
@@ -179,34 +178,15 @@ func (s *svc) Init(ctx context.Context, opts Options) error {
179178
}
180179
}
181180

182-
// Configure state sync parameters using snapshot RPC (reuse variable from above)
181+
// Configure state sync parameters using snapshot RPC
183182
progress("Configuring state sync parameters...")
184-
tp, err := s.stp.ComputeTrust(ctx, snapPrimary)
183+
tp, err := s.stp.ComputeTrust(ctx, snapshotRPC)
185184
if err != nil {
186185
return fmt.Errorf("compute trust params: %w", err)
187186
}
188-
// Build and filter RPC servers to those that accept JSON-RPC POST (light client requirement)
189-
// Add both primary and secondary (fallback to node1 if secondary not provided)
190-
candidates := []string{hostToStateSyncURL(snapPrimary)}
191-
snapSecondary := opts.SnapshotRPCSecondary
192-
if snapSecondary == "" {
193-
// Default to fullnode-2 as secondary witness if not specified
194-
snapSecondary = fullnodeRPCs[1]
195-
}
196-
if snapSecondary != snapPrimary {
197-
candidates = append(candidates, hostToStateSyncURL(snapSecondary))
198-
}
199-
200-
rpcServers := s.pickWorkingRPCs(ctx, candidates)
201-
if len(rpcServers) == 0 {
202-
return fmt.Errorf("no working RPC servers for state sync (JSON-RPC POST failed)")
203-
}
204-
// Ensure we provide two entries (primary + witness). Only duplicate as last resort.
205-
if len(rpcServers) == 1 {
206-
// Try adding fullnode-2 as fallback
207-
fallback := "http://34.72.243.200:26657" // fullnode-2
208-
rpcServers = append(rpcServers, fallback)
209-
}
187+
// Build RPC servers list (state sync requires at least 2 entries for verification)
188+
rpcURL := hostToStateSyncURL(snapshotRPC)
189+
rpcServers := []string{rpcURL, rpcURL} // Duplicate single endpoint for 2-entry requirement
210190
progress("Backing up configuration...")
211191
if _, err := cfgs.Backup(); err == nil { /* best-effort */
212192
}

internal/process/cosmovisor_sup.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ func (s *CosmovisorSupervisor) Start(opts StartOpts) (int, error) {
217217
args := []string{
218218
"run", "start",
219219
"--home", opts.HomeDir,
220-
"--pruning=nothing",
220+
"--pruning=everything",
221221
"--minimum-gas-prices=1000000000upc",
222222
"--rpc.laddr=tcp://0.0.0.0:26657",
223223
"--json-rpc.address=0.0.0.0:8545",

0 commit comments

Comments
 (0)