Files
ethereum-rpc-docker/cronos/scripts/init.sh
T
claude 61179a0dc3 cronos-mainnet: add persistent peers and consensus timeouts to prevent sync stall
- Add PERSISTENT_PEERS env var with official cronos seeds
- Add MAX_NUM_OUTBOUND_PEERS=40 and MAX_NUM_INBOUND_PEERS=80
- Add SKIP_TIMEOUT_COMMIT=true for RPC nodes
- Apply these settings to config.toml in init.sh

Fixes block-sync-exit + slow consensus-mode catchup recurrence on rpc-us-50.
Job: 60bac0e9. Date: 2026-09-23
2026-09-23 03:14:36 +00:00

71 lines
4.6 KiB
Bash

#!/bin/sh
# cronosd entrypoint — Cronos (Cosmos-SDK + embedded EVM). EVM JSON-RPC :8545 / WS :8546
# are the dshackle/traefik upstream; CometBFT :26657 stays internal. Bootstrap params
# (chain_id, genesis_url, seeds, app.toml tunables) come from context.yml via env.
set -e
. /usr/local/bin/cometbft-common.sh
HOME_DIR="/root/.cronos"
CONFIG_DIR="$HOME_DIR/config"
CHAINID="${CHAINID:-cronosmainnet_25-1}"
API="${API:-eth,txpool,net,debug,web3}"
GENESIS_URL="${GENESIS_URL:-https://raw.githubusercontent.com/crypto-org-chain/cronos-mainnet/master/cronosmainnet_25-1/genesis.json}"
SEEDS="${SEEDS:-0d5cf1394a1cfde28dc8f023567222abc0f47534@seed-0.cronos.com:26656,3032073adc06d710dd512240281637c1bd0c8a7b@seed-1.cronos.com:26656,04f43116b4c6c70054d9c2b7485383df5b1ed1da@seed-2.cronos.com:26656,337377dcda43d79c537d2c4d93ad3b698ce9452e@bd-cronos-mainnet-seed-node-01.bdnodes.net:26656}"
STATESYNC_RPC="${STATESYNC_RPC:-https://cronos-rpc.publicnode.com:443}"
PERSISTENT_PEERS="${PERSISTENT_PEERS:-0d5cf1394a1cfde28dc8f023567222abc0f47534@seed-0.cronos.com:26656,3032073adc06d710dd512240281637c1bd0c8a7b@seed-1.cronos.com:26656,04f43116b4c6c70054d9c2b7485383df5b1ed1da@seed-2.cronos.com:26656,337377dcda43d79c537d2c4d93ad3b698ce9452e@bd-cronos-mainnet-seed-node-01.bdnodes.net:26656}"
MAX_NUM_OUTBOUND_PEERS="${MAX_NUM_OUTBOUND_PEERS:-40}"
MAX_NUM_INBOUND_PEERS="${MAX_NUM_INBOUND_PEERS:-80}"
SKIP_TIMEOUT_COMMIT="${SKIP_TIMEOUT_COMMIT:-true}"
MIN_GAS="${MIN_GAS:-5000000000000basecro}"
PRUNING="${PRUNING:-custom}"
PRUNING_KEEP_RECENT="${PRUNING_KEEP_RECENT:-100}"
PRUNING_INTERVAL="${PRUNING_INTERVAL:-19}"
JSON_RPC_ENABLE="${JSON_RPC_ENABLE:-true}"
JSON_RPC_ENABLE_INDEXER="${JSON_RPC_ENABLE_INDEXER:-true}"
FEEHISTORY_CAP="${FEEHISTORY_CAP:-250}"
JSON_RPC_FEEHISTORY_CAP="${JSON_RPC_FEEHISTORY_CAP:-$FEEHISTORY_CAP}"
JSON_RPC_LOGS_CAP="${JSON_RPC_LOGS_CAP:-10000}"
JSON_RPC_BLOCK_RANGE_CAP="${JSON_RPC_BLOCK_RANGE_CAP:-10000}"
JSON_RPC_HTTP_TIMEOUT="${JSON_RPC_HTTP_TIMEOUT:-30s}"
JSON_RPC_WS_ORIGINS="${JSON_RPC_WS_ORIGINS:-*}"
EVM_MAX_TX_GAS_WANTED="${EVM_MAX_TX_GAS_WANTED:-500000}"
ct_apk curl jq
if cronosd init "${MONIKER:-rpc-node}" --chain-id "$CHAINID" --home "$HOME_DIR" >/dev/null 2>&1; then
ct_log "fresh init; fetching genesis"
ct_fetch "$GENESIS_URL" "$CONFIG_DIR/genesis.json" required
ct_localize_home "$CONFIG_DIR"
ct_set_min_gas_prices "$CONFIG_DIR/app.toml" "$MIN_GAS"
else
ct_log "already initialized, continuing"
fi
sed -i -e "s/^pruning *=.*/pruning = \"$PRUNING\"/" "$CONFIG_DIR/app.toml"
sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"$PRUNING_KEEP_RECENT\"/" "$CONFIG_DIR/app.toml"
sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"$PRUNING_INTERVAL\"/" "$CONFIG_DIR/app.toml"
sed -i -e "s/^indexer *=.*/indexer = \"null\"/" "$CONFIG_DIR/config.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^address = .*|address = \"0.0.0.0:8545\"|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^ws-address = .*|ws-address = \"0.0.0.0:8546\"|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^ws-origins = .*|ws-origins = \"$JSON_RPC_WS_ORIGINS\"|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^api = .*|api = \"$API\"|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^enable = .*|enable = $JSON_RPC_ENABLE|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^enable-indexer = .*|enable-indexer = $JSON_RPC_ENABLE_INDEXER|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^feehistory-cap = .*|feehistory-cap = $FEEHISTORY_CAP|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^logs-cap = .*|logs-cap = $JSON_RPC_LOGS_CAP|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^block-range-cap = .*|block-range-cap = $JSON_RPC_BLOCK_RANGE_CAP|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[json-rpc\]/,/^\[/{s|^http-timeout = .*|http-timeout = \"$JSON_RPC_HTTP_TIMEOUT\"|}" "$CONFIG_DIR/app.toml"
sed -i "/^\[evm\]/,/^\[/{s|^max-tx-gas-wanted = .*|max-tx-gas-wanted = $EVM_MAX_TX_GAS_WANTED|}" "$CONFIG_DIR/app.toml"
ct_patch_p2p "$CONFIG_DIR/config.toml" "$IP" "${P2P_PORT:-10521}"
ct_merge_seeds "$CONFIG_DIR/config.toml" "$SEEDS"
ct_set_persistent_peers "$CONFIG_DIR/config.toml" "$PERSISTENT_PEERS"
sed -i "s/^max_num_outbound_peers = .*/max_num_outbound_peers = ${MAX_NUM_OUTBOUND_PEERS}/" "$CONFIG_DIR/config.toml"
sed -i "s/^max_num_inbound_peers = .*/max_num_inbound_peers = ${MAX_NUM_INBOUND_PEERS}/" "$CONFIG_DIR/config.toml"
sed -i "s/^skip_timeout_commit = .*/skip_timeout_commit = ${SKIP_TIMEOUT_COMMIT}/" "$CONFIG_DIR/config.toml"
ct_configure_statesync "$CONFIG_DIR/config.toml" "$STATESYNC_RPC" 2000
ct_set_moniker "$CONFIG_DIR/config.toml" "${MONIKER:-rpc-node}"
exec cronosd start --chain-id "$CHAINID" --minimum-gas-prices "$MIN_GAS" "$@"