This commit is contained in:
goldsquid
2025-09-05 15:48:27 +07:00
parent 781ce60757
commit 0dd7fecc40
3 changed files with 159 additions and 0 deletions

45
sei/scripts/init.sh Normal file
View File

@@ -0,0 +1,45 @@
#!/bin/sh
set -e # Exit on failure
echo "MONIKER: $MONIKER"
HOME_DIR="/root/.sei"
CONFIG_DIR="$HOME_DIR/config"
# Create config directory
mkdir -p "$CONFIG_DIR"
P2P_STRING="tcp:\\/\\/0\\.0\\.0\\.0\\:${P2P_PORT:-55696}"
NAT_STRING="${IP}:${P2P_PORT:-55696}"
env
if seid init ${MONIKER} --chain-id ${CHAIN_SPEC:-sei} --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
else
echo "Already initialized, continuing!" >&2
fi
# 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"
sed -i "/^\[p2p\]/,/^\[/{s|^external_address = .*|external_address = \"$NAT_STRING\"|}" "$CONFIG_DIR/config.toml"
# Update moniker if set
if [ -n "$MONIKER" ] && [ -f "$CONFIG_DIR/config.toml" ]; then
sed -i "s/^moniker = \".*\"/moniker = \"$MONIKER\"/" "$CONFIG_DIR/config.toml"
fi
if [ -e $CONFIG_DIR/priv_validator_state.json ]; then
if [ ! -e $HOME_DIR/data/priv_validator_state.json ]; then
cp $CONFIG_DIR/priv_validator_state.json $HOME_DIR/data/priv_validator_state.json
fi
fi
exec seid start --chain-id ${CHAIN_SPEC:-sei-testnet-1} --home $HOME_DIR --db_dir $HOME_DIR/data $@

9
sei/sei.Dockerfile Normal file
View File

@@ -0,0 +1,9 @@
ARG SEI_IMAGE
ARG SEI_VERSION
FROM ${SEI_IMAGE}:${SEI_VERSION}
COPY ./scripts/init.sh /usr/local/bin/init.sh
RUN chmod +x /usr/local/bin/init.sh
ENTRYPOINT [ "init.sh" ]

View File

@@ -0,0 +1,105 @@
---
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-mainnet-sei-pruned.yml
#
# docker compose up -d
#
# curl -X POST https://${IP}.traefik.me/sei-mainnet-sei-pruned \
# -H "Content-Type: application/json" \
# --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
services:
sei-mainnet-sei-pruned:
build:
context: ./sei
dockerfile: sei.Dockerfile
args:
SEI_VERSION: ${SEI_MAINNET_SEI_VERSION:-v6.1.9}
SEI_IMAGE: ${SEI_MAINNET_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:
- 10019:10019
- 10019:10019/udp
expose:
- 8545
environment:
- IP=${IP}
- MONIKER=d${DOMAIN:-local}
- P2P_PORT=10019
restart: unless-stopped
stop_grace_period: 5m
networks:
- chains
volumes:
- ${SEI_MAINNET_SEI_PRUNED_DATA:-sei-mainnet-sei-pruned}:/root/.sei
- /slowdisk:/slowdisk
logging: *logging-defaults
labels:
- prometheus-scrape.enabled=false
- traefik.enable=true
- traefik.http.middlewares.sei-mainnet-sei-pruned-stripprefix.stripprefix.prefixes=/sei-mainnet-sei-pruned
- traefik.http.services.sei-mainnet-sei-pruned.loadbalancer.server.port=8545
- ${NO_SSL:-traefik.http.routers.sei-mainnet-sei-pruned.entrypoints=websecure}
- ${NO_SSL:-traefik.http.routers.sei-mainnet-sei-pruned.tls.certresolver=myresolver}
- ${NO_SSL:-traefik.http.routers.sei-mainnet-sei-pruned.rule=Host(`$DOMAIN`) && (Path(`/sei-mainnet-sei-pruned`) || Path(`/sei-mainnet-sei-pruned/`))}
- ${NO_SSL:+traefik.http.routers.sei-mainnet-sei-pruned.rule=Path(`/sei-mainnet-sei-pruned`) || Path(`/sei-mainnet-sei-pruned/`)}
- traefik.http.routers.sei-mainnet-sei-pruned.middlewares=sei-mainnet-sei-pruned-stripprefix, ipallowlist
volumes:
sei-mainnet-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
method-groups:
enabled:
- debug
- filter
methods:
disabled:
enabled:
- name: txpool_content # TODO: should be disabled for rollup nodes
...