Build on X Layer

Setup testnet RPC#

xlayer-erigon is a fork of Erigon, optimized for syncing with the X Layer network.

Minimum System Requirements#

Hardware Requirements#

  • CPU: At least 8 cores (16 cores recommended)
  • Memory: 32 GB RAM (64 GB recommended)
  • Storage: 2 TB SSD available space
  • Network: Stable internet connection, at least 100 Mbps

Software Requirements#

  • Operating System: Linux (Ubuntu 20.04+) or macOS
  • Go: Version 1.21 or higher
  • Git: For cloning the repository

Installation Steps#

1. Clone the Project#

git clone https://github.com/okx/xlayer-erigon.git
cd xlayer-erigon

2. Build Binary#

# Build the main program
make cdk-erigon

3. Create Data Directory (if needed)#

# Create data storage directory
mkdir -p ./data

# Ensure correct directory permissions
chmod 755 ./data

Configuration#

Configuration File Setup#

The project uses a YAML format configuration file. You can generate your configuration from the example file:

# Copy the example configuration
cp xlayerconfig-testnet.yaml.example xlayerconfig-testnet.yaml

Important Configuration Fields#

⚠️ You must modify the following fields before starting the node:

1. Data Directory (datadir)#

datadir: ./data/  # Change this to your preferred data storage path
  • Purpose: Specifies where blockchain data will be stored
  • Configuration Options:
    • If you have an existing data directory: Use your current data directory path
    • If you're starting fresh: Use the directory you created in step 3 (e.g., ./data/)
    • Custom location: You can specify any directory path you prefer

2. L1 RPC URL (zkevm.l1-rpc-url)#

zkevm.l1-rpc-url: {your-eth-sepolia-l1-rpc}  # Replace with your L1 RPC endpoint
  • Purpose: Ethereum Sepolia testnet RPC endpoint for L1 data synchronization
  • Options:
    • Use the default public endpoint (rate-limited)
    • Use your own Infura/Alchemy endpoint (recommended for production)
    • Use a local Ethereum node

Configuration Validation#

Before starting the node, verify your configuration:

Note: The path ./build/bin/cdk-erigon may differ from your actual build path. Please check the path output after running make cdk-erigon and adjust accordingly.

# Check if the configuration file is valid
./build/bin/cdk-erigon --config="./xlayerconfig-testnet.yaml" --help

Starting the Node#

Basic Startup Command#

# Start with configuration file
./build/bin/cdk-erigon --config="./xlayerconfig-testnet.yaml"

# Or start in background mode
nohup ./build/bin/cdk-erigon --config="./xlayerconfig-testnet.yaml" > logs/erigon-$(date +%Y%m%d-%H%M%S).log 2>&1 &

# If you see the following content in your log, the startup is successful:
INFO[09-01|14:28:57.801] [1/17 L1Syncer] L1 Blocks processed progress (amounts): 146000/3950193 (3%)
INFO[09-01|14:29:07.806] [1/17 L1Syncer] L1 Blocks processed progress (amounts): 266000/3950193 (6%)
INFO[09-01|14:29:17.810] [1/17 L1Syncer] L1 Blocks processed progress (amounts): 363000/3950193 (9%)