0%

build-PoS-Ethereum

How to deploy a private PoS Ethereum with Geth and Prysm.

SPEC and usage

Execution-api

1
2
3
4
5
6
7
8
curl localhost:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":0}' | jq
curl localhost:8545 -X POST -H "Content-Type: application/json" -d '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":0}' | jq
# response
{
"jsonrpc": "2.0",
"id": 0,
"result": "0x1"
}

Beacon-api,可采用curl发请求,类似执行层客户端进行调用

1
2
3
4
5
6
7
8
9
10
11
curl http://localhost:3500/eth/v1/node/syncing | jq
# response
{
"data": {
"head_slot": "11135548",
"sync_distance": "1",
"is_syncing": false,
"is_optimistic": true,
"el_offline": true
}
}

Run on mainnet

Clients: Geth and Prysm

Tutorial: https://docs.prylabs.network/docs/install/install-with-script

1
2
3
./geth --mainnet --http --http.api eth,net,engine,admin --authrpc.jwtsecret=../jwt.hex

./prysm.sh beacon-chain --execution-endpoint=http://localhost:8551 --mainnet --jwt-secret=../jwt.hex --checkpoint-sync-url=https://beaconstate.info --genesis-beacon-api-url=https://beaconstate.info

Try to sync a beacon node from checkpoint, and sync chain & state in Geth, will take a few hours.

Warnings from Prysm, validator related.

1
node: 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).

Check status

Tutorial: https://docs.prylabs.network/docs/monitoring/checking-status

检查共识层客户端的同步是否完成

1
2
3
4
5
6
7
8
9
10
11
12
13
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 112 100 112 0 0 14000 0 --:--:-- --:--:-- --:--:-- 14000
{
"data": {
"head_slot": "11135127",
"sync_distance": "0",
"is_syncing": false,
"is_optimistic": true,
"el_offline": true # still syncing
}
}

共识层客户端已经同步完成,但是和执行层客户端未连通

检查执行层客户端的同步是否完成

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
./geth attach
eth.syncing
# expecting a false
{
currentBlock: 15314380,
healedBytecodeBytes: 2053529,
healedBytecodes: 446,
healedTrienodeBytes: 1968473762,
healedTrienodes: 6519351,
healingBytecode: 0,
healingTrienodes: 0,
highestBlock: 21917863,
startingBlock: 0,
syncedAccountBytes: 60708967041,
syncedAccounts: 282697646,
syncedBytecodeBytes: 10186461772,
syncedBytecodes: 1519696,
syncedStorage: 1250847116,
syncedStorageBytes: 279825979846,
txIndexFinishedBlocks: 0,
txIndexRemainingBlocks: 1
}

chain download 70%

state 已经下载完毕

Private testnet via prysm tutorial

Tutorial: https://docs.prylabs.network/docs/advanced/proof-of-stake-devnet

Using go 1.23.3

Not tried yet.

Private testnet via kurtosis

Tutorial: https://geth.ethereum.org/docs/fundamentals/kurtosis

kurtosis offers container-like capability.

First init a .yaml file with 2 geth-lighthouse clients and a geth-prysm client.

1
2
3
4
5
6
7
8
9
10
participants:
- el_type: geth
cl_type: lighthouse
count: 2
- el_type: geth
cl_type: prysm
network_params:
network_id: "95999599"
additional_services:
- dora

Then run:

1
kurtosis run github.com/ethpandaops/ethereum-package --args-file ./network_params.yaml --image-download always

Works with some extra docker proxy support.

image-20250225163635550

The explorer is available at http://127.0.0.1:10642/.

image-20250225163753070

You can send rpc requests to the deployed geth-lighthouse client.

1
2
$ curl -X POST -H "Content-Type: application/json" --data '{"method":"eth_blockNumber","params":[],"id":1,"jsonrpc":"2.0"}' http://127.0.0.1:10305
{"jsonrpc":"2.0","id":1,"result":"0x70"}

Check and stop the running enclave.

1
2
kurtosis enclave ls
kurtosis enclave stop [enclave-name]

Redo on zgclab server.

1
2
git clone https://github.com/ethpandaops/ethereum-package.git
kurtosis run . --args-file ../network_params.yaml --image-download always

Need to tag the name of the docker images pulled from third party

1
docker tag gcr.mirrorify.net/prysmaticlabs/prysm/validator:stable gcr.io/prysmaticlabs/prysm/validator:stable

Works fine for me. enclave stopped earthy-ocean.

image-20250225200345624