diff --git a/sei/mainnet.env b/sei/mainnet.env new file mode 100644 index 00000000..35bc6ad0 --- /dev/null +++ b/sei/mainnet.env @@ -0,0 +1,2 @@ +CHAIN_SPEC=pacific-1 +GENESIS_URL=https://raw.githubusercontent.com/sei-protocol/testnet/main/pacific-1/genesis.json \ No newline at end of file diff --git a/sei/scripts/init.sh b/sei/scripts/init.sh index ce7e7993..5a769c0b 100644 --- a/sei/scripts/init.sh +++ b/sei/scripts/init.sh @@ -4,6 +4,24 @@ set -e # Exit on failure echo "MONIKER: $MONIKER" +# needs CHAIN_SPEC to be set +if [ -z "$CHAIN_SPEC" ]; then + echo "CHAIN_SPEC is not set" + exit 1 +fi + +# needs GENESIS_URL to be set +if [ -z "$GENESIS_URL" ]; then + echo "GENESIS_URL is not set" + exit 1 +fi + +# needs PEERS to be set +if [ -z "$PEERS" ]; then + echo "PEERS is not set" + exit 1 +fi + HOME_DIR="/root/.sei" CONFIG_DIR="$HOME_DIR/config" @@ -18,22 +36,28 @@ env apk add curl jq if [ $? -ne 0 ]; then exit 1; fi -if seid init ${MONIKER} --chain-id ${CHAIN_SPEC:-pacific-1} --home $HOME_DIR/; then +curl -sL "$GENESIS_URL" -o "$CONFIG_DIR/genesis.json" + +if seid init ${MONIKER} --chain-id ${CHAIN_SPEC} --home $HOME_DIR/; then # somehow it's better to make home static to /root sed -i 's|~/|/root/|g' "$CONFIG_DIR/config.toml" sed -i 's|~/|/root/|g' "$CONFIG_DIR/app.toml" sed -i 's/minimum-gas-prices = ""/minimum-gas-prices = "0.01usei"/g' $CONFIG_DIR/app.toml + + sed -i -e "s/^#concurrency-workers *=.*/concurrency-workers = 500/" $CONFIG_DIR/app.toml + sed -i -e "s/^occ-enabled *=.*/occ-enabled = true/" $CONFIG_DIR/app.toml + sed -i -e "s/^pruning *=.*/pruning = \"custom\"/" $CONFIG_DIR/app.toml sed -i -e "s/^pruning-keep-recent *=.*/pruning-keep-recent = \"100\"/" $CONFIG_DIR/app.toml sed -i -e "s/^pruning-interval *=.*/pruning-interval = \"19\"/" $CONFIG_DIR/app.toml sed -i -e "s/^indexer *=.*/indexer = \"null\"/" $CONFIG_DIR/config.toml else echo "Already initialized, resetting!" >&2 - seid tendermint unsafe-reset-all --home $HOME_DIR fi +seid tendermint unsafe-reset-all --home $HOME_DIR STATYSYNC_RPC=https://sei-rpc.stakeme.pro:443 LATEST_HEIGHT=$(curl -s $STATYSYNC_RPC/block | jq -r .block.header.height) BLOCK_HEIGHT=$((LATEST_HEIGHT - 10000)) @@ -44,6 +68,9 @@ s|^(trust-height[[:space:]]+=[[:space:]]+).*$|\1$BLOCK_HEIGHT| ; \ s|^(trust-hash[[:space:]]+=[[:space:]]+).*$|\1\"$TRUST_HASH\"| ; \ s|^(seeds[[:space:]]+=[[:space:]]+).*$|\1\"\"|" $CONFIG_DIR/config.toml +# add peers to the config +sed -i 's/persistent-peers = .*/persistent-peers = "'$PEERS'"/' $CONFIG_DIR/config.toml + # apply a port change to the config sed -i "/^\[p2p\]/,/^\[/{s|^laddr = .*|laddr = \"$P2P_STRING\"|}" "$CONFIG_DIR/config.toml" #sed -i "s/^laddr = \".*\"/laddr = \"$P2P_STRING\"/" "$CONFIG_DIR/config.toml" @@ -60,4 +87,4 @@ if [ ! -e $HOME_DIR/data/priv_validator_state.json ]; then fi fi -exec seid start --chain-id ${CHAIN_SPEC:-pacific-1} --home $HOME_DIR $@ +exec seid start --chain-id ${CHAIN_SPEC} --home $HOME_DIR $@ diff --git a/sei/sei/sei-mainnet-sei-pruned.yml b/sei/sei/sei-mainnet-sei-pruned.yml index 1944551c..ec210a88 100644 --- a/sei/sei/sei-mainnet-sei-pruned.yml +++ b/sei/sei/sei-mainnet-sei-pruned.yml @@ -55,10 +55,13 @@ services: - 10019:10019/udp expose: - 8545 + env_file: + - ./sei/mainnet.env environment: - IP=${IP} - MONIKER=d${DOMAIN:-local} - P2P_PORT=10019 + - PEERS=${SEI_MAINNET_SEI_PEERS:-3be6b24cf86a5938cce7d48f44fb6598465a9924@p2p.state-sync-0.pacific-1.seinetwork.io:26656,b21279d7092fde2e41770832a1cacc7d0051e9dc@p2p.state-sync-1.pacific-1.seinetwork.io:26656,616c05e9ba24acc89c0de630b5e3adbedaebb478@p2p.state-sync-2.pacific-1.seinetwork.io:26656} restart: unless-stopped stop_grace_period: 5m networks: diff --git a/sei/sei/sei-testnet-sei-pruned.yml b/sei/sei/sei-testnet-sei-pruned.yml new file mode 100644 index 00000000..bb20f831 --- /dev/null +++ b/sei/sei/sei-testnet-sei-pruned.yml @@ -0,0 +1,108 @@ +--- +x-logging-defaults: &logging-defaults + driver: json-file + options: + max-size: "10m" + max-file: "3" + +# Usage: +# +# mkdir rpc && cd rpc +# +# git init +# git remote add origin https://github.com/StakeSquid/ethereum-rpc-docker.git +# git fetch origin vibe +# git checkout origin/vibe +# +# docker run --rm alpine sh -c "printf '0x'; head -c32 /dev/urandom | xxd -p -c 64" > .jwtsecret +# +# env +# ... +# IP=$(curl ipinfo.io/ip) +# DOMAIN=${IP}.traefik.me +# COMPOSE_FILE=base.yml:rpc.yml:sei/sei/sei-testnet-sei-pruned.yml +# +# docker compose up -d +# +# curl -X POST https://${IP}.traefik.me/sei-testnet-sei-pruned \ +# -H "Content-Type: application/json" \ +# --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' + +services: + sei-testnet-sei-pruned: + build: + context: ./sei + dockerfile: sei.Dockerfile + args: + SEI_VERSION: ${SEI_TESTNET_SEI_VERSION:-v6.1.9} + SEI_IMAGE: ${SEI_TESTNET_SEI_IMAGE:-ghcr.io/sei-protocol/sei} + sysctls: + # TCP Performance + net.ipv4.tcp_slow_start_after_idle: 0 # Disable slow start after idle + net.ipv4.tcp_no_metrics_save: 1 # Disable metrics cache + net.ipv4.tcp_rmem: 4096 87380 16777216 # Increase TCP read buffers + net.ipv4.tcp_wmem: 4096 87380 16777216 # Increase TCP write buffers + net.core.somaxconn: 32768 # Higher connection queue + # Memory/Connection Management + # net.core.netdev_max_backlog: 50000 # Increase network buffer + net.ipv4.tcp_max_syn_backlog: 30000 # More SYN requests + net.ipv4.tcp_max_tw_buckets: 2000000 # Allow more TIME_WAIT sockets + ulimits: + nofile: 1048576 # Max open files (for RPC/WS connections) + user: root + ports: + - 10889:10889 + - 10889:10889/udp + expose: + - 8545 + env_file: + - ./sei/testnet.env + environment: + - IP=${IP} + - MONIKER=d${DOMAIN:-local} + - P2P_PORT=10889 + - PEERS=${SEI_TESTNET_SEI_PEERS:-b2664ccaa84a04b67683093fefb802b172ead6d1@sei-a2-rpc.p2p.brocha.in:30612,babc3f3f7804933265ec9c40ad94f4da8e9e0017@testnet-seed.rhinostake.com:11956} + restart: unless-stopped + stop_grace_period: 5m + networks: + - chains + volumes: + - ${SEI_TESTNET_SEI_PRUNED_DATA:-sei-testnet-sei-pruned}:/root/.sei + - /slowdisk:/slowdisk + logging: *logging-defaults + labels: + - prometheus-scrape.enabled=false + - traefik.enable=true + - traefik.http.middlewares.sei-testnet-sei-pruned-stripprefix.stripprefix.prefixes=/sei-testnet-sei-pruned + - traefik.http.services.sei-testnet-sei-pruned.loadbalancer.server.port=8545 + - ${NO_SSL:-traefik.http.routers.sei-testnet-sei-pruned.entrypoints=websecure} + - ${NO_SSL:-traefik.http.routers.sei-testnet-sei-pruned.tls.certresolver=myresolver} + - ${NO_SSL:-traefik.http.routers.sei-testnet-sei-pruned.rule=Host(`$DOMAIN`) && (Path(`/sei-testnet-sei-pruned`) || Path(`/sei-testnet-sei-pruned/`))} + - ${NO_SSL:+traefik.http.routers.sei-testnet-sei-pruned.rule=Path(`/sei-testnet-sei-pruned`) || Path(`/sei-testnet-sei-pruned/`)} + - traefik.http.routers.sei-testnet-sei-pruned.middlewares=sei-testnet-sei-pruned-stripprefix, ipallowlist + +volumes: + sei-testnet-sei-pruned: + +x-upstreams: + - id: $${ID} + labels: + provider: $${PROVIDER} + connection: + generic: + rpc: + url: $${RPC_URL} + ws: + frameSize: 20Mb + msgSize: 50Mb + url: $${WS_URL} + chain: sei-testnet + method-groups: + enabled: + - debug + - filter + methods: + disabled: + enabled: + - name: txpool_content # TODO: should be disabled for rollup nodes +... \ No newline at end of file diff --git a/sei/testnet.env b/sei/testnet.env new file mode 100644 index 00000000..e69de29b