> For the complete documentation index, see [llms.txt](https://manual.boxexchanger.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://manual.boxexchanger.net/dlya-razrabotchikov/ustanovka-node/ethereum-node.md).

# Ethereum Node

{% hint style="success" %}
**Минимальные требования к серверу:**

* **Диск:** Не менее 2 ТБ SSD (NVMe).
* **Процессор:** Минимум 8 ядер.
* **Память:** 16 ГБ.
* **Программное обеспечение:** Необходимо наличие установленного Docker.
  {% endhint %}

### Prepare file system

```bash
mkdir -p /nodes/eth
```

Generate jwt secret:&#x20;

```bash
openssl rand -hex 32 | tr -d "\n" > /nodes/eth/jwt.secret
```

Create docker-compose.yml

```bash
nano /nodes/eth/docker-compose.yml
```

{% hint style="warning" %}
**Внимание:** Замените **\_YOUR\_HOST\_IP\_** на IP вашего сервера.&#x20;
{% endhint %}

{% code title="docker-compose.yml" %}

```yaml
x-logging:
  &default-logging
  driver: "json-file"
  options:
    max-file: "1"
    max-size: "500m"

services:
  prysm-beacon:
    container_name: prysm-beacon
    image: gcr.io/prysmaticlabs/prysm/beacon-chain:latest
    restart: unless-stopped
    command:
      - --datadir=/data
      - --rpc-host=0.0.0.0
      - --grpc-gateway-host=0.0.0.0
      - --monitoring-host=0.0.0.0
      - --execution-endpoint=http://geth:8551
      - --jwt-secret=/tmp/jwt.secret
      - --accept-terms-of-use
      #- --checkpoint-sync-url=https://sync.invis.tools
      - --genesis-beacon-api-url=https://sync.invis.tools
      - --p2p-denylist=private
      - --p2p-host-ip=_YOUR_HOST_IP_
      #- --clear-db=true
      #- --force-clear-db=true
    ports:
      - 127.0.0.1:3500:3500
      - 12000:12000/udp
      - 13000:13000
    volumes:
      - ./prysm-beacon:/data
      - ./jwt.secret:/tmp/jwt.secret
    logging: *default-logging

  geth:
    container_name: geth
    image: ethereum/client-go:latest
    volumes:
      - ./data-ethereum:/root/.ethereum
      - ./jwt.secret:/tmp/jwt.secret
    restart: unless-stopped
    stop_signal: SIGINT
    stop_grace_period: 5m
    ports:
      - 127.0.0.1:28545:8545
      - 30303:30303/tcp
      - 30303:30303/udp
    command:
      - --cache=32000
      - --authrpc.vhosts=*
      - --authrpc.addr=0.0.0.0
      - --authrpc.jwtsecret=/tmp/jwt.secret
      - --http
      - --ws
      - --ws.addr=0.0.0.0
      - --ws.port=8545
      - --ws.origins=*
      - --ws.api=web3,eth,net
      - --http.api=web3,eth,net
      - --http.addr=0.0.0.0
      - --http.port=8545
      - --http.vhosts=*
    logging: *default-logging

```

{% endcode %}

{% hint style="info" %}
**Fast sync:** Для того, чтобы ускорить синхронизацию beacon node, необходимо раскомментировать строку `--checkpoint-sync-url=https://sync.invis.tools`. После этого запустите контейнер и проверьте логи контейнера beacon. После успешного завершения синхронизации закомментируйте строку обратно.
{% endhint %}

### Запуск geth node:&#x20;

```bash
cd /nodes/eth
docker compose up -d
```

### Открываем порт доступа

Создаем прокси с портов \
&#x20; \- localhost:28545 на порт **8545** для geth rpc&#x20;

<details>

<summary>Настраиваем прокси на caddy</summary>

Устанавливаем caddy <https://caddyserver.com/docs/install>\
\
Документация подготовлена для операционной системы **Debian, Ubuntu**

```shell
apt install -y debian-keyring debian-archive-keyring apt-transport-https
```

```shell
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg
```

```shell
curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' |  tee /etc/apt/sources.list.d/caddy-stable.list
```

```shell
apt update
```

```shell
apt install caddy
```

конфигурируем caddy  для прокси \
28545 на порт **8545** для внешней сети&#x20;

```bash
nano /etc/caddy/Caddyfile
```

**! Замените \_RANDOM\_STRING\_ на свою рандомную строку.**&#x20;

{% code title="/etc/caddy/Caddyfile" %}

```clike
:8545 {
  @websockets {
    header_regexp Connection (U|u)pgrade
    header Upgrade websocket
  }
  handle_path /_RANDOM_STRING_* {
    reverse_proxy @websockets 127.0.0.1:28545
    reverse_proxy 127.0.0.1:28545
  }
  respond 404
}
```

{% endcode %}

запускаем caddy

```bash
systemctl enable --now caddy
```

или перезагружаем если необходимо&#x20;

`systemctl restart caddy`

</details>

{% hint style="warning" %}
**Открытие порта для RPC:** Для доступа к RPC необходимо открыть порт **8545** в настройках фаервола для IP-адреса сервера, с которого будет происходить подключение.
{% endhint %}

### Доступы

**RPC:** `http://ip.host:8545/_RANDOM_STRING_/`
