Ethereum 2.0 client Prysm builds and runs node records

Preface

Main reference documents:Prysm official documentation
System situation: Ubuntu 18.04 and has been replaced by Alibaba source
Configuration requirements:


1. What is Prysm?

Prysm is an implementation of the Ethereum proof-of-stake consensus specification.

Using Prysm to run a node and stake ETH can be divided into the following three steps:

  1. Use the execution layer client to configure the execution node.
  2. Use the consensus layer client Prysm to configure the beacon node.
  3. Use Prysm (optional) to configure a validator and stake ETH.

2. Installation and operation steps

1.prysm installation

There are three main ways to install Prysm:

  • Method 1: Install using Docker

It may be a network problem, and the connection failed after trying this method multiple times. Now attach the pull and startup code:

①Use docker to pull the prysm image

docker pull gcr.io/prysmaticlabs/prysm/beacon-chain:v3.1.1

②Prysm container starts
Create a new prysm directory

mkdir prysm && cd prysm

prysm container starts (The prerequisite is that the jwt.hex file has been generated. How to generate the file can be found below.

docker run -itd --restart=unless-stopped  \
   -v /etc/localtime:/etc/localtime \
   -v /etc/timezone:/etc/timezone \
   --name beacon-node \
   -v $(pwd)/data:/data -v $(pwd)/data/jwt.hex:/opt/jwt.hex \
  --network=host \
   gcr.io/prysmaticlabs/prysm/beacon-chain:v3.1.1 \
  --datadir=/data \
  --jwt-secret=/opt/jwt.hex \
  --rpc-host=0.0.0.0 \
  --grpc-gateway-host=0.0.0.0 \
  --monitoring-host=0.0.0.0 \
  --execution-endpoint=http://127.0.0.1:8551 \
  --accept-terms-of-use=true

Trace beacon-node log output

docker logs -f beacon-node
  • Method 2: Install using a script

This step is recommended on the official website and is also how I successfully installed it.

①Create a folder

sudo mkdir ethereum
cd ethereum
sudo mkdir consensus
cd .. #Return to the previous directory
sudo mkdir execution

That is the directory structure like this:


②Switch to the consensus directory

cd ethereum/consensus

③Create a new prysm data folder

sudo mkdir prysm && cd prysm

④ Pull the script and modify the file permissions

curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh && chmod +x prysm.sh

⑤Generate JWT Secret

The HTTP connection between beacon node and execution node needs to useJWTToken for authentication. There are several ways to generate this JWT token:

  • Use onlineGenerate website, copy and copy it to the newly created jwt.hex folder.
  • Generated via OpenSSL command:openssl rand -hex 32 | tr -d "\n" > "jwt.hex"
  • Generate using geth client
  • Generate using prysm (this method is used here)
    Switch to the prysm directory and execute:
    ./prysm.sh beacon-chain generate-auth-secret #The jwt.hex file path generated in this way is in the consensus directory
Note: The jwt.hex file can be placed in any location, as long as the jwt.hex file path in subsequent commands is written as the actual storage path.
The fourth method is used here, and its absolute path is:/opt/ethereum/consensus/jwt.hex
  • Method 3: Build from source code using Bazel (don’t know, haven’t tried it)

2. Run geth client

① Ensure that go (1.18+) and c compiler are installed on the system. Tutorial on installing geth.Can be referenced

The official website’s version requirement for geth client is 1.10.22+
②Start the geth client (run an execution node in the execution layer of Ethereum)

geth --http --http.api eth,net,engine,admin --authrpc.jwtsecret /opt/ethereum/consensus/jwt.hex

Parameter definitions can be found at:Website introduction

Synchronization can take a long time – from a few hours to a few days. You can proceed to the next step while performing node synchronization.
You can open another terminal and check the geth execution node status through the following command

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

If the following response appears, it proves that the node has completed synchronization:

3. Use prysm to run beacon node

Execute in prysm folder

./prysm.sh beacon-chain --execution-endpoint=http://localhost:8551 --jwt-secret=/opt/ethereum/consensus/jwt.hex --suggested-fee-recipient=0x01234567722E6b0000012BFEBf6177F1D2e9758D9

Your beacon node will now begin syncing. This usually takes a couple days, but it can take longer depending on your network and hardware specs.
Congratulations – you’re now running a full, Merge-ready Ethereum node. To check the status of your node, visit Check node and validator status.

You can use the following command to query the node synchronization status

curl http://localhost:3500/eth/v1alpha1/node/syncing

According to the tutorial, if the synchronization is completed, return{"syncing":false}
But after running for an afternoon, the status of the query is:

Related Posts

Websocket obtains session, synchronizes login user information, and solves the problem of inconsistency between null and session.

Developers, what exactly are Docker images, containers and repositories?

Mobaihe CM311-1a does not require disassembly, flash firmware and + brush armbian to install docker and run Qinglong panel

Detailed explanation of Ethernet MAC frame format

Application of 300PLCmpi to Ethernet in aluminum profile aging furnace through Xingda Easy Control MPI-ETH-XD1.0

“Shopping Cashback Points Redemption” – Shopping Cashback Method with Blockchain Thinking

Detailed process and problem solving of installing Docker under Windows

HarmonyOS IoT device kernel programming interface—–Message queue

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

*