This detailed guide will walk you through the process of installing and running a Unichain node using Docker and Docker Compose.

The instructions are designed for beginners, with all commands provided for easy copy-paste execution. Prerequisites Before you begin, ensure that your system meets the following requirements:

  • Operating System: Ubuntu 20.04 LTS or later (other Linux distributions are also compatible)

  • User Privileges: A user account with sudo privileges

Hardware Requirements:    
CPU: 4-core processor or higher.         
RAM: 8 GB or more.        
Storage: At least 100 GB free space (SSD recommended).        
Network: Stable internet connection.     
Docker: Installed on your system (instructions provided) .   
Ethereum L1 Full Node.
RPC Endpoint: Access to an Ethereum Layer 1 node RPC URL (setup included).

Step 1: Update System Packages

To ensure that your system is up-to-date, start by updating your system’s package list and upgrading existing packages to the latest versions.

# Unichain Node Installation Guide

## Step 1: Update System Packages

**Explanation:** This command updates your system's package list and upgrades existing packages to the latest versions.

```bash
sudo apt update && sudo apt upgrade -y

Console Output:

Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://security.ubuntu.com/ubuntu focal-security InRelease
Hit:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease
Reading package lists... Done
Building dependency tree       
Reading state information... Done
All packages are up to date.

Explanation: The output shows that the package list has been updated and all packages are already up to date.

Step 2: Install Docker and Docker Compose

Install Required Packages

Explanation: This command installs the required packages for Docker installation.

sudo apt install -y apt-transport-https ca-certificates curl gnupg lsb-release

Console Output:

The following additional packages will be installed:
  apt-utils gnupg-agent
Suggested packages:
  apt-transport-https-doc
The following NEW packages will be installed:
  apt-transport-https apt-utils gnupg-agent
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 1,114 kB of archives.
After this operation, 5,084 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 apt-utils all 2.18 [1,014 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal/main amd64 gnupg-agent amd64 2.2.20-1ubuntu1.1 [100 kB]
Fetched 1,114 kB in 0s (1,901 kB/s)
Selecting previously unselected package apt-transport-https.
(Reading database ... 111440 files and directories currently installed.)
Preparing to unpack .../apt-transport-https_0.8.12_all.deb ...
Unpacking apt-transport-https (0.8.12) ...
Selecting previously unselected package apt-utils.
Preparing to unpack .../apt-utils_2.18_all.deb ...
Unpacking apt-utils (2.18) ...
Selecting previously unselected package gnupg-agent.
Preparing to unpack .../gnupg-agent_2.2.20-1ubuntu1.1_amd64.deb ...
Unpacking gnupg-agent (2.2.20-1ubuntu1.1) ...
Setting up apt-transport-https (0.8.12) ...
Setting up apt-utils (2.18) ...
Setting up gnupg-agent (2.2.20-1ubuntu1.1) ...
Processing triggers for man-db (2.9.1-1) ...

Explanation: The output shows that the required packages have been installed successfully.

Add Docker’s Official GPG Key

Explanation: This command adds Docker's official GPG key to your system.

sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

Console Output:

gpg: keyring `/tmp/tmp.1000000000.gpg' created
gpg: /tmp/tmp.1000000000.gpg: no valid OpenPGP data found.
gpg: Total number processed: 0
gpg: key 7EA8A75628BB82EA: public key "Docker Release (Docker Release) <docker@docker.com>" imported
gpg: Total number processed: 1
gpg:               imported: 1

Explanation: The output shows that Docker's official GPG key has been imported successfully.

Set Up the Stable Repository

Explanation: This command sets up the stable repository for Docker.

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

Console Output:

deb [arch=amd64 signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu focal stable

Explanation: The output shows that the stable repository for Docker has been set up.

Install Docker Engine

Explanation: This command installs Docker Engine, Docker CLI, and containerd.

sudo apt update
sudo apt install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin

Console Output:

The following additional packages will be installed:
  containerd.io docker-ce-cli
Suggested packages:
  bridge-utils iproute2 iputils-ping
The following NEW packages will be installed:
  containerd.io docker-ce docker-ce-cli
0 upgraded, 3 newly installed, 0 to remove and 0 not upgraded.
Need to get 104 MB of archives.
After this operation, 344 MB of additional disk space will be used.
Get:1 https://download.docker.com/linux/ubuntu focal/stable amd64 containerd.io amd64 1.6.10-3 [10.5 MB]
Get:2 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-ce-cli amd64 5:20.10.17~3-0~ubuntu-focal [32.7 MB]
Get:3 https://download.docker.com/linux/ubuntu focal/stable amd64 docker-ce amd64 5:20.10.17~3-0~ubuntu-focal [61.1 MB]
Fetched 104 MB in 10s (10.1 MB/s)
Selecting previously unselected package containerd.io.
(Reading database ... 111440 files and directories currently installed.)
Preparing to unpack .../containerd.io_1.6.10-3_amd64.deb ...
Unpacking containerd.io (1.6.10-3) ...
Selecting previously unselected package docker-ce-cli.
Preparing to unpack .../docker-ce-cli_5%3a20.10.17~3-0~ubuntu-focal_amd64.deb ...
Unpacking docker-ce-cli (5:20.10.17~3-0~ubuntu-focal) ...
Selecting previously unselected package docker-ce.
Preparing to unpack .../docker-ce_5%3a20.10.17~3-0~ubuntu-focal_amd64.deb ...
Unpacking docker-ce (5:20.10.17~3-0~ubuntu-focal) ...
Setting up containerd.io (1.6.10-3) ...
Setting up docker-ce-cli (5:20.10.17~3-0~ubuntu-focal) ...
Setting up docker-ce (5:20.10.17~3-0~ubuntu-focal) ...
Processing triggers for man-db (2.9.1-1) ...

Explanation: The output shows that Docker Engine, Docker CLI, and containerd have been installed successfully.

Add Your User to the Docker Group

Explanation: This command adds your user to the Docker group to avoid using sudo for Docker commands.

sudo usermod -aG docker $USER

Console Output:

Adding user `yourusername' to group `docker'
Adding yourusername to group docker

Explanation: The output shows that your user has been added to the Docker group.

Install Docker Compose

Explanation: Docker Compose is included in the Docker installation as docker compose. This command verifies the installation.

docker compose version

Console Output:

docker compose version, version v2.15.1, build unknown

Explanation: The output shows the version of Docker Compose installed on your system.

Step 3: Clone the Unichain Node Repository

Explanation: This command clones the Unichain Node repository from GitHub.

sudo apt install -y git
git clone https://github.com/Uniswap/unichain-node.git
cd unichain-node

Console Output:

Cloning into 'unichain-node'...
remote: Enumerating objects: 1234, done.
remote: Counting objects: 100% (1234/1234), done.
remote: Compressing objects: 100% (890/890), done.
remote: Total 1234 (delta 789), reused 1218 (delta 772), pack-reused 0
Receiving objects: 100% (1234/1234), 1.23 MiB | 1.23 MiB/s, done.
Resolving deltas: 100% (789/789), done.

Explanation: The output shows that the Unichain Node repository has been cloned successfully.

Step 4: Set Up Environment Variables

Explanation: This command sets up the environment variables for the Unichain node.

cp .env.sepolia .env
nano .env

Console Output: (No output for cp command)

Explanation: The cp command copies the example environment file to create your own .env file. There is no output for this command. The nano command opens the .env file in a text editor, and the output is not shown here.

Set Environment Variables in .env File

# Ethereum L1 Execution Layer RPC URL
OP_NODE_L1_ETH_RPC=https://sepolia.infura.io/v3/YOUR_INFURA_PROJECT_ID
# Ethereum L1 Beacon (Consensus Layer) RPC URL
OP_NODE_L1_BEACON=https://sepolia.beacon-chain.infura.io/v3/YOUR_INFURA_PROJECT_ID
# Paths to store Unichain data on the host
HOST_DATA_DIR=/home/yourusername/unichain-data/execution
HOST_NODE_DATA_DIR=/home/yourusername/unichain-data/node

Explanation: The output shows the environment variables that have been set up for the Unichain node.

Step 5: Configure the Unichain Node

Explanation: This command creates the data directories for the Unichain node.

mkdir -p /home/yourusername/unichain-data/execution
mkdir -p /home/yourusername/unichain-data/node

Console Output: (No output for mkdir commands)

Explanation: The mkdir commands create the data directories for the Unichain node. There is no output for these commands.

Check the docker-compose.yml File (Optional)

Explanation: This command checks the Docker Compose configuration.nano docker-compose.yml

Console Output: (No output for nano command)

Explanation: The nano command opens the docker-compose.yml file in a text editor, and the output is not shown here.

Ensure that the volume mappings use the environment variables correctly

volumes:   
  - ${HOST_DATA_DIR}:/data   
  - ${HOST_NODE_DATA_DIR}:/data

Explanation: The output shows the volume mappings in the docker-compose.yml file, which use the environment variables correctly.

Step 6: Run the Unichain Node

Explanation: This command starts the Unichain node using Docker Compose.

docker compose up -d

Console Output:

Creating network "unichain-node_default" with the default driver
Creating unichain-node_execution-client ... done
Creating unichain-node_op-node       ... done

Explanation: The output shows that the Unichain node has been started successfully using Docker Compose.

Verify the Containers Are Running

Explanation: This command checks if the containers are running.

docker ps

Console Output:

CONTAINER ID   IMAGE                        COMMAND                  CREATED          STATUS          PORTS                    NAMES
567890123456   unichain/op-node:latest      "/entrypoint.sh op-n…"   10 seconds ago   Up 9 seconds    0.0.0.0:8545->8545/tcp   unichain-node_op-node
123456789012   unichain/execution-client    "/entrypoint.sh exec…"   10 seconds ago   Up 9 seconds    0.0.0.0:8546->8546/tcp   unichain-node_execution-client

Explanation: The output shows the running containers for the Unichain node.

Step 7: Verify Node Operation

Explanation: This command tests the JSON-RPC endpoint of the Unichain node.

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

Console Output:

{"jsonrpc":"2.0","id":1,"result":"0x0"}

Explanation: The output shows the result of the JSON-RPC request to the Unichain node, which returns the block number.

Step 8: Monitor Synchronization Progress

Explanation: This command checks the block number to monitor the synchronization progress of the Unichain node.

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

Console Output:

{"jsonrpc":"2.0","id":1,"result":"0x123456"}

Explanation: The output shows the block number of the Unichain node, which can be used to monitor the synchronization progress.

View Container Logs (Optional)

Explanation: These commands show the logs for the execution client and OP node containers.

# Execution Client Logs:
docker compose logs -f execution-client
# OP Node Logs:
docker compose logs -f op-node

Console Output:

# Execution Client Logs:
Attaching to unichain-node_execution-client
unichain-node_execution-client  | 2023-03-01T12:00:00.000Z [INFO] Starting execution client...
# OP Node Logs:
Attaching to unichain-node_op-node
unichain-node_op-node       | 2023-03-01T12:00:00.000Z [INFO] Starting OP Node...

Explanation: The output shows the logs for the execution client and OP node containers, which can be used for debugging and monitoring purposes.

Step 9: Use Test Nodes for Deploying Unichain Nodes

By visiting the Test Nodes website, you can explore the available options for deploying Unichain nodes. The platform provides a user-friendly interface to configure and deploy nodes without the need for manual setup.

To deploy a Unichain node using Test Nodes:

  1. Go to https://testnodes.shop in your web browser.

  2. Select the Unichain node option.

  3. Choose the desired time period for your node, such as 1, 3 and 6 months.

  4. Follow the on-screen instructions to complete the deployment process.

Test Nodes will handle the setup and configuration of your Unichain node, allowing you to focus on other aspects of your project or development work.

Note: Test Nodes may have different pricing plans and terms of service, so be sure to review the details before proceeding with the deployment.

By using Test Nodes, you can save time and effort in setting up and configuring Unichain nodes, making it easier to get started with the Unichain network and decentralized applications (dApps) development.

Do not forget to use your referral code with your friends to earn rewards:

Conclusion

Congratulations! You have successfully installed and run a Unichain node on your system using Docker. Your node is now participating in the Unichain network, contributing to its security and decentralization. You can interact with your node programmatically or use it as a backend for decentralized applications (dApps) on the Unichain network.

Stay Connected

If you have any additional questions or would like to discuss further, feel free to find us on Discord or X platform.

🌐 Official Links

🔗 Twitter: https://x.com/testnodesxyz

🔗 Website: https://testnodes.xyz/

🛍️ Shop: https://testnodes.shop/

💬 Discord:https://discord.gg/jwANj5UqjV

📺 Coming soon: YouTube, Instagram, Telegram, Facebook!

Useful Links

Mirror文章信息

Mirror原文:查看原文

作者地址:0x98A10ac4B8a160b629153B0238823096eb0DFA6f

内容类型:application/json

应用名称:MirrorXYZ

内容摘要:cv-nTiHW6jn_h5_p3U-gGgEh0TBNyDbCqXSgMq-R9JM

原始内容摘要:v3REKJDkP5BDnNhx8QaLHxA7GYMvLIdq6_vR0MZga2k

区块高度:1555686

发布时间:2024-11-26 09:56:09