Start Ethereum (Shanghai) main network full node

Problem Description

After using the latest geth version, the following problems will occur when starting the geth mainnet node according to the previous method:

Reasons for the failure of the old version of geth

Post-merge network, but no beacon client seen. Please launch one to follow the chain!

problem causes

The above message is emitted when Geth is run without a consensus client on a post-merge proof-of-stake network. Since Ethereum moved to proof-of-stake Geth alone is not enough to follow the chain because the consensus logic is now implemented by a separate piece of software called a consensus client. This log message is displayed when the consensus client is missing. Read more about this on our consensus clients page.

The above message is emitted when Geth is running without a consensus client on the merged proof-of-stake network. Since Ethereum moved to proof-of-stake, Geth alone is not enough to keep track of the chain, as the consensus logic is now implemented by separate software called the consensus client. This log message is displayed when consensus clients are missing. Read more about it on our Consensus client page.

The new version geth starts

Download, install and start a consensus client. The installation reference documentation is here .

3.1 clefCreate an account using

1. Compile clefthe client

Note: If you can't access, github.comyou need to go online scientifically

//  下载ethertum源码
git clone https://github.com/ethereum/go-ethereum.git
cd go-ethereum/cmd/clef/
// 需要科学上网
go build 

mv clef ../geth-linux

2. Generate an account

$ mkdir act
$ clef init

WARNING!

Clef is an account management tool. It may, like any software, contain bugs.

Please take care to
- backup your keystore files,
- verify that the keystore(s) can be opened with your password.

Clef is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.

Enter 'ok' to proceed:
> ok
The master seed of clef will be locked with a password.
Please specify a password. Do not forget this password!
Password: 

// 生成账号
$ clef newaccount --keystore [keystore path]

WARNING!

Clef is an account management tool. It may, like any software, contain bugs.

Please take care to
- backup your keystore files,
- verify that the keystore(s) can be opened with your password.

Clef is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the GNU General Public License for more details.

Enter 'ok' to proceed:
> ok

## New account password

Please enter a password for the new account to be created (attempt 0 of 3)
> 
-----------------------
INFO [04-18|12:13:39.005] Your new key was generated               address=0x9E7b07952Fcb2197AF96964e08579f5a2E969FeC
WARN [04-18|12:13:39.005] Please backup your key file!             path=/home/baas/data/ethereum/acts/UTC--2023-04-18T04-13-37.353476343Z--9e7b07952fcb2197af96964e08579f5a2e969fec
WARN [04-18|12:13:39.005] Please remember your password! 
Generated account 0x9E7b07952Fcb2197AF96964e08579f5a2E969FeC

3. Start clef

I don't know when to start

// 连接主网
clef --keystore acts --configdir clef
// 连接其他网络,使用 --chainid 参数
clef --keystore acts --configdir clef --chainid 11155111

More chainid reference website: chainlist.org

4. Start the Consensus Client

Currently supported Consesus clients are:

The consensus client must be started with the correct port configuration to establish an RPC connection to the local Geth instance. In the example above, localhost:8551 is authorized for this purpose. The consensus client has a command like --http-webprovider that takes the exposed Geth port as an argument.
Consensus clients also need Geth's jwt-secret path in order to authenticate RPC connections between them. Every consensus client has a command like --jwt-secret that takes a file path as an argument. This must match the --authrpc.jwtsecret path provided to Geth.
Consensus clients expose a Beacon API that can be used to check the status of Beacon clients or download blocks and consensus data by sending requests using tools such as Curl. See the documentation for each consensus client for more information on this.

The following uses Prysmto start the consensus client.
The types of beacon chain nodes are as follows:

Since there is no ETH, only ordinary nodes of `beacon` can be started.
// 下载 prysm
mkdir consensus
cd consensus
mkdir prysm && cd prysm
curl https://raw.githubusercontent.com/prysmaticlabs/prysm/master/prysm.sh --output prysm.sh && chmod +x prysm.sh

// Generate JWT Secret
<!--信标节点和执行节点之间的 HTTP 连接需要使用 JWT 令牌进行身份验证。 有几种方法可以生成此 JWT 令牌:使用像这样的在线生成器。 将此值复制并粘贴到 jwt.hex 文件中。-->
<!--使用像 OpenSSL 这样的实用程序通过命令创建令牌:openssl rand -hex 32 |  tr -d "\n" > "jwt.hex"。-->
<!--使用执行客户端生成 jwt.hex 文件。-->
<!--使用 Prysm 生成 jwt.hex 文件:-->
<!--Optional. This command is necessary only if you've previously configured USE_PRYSM_VERSION-->
$ USE_PRYSM_VERSION=v4.0.0

<!--Required.-->
$ ./prysm.sh beacon-chain generate-auth-secret

beacon-chainintroduce:

  • The Beacon Chain introduces proof-of-stake to the Ethereum ecosystem.
  • It merges with the original Ethereum proof-of-work chain in September 2022.
  • The Beacon Chain introduces the consensus logic and block gossip protocol that now secures Ethereum.

5. Use geth to start the execution node

In order to connect to consensus clients, Geth must expose a port for inter-client RPC connections.
RPC connections must be authenticated using the jwtsecret file. Created and saved to by default <datadir>/geth/jwtsecret, but can also be created and saved to a custom location, or can be generated and provided to Geth --authrpc.jwtsecretitself . Both Geth and the consensus client require jwtsecretthe file .
Authorization must then be applied to specific addresses/ports. This is done by passing the address to --authrpc.addrand the port number to . --authrpc.portIt is also safe to --authrpc.vhostsprovide localhost or the wildcard * so that Geth will accept incoming requests from the virtual host as it only works on ports authenticated with jwtsecret.

// 
geth --datadir /home/baas/data/ethereum/geth-data --authrpc.addr localhost --authrpc.port 8551 --authrpc.vhosts localhost --authrpc.jwtsecret consensus/prysm/jwt.hex --http --http.api eth,net --signer=clef/clef.ipc --http 

// 如果不想被其他节点发现,则增加 --nodiscover 参数

6. Start the consensus node

// Run a beacon node using Prysm
<!-- prysm.sh 和 jwt.hex 在同一目录-->
$ ./prysm.sh beacon-chain --execution-endpoint=http://localhost:8551 --jwt-secret=jwt.hex  --suggested-fee-recipient=0x9E7b07952Fcb2197AF96964e08579f5a2E969FeC
Latest Prysm version is v4.0.2.
Beacon chain is up to date.
Verifying binary integrity.
beacon-chain-v4.0.2-linux-amd64: OK
gpg: Signature made Thu 13 Apr 2023 12:01:31 PM CST
gpg:                using RSA key 0AE0051D647BA3C1A917AF4072E33E4DF1A5036E
gpg: Good signature from "Preston Van Loon <[email protected]>" [unknown]
gpg:                 aka "Preston Van Loon <[email protected]>" [unknown]
gpg:                 aka "Preston Van Loon <[email protected]>" [unknown]
gpg:                 aka "Preston Van Loon (0xf71E9C766Cdf169eDFbE2749490943C1DC6b8A55) <[email protected]>" [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 /home/baas/data/ethereum/consensus/prysm/dist/beacon-chain-v4.0.2-linux-amd64 has been signed by Prysmatic Labs.
Starting Prysm beacon-chain --execution-endpoint=http://localhost:8551 --jwt-secret=jwt.hex --suggested-fee-recipient=0x9E7b07952Fcb2197AF96964e08579f5a2E969FeC

Prysmatic Labs Terms of Use

By downloading, accessing or using the Prysm implementation (“Prysm”), you (referenced herein
as “you” or the “user”) certify that you have read and agreed to the terms and conditions below.

TERMS AND CONDITIONS: https://github.com/prysmaticlabs/prysm/blob/master/TERMS_OF_SERVICE.md


Type "accept" to accept this terms and conditions [accept/decline]: (default: decline):
// 输入 accept, 回车开始同步

7. Check the synchronization status

Status monitoring items refer to " Check node and validator status "

(1) geth node

$ geth attach http://localhost:8545
> eth.syncing
false

A sync status of false means your node is fully synced.

(2) View Beacon node synchronization

$ curl http://localhost:3500/eth/v1/node/syncing | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100   113  100   113    0     0  56500      0 --:--:-- --:--:-- --:--:-- 56500
{
  "data": {
    "head_slot": "8639",
    "sync_distance": "6239308",
    "is_syncing": true,
    "is_optimistic": false,
    "el_offline": true
  }
}
  • When you see “is_syncing”:false, your beacon node is fully synced with the beacon chain.
  • “is_optimistic”:falseYour beacon node sees your execution node when you see :
      1. not started yet,
      1. have not synced through the merged block, or
      1. Fully synchronized with the executive layer blockchain.
$ curl http://localhost:8080/healthz
*prometheus.Service: OK
*execution.Service: ERROR, retryExecutionClientConnection: processPastLogs: no contract code at given address
*attestations.Service: OK
*blockchain.Service: OK
*sync.Service: ERROR, out of sync
*rpc.Service: ERROR, syncing
*p2p.Service: OK
*initialsync.Service: ERROR, syncing
*builder.Service: OK
*gateway.Gateway: OK

processPastLogs: no contract code at given addressThe table name is currently still in the synchronization ledger.

(3) Check the connection between Beacon Node and Geth Node

$ curl http://localhost:3500/eth/v1alpha1/node/eth1/connections
{"currentAddress":"http://localhost:8551","currentConnectionError":"retryExecutionClientConnection: processPastLogs: no contract code at given address","addresses":["http://localhost:8551"],"connectionErrors":[]}

If you see currentConnectionError: no contract code at given address, your execution nodes are probably still syncing. Otherwise, if you don't see any errors, your beacon node is connected to your execution node.

So wait a few hours or a few days for the sync to complete.

Guess you like

Origin blog.csdn.net/shuizhongmose/article/details/130225841