🐳Docker

Authors: [jLeopoldA]

System Requirements

CPU
OS
Ram
Disk

vCpu 4 min

Used: Debian / Ubuntu 22.04

16GB minimum

13.5 TB (SSD)

Archival Node size is 973GB as of 11/20/2024

With their Eggfruit upgrade in September 2024, the Polygon team made the official recommendation that all infra providers will need to begin running the cdk-erigon RPC Node. While zkEVm Node is still operational, it is no longer being maintained by the Polygon team. Additionally, we found slight POI divergence in our integration testing. Please use the test below as an initial screening for Proof of Indexing when working with this chain.

Initial Test for Proof of Indexing

Due to POI divergences found with X Layer, we created an initial test below for indexers that may indicate that their setup allows them to sync other subgraphs and be in majority consensus.

  • Sync the following subgraph: QmWHYMV9mPZ6zoomwWSZbN24sdGSEQhy1efritMiETpxqS

  • Query to grab the POI

{ "query": "{ proofOfIndexing(subgraph: "QmWHYMV9mPZ6zoomwWSZbN24sdGSEQhy1efritMiETpxqS", blockNumber: 3041190, blockHash: "0xa819924ad94bcf3295826d5ad916c9ef06fac8cb46a6273d3bcc7aec822e22e7", indexer: "0x0000000000000000000000000000000000000000") }" }

If there is a match for the Consensus POI provided below, it may indicate that their setup allows them to sync other subgraphs and be in the majority consensus. If they get a match for the Divergent POI, this can be an indication of a data determinism issue.

Consensus 0xa1223b5cbabf16d9896c2bd19099d08e5ce45c7ff308674b3ea7ada5367334bf

Divergent 0x411bf0293e96a1459167ef1828aa7d70cd6c2e1f8c4210e0edf0fa8827eeed69

  • Shell into your index node and run this curl command

curl -s -X POST -H "Content-Type: application/json" --data '{"query": "{ proofOfIndexing(subgraph: "QmWHYMV9mPZ6zoomwWSZbN24sdGSEQhy1efritMiETpxqS", blockNumber: 3041190, blockHash: "0xa819924ad94bcf3295826d5ad916c9ef06fac8cb46a6273d3bcc7aec822e22e7", indexer: "0x0000000000000000000000000000000000000000") }"}' "http://localhost:8030/graphql"

Required Installations

Requirements to create an X Layer node are Docker, Docker-Compose and an Ethereum L1 node.

Pre-Requisites

Update

sudo apt update -y && sudo apt upgrade -y && sudo apt autoremove -y

Setting up Firewall

Set explicit default UFW rules

sudo ufw default deny incoming
sudo ufw default allow outgoing

Allow SSH

sudo ufw allow 22/tcp

Allow remote RPC connections with X Layer node

sudo ufw allow 8545

Install Docker and Docker-Compose

# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl
sudo install -m 0755 -d /etc/apt/keyrings
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
sudo chmod a+r /etc/apt/keyrings/docker.asc

# Add the repository to Apt sources:
echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
  $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
  sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update

# Install Docker Packages
 sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
 
 # Verify Docker Installation is Successful
sudo docker run hello-world

# Install Docker-Compose
sudo apt-get update
sudo apt-get install docker-compose-plugin

# Verify Docker-Compose installation by checking the version
docker compose version

# Expected output
Docker Compose version vN.N.N

Set up X Layer Node

# Make a directory
mkdir -p /root/xlayer-node && cd /root/xlayer-node

# Download mainnet X-Layer script
curl -fsSL https://raw.githubusercontent.com/okx/Deploy/main/setup/zknode/run_xlayer_mainnet.sh | bash -s init && cp ./mainnet/example.env ./mainnet/.env

# Alternatively: Download testnet X-Layer script
curl -fsSL https://raw.githubusercontent.com/okx/Deploy/main/setup/zknode/run_xlayer_testnet.sh | bash -s init && cp ./testnet/example.env ./testnet/.env

# Edit mainnet .env
nano ./mainnet/.env

# Alternatively: Edit testnet .env
nano ./testnet/.env

Values for .env file

# URL of a JSON RPC for Ethereum mainnet or Sepolia testnet
XLAYER_NODE_ETHERMAN_URL = "http://your.L1node.url"

# PATH WHERE THE STATEDB POSTGRES CONTAINER WILL STORE PERSISTENT DATA
XLAYER_NODE_STATEDB_DATA_DIR = "./xlayer_mainnet_data/statedb" # OR ./xlayer_testnet_datastatedb/ for testnet

# PATH WHERE THE POOLDB POSTGRES CONTAINER WILL STORE PERSISTENT DATA #
XLAYER_NODE_POOLDB_DATA_DIR = "./xlayer_mainnet_data/pooldb" # OR ./xlayer_testnet_data/pooldb/ for testnet

Restore latest Layer 2 snapshot

Restoring the Layer 2 snapshot database locally will allow synchronizing of Layer 2 data quickly.

# mainnet
./run_xlayer_mainnet.sh restore

# If using testnet
./run_xlayer_testnet.sh restore

Start X Layer Node

# mainnet
./run_xlayer_mainnet.sh start

# If using testnet
./run_xlayer_testnet.sh start

docker ps -a

# The following containers should be available: 
xlayer-rpc
xlayer-sync
xlayer-state-db
xlayer-pool-db
xlayer-prover

Query X Layer Node

curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":83}' http://localhost:8545

# The response should resemble the follow
{"jsonrpc":"2.0","id":1,"result":"0xcab5ab"}

Additional Commands

# Stop X Layer Node
./run_xlayer_mainnet.sh stop

# Restart
./run_xlayer_mainnet.sh restart

# Updating
./run_xlayer_mainnet.sh update

Access Logs

# TO VIEW LOGS
docker logs [container id OR container name]

Last updated