Over 700 subscribers
Hardware Requirement:
OS: Ubuntu 20.04 or later | ||
---|---|---|
RAM | CPU | Disk |
8-16 GB | 4-6 core | เริ่มแรกจะอยู่ที่ราว 550 GB และเพิ่มขึ้นได้มากกว่า 1 TB+ |
ขั้นตอนที่ 1 เช่า VPS และ setup
ขั้นตอนที่ 2 สร้าง Directories
mkdir -p /root/ethereum/execution
mkdir -p /root/ethereum/consensus
ขั้นตอนที่ 3 Generate the JWT secret:
openssl rand -hex 32 > /root/ethereum/jwt.hex
cat /root/ethereum/jwt.hex
ขั้นตอนที่ 4 กำหนดค่า docker-compose.yml
cd ethereum
nano docker-compose.yml
ก็อปอันข้างล่างทั้งหมดไปวาง --> วางแล้วกด CTRL + X --> กด Y --> Enter
services:
geth:
image: ethereum/client-go:stable
container_name: geth
network_mode: host
restart: unless-stopped
ports:
- 30303:30303
- 30303:30303/udp
- 8545:8545
- 8546:8546
- 8551:8551
volumes:
- /root/ethereum/execution:/data
- /root/ethereum/jwt.hex:/data/jwt.hex
command:
- --sepolia
- --http
- --http.api=eth,net,web3
- --http.addr=0.0.0.0
- --authrpc.addr=0.0.0.0
- --authrpc.vhosts=*
- --authrpc.jwtsecret=/data/jwt.hex
- --authrpc.port=8551
- --syncmode=snap
- --datadir=/data
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
prysm:
image: gcr.io/prysmaticlabs/prysm/beacon-chain
container_name: prysm
network_mode: host
restart: unless-stopped
volumes:
- /root/ethereum/consensus:/data
- /root/ethereum/jwt.hex:/data/jwt.hex
depends_on:
- geth
ports:
- 4000:4000
- 3500:3500
command:
- --sepolia
- --accept-terms-of-use
- --datadir=/data
- --disable-monitoring
- --rpc-host=0.0.0.0
- --execution-endpoint=http://127.0.0.1:8551
- --jwt-secret=/data/jwt.hex
- --rpc-port=4000
- --grpc-gateway-corsdomain=*
- --grpc-gateway-host=0.0.0.0
- --grpc-gateway-port=3500
- --min-sync-peers=3
- --checkpoint-sync-url=https://checkpoint-sync.sepolia.ethpandaops.io
- --genesis-beacon-api-url=https://checkpoint-sync.sepolia.ethpandaops.io
logging:
driver: "json-file"
options:
max-size: "10m"
max-file: "3"
ขั้นตอนที่ 5 Port conflicts:
apt install net-tools
netstat -tuln | grep -E '30303|8545|8546|8551|4000|3500'
ขั้นตอนที่ 6 รันโหนด GETH / Prysm
เริ่มโหนด
docker compose up -d
เช็คการทำงานด้วยคำสั่งนี้ ถ้าเคยปิดหน้าการทำงานปิด Termius ไปแล้วให้ cd
docker compose logs -fn 100
ถ้าเคยปิดหน้าการทำงานบน Termius ไปแล้วใช้คำสั่งเช็คไม่ได้ ให้ใช้คำสั่ง cd ethereum ก่อน
ขั้นตอนที่ 7 เช็คว่า node sync หรือยัง
สำหรับ Geth หรือก็คือตัว Sepolia RPC (ถ้าเคยปิดหน้าการทำงานบน Termius ไปแล้วใช้คำสั่งเช็คไม่ได้ ให้ใช้คำสั่ง cd ethereum ก่อน)
curl -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://localhost:8545
ถ้าได้แบบนี้แปลว่ายังไม่ sync ตัวเลข 0x ในนี้จะลงท้ายไม่เหมือนกันนะ แต่มันจะยาวแบบนี้แหละ
{"jsonrpc":"2.0","id":1,"result":{"currentBlock":"0x3398be","healedBytecodeBytes":"0x0","healedBytecodes":"0x0","healedTrienodeBytes":"0x0","healedTrienodes":"0x0","healingBytecode":"0x0","healingTrienodes":"0x0","highestBlock":"0x7f6102","startingBlock":"0x0","syncedAccountBytes":"0x595390dc","syncedAccounts":"0x63d88a","syncedBytecodeBytes":"0xb0790424","syncedBytecodes":"0x93f39","syncedStorage":"0x446701e","syncedStorageBytes":"0x3c6f5cee2","txIndexFinishedBlocks":"0x0","txIndexRemainingBlocks":"0x1"}}
ถ้า sync แล้วจะได้แบบนี้
{"jsonrpc":"2.0","id":1,"result":false}
สำหรับ Prysm หรือ Beacon RPC
curl http://localhost:3500/eth/v1/node/syncing
ถ้าได้แบบนี้แปลว่ายังไม่ sync โดย Sync distance จะหมายถึงจำนวน slot ที่ยังตามหลังอยู่และ true หมายถึงกำลัง sync อยู่
{"data":{"head_slot":"12345","sync_distance":"100","is_syncing":true}}
ถ้า sync แล้วจะได้แบบนี้ โดย Sync distance 0 และขึ้น false แปลว่า sync เรียบร้อยแล้ว
{"data":{"head_slot":"12345","sync_distance":"0","is_syncing":false}}
ขั้นตอนที่ 8 VPS Firewall
เปิด Firewall
sudo ufw allow 22
sudo ufw allow ssh
sudo ufw enable
เปิด Geth P2P ports:
sudo ufw allow 30303/tcp # Geth P2P
sudo ufw allow 30303/udp # Geth P2P
เปิด ports สำหรับ IP ที่ต้องการ
sudo ufw allow from <ip address ของ vps ของ aztec node> to any port 8545 proto tcp
sudo ufw allow from <ip address ของ vps ของ aztec node> to any port 3500 proto tcp
คำสั่งข้างล่างเฉพาะถ้ารัน Aztec node กับ Geth + Prysm node ใน VPS ip address เดียวกันให้ใส่แบบนี้
sudo ufw allow from 127.0.0.1 to any port 8545 proto tcp
sudo ufw allow from 127.0.0.1 to any port 3500 proto tcp
ขั้นตอนที่ 9 ทำ RPC Endpoints เพื่อนำไปใส่ตอนรันโหนด Aztec
Sepolia RPC ให้เติมแบบนี้ http://<ip address ของ vps ที่รัน rpc>:8545
ยกตัวอย่างจะได้เป็น http://69.69.69.69:8545
Beacon RPC ให้เติมแบบนี้ http://<ip address ของ vps ที่รัน rpc>:3500
เฉพาะถ้ารัน Aztec node กับ Geth + Prysm node ใน VPS ip address เดียวกันให้ใส่แบบนี้
Sepolia RPC:http://localhost:8545
Beacon RPC:http://localhost:3500
ก็คือไม่ต้องเติมอะไร ใส่ไปแบบนั้นเลย
คำสั่งตรวจระบบต่างๆ
เช็คการใช้ hardware (กด copy ทางขวานะครับ แล้วนำไปวางมันจะมาอยู่ แต่ไม่แน่ใจทำไมตัวอักษรไม่ขึ้นในหน้านี้)
ดูการใช้งานพื้นที่ disk:
df -h
ดูการใช้งานพื้นที่ disk ของ Geth:
docker exec -it geth du -sh /data
ดูการใช้งานพื้นที่ disk ของPrysm :
docker exec -it prysm du -sh /data
Cryptobobo