# THIS HAS BEEN MOVED TO https://notes.ethereum.org/@launchpad/zhejiang
# THE DOCS YOU READ BELOW ARE OUTDATED!
TODO before publishing
* make sure that withdrawal-devnet-0/1 is replaced with Zhejiang
* make sure bootnodes are pointing to the correct place
* make sure all github links are correct
* change network id
# How to run a node on the Zhejiang testnet?
## Who is this guide for?
This guide is meant to be a starting point and provides a mid-level summary of the required steps. It is not intended to be a beginner's guide, so copying and running commands from here may not work without some tweaking.
The testnet is meant to mimic a chain that is post-merge. Therefore, the genesis state will be in a merged state. The chain will have to go through a fork on both EL and CL at the same time. This fork is called Shanghai on the EL side and Capella on the CL side. These two events will be triggered simultaneously.
This is achieved by EL forking at a specific time rather than at a block number, and CL forking at a specific epoch.
## What is in the Zhejiang testnet?
The Zhejiang testnet aims to test the following features:
- Withdrawals
- Timestamp based forking
- Warm COINBASE
- PUSH0
- Limit/meter initcode
- BLS to Execution changes at scale
A future testnet will be launched in Jan '23 that impliments all the final Shanghai EIPs.
More details about these other changes can be found [here](https://github.com/ethereum/execution-specs/blob/master/network-upgrades/mainnet-upgrades/shanghai.md#eips-considered-for-inclusion)
The JSON-RPC endpoint, faucet, and other tooling URLs can be found on https://zhejiang.ethpandaops.io/
### Feature explanation:
#### Withdrawals
The partial withdrawals feature will be automatically triggered on all addresses that already have `0x01` withdrawal credentials set. For those that use `0x00` (legacy BLS credentials), they will need to first change their credentials from `0x00` to `0x01` before this feature can be tested.
#### BLS to Execution Changes
Changing `0x00` to `0x01` credential is currently only supported by a single tool [ethdo](https://github.com/wealdtech/ethdo/blob/master/docs/changingwithdrawalcredentials.md). Hopefully, over time there will be multiple different tools that offer this functionality. A detailed description of how to convert your address and trigger a full exit is described in another guide (all instructions done with docker!) that can be found [here](https://notes.ethereum.org/@bbusa/withdrawals).
# Which version/branch do I use?
#### Consensus layer
| Client Name | Git Branch | Docker image |
|--- |--- |--- |
| Lighthouse | [capella](https://github.com/sigp/lighthouse/tree/capella) | sigp/lighthouse:capella |
| Teku | [master](https://github.com/Consensys/teku/) | consensys/teku:develop |
| Lodestar | [unstable](https://github.com/chainsafe/lodestar/tree/unstable) | chainsafe/lodestar:next |
| Prysm | [capella](https://github.com/prysmaticlabs/prysm/tree/capella) | gcr.io/prysmaticlabs/prysm/beacon-chain:capella-6b2721 gcr.io/prysmaticlabs/prysm/validator:HEAD-29dfca |
| Nimbus | [unstable](https://github.com/status-im/nimbus-eth2/tree/unstable) | ethpandaops/nimbus:merge-aff0505 |
#### Execution layer
| Client Name | Git Branch | Docker image |
|--- |--- |--- |
| Geth | [lightclient/withdrawals-timestamp](https://github.com/lightclient/go-ethereum/tree/withdrawals-timestamp) | ethpandaops/geth:withdrawal-devnet-1-9c4a92b |
| Nethermind | [master](https://github.com/NethermindEth/nethermind/) | nethermindeth/nethermind:withdrawals |
| Besu | [siladu/shanghaitime-forkid-withdrawals-evm](https://github.com/siladu/besu/tree/shanghaitime-forkid-withdrawals-evm) | siladu/besu:22.10.3-SNAPSHOT-openjdk-11-debug-withdrawals-evm-0455b22 |
| EthereumJS | [master](https://github.com/ethereumjs/ethereumjs-monorepo) | g11tech/ethereumjs:latest |
| Erigon | [devel](https://github.com/ledgerwatch/erigon/tree/devel) | thorax/erigon:devel |
## Preparation
Download the configs from https://github.com/ethpandaops/withdrawals-testnet/tree/master/withdrawal-devnet-1/custom_config_data.
```shell=
git clone https://github.com/ethpandaops/withdrawals-testnet.git
cd withdrawals-testnet/withdrawal-devnet-0/custom_config_data
```
Generate the JWT secret with openssl
```shell=
openssl rand -hex 32 | tr -d "\n" > "/tmp/jwtsecret"
```
This file needs to be passed to both the Execution Client and the Consensus Client. If you do not specify a JWT secret, then the execution and/or consensus layer client will automatically generate one for you. You will then have to specify this secret in the Consensus Layer client.
# Run an Execution Layer Client
## Geth
Pre-requisites: `git, make, go, gcc`.
Clone and build the `withdrawals-timestamp` branch of [Geth](https://github.com/lightclient/go-ethereum/tree/withdrawals-timestamp) (lightclient's repo)
```shell=
git clone -b withdrawals-timestamp https://github.com/lightclient/go-ethereum.git
cd go-ethereum
make geth
cd ..
```
From the `custom_config_data` folder start the client
```shell=
./go-ethereum/build/bin/geth --datadir "geth-datadir" init genesis.json
./go-ethereum/build/bin/geth \
--datadir "geth-datadir" \
--http --http.api="engine,eth,web3,net,debug" \
--ws --ws.api="engine,eth,web3,net,debug" \
--http.corsdomain "*" \
--networkid=1337805 \
--syncmode=full \
--authrpc.jwtsecret=/tmp/jwtsecret \
--bootnodes "enode://b896e651b9d100ece367bf6a360b22b7e3032f542c1bffcc102f94e79a44d74b227bbcf67218e25d375ddd50beaf229135d3e42a260717c3d82eb897ce8b9069@167.71.60.16:30303"
```
## Nethermind
Pre-requisites: `git, dotnet`
Please ensure you have Node 12.x+ installed.
Clone and build the `feature/shanghai-eip-4895-withdrawals` branch of [Nethermind](https://github.com/NethermindEth/nethermind/tree/feature/shanghai-eip-4895-withdrawals)
```shell=
git clone --recursive -b feature/shanghai-eip-4895-withdrawals https://github.com/NethermindEth/nethermind.git
cd nethermind/src/Nethermind
dotnet build Nethermind.sln -c Release
```
From the `custom_config_data/nethermind/src/Nethermind/` folder start the client
```shell=
cd Nethermind.Runner
dotnet run -c Release -- \
--config withdrawals_devnet \
--datadir="../../../../nethermind-datadir" \
--JsonRpc.Host=0.0.0.0 \
--JsonRpc.JwtSecretFile=/tmp/jwtsecret \
--Init.ChainSpecPath="../../../../chainspec.json" \
--Network.StaticPeers="enode://b896e651b9d100ece367bf6a360b22b7e3032f542c1bffcc102f94e79a44d74b227bbcf67218e25d375ddd50beaf229135d3e42a260717c3d82eb897ce8b9069@167.71.60.16:30303"
```
## Besu
Pre-requisites: `git, jvm`
Clone and build the `shanghaitime-forkid-withdrawals-evm` branch of [Besu](https://github.com/siladu/besu/tree/shanghaitime-forkid-withdrawals)
```shell=
git clone --recursive -b shanghaitime-forkid-withdrawals https://github.com/siladu/besu.git
cd besu
./gradlew installDist
cd ..
```
From the `custom_config_data` folder start the client
```shell=
besu/build/install/besu/bin/besu \
--network=1337805 \
--data-path="besu-datadir" \
--genesis-file="besu.json" \
--rpc-http-enabled=true \
--rpc-http-host="0.0.0.0" \
--rpc-http-cors-origins="*"\
--rpc-ws-enabled=true \
--rpc-ws-host="0.0.0.0" \
--host-allowlist="*" \
--engine-host-allowlist="*"\
--engine-jwt-enabled=true \
--engine-jwt-secret=/tmp/jwtsecret \
--bootnodes="enode://b896e651b9d100ece367bf6a360b22b7e3032f542c1bffcc102f94e79a44d74b227bbcf67218e25d375ddd50beaf229135d3e42a260717c3d82eb897ce8b9069@167.71.60.16:30303"
```
## EthereumJS
Pre-requisites: `git, node, npm`
Please ensure you have [Node 18.x+](https://github.com/nodesource/distributions/blob/master/README.md) installed.
Clone and build from source
```shell=
git clone --depth 1 --branch master https://github.com/ethereumjs/ethereumjs-monorepo.git
cd ethereumjs-monorepo
npm i
```
From the `custom_config_data` folder start the client
```shell=
cd packages/client
npm run client:start -- \
--datadir ../../../ethereumjs-datadir \
--gethGenesis ../../../genesis.json \
--saveReceipts \
--rpc --rpcport=8545 \
--ws \
--jwt-secret=/tmp/jwtsecret \
--rpcEngine --rpcEnginePort=8551 \
--bootnodes="enode://b896e651b9d100ece367bf6a360b22b7e3032f542c1bffcc102f94e79a44d74b227bbcf67218e25d375ddd50beaf229135d3e42a260717c3d82eb897ce8b9069@167.71.60.16:30303"
```
This will create a secret in ethereumjs-datadir/jwtsecret, you will need to provide this secret to the CL client.
## Erigon
### Erigon hasn't officially released a withdrawal compatible version yet!
Pre-requisites: `git, go`
Clone and build from source
```shell=
git clone --branch=devel https://github.com/ledgerwatch/erigon
cd erigon
make erigon rpcdaemon
cd ..
```
From the `custom_config_data` folder start the client
```shell=
### Initialize database
./erigon/build/bin/erigon init \
--datadir=erigon-datadir genesis.json
### run Erigon
./erigon/build/bin/erigon \
--datadir erigon-datadir \
--externalcl \
--networkid=1337805 \
--authrpc.jwtsecret=/tmp/jwtsecret \
--http --http.api=engine,net,eth \
--bootnodes="enode://b896e651b9d100ece367bf6a360b22b7e3032f542c1bffcc102f94e79a44d74b227bbcf67218e25d375ddd50beaf229135d3e42a260717c3d82eb897ce8b9069@167.71.60.16:30303"
```
# Execution layer conculsions
After starting the client, you will be able to interact with the client using the following ports:
* localhost:8545: Web3 json rpc
* localhost:8550: Engine json rpc
* localhost:8551: Engine json rpc with json rpc authentication
* jwt.hex in the repository where you ran the rpcdaemon: verification key for JWT authentication
# Run a Consensus Layer Client
## Lighthouse
Pre-requisites: `git, rust`
Please ensure you have [RustC 1.59.x+](https://rustup.rs) installed.
Clone and build from source
```shell=
git clone -b capella https://github.com/sigp/lighthouse.git
cd lighthouse
make
cd ..
```
From the `custom_config_data` folder start the client
```shell=
lighthouse \
--testnet-dir="." \
bn \
--datadir lighthouse-dir \
--eth1 \
--http \
--http-allow-sync-stalled \
--execution-endpoints http://127.0.0.1:8551 \
--enr-udp-port=9000 \
--enr-tcp-port=9000 \
--discovery-port=9000 \
--jwt-secrets="/tmp/jwtsecret" \
--boot-nodes="enr:-Iq4QJk4WqRkjsX5c2CXtOra6HnxN-BMXnWhmhEQO9Bn9iABTJGdjUOurM7Btj1ouKaFkvTRoju5vz2GPmVON2dffQKGAX53x8JigmlkgnY0gmlwhLKAlv6Jc2VjcDI1NmsxoQK6S-Cii_KmfFdUJL2TANL3ksaKUnNXvTCv1tLwXs0QgIN1ZHCCIyk" \
--suggested-fee-recipient=<enter-eth-address-here>
```
## Lodestar
Pre-requisites: `git, nodejs, yarn`
More info about how to install dependencies can be found [here](https://chainsafe.github.io/lodestar/install/source/)
Clone and build the client
```shell=
git clone -b unstable https://github.com/chainsafe/lodestar.git
cd lodestar
yarn install --ignore-optional
yarn run build
```
From the `custom_config_data/lodestar` folder start the client
```shell=
./lodestar beacon \
--dataDir="../lodestar-beacondata" \
--paramsFile="../config.yaml" \
--genesisStateFile="../genesis.ssz" \
--execution.urls="http://127.0.0.1:8551" \
--jwt-secret="/tmp/jwtsecret" \
--bootnodes="enr:-Iq4QJk4WqRkjsX5c2CXtOra6HnxN-BMXnWhmhEQO9Bn9iABTJGdjUOurM7Btj1ouKaFkvTRoju5vz2GPmVON2dffQKGAX53x8JigmlkgnY0gmlwhLKAlv6Jc2VjcDI1NmsxoQK6S-Cii_KmfFdUJL2TANL3ksaKUnNXvTCv1tLwXs0QgIN1ZHCCIyk" \
--suggestedFeeRecipient=<enter-eth-address-here>
```
## Teku
Pre-requisites: `git, java`
Ensure Java 11 or above is installed (Ubuntu: sudo apt install default-jre).
```shell=
git clone -b asdf https://github.com/ConsenSys/teku.git
cd teku
./gradlew installDist
cd ..
```
The teku executable is now available in ./teku/build/install/teku/bin/teku. You can also use the pre-built distribution or the consensys/teku:develop docker image.
From the `custom_config_data` folder start the client
```shell=
./teku/build/install/teku/bin/teku \
--data-path="teku-datadir" \
--network="config.yaml" \
--initial-state="genesis.ssz" \
--ee-endpoint="http://localhost:8551" \
--Xee-version=kilnv2 \
--ee-jwt-secret-file="/tmp/jwtsecret" \
--p2p-discovery-bootnodes="enr:-Iq4QJk4WqRkjsX5c2CXtOra6HnxN-BMXnWhmhEQO9Bn9iABTJGdjUOurM7Btj1ouKaFkvTRoju5vz2GPmVON2dffQKGAX53x8JigmlkgnY0gmlwhLKAlv6Jc2VjcDI1NmsxoQK6S-Cii_KmfFdUJL2TANL3ksaKUnNXvTCv1tLwXs0QgIN1ZHCCIyk" \
--validators-proposer-default-fee-recipient=<Enter-eth-address-here>
```
## Prysm
Pre-requisites: `git, bazel`
Ensure bazel 5.3.+ is [installed](https://docs.prylabs.network/docs/install/install-with-bazel#install-bazel-using-bazelisk).
```shell=
mkdir -p prysm-dir
export genesis=$PWD/genesis.ssz
export prysmdir=$PWD/prysm-dir
export config=$PWD/config.yaml
git clone -b capella https://github.com/prysmaticlabs/prysm.git
cd prysm
bazel build //cmd/beacon-chain:beacon-chain
```
From the `custom_config_data/prysm` folder start the client
```shell=
bazel run //cmd/beacon-chain -- \
--accept-terms-of-use=true \
--genesis-state=$genesis \
--datadir=$prysmdir \
--chain-config-file=$config \
--execution-endpoint=http://localhost:8551 \
--jwt-secret=/tmp/jwtsecret \
--bootstrap-node=enr:-Iq4QJk4WqRkjsX5c2CXtOra6HnxN-BMXnWhmhEQO9Bn9iABTJGdjUOurM7Btj1ouKaFkvTRoju5vz2GPmVON2dffQKGAX53x8JigmlkgnY0gmlwhLKAlv6Jc2VjcDI1NmsxoQK6S-Cii_KmfFdUJL2TANL3ksaKUnNXvTCv1tLwXs0QgIN1ZHCCIyk \
--suggested-fee-recipient=<Enter-eth-address-here>
```
## Nimbus
Pre-requisites: `git, make, gcc`
Ensure that the websocket related flags (--ws) are present on your EL (e.g: Geth). Nethermind enables websockets by default. Nimbus can use either http or ws.
Clone and build from source (use branch unstable)
```shell=
git clone --branch=unstable https://github.com/status-im/nimbus-eth2.git
cd nimbus-eth2
make update
make -j4 nimbus_beacon_node
cd ..
```
Start the client
```shell=
nimbus-eth2/build/nimbus_beacon_node \
--data-dir=./nimbus-datadir\
--jwt-secret=/tmp/jwtsecret \
--web3-url=http://127.0.0.1:8551 \
--rest \
--network=./ \
--bootstrap-node=enr:-Iq4QJk4WqRkjsX5c2CXtOra6HnxN-BMXnWhmhEQO9Bn9iABTJGdjUOurM7Btj1ouKaFkvTRoju5vz2GPmVON2dffQKGAX53x8JigmlkgnY0gmlwhLKAlv6Jc2VjcDI1NmsxoQK6S-Cii_KmfFdUJL2TANL3ksaKUnNXvTCv1tLwXs0QgIN1ZHCCIyk \
--suggested-fee-recipient=<Enter-eth-address-here>
```
{%hackmd theme-dark %}
<style>
.markdown-body pre {background-color: #1E1E1E;border: 1px solid #555 !important;color: #73BCE0;border-radius:8px;/*border-radius:0px;*/ } .markdown-body pre .htmlembedded {color: #C8D4C8 !important; } .markdown-body pre .hljs-tag {color: #6D726E; } .markdown-body pre .token.keyword {color: #C586C0; } .markdown-body pre .token.string, .markdown-body pre .hljs-string {color: #C68362; } .markdown-body pre .hljs-comment, .markdown-body pre .token.comment {color: #6A9955; } .markdown-body pre .hljs-attr {color: #73BCE0; } .markdown-body pre .hljs-name {color:#569CD6; } .markdown-body pre .token.operator {color:#C8D4C8;background:transparent; } .markdown-body pre .token.property {color: #73BCE0; } .markdown-body pre .token.function {color: #DCDCAA; } .markdown-body pre .token.builtin {color: #34B294; } .markdown-body pre .token.number {color: #B5CEA8; } .markdown-body pre .token.constant {color: #3BC1FF; } .markdown-body pre .hljs-addition {color: #96D47D;background: #373D29; } .markdown-body pre .hljs-deletion {color: #E76A6A;background: #4B1818; } .markdown-body pre .hljs-selector-class {color: #D7BA5F; } .markdown-body pre .hljs-attribute {color: #9CDCFE; } .markdown-body pre .hljs-number {color: #C68362; } .markdown-body pre .hljs-meta {color: #2C7CD6; }
</style>