Skip to content

Commit bc8e87b

Browse files
committed
feat: run random beacon
1 parent 256c327 commit bc8e87b

File tree

2 files changed

+206
-0
lines changed

2 files changed

+206
-0
lines changed
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
---
2+
description: Run a Random Beacon Service.
3+
title: Run a Random Beacon Service
4+
---
5+
6+
## Overview
7+
8+
This guide demonstrates how to run a Random Beacon Service to [generate random beacon](https://github.com/ronin-chain/REPs/blob/main/REP-0010/REP-0010.md#compute-random-beacon). If you're an active Ronin Governing Validator, you need to run this service.
9+
10+
Governing Validators can choose to run the Random Beacon Service in standalone mode or combined mode. We suggest to use standalone mode to increase the security and stability of the system.
11+
12+
## Prerequisites
13+
14+
Before setting up the Random Beacon Service, we need to prepare:
15+
- Docker
16+
- Registered the [VRF key](../manage/vrf-key.mdx)
17+
- A Ronin address to submit the random beacon. This can be any address.
18+
19+
## Run Random Beacon Service in standalone mode
20+
21+
1. Setup directories and create a directory for postgres db data
22+
```
23+
mkdir -p ~/ronin-random-beacon/docker
24+
cd ~/ronin-random-beacon
25+
mkdir -p ~/ronin-random-beacon/db
26+
```
27+
28+
2. In the docker directory, create a `docker-compose.yml` file with the following configuration:
29+
30+
```
31+
version: '3.5'
32+
33+
services:
34+
ronin-random-beacon-chain:
35+
image: ${NODE_IMAGE}
36+
restart: always
37+
logging:
38+
options:
39+
max-size: 10m
40+
max-file: "3"
41+
environment:
42+
RONIN_RANDOM_BEACON_PARAMS: ${RONIN_RANDOM_BEACON_PARAMS}
43+
RONIN_PRIVATE_KEY: ${RONIN_PRIVATE_KEY}
44+
RONIN_SECRET_KEY: ${RONIN_SECRET_KEY}
45+
RONIN_RPC_ENDPOINT: ${RONIN_RPC_ENDPOINT}
46+
RONIN_VERBOSITY: ${RONIN_VERBOSITY}
47+
RONIN_DATABASE_URL: postgresql://${DB_USER}:${DB_PASS}@ronin-random-beacon-chain-db:5432/${DB_NAME}?sslmode=disable
48+
depends_on:
49+
- ronin-random-beacon-chain-db
50+
ronin-random-beacon-chain-db:
51+
image: postgres:14
52+
restart: always
53+
ports:
54+
- "127.0.0.1:5432:5432"
55+
logging:
56+
options:
57+
max-size: 10m
58+
max-file: "3"
59+
volumes:
60+
- ~/ronin-random-beacon/db:/var/lib/postgresql/data
61+
healthcheck:
62+
test: ["CMD-SHELL", "pg_isready -U ${DB_USER}"]
63+
interval: 30s
64+
timeout: 30s
65+
retries: 3
66+
environment:
67+
POSTGRES_USER: ${DB_USER}
68+
POSTGRES_PASSWORD: ${DB_PASS}
69+
```
70+
71+
This compose file defines the ronin-random-beacon service that pulls a Ronin random beacon image from the GitHub Container Registry. ( https://github.com/ronin-chain/ronin-random-beacon/pkgs/container/ronin-random-beacon)
72+
73+
**Note.** In case you want to connect to node container in different docker-compose in the same machine, please check [here](https://docs.docker.com/compose/networking/#use-a-pre-existing-network) for reusing the existing network in the above setting for making a connection between random-beacon service with rpc node service.
74+
75+
For example if the current docker network of node containers you wanna connect is `ronin_default`. Then put this block in per service inside the above docker-compose to connect to the existing network.
76+
77+
```
78+
...
79+
ronin-random-beacon-chain:
80+
image: ${NODE_IMAGE}
81+
restart: always
82+
networks:
83+
- ronin_default
84+
...
85+
ronin-random-beacon-chain-db:
86+
image: postgres:14
87+
restart: always
88+
networks:
89+
- ronin_default
90+
...
91+
```
92+
93+
3. In the docker directory, create an `.env` file and add the following content, replacing the `<...>` placeholder values with your information:
94+
95+
```
96+
NODE_IMAGE=<NODE_IMAGE>
97+
DB_USER=<DB_USER>
98+
DB_PASS=<DB_PASS>
99+
DB_NAME=<DB_NAME>
100+
# your ronin private key with the 0x prefix for submitting the transactions to chain.
101+
RONIN_PRIVATE_KEY=<RONIN_PRIVATE_KEY>
102+
# Your VRF Secret key with the 0x prefix
103+
RONIN_SECRET_KEY=<RONIN_SECRET_KEY>
104+
RONIN_RANDOM_BEACON_PARAMS=--config-file /opt/config/mainnet/
105+
RONIN_RPC_ENDPOINT=<YOUR_RPC_ENDPOINT>
106+
RONIN_VERBOSITY=4
107+
```
108+
109+
4. Start the node
110+
111+
```
112+
cd ~/ronin-random-beacon && docker-compose up -d
113+
```
114+
115+
5. Review the log
116+
117+
```
118+
docker logs ronin-random-beacon-chain -f –tail 100
119+
```
120+
121+
## Run Random Beacon Service in combined mode
122+
123+
1. Setup directory for postgres db data (assume that your node directory is as same as setting in [here](./mainnet/run-validator.md))
124+
125+
```
126+
cd ~/ronin
127+
mkdir -p ronin-random-beacon-db
128+
```
129+
130+
2. In the docker directory, append the current docker-compose.yml file with the following configuration:
131+
132+
```
133+
version: '3.5'
134+
135+
services:
136+
...
137+
...
138+
ronin-random-beacon-chain:
139+
image: ${RONIN_RANDOM_BEACON_CHAIN_IMAGE}
140+
restart: always
141+
logging:
142+
options:
143+
max-size: 10m
144+
max-file: "3"
145+
environment:
146+
RONIN_RANDOM_BEACON_PARAMS: ${RONIN_RANDOM_BEACON_PARAMS}
147+
RONIN_PRIVATE_KEY: ${RONIN_RANDOM_BEACON_CHAIN_PRIVATE_KEY}
148+
RONIN_SECRET_KEY: ${RONIN_RANDOM_BEACON_CHAIN_SECRET_KEY}
149+
RONIN_RPC_ENDPOINT: ${RONIN_RANDOM_BEACON_CHAIN_RPC_ENDPOINT}
150+
RONIN_VERBOSITY: ${RONIN_RANDOM_BEACON_CHAIN_VERBOSITY}
151+
RONIN_DATABASE_URL: postgresql://${RONIN_RANDOM_BEACON_DB_USER}:${RONIN_RANDOM_BEACON_DB_PASS}@ronin-random-beacon-chain-db:5432/${RONIN_RANDOM_BEACON_DB_NAME}?sslmode=disable
152+
depends_on:
153+
- ronin-random-beacon-chain-db
154+
ronin-random-beacon-chain-db:
155+
image: postgres:14
156+
restart: always
157+
ports:
158+
- "127.0.0.1:5432:5432"
159+
logging:
160+
options:
161+
max-size: 10m
162+
max-file: "3"
163+
volumes:
164+
- ~/ronin/ronin-random-beacon-db:/var/lib/postgresql/data
165+
healthcheck:
166+
test: ["CMD-SHELL", "pg_isready -U ${RONIN_RANDOM_BEACON_DB_USER}"]
167+
interval: 30s
168+
timeout: 30s
169+
retries: 3
170+
environment:
171+
POSTGRES_USER: ${RONIN_RANDOM_BEACON_DB_USER}
172+
POSTGRES_PASSWORD: ${RONIN_RANDOM_BEACON_DB_PASS}
173+
```
174+
175+
This compose file defines the `ronin-random-beacon` service that pulls a Ronin random beacon image from the GitHub Container Registry.
176+
177+
3. In the docker directory, create an `.env` file and add the following content, replacing the `<...>` placeholder values with your information:
178+
179+
```
180+
RONIN_RANDOM_BEACON_CHAIN_IMAGE=<RONIN_RANDOM_BEACON_CHAIN_IMAGE>
181+
RONIN_RANDOM_BEACON_DB_USER=<RONIN_RANDOM_BEACON_DB_USER>
182+
RONIN_RANDOM_BEACON_DB_PASS=<RONIN_RANDOM_BEACON_DB_PASS>
183+
RONIN_RANDOM_BEACON_DB_NAME=<RONIN_RANDOM_BEACON_DB_NAME>
184+
# your ronin private key with the 0x prefix for submitting the transactions to chain.
185+
RONIN_RANDOM_BEACON_CHAIN_PRIVATE_KEY=<RONIN_RANDOM_BEACON_CHAIN_PRIVATE_KEY>
186+
# Your VRF Secret key with the 0x prefix
187+
RONIN_RANDOM_BEACON_CHAIN_SECRET_KEY=<RONIN_RANDOM_BEACON_CHAIN_SECRET_KEY>
188+
RONIN_RANDOM_BEACON_PARAMS=--config-file /opt/config/mainnet/
189+
RONIN_RANDOM_BEACON_CHAIN_RPC_ENDPOINT=http://node:8545
190+
RONIN_RANDOM_BEACON_CHAIN_VERBOSITY=4
191+
192+
```
193+
194+
4. Start the node
195+
196+
```
197+
cd ~/ronin && docker-compose up -d
198+
```
199+
200+
5. Review the log
201+
202+
```
203+
docker logs ronin-random-beacon-chain -f –tail 100
204+
```

sidebars.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ const sidebars = {
272272
'validators/setup/cli',
273273
// Latest version
274274
'validators/setup/upgrade-validator',
275+
// Latest version
276+
'validators/setup/random-beacon',
275277
// Clean data
276278
'validators/setup/clean-data',
277279
// Network parameters

0 commit comments

Comments
 (0)