部署prysm mainnet
部署prysm
下载prysm
mkdir -pv /data/prysm && cd /data/prysm
curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh && chmod +x prysm.sh
生成JWT Secret
## Optional. This command is necessary only if you've previously configured USE_PRYSM_VERSION
USE_PRYSM_VERSION=v3.1.2
## Required.
./prysm.sh beacon-chain generate-auth-secret
gpg: key 72E33E4DF1A5036E: public key "Preston Van Loon <preston@prysmaticlabs.com>" imported
gpg: Total number processed: 1
gpg: imported: 1
beacon-chain-v3.2.0-linux-amd64: OK
gpg: Signature made Fri Dec 16 03:30:50 2022 UTC
gpg: using RSA key 0AE0051D647BA3C1A917AF4072E33E4DF1A5036E
gpg: Good signature from "Preston Van Loon <preston@prysmaticlabs.com>" [unknown]
gpg: WARNING: This key is not certified with a trusted signature!
gpg: There is no indication that the signature belongs to the owner.
Primary key fingerprint: 0AE0 051D 647B A3C1 A917 AF40 72E3 3E4D F1A5 036E
Verified /data/prysm/dist/beacon-chain-v3.2.0-linux-amd64 has been signed by Prysmatic Labs.
Starting Prysm beacon-chain generate-auth-secret
[2023-01-17 06:08:43] INFO Successfully wrote JSON-RPC authentication secret to file /data/prysm/jwt.hex
查看生成文件
# ls /data/prysm/ -l
total 16
drwxr-xr-x 2 root root 134 Jan 17 06:08 dist
-rw------- 1 root root 66 Jan 17 06:08 jwt.hex
-rwxr-xr-x 1 root root 9538 Jan 17 06:07 prysm.sh
部署geth
下载geth
# cd /opt
# wget https://gethstore.blob.core.windows.net/builds/geth-alltools-linux-amd64-1.10.26-e5eb32ac.tar.gz
# tar xf geth-alltools-linux-amd64-1.10.26-e5eb32ac.tar.gz -C /usr/local/
# ln -sv /usr/local/geth-alltools-linux-amd64-1.10.26-e5eb32ac/ /usr/local/geth
'/usr/local/geth' -> '/usr/local/geth-alltools-linux-amd64-1.10.26-e5eb32ac/'
创建geth数据目录
# mkdir -pv /data/eth
mkdir: created directory '/data/eth'
geth.service
[Unit]
Description=goerli chain
StartLimitIntervalSec=500
StartLimitBurst=5
[Service]
Restart=on-failure
RestartSec=5s
ExecStart=/usr/local/geth/geth --mainnet --http --http.addr "0.0.0.0" --http.api eth,net,engine,admin --syncmode snap --gcmode archive --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret /data/prysm/jwt.hex --datadir /data/eth --allow-insecure-unlock
Type=simple
User=root
KillSignal=SIGINT
TimeoutStopSec=12000
[Install]
WantedBy=multi-user.target
设置开机启动
# systemctl enable geth
Created symlink /etc/systemd/system/multi-user.target.wants/geth.service → /lib/systemd/system/geth.service.
运行geth服务
# systemctl start geth
查看geth运行状态
# journalctl -u geth -f
Jan 17 06:34:37 geth-01 geth[14134]: INFO [01-17|06:34:37.141] HTTP server started endpoint=[::]:8545 auth=false prefix= cors= vhosts=localhost
Jan 17 06:34:37 geth-01 geth[14134]: INFO [01-17|06:34:37.141] WebSocket enabled url=ws://127.0.0.1:8551
Jan 17 06:34:37 geth-01 geth[14134]: INFO [01-17|06:34:37.141] HTTP server started endpoint=127.0.0.1:8551 auth=true prefix= cors=localhost vhosts=localhost
Jan 17 06:34:37 geth-01 geth[14134]: INFO [01-17|06:34:37.282] Generated state snapshot accounts=8893 slots=0 storage=409.64KiB dangling=0 elapsed=154.000ms
Jan 17 06:34:41 geth-01 geth[14134]: INFO [01-17|06:34:41.536] New local node record seq=1,673,937,277,138 id=a4995bfbfb44b6d6 ip=43.206.197.202 udp=30303 tcp=30303
Jan 17 06:34:47 geth-01 geth[14134]: INFO [01-17|06:34:47.143] Looking for peers peercount=0 tried=19 static=0
Jan 17 06:34:57 geth-01 geth[14134]: INFO [01-17|06:34:57.476] Looking for peers peercount=0 tried=26 static=0
Jan 17 06:35:07 geth-01 geth[14134]: INFO [01-17|06:35:07.476] Looking for peers peercount=0 tried=35 static=0
Jan 17 06:35:12 geth-01 geth[14134]: WARN [01-17|06:35:12.131] Post-merge network, but no beacon client seen. Please launch one to follow the chain!
Jan 17 06:35:17 geth-01 geth[14134]: INFO [01-17|06:35:17.583] Looking for peers peercount=0 tried=34 static=0
Jan 17 06:35:27 geth-01 geth[14134]: INFO [01-17|06:35:27.808] Looking for peers peercount=1 tried=40 static=0
运行beacon 节点
创建prysm数据目录
# mkdir -pv /data/prysm/data
mkdir: created directory '/data/prysm/data'
prysm.service
[Unit]
Description=prysm mainnet
After=network-online.target
Wants=network-online.target
[Service]
User=root
WorkingDirectory=/data/prysm
ExecStart=/data/prysm/prysm.sh beacon-chain --execution-endpoint=http://localhost:8551 --jwt-secret=/data/prysm/jwt.hex --datadir=/data/prysm/data --accept-terms-of-use=true
Restart=always
RestartSec=3
LimitNOFILE=65535
[Install]
WantedBy=multi-user.target
设置开机运行prysm服务
# systemctl enable prysm
Created symlink /etc/systemd/system/multi-user.target.wants/prysm.service → /lib/systemd/system/prysm.service.
运行prysm服务
# systemctl start prysm
查看prysm服务
# journalctl -u prysm -f
Jan 17 06:39:52 geth-01 systemd[1]: Started prysm goerli.
Jan 17 06:39:52 geth-01 prysm.sh[14333]: Latest Prysm version is v3.2.0.
Jan 17 06:39:52 geth-01 prysm.sh[14333]: Beacon chain is up to date.
Jan 17 06:39:52 geth-01 prysm.sh[14333]: Verifying binary integrity.
Jan 17 06:39:53 geth-01 prysm.sh[14347]: beacon-chain-v3.2.0-linux-amd64: OK
Jan 17 06:39:53 geth-01 prysm.sh[14349]: gpg: Signature made Fri Dec 16 03:30:50 2022 UTC
Jan 17 06:39:53 geth-01 prysm.sh[14349]: gpg: using RSA key 0AE0051D647BA3C1A917AF4072E33E4DF1A5036E
Jan 17 06:39:53 geth-01 prysm.sh[14349]: gpg: Good signature from "Preston Van Loon <preston@prysmaticlabs.com>" [unknown]
Jan 17 06:39:53 geth-01 prysm.sh[14349]: gpg: WARNING: This key is not certified with a trusted signature!
Jan 17 06:39:53 geth-01 prysm.sh[14349]: gpg: There is no indication that the signature belongs to the owner.
Jan 17 06:39:53 geth-01 prysm.sh[14349]: Primary key fingerprint: 0AE0 051D 647B A3C1 A917 AF40 72E3 3E4D F1A5 036E
Jan 17 06:39:53 geth-01 prysm.sh[14333]: Verified /data/prysm/dist/beacon-chain-v3.2.0-linux-amd64 has been signed by Prysmatic Labs.
Jan 17 06:39:53 geth-01 prysm.sh[14333]: Starting Prysm beacon-chain --execution-endpoint=http://localhost:8551 --jwt-secret=/data/prysm/jwt.hex --datadir=/data/prysm/data --accept-terms-of-use=true
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Finished reading JWT secret from /data/prysm/jwt.hex"
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=warning msg="Running on Ethereum Mainnet" prefix=flags
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=warning msg="In order to receive transaction fees from proposing blocks, you must provide flag --suggested-fee-recipient with a valid ethereum address when starting your beacon node. Please see our documentation for more information on this requirement (https://docs.prylabs.network/docs/execution-node/fee-recipient)." prefix=node
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Checking DB" database-path="/data/prysm/data/beaconchaindata" prefix=node
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Opening Bolt DB at /data/prysm/data/beaconchaindata/beaconchain.db" prefix=db
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Deposit contract: 0x00000000219ab540356cbb839cbe05303d7705fa" prefix=node
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Running node with peer id of 16Uiu2HAm3aAAmAwWGP59By6YJkrLQG9ntWYWimLGvtcgFHKUP6E2 " prefix=p2p
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Waiting for state to be initialized" prefix=initial-sync
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="gRPC server listening on port" address="127.0.0.1:4000" prefix=rpc
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=warning msg="You are using an insecure gRPC server. If you are running your beacon node and validator on the same machines, you can ignore this message. If you want to know how to enable secure connections, see: https://docs.prylabs.network/docs/prysm-usage/secure-grpc" prefix=rpc
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Starting beacon node" prefix=node version="Prysm/v3.2.0/3d6d0a12dd189abcd2cfbba1c3d56505a1dd595c. Built at: 2022-12-15 23:40:50+00:00"
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Blockchain data already exists in DB, initializing..." prefix=blockchain
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Starting API middleware" prefix=gateway
Jan 17 06:39:53 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:53" level=info msg="Starting gRPC gateway" address="127.0.0.1:3500" prefix=gateway
Jan 17 06:39:54 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:54" level=info msg="Starting initial chain sync..." prefix=initial-sync
Jan 17 06:39:54 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:54" level=info msg="Waiting for enough suitable peers before syncing" prefix=initial-sync required=3 suitable=0
Jan 17 06:39:54 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:54" level=info msg="Started discovery v5" ENR="enr:-MK4QFG3YsyoHMfVRa17BKiRpojnRyhnSc0oTTpisTK6cGq4M0E8jJvQiZcJFsJU9-xzYpEYME4b00l_K8IXEdDv2CGGAYW-dKaah2F0dG5ldHOIAAAAAAAAAACEZXRoMpBKJsWLAgAAAP__________gmlkgnY0gmlwhKwQAV2Jc2VjcDI1NmsxoQJ5CgPyp29VN6TYv2T3HDOacohxHWmnFrJXpmLpBCL6B4hzeW5jbmV0cwCDdGNwgjLIg3VkcIIu4A" prefix=p2p
Jan 17 06:39:54 geth-01 prysm.sh[14333]: time="2023-01-17 06:39:54" level=info msg="Node started p2p server" multiAddr="/ip4/172.16.1.93/tcp/13000/p2p/16Uiu2HAm3aAAmAwWGP59By6YJkrLQG9ntWYWimLGvtcgFHKUP6E2" prefix=p2p
Jan 17 06:40:08 geth-01 prysm.sh[14333]: time="2023-01-17 06:40:08" level=info msg="Connected to new endpoint: http://localhost:8551" prefix=powchain
查看区块同步
prysm节点
使用以下命令检查节点的同步状态:
# curl http://localhost:3500/eth/v1alpha1/node/syncing
如果节点已完成同步,将看到响应:
{"syncing":false}
geth节点
使用以下命令检查节点的同步状态:
# curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' http://localhost:8545
如果节点已完成同步,将看到响应:
{"jsonrpc":"2.0","id":1,"result":false}
查询最新区块高度
# curl -H "Content-Type: application/json" -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' http://localhost:8545
{"jsonrpc":"2.0","id":1,"result":"0xedd589"}
参考文档
geth下载地址: https://geth.ethereum.org/downloads
prysm: https://docs.prylabs.network/docs/execution-node/authentication
geth主网区块浏览器:https://etherscan.io/