├── .gitignore ├── Dockerfile ├── README.md ├── example_transaction.py ├── from_docker.md ├── from_source.md ├── generate_eth1_conf.py ├── generate_eth1_nethermind_conf.py ├── generate_eth2_conf.py ├── generate_eth2_validator_data.sh ├── genesis_validators.yaml ├── mergenet.yaml ├── requirements.txt ├── rpc_examples ├── README.md ├── consensus_assembleBlock.sh ├── consensus_newBlock.sh ├── consensus_setHead.sh └── get_genesis_hash.sh └── run_multiclient_docker.sh /.gitignore: -------------------------------------------------------------------------------- 1 | venv 2 | # output 3 | clients 4 | nodes 5 | # in each testnet dir, the 'private' dir holds the validator keys etc. 6 | private 7 | mynetwork 8 | 9 | testnets 10 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:20.10 2 | RUN apt-get update 3 | RUN apt-get install -y tzdata 4 | 5 | RUN apt-get install -y python3-dev python3-venv python3-pip 6 | RUN python3 -m venv /venv 7 | COPY requirements.txt /requirements.txt 8 | RUN /venv/bin/pip install -r /requirements.txt 9 | ENV PATH=$PATH:/venv/bin VIRTUAL_ENV=/venv 10 | 11 | RUN apt-get install -y curl 12 | RUN curl https://dl.google.com/go/go1.16.3.linux-amd64.tar.gz | tar -xz -C /usr/local 13 | ENV PATH=$PATH:/usr/local/gopath/bin:/usr/local/go/bin GOPATH=/usr/local/gopath 14 | 15 | RUN go install github.com/protolambda/eth2-testnet-genesis@latest 16 | RUN go install github.com/protolambda/eth2-val-tools@latest 17 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # DEPRECATED 2 | 3 | Warning: this repository is outdated. Please refer to the official documentation of each of the ethereum clients to join a testnet. 4 | 5 | # Mergenet tutorial 6 | 7 | Let's set up a local eth1-eth2 merge testnet! 8 | 9 | ## Preparing the setup environment 10 | 11 | In this tutorial, we use a series of scripts to generate configuration 12 | files, and these scripts have dependencies that we need to 13 | install. You can either install these dependencies on your host or you 14 | can run those scripts inside a docker container. We call this 15 | environment setupenv. 16 | 17 | Preparing the setup environment on your host: 18 | ```shell 19 | apt-get install python3-dev python3-pip python3-venv golang 20 | 21 | # Check that you have Go 1.16+ installed 22 | go version 23 | 24 | # Create, start and install python venv 25 | python -m venv venv 26 | . venv/bin/activate 27 | pip install -r requirements.txt 28 | 29 | # Install eth2-testnet-genesis tool (Go 1.16+ required) 30 | go install github.com/protolambda/eth2-testnet-genesis@latest 31 | # Install eth2-val-tools 32 | go install github.com/protolambda/eth2-val-tools@latest 33 | # You are now in the right directory to run the setupenv commands below. 34 | ``` 35 | 36 | Alternatively, you can use docker: 37 | ```shell 38 | docker build -t setupenv . 39 | docker run -i -v $PWD:/mergenet-tutorial \ 40 | -v /etc/passwd:/etc/passwd -h setupenv \ 41 | -u $(id -u):$(id -g) -t setupenv \ 42 | /bin/bash 43 | # docker spawns a shell and inside that run: 44 | cd /mergenet-tutorial 45 | # You are now in the right directory to run the setupenv commands below. 46 | ``` 47 | 48 | ## Create chain configurations 49 | 50 | Set `eth1_genesis_timestamp` inside `mergenet.yaml`to the current 51 | timestamp or a timestamp in the future. To use the current timestamp 52 | run: 53 | ```shell 54 | sed -i -e s/GENESIS_TIMESTAMP/$(date +%s)/ mergenet.yaml 55 | ``` 56 | 57 | Otherwise tweak mergenet.yaml as you like. The current default is to 58 | have the Eth2 genesis 10 minutes after the Eth1 genesis. 59 | 60 | ```shell 61 | # Inside your setupenv: Generate ETH1/ETH2 configs 62 | export TESTNET_NAME="mynetwork" 63 | mkdir -p "$TESTNET_NAME/public" "$TESTNET_NAME/private" 64 | # Configure Eth1 chain 65 | python generate_eth1_conf.py > "$TESTNET_NAME/public/eth1_config.json" 66 | # Configure Eth2 chain 67 | python generate_eth2_conf.py > "$TESTNET_NAME/public/eth2_config.yaml" 68 | ``` 69 | 70 | Configure tranche(s) of validators, edit `genesis_validators.yaml`. 71 | Note: defaults test-purpose mnemonic and configuration is included already, no need to edit for minimal local setup. 72 | Make sure that total of `count` entries is more than the configured `MIN_GENESIS_ACTIVE_VALIDATOR_COUNT` (eth2 config). 73 | 74 | ## Prepare Eth2 data 75 | 76 | Get the tools 77 | [eth2-testnet-genesis](https://github.com/protolambda/eth2-testnet-genesis) and 78 | [eth2-val-tools](https://github.com/protolambda/eth2-val-tools), and then run: 79 | 80 | ```shell 81 | export VALIDATOR_NODE_NAME="valclient0" 82 | bash ./generate_eth2_validator_data.sh 83 | ``` 84 | 85 | ## Start nodes 86 | 87 | This documents how to build the binaries from source, so you can make changes and check out experimental git branches. 88 | It's possible to build docker images (or use pre-built ones) as well. Ask the client devs for alternative install instructions. 89 | 90 | ```shell 91 | mkdir clients 92 | 93 | mkdir "$TESTNET_NAME/nodes" 94 | ``` 95 | 96 | You can choose to run clients in two ways: 97 | - [Build and run from source](./from_source.md) 98 | - [Run in docker](./from_docker.md) 99 | 100 | The docker instructions include how to configure each of the clients. 101 | Substitute docker volume-mounts with your own directory layout choices, the instructions are otherwise the same. 102 | 103 | ## Genesis 104 | 105 | Now wait for the genesis of the chain! 106 | `actual_genesis_timestamp = eth1_genesis_timestamp + eth2_genesis_delay` 107 | 108 | ## Bonus 109 | 110 | ### Test ETH transaction 111 | 112 | Import a pre-mined account into some web3 wallet (e.g. metamask), connect to local RPC, and send a transaction with a GUI. 113 | 114 | Run `example_transaction.py`. 115 | 116 | ### Test deposit 117 | 118 | TODO 119 | 120 | ### Test contract deployment 121 | 122 | TODO 123 | 124 | -------------------------------------------------------------------------------- /example_transaction.py: -------------------------------------------------------------------------------- 1 | from web3 import Web3 2 | import json 3 | import ruamel.yaml as yaml 4 | 5 | provider = Web3.HTTPProvider('http://localhost:8545') 6 | w3 = Web3(provider) 7 | 8 | w3.eth.account.enable_unaudited_hdwallet_features() 9 | 10 | with open("mergenet.yaml") as stream: 11 | data = yaml.safe_load(stream) 12 | 13 | src_acct = w3.eth.account.from_mnemonic( 14 | data['mnemonic'], account_path=list(data['eth1_premine'].keys())[0], passphrase='') 15 | 16 | dest_acct = w3.eth.account.from_mnemonic( 17 | data['mnemonic'], account_path=list(data['eth1_premine'].keys())[1], passphrase='') 18 | 19 | transaction = { 20 | 'to': dest_acct.address, 21 | 'value': w3.toWei(1, 'ether'), 22 | 'gas': 21000, 23 | 'gasPrice': 4, 24 | 'nonce': 0, 25 | 'chainId': int(data['chain_id']) 26 | } 27 | 28 | print("signing transaction:") 29 | print(json.dumps(transaction, indent=" ")) 30 | 31 | signed_transaction = src_acct.sign_transaction(transaction) 32 | 33 | tx_hash = w3.eth.send_raw_transaction(signed_transaction.rawTransaction) 34 | print("tx hash: ", tx_hash) 35 | -------------------------------------------------------------------------------- /from_docker.md: -------------------------------------------------------------------------------- 1 | # Running nodes with Docker 2 | 3 | This doc guides you through running each client 4 | with custom testnet configuration for testing the Rayonism merge prototypes. 5 | 6 | All of the instructions are very verbose about port configuration, 7 | so you can change the ports easily, and avoid port overlaps. 8 | 9 | Each of the instructions assumes you want to mount 10 | testnet configuration, a datadir for the node, maybe a genesis-state for beacon nodes, and maybe keys/secrets for validators. 11 | 12 | It's recommended you create the data dirs on the host, so docker doesn't have to during the run, and permissions match the user-permissions in the container. 13 | Nethermind is an odd one here, running as non-root user is problematic. 14 | 15 | ## Tooling 16 | 17 | [Docs](https://github.com/protolambda/eth2-bootnode) 18 | 19 | ``` 20 | protolambda/eth2-bootnode:latest 21 | ``` 22 | 23 | ## Execution clients 24 | 25 | ### Besu 26 | 27 | [Docs](https://besu.hyperledger.org/en/stable/HowTo/Get-Started/Installation-Options/Run-Docker-Image/) 28 | 29 | Note: merge/rayonism is not supported on the main branch/images yet. Use below image, from one of the Besu devs: 30 | ``` 31 | suburbandad/besu:rayonism 32 | ``` 33 | 34 | #### Running 35 | 36 | ```shell 37 | mkdir -p ${PWD}/$TESTNET_NAME/nodes/besu0 38 | docker run \ 39 | --name besu0 \ 40 | -u $(id -u):$(id -g) --net host \ 41 | -v ${PWD}/$TESTNET_NAME/public/eth1_config.json:/networkdata/eth1_config.json \ 42 | -v ${PWD}/$TESTNET_NAME/nodes/besu0:/besudata \ 43 | suburbandad/besu:rayonism \ 44 | --data-path="/besudata" \ 45 | --genesis-file="/networkdata/eth1_config.json" \ 46 | --rpc-http-enabled --rpc-http-api=ETH,NET,CONSENSUS \ 47 | --rpc-http-host=0.0.0.0 \ 48 | --rpc-http-port=8545 \ 49 | --rpc-http-cors-origins="*" \ 50 | --rpc-ws-enabled --rpc-ws-api=ETH,NET,CONSENSUS \ 51 | --rpc-ws-host=0.0.0.0 \ 52 | --rpc-ws-port=8546 \ 53 | --Xmerge-support=true \ 54 | --discovery-enabled=false \ 55 | --miner-coinbase="0x1000000000000000000000000000000000000000" 56 | ``` 57 | 58 | ### Geth 59 | 60 | [Docs](https://geth.ethereum.org/docs/install-and-build/installing-geth#run-inside-docker-container) 61 | ``` 62 | ethereum/client-go:latest 63 | ``` 64 | 65 | #### Initialization 66 | 67 | Important: for custom testnets, you will need to init the data-dir before running the client, like below: 68 | 69 | ```shell 70 | mkdir -p ${PWD}/$TESTNET_NAME/nodes/geth0 71 | docker run \ 72 | --name tmpgeth \ 73 | --rm \ 74 | -u $(id -u):$(id -g) --net host \ 75 | -v ${PWD}/$TESTNET_NAME/public/eth1_config.json:/networkdata/eth1_config.json \ 76 | -v ${PWD}/$TESTNET_NAME/nodes/geth0:/gethdata \ 77 | ethereum/client-go:latest \ 78 | --catalyst \ 79 | --datadir "/gethdata/chaindata" \ 80 | init "/networkdata/eth1_config.json" 81 | ``` 82 | 83 | #### Running: 84 | 85 | ```shell 86 | docker run \ 87 | --name geth0 \ 88 | -u $(id -u):$(id -g) --net host \ 89 | -v ${PWD}/$TESTNET_NAME/public/eth1_config.json:/networkdata/eth1_config.json \ 90 | -v ${PWD}/$TESTNET_NAME/nodes/geth0:/gethdata \ 91 | ethereum/client-go:latest \ 92 | --catalyst \ 93 | --http --http.api net,eth,consensus \ 94 | --http.port 8545 \ 95 | --http.addr 0.0.0.0 \ 96 | --http.corsdomain "*" \ 97 | --ws --ws.api net,eth,consensus \ 98 | --ws.port 8546 \ 99 | --ws.addr 0.0.0.0 \ 100 | --nodiscover \ 101 | --miner.etherbase 0x1000000000000000000000000000000000000000 \ 102 | --datadir "/gethdata/chaindata" 103 | ``` 104 | 105 | ### Nethermind 106 | 107 | [Docs](https://docs.nethermind.io/nethermind/ethereum-client/docker) 108 | ``` 109 | nethermind/nethermind:latest 110 | ``` 111 | #### Generate config 112 | 113 | ```shell 114 | # Inside your setupenv, run 115 | python generate_eth1_nethermind_conf.py > "$TESTNET_NAME/public/eth1_nethermind_config.json" 116 | ``` 117 | 118 | #### Running: 119 | 120 | Note: the nethermind docker cannot handle user changes (error on p2p key write, permissions problem), the container runs nethermind root internally. 121 | ```shell 122 | docker run \ 123 | --net host \ 124 | --name nethermind0 \ 125 | -v ${PWD}/$TESTNET_NAME/public/eth1_nethermind_config.json:/networkdata/eth1_nethermind_config.json \ 126 | -v ${PWD}/$TESTNET_NAME/nodes/nethermind0:/netherminddata \ 127 | -itd nethermind/nethermind \ 128 | -c catalyst \ 129 | --datadir "/netherminddata" \ 130 | --Init.ChainSpecPath "/networkdata/eth1_nethermind_config.json" \ 131 | --JsonRpc.Enabled true \ 132 | --JsonRpc.EnabledModules "net,eth,consensus" \ 133 | --Init.WebSocketsEnabled true \ 134 | --JsonRpc.Port 8545 \ 135 | --JsonRpc.WebSocketsPort 8546 \ 136 | --JsonRpc.Host 0.0.0.0 \ 137 | --Merge.BlockAuthorAccount 0x1000000000000000000000000000000000000000 138 | ``` 139 | 140 | ## Consensus clients 141 | 142 | ### Teku 143 | 144 | Note starts a beacon node by default, use the `validator` subcommand to run the separate validator-client. 145 | 146 | [Docs](https://docs.teku.consensys.net/en/latest/HowTo/Get-Started/Installation-Options/Run-Docker-Image/) 147 | 148 | Note: the main repo does not support merge/rayonism yet. 149 | Use the below image by Mikhail, working on the TXRX (a Consensys R&D team) fork: 150 | ``` 151 | mkalinin/teku:rayonism 152 | ``` 153 | 154 | #### Running the beacon node: 155 | 156 | ```shell 157 | mkdir -p ${PWD}/$TESTNET_NAME/nodes/teku0bn 158 | docker run \ 159 | --name teku0bn \ 160 | -u $(id -u):$(id -g) --net host \ 161 | -v ${PWD}/$TESTNET_NAME/nodes/teku0bn:/beacondata \ 162 | -v ${PWD}/$TESTNET_NAME/public/eth2_config.yaml:/networkdata/eth2_config.yaml \ 163 | -v ${PWD}/$TESTNET_NAME/public/genesis.ssz:/networkdata/genesis.ssz \ 164 | mkalinin/teku:rayonism \ 165 | --network "/networkdata/eth2_config.yaml" \ 166 | --data-path "/beacondata" \ 167 | --p2p-enabled=true \ 168 | --logging=debug \ 169 | --initial-state "/networkdata/genesis.ssz" \ 170 | --eth1-endpoint "http://localhost:8545" \ 171 | --p2p-discovery-bootnodes "COMMA_SEPARATED_ENRS_HERE" \ 172 | --metrics-enabled=true --metrics-interface=0.0.0.0 --metrics-port="8000" \ 173 | --p2p-discovery-enabled=true \ 174 | --p2p-peer-lower-bound=1 \ 175 | --p2p-port="9000" \ 176 | --rest-api-enabled=true \ 177 | --rest-api-docs-enabled=true \ 178 | --rest-api-interface=0.0.0.0 \ 179 | --rest-api-port="4000" \ 180 | --metrics-host-allowlist="*" \ 181 | --rest-api-host-allowlist="*" \ 182 | --Xdata-storage-non-canonical-blocks-enabled=true 183 | # optional: 184 | # --p2p-advertised-ip=1.2.3.4 185 | ``` 186 | 187 | #### Running the validator: 188 | 189 | ```shell 190 | # prepare keys 191 | NODE_PATH="$TESTNET_PATH/nodes/teku0vc" 192 | mkdir -p "$NODE_PATH" 193 | cp -r "$TESTNET_PATH/private/validator0/teku-keys" "$NODE_PATH/keys" 194 | cp -r "$TESTNET_PATH/private/validator0/teku-secrets" "$NODE_PATH/secrets" 195 | 196 | docker run \ 197 | --name teku0vc \ 198 | -u $(id -u):$(id -g) --net host \ 199 | -v ${PWD}/$TESTNET_NAME/nodes/teku0vc:/validatordata \ 200 | -v ${PWD}/$TESTNET_NAME/public/eth2_config.yaml:/networkdata/eth2_config.yaml \ 201 | mkalinin/teku:rayonism vc \ 202 | --network "/networkdata/eth2_config.yaml" \ 203 | --data-path "/validatordata" \ 204 | --beacon-node-api-endpoint "http://localhost:4000" \ 205 | --validators-graffiti="hello" \ 206 | --validator-keys "/validatordata/keys:/validatordata/secrets" 207 | ``` 208 | 209 | ### Lighthouse 210 | 211 | Note: The image entry point is plain shell. And the Beacon node (`bn`) and Validator client (`vc`) are available through the same binary. Use looks like `docker run sigp/lighthouse:rayonism lighthouse bn --options-here` 212 | 213 | [Docs](https://lighthouse-book.sigmaprime.io/docker.html) 214 | 215 | Note: merge prototype work is not part of the client yet, use the `rayonism` docker tag instead. 216 | ``` 217 | sigp/lighthouse:rayonism 218 | 219 | # If you need minimal-config and portable features enabled: 220 | protolambda/lighthouse:rayonism 221 | ``` 222 | 223 | #### Running the beacon node: 224 | 225 | ```shell 226 | mkdir -p ${PWD}/$TESTNET_NAME/nodes/lighthouse0bn 227 | docker run \ 228 | --name lighthouse0bn \ 229 | -u $(id -u):$(id -g) --net host \ 230 | -v ${PWD}/$TESTNET_NAME/nodes/lighthouse0bn:/beacondata \ 231 | -v ${PWD}/$TESTNET_NAME/public/eth2_config.yaml:/networkdata/eth2_config.yaml \ 232 | -v ${PWD}/$TESTNET_NAME/public/genesis.ssz:/networkdata/genesis.ssz \ 233 | sigp/lighthouse:rayonism \ 234 | lighthouse \ 235 | --datadir "/beacondata" \ 236 | --testnet-deposit-contract-deploy-block 0 \ 237 | --testnet-genesis-state "/networkdata/genesis.ssz" \ 238 | --testnet-yaml-config "/networkdata/eth2_config.yaml" \ 239 | --debug-level=debug \ 240 | beacon_node \ 241 | --enr-tcp-port=9000 --enr-udp-port=9000 \ 242 | --port=9000 --discovery-port=9000 \ 243 | --eth1 --eth1-endpoints "http://localhost:8545" \ 244 | --boot-nodes "COMMA_SEPARATED_ENRS_HERE" \ 245 | --http \ 246 | --http-address 0.0.0.0 \ 247 | --http-port "4000" \ 248 | --metrics \ 249 | --metrics-address 0.0.0.0 \ 250 | --metrics-port "8000" \ 251 | --listen-address 0.0.0.0 252 | # optional: 253 | # --enr-address=1.2.3.4 254 | ``` 255 | 256 | #### Running the validator: 257 | 258 | ```shell 259 | # prepare keys 260 | NODE_PATH="$TESTNET_PATH/nodes/lighthouse0vc" 261 | mkdir -p "$NODE_PATH" 262 | cp -r "$TESTNET_PATH/private/validator0/keys" "$NODE_PATH/keys" 263 | cp -r "$TESTNET_PATH/private/validator0/secrets" "$NODE_PATH/secrets" 264 | 265 | docker run \ 266 | --name lighthouse0vc \ 267 | -u $(id -u):$(id -g) --net host \ 268 | -v ${PWD}/$TESTNET_NAME/nodes/lighthouse0vc:/validatordata \ 269 | -v ${PWD}/$TESTNET_NAME/public/eth2_config.yaml:/networkdata/eth2_config.yaml \ 270 | sigp/lighthouse:rayonism \ 271 | lighthouse \ 272 | --testnet-deposit-contract-deploy-block 0 \ 273 | --testnet-genesis-state "/networkdata/genesis.ssz" \ 274 | --testnet-yaml-config "/networkdata/eth2_config.yaml" \ 275 | validator_client \ 276 | --init-slashing-protection \ 277 | --beacon-nodes "http://localhost:4000" \ 278 | --graffiti="hello" \ 279 | --validators-dir "/validatordata/keys" \ 280 | --secrets-dir "/validatordata/secrets" 281 | ``` 282 | 283 | 284 | ### Prysm 285 | 286 | Note: `mainnet` and `minimal` refer to base configurations. Custom testnet configs can extend one of these two. 287 | 288 | [Docs](https://docs.prylabs.network/docs/install/install-with-docker) 289 | 290 | ``` 291 | gcr.io/prysmaticlabs/prysm/beacon-chain:merge-mainnet 292 | gcr.io/prysmaticlabs/prysm/validator:merge-mainnet 293 | 294 | gcr.io/prysmaticlabs/prysm/beacon-chain:merge-minimal 295 | gcr.io/prysmaticlabs/prysm/validator:merge-minimal 296 | ``` 297 | 298 | #### Running the beacon node: 299 | 300 | ```shell 301 | mkdir -p ${PWD}/$TESTNET_NAME/nodes/prysm0bn 302 | docker run \ 303 | --name prysm0bn \ 304 | -u $(id -u):$(id -g) --net host \ 305 | -v ${PWD}/$TESTNET_NAME/nodes/prysm0bn:/beacondata \ 306 | -v ${PWD}/$TESTNET_NAME/public/eth2_config.yaml:/networkdata/eth2_config.yaml \ 307 | -v ${PWD}/$TESTNET_NAME/public/genesis.ssz:/networkdata/genesis.ssz \ 308 | gcr.io/prysmaticlabs/prysm/beacon-chain:merge-minimal \ 309 | --accept-terms-of-use=true \ 310 | --datadir="/beacondata" \ 311 | --min-sync-peers=0 \ 312 | --contract-deployment-block 0 \ 313 | --http-web3provider="http://localhost:8545" \ 314 | --bootstrap-node="REPEAT_THIS_FLAG_TO_ADD_EVERY_ENR" \ 315 | --chain-config-file="/networkdata/eth2_config.yaml" \ 316 | --genesis-state="/networkdata/genesis.ssz" \ 317 | --verbosity=debug \ 318 | --p2p-max-peers=30 \ 319 | --p2p-udp-port=9000 --p2p-tcp-port=9000 \ 320 | --monitoring-host=0.0.0.0 --monitoring-port=8000 \ 321 | --rpc-host=0.0.0.0 --rpc-port=4001 \ 322 | --grpc-gateway-host=0.0.0.0 \ 323 | --grpc-gateway-port=4000 \ 324 | --verbosity="debug" \ 325 | --enable-debug-rpc-endpoints \ 326 | --min-sync-peers 1 327 | # Optional: 328 | # --p2p-host-ip=1.2.3.4 329 | ``` 330 | 331 | #### Running the validator: 332 | 333 | ```shell 334 | # prepare keys 335 | NODE_PATH="$TESTNET_PATH/nodes/prysm0vc" 336 | mkdir -p "$NODE_PATH/wallet/direct/accounts" 337 | cp "$TESTNET_PATH/private/validator0/prysm/all-accounts.keystore.json" "$NODE_PATH/wallet/direct/accounts/all-accounts.keystore.json" 338 | cp "$TESTNET_PATH/private/validator0/prysm/keymanageropts.json" "$NODE_PATH/wallet/direct/keymanageropts.json" 339 | echo -n "bulkpasshere" > "$NODE_PATH/wallet_pass.txt" 340 | 341 | docker run \ 342 | --name prysm0vc \ 343 | -u $(id -u):$(id -g) --net host \ 344 | -v ${PWD}/$TESTNET_NAME/nodes/prysm0vc:/validatordata \ 345 | -v ${PWD}/$TESTNET_NAME/public/eth2_config.yaml:/networkdata/eth2_config.yaml \ 346 | gcr.io/prysmaticlabs/prysm/validator:merge-minimal \ 347 | --accept-terms-of-use=true \ 348 | --datadir="/validatordata" \ 349 | --chain-config-file="/networkdata/eth2_config.yaml" \ 350 | --beacon-rpc-provider="127.0.0.1:4001" \ 351 | --graffiti="hello" \ 352 | --wallet-dir=/validatordata/wallet \ 353 | --wallet-password-file="/validatordata/pass.txt" 354 | ``` 355 | 356 | ### Nimbus 357 | 358 | Note: different docker images for different configs. Loading custom testnet configurations is still a W.I.P. 359 | 360 | [Docs](https://nimbus.guide/docker.html) 361 | 362 | Note: merge/rayonism is not supported on the main branch/images yet. Use below image, from the Nimbus team: 363 | 364 | ``` 365 | statusteam/nimbus_beacon_node:amd64-amphora 366 | ``` 367 | 368 | #### Running the beacon node: 369 | 370 | ```shell 371 | mkdir -p ${PWD}/$TESTNET_NAME/nodes/nimbus0bn 372 | docker run \ 373 | --name nimbus0bn \ 374 | -u $(id -u):$(id -g) --net host \ 375 | -v ${PWD}/$TESTNET_NAME/nodes/nimbus0bn:/beacondata \ 376 | -v ${PWD}/$TESTNET_NAME/public/eth2_config.yaml:/networkdata/eth2_config.yaml \ 377 | -v ${PWD}/$TESTNET_NAME/public/genesis.ssz:/networkdata/genesis.ssz \ 378 | statusteam/nimbus_beacon_node:amd64-amphora \ 379 | --network=TODO \ 380 | --max-peers="60" \ 381 | --data-dir="/beacondata" \ 382 | --validators-dir="/validatordata/keys" \ 383 | --secrets-dir="/validatordata/secrets" 384 | --web3-url="ws://localhost:8546" \ 385 | --bootstrap-node="REPEAT_THIS_FLAG_TO_ADD_EVERY_ENR" \ 386 | --udp-port=9000 \ 387 | --tcp-port=9000 \ 388 | --listen-address=0.0.0.0 \ 389 | --graffiti="hello" \ 390 | --enr-auto-update=false \ 391 | --log-level="debug" \ 392 | --log-file="/dev/null" \ 393 | --rpc --rpc-port=4001 --rpc-address=0.0.0.0 \ 394 | --rest --rest-port=4000 --rpc-address=0.0.0.0 \ 395 | --metrics --metrics-port=8000 --metrics-address=0.0.0.0 \ 396 | --log-file="/dev/null" 397 | # optional: 398 | # --nat="extip:1.2.3.4" 399 | ``` 400 | 401 | Note: local network configuration is undocumented and does not work out of the box. 402 | May require custom docker image. 403 | 404 | Note: websocket eth1 connections only. 405 | - `ws://127.0.0.1:8546` for geth 406 | - `ws://127.0.0.1:8546/ws` for besu 407 | - `ws://127.0.0.1:8546` (for nethermind) 408 | 409 | #### Running the validator: 410 | 411 | Since validators are attached directly to the beacon node, running a validator client 412 | is not necessary. 413 | -------------------------------------------------------------------------------- /from_source.md: -------------------------------------------------------------------------------- 1 | # Building clients from source 2 | 3 | When making changes to clients for interop purposes, you may not want to use docker. 4 | This doc describes how to build every client from source. 5 | 6 | This guide assumes a Linux or MacOS install. 7 | For Windows, please refer to the build instructions by the client (if compatible with windows at all). 8 | 9 | For instructions how to use the CLI arguments of the nodes, see the [Docker tutorial](./from_docker.md). 10 | 11 | ## Geth 12 | 13 | ### Prerequisites 14 | 15 | 1. Install `go` 16 | 2. Add Go to your Path: 17 | ```shell 18 | export GOPATH=$HOME/go 19 | export GOROOT=/usr/lib/go 20 | export PATH="$PATH:$GOPATH/bin" 21 | ``` 22 | 23 | ### Build 24 | 25 | ```shell 26 | git clone git@github.com:ethereum/go-ethereum.git 27 | cd go-ethereum 28 | 29 | # To build a binary: 30 | go build -o ./build/bin/catalyst ./cmd/geth 31 | # Or, to build a binary and add it to your go bin path: 32 | go install ./cmd/geth 33 | ``` 34 | 35 | ### Initialize 36 | 37 | To run a custom testnet, Geth needs to initialize its storage and configuration. 38 | Run the `geth --catalyst init` command to initialize. 39 | See [docker instructions](./from_docker.md#initialization) for details. 40 | 41 | ### Run 42 | 43 | ```shell 44 | ./build/bin/catalyst --options-here 45 | # Or, when installed globally as regular geth executable: 46 | geth --options-here 47 | ``` 48 | 49 | ---- 50 | 51 | ## Nethermind 52 | 53 | ### Prerequisites 54 | 55 | 1. Install `dotnet-sdk` and `dotnet-runtime` 56 | 2. Add Dotnet to your Path: 57 | ```shell 58 | export PATH="$PATH:$HOME/.dotnet/tools" 59 | ``` 60 | 3. Check if you have the aspnet runtime: `dotnet --list-runtimes` 61 | 4. Install `aspnet-runtime` if you have not 62 | 5. `libsnappy-dev libc6-dev libc6` (snappy and glibc) 63 | 64 | ### Build 65 | 66 | ```shell 67 | git clone git@github.com:NethermindEth/nethermind.git 68 | cd nethermind 69 | # Make sure you have git-submoduled dependencies 70 | git submodule init 71 | git submodule update 72 | 73 | cd src/Nethermind 74 | dotnet build Nethermind.sln -c Release 75 | ``` 76 | 77 | ### Run 78 | 79 | ```shell 80 | cd src/Nethermind/Nethermind.Runner 81 | dotnet run -c Release --no-build -- --options-here 82 | ``` 83 | 84 | ---- 85 | 86 | ## Teku (TXRX fork) 87 | 88 | ### Prerequisites 89 | 90 | 1. Install open-jdk 15+ (or oracle jdk) 91 | 92 | ### Build 93 | 94 | ```shell 95 | git clone https://github.com/txrx-research/teku.git 96 | cd teku 97 | 98 | ./gradlew installDist 99 | ``` 100 | 101 | ### Run 102 | 103 | ```shell 104 | ./build/install/teku/bin/teku --options-here 105 | ``` 106 | 107 | ---- 108 | 109 | ## Prysm 110 | 111 | ### Prerequisites 112 | 113 | 1. General toolchain requirements: 114 | - UNIX operating system 115 | - The `cmake` package installed 116 | - The git package installed 117 | - `libssl-dev` installed 118 | - `libgmp-dev` installed 119 | - `libtinfo5` installed 120 | 2. Install go 1.16+ 121 | 3. Install Bazel 3.7 (warning, older than latest bazel 4). 122 | - [Install instructions for Bazel](https://docs.bazel.build/versions/3.7.0/install.html) 123 | - For bazel multi-version usage with bazelisk, see https://github.com/bazelbuild/bazelisk/blob/master/README.md 124 | 4. If building an older prysm branch, [work around LLVM build issue](https://github.com/prysmaticlabs/prysm/issues/8072), [Fixed here](https://github.com/prysmaticlabs/prysm/pull/8839) 125 | 5. If you want to build docker images, you may need to patch bazel workspace with https://github.com/bazelbuild/rules_docker/releases/tag/v0.17.0 126 | See https://github.com/bazelbuild/rules_docker/issues/1814 for context. 127 | Update: Prysm uses a different work around with bazel patch files. 128 | 6. Note: the docker image produced by Bazel uses GLIBC 2.24 (debian9 base, via `go_image` -> "distroless" -> debian). 129 | Most GLIBC symbols used by Prysm are 2.14 and older. The exception is `pthread_sigmask` which changed in GLIBC 2.32: 130 | if your system GLIBC is too "new" (last 9 months...), you can't compile a working docker image with Bazel. 131 | At the same time, the GLIBC usage breaks the Alpine docker image build too. 132 | 133 | ### Build 134 | 135 | ```shell 136 | git clone -b merge git@github.com:prysmaticlabs/prysm.git 137 | cd prysm 138 | ``` 139 | 140 | ```shell 141 | bazel build //beacon-chain:beacon-chain 142 | bazel build //validator:validator 143 | ``` 144 | 145 | To generate docker images: 146 | 147 | ```shell 148 | # Note: suffix '--define=ssz=minimal' to the bazel commands to build for minimal variant of eth2 spec 149 | bazel run //beacon-chain:image_bundle 150 | bazel run //validator:image_bundle 151 | 152 | # retag the images to rayonism specific names 153 | docker tag gcr.io/prysmaticlabs/prysm/beacon-chain:latest protolambda/prysm-beacon:rayonism 154 | docker tag gcr.io/prysmaticlabs/prysm/validator:latest protolambda/prysm-validator:rayonism 155 | ``` 156 | 157 | ### Run 158 | 159 | When running with bazel: 160 | ```shell 161 | bazel run //beacon-chain -- --options-here 162 | ``` 163 | Or run the created docker image. 164 | 165 | ---- 166 | 167 | ## Lighthouse 168 | 169 | ### Prerequisites 170 | 171 | 1. Install Rust. Recommendation: install "rustup", to easily switch rust versions. 172 | ```shell 173 | # System deps (assuming Ubuntu, you may need to parse to your OS) 174 | sudo apt install -y git gcc g++ make cmake pkg-config 175 | # Install Rust 176 | curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh 177 | ``` 178 | 2. Select stable rust version: `rustup +stable default` 179 | 3. Update your rust version (if installed previously): `rustup +stable update` 180 | 181 | ### Build 182 | 183 | Checkout lighthouse rayonism, then run the make script: 184 | ```shell 185 | git clone -b merge-f2f git@github.com:sigp/lighthouse.git 186 | cd lighthouse 187 | 188 | make install 189 | # Note: 190 | # - to support loading multiple configs, you need to use the "spec-minimal" cargo feature 191 | # - to make the docker image portable between machines (at cost of some BLS optimizations etc.), use portable feature. 192 | # E.g. 193 | # cargo install --path lighthouse --force --locked --features portable,spec-minimal 194 | ``` 195 | 196 | ### Run 197 | 198 | ```shell 199 | ./target/release/lighthouse --options-here 200 | ``` 201 | 202 | ---- 203 | 204 | ## Nimbus 205 | 206 | ### Prerequisites 207 | 208 | https://nimbus.guide/install.html 209 | 210 | ### Build 211 | 212 | ```shell 213 | git clone -b amphora-merge-interop git@github.com:status-im/nimbus-eth2 214 | cd nimbus-eth2 215 | ``` 216 | 217 | ```shell 218 | make update 219 | make nimbus_beacon_node 220 | ``` 221 | 222 | ### Run 223 | 224 | ```shell 225 | ./build/nimbus_beacon_chain --options-here 226 | ``` 227 | -------------------------------------------------------------------------------- /generate_eth1_conf.py: -------------------------------------------------------------------------------- 1 | from web3.auto import w3 2 | import json 3 | import ruamel.yaml as yaml 4 | import sys 5 | 6 | w3.eth.account.enable_unaudited_hdwallet_features() 7 | 8 | mergenet_config_path = "mergenet.yaml" 9 | if len(sys.argv) > 1: 10 | mergenet_config_path = sys.argv[1] 11 | 12 | with open(mergenet_config_path) as stream: 13 | data = yaml.safe_load(stream) 14 | 15 | out = { 16 | "config": { 17 | "chainId": int(data['chain_id']), 18 | "homesteadBlock": 0, 19 | "eip150Block": 0, 20 | "eip155Block": 0, 21 | "eip158Block": 0, 22 | "byzantiumBlock": 0, 23 | "constantinopleBlock": 0, 24 | "petersburgBlock": 0, 25 | "istanbulBlock": 0, 26 | "berlinBlock": 0, 27 | "catalystBlock": 0 28 | }, 29 | "alloc": { 30 | # Allocate 1 wei to all possible pre-compiles. 31 | # See https://github.com/ethereum/EIPs/issues/716 "SpuriousDragon RIPEMD bug" 32 | # E.g. Rinkeby allocates it like this. 33 | # See https://github.com/ethereum/go-ethereum/blob/092856267067dd78b527a773f5b240d5c9f5693a/core/genesis.go#L370 34 | **{ 35 | "0x" + i.to_bytes(length=20, byteorder='big').hex(): { 36 | "balance": "1", 37 | } for i in range(256) 38 | }, 39 | data['deposit_contract_address']: { 40 | "balance": "0", 41 | "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", 42 | "storage": { 43 | "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", 44 | "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", 45 | "0x0000000000000000000000000000000000000000000000000000000000000024": "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c", 46 | "0x0000000000000000000000000000000000000000000000000000000000000025": "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c", 47 | "0x0000000000000000000000000000000000000000000000000000000000000026": "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30", 48 | "0x0000000000000000000000000000000000000000000000000000000000000027": "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1", 49 | "0x0000000000000000000000000000000000000000000000000000000000000028": "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c", 50 | "0x0000000000000000000000000000000000000000000000000000000000000029": "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193", 51 | "0x000000000000000000000000000000000000000000000000000000000000002a": "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1", 52 | "0x000000000000000000000000000000000000000000000000000000000000002b": "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", 53 | "0x000000000000000000000000000000000000000000000000000000000000002c": "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", 54 | "0x000000000000000000000000000000000000000000000000000000000000002d": "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f", 55 | "0x000000000000000000000000000000000000000000000000000000000000002e": "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e", 56 | "0x000000000000000000000000000000000000000000000000000000000000002f": "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784", 57 | "0x0000000000000000000000000000000000000000000000000000000000000030": "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb", 58 | "0x0000000000000000000000000000000000000000000000000000000000000031": "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb", 59 | "0x0000000000000000000000000000000000000000000000000000000000000032": "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab", 60 | "0x0000000000000000000000000000000000000000000000000000000000000033": "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4", 61 | "0x0000000000000000000000000000000000000000000000000000000000000034": "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f", 62 | "0x0000000000000000000000000000000000000000000000000000000000000035": "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa", 63 | "0x0000000000000000000000000000000000000000000000000000000000000036": "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c", 64 | "0x0000000000000000000000000000000000000000000000000000000000000037": "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167", 65 | "0x0000000000000000000000000000000000000000000000000000000000000038": "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7", 66 | "0x0000000000000000000000000000000000000000000000000000000000000039": "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0", 67 | "0x000000000000000000000000000000000000000000000000000000000000003a": "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544", 68 | "0x000000000000000000000000000000000000000000000000000000000000003b": "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765", 69 | "0x000000000000000000000000000000000000000000000000000000000000003c": "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4", 70 | "0x000000000000000000000000000000000000000000000000000000000000003d": "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1", 71 | "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", 72 | "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", 73 | "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" 74 | } 75 | } 76 | }, 77 | "coinbase": "0x0000000000000000000000000000000000000000", 78 | "difficulty": "0x01", 79 | "extraData": "", 80 | "gasLimit": "0x400000", 81 | "nonce": "0x1234", 82 | "mixhash": "0x0000000000000000000000000000000000000000000000000000000000000000", 83 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 84 | "timestamp": str(data['eth1_genesis_timestamp']), 85 | "baseFeePerGas": "0x7" 86 | } 87 | 88 | for key, value in data['eth1_premine'].items(): 89 | acct = w3.eth.account.from_mnemonic(data['mnemonic'], account_path=key, passphrase='') 90 | weival = value.replace('ETH', '0' * 18) 91 | out["alloc"][acct.address] = {"balance": weival} 92 | 93 | print(json.dumps(out, indent=' ')) 94 | -------------------------------------------------------------------------------- /generate_eth1_nethermind_conf.py: -------------------------------------------------------------------------------- 1 | from web3.auto import w3 2 | import json 3 | import ruamel.yaml as yaml 4 | import sys 5 | 6 | w3.eth.account.enable_unaudited_hdwallet_features() 7 | 8 | mergenet_config_path = "mergenet.yaml" 9 | if len(sys.argv) > 1: 10 | mergenet_config_path = sys.argv[1] 11 | 12 | with open(mergenet_config_path) as stream: 13 | data = yaml.safe_load(stream) 14 | 15 | out = { 16 | "name": "Catalyst", 17 | "engine": { 18 | "Eth2Merge": { 19 | } 20 | }, 21 | "params": { 22 | "gasLimitBoundDivisor": "0x400", 23 | "accountStartNonce": "0x0", 24 | "maximumExtraDataSize": "0x20", 25 | "minGasLimit": "0x1388", 26 | "networkID": int(data['chain_id']), 27 | "eip150Transition": "0x0", 28 | "eip155Transition": "0x0", 29 | "eip158Transition": "0x0", 30 | "eip160Transition": "0x0", 31 | "eip161abcTransition": "0x0", 32 | "eip161dTransition": "0x0", 33 | "eip140Transition": "0x0", 34 | "eip211Transition": "0x0", 35 | "eip214Transition": "0x0", 36 | "eip658Transition": "0x0", 37 | "eip145Transition": "0x0", 38 | "eip1014Transition": "0x0", 39 | "eip1052Transition": "0x0", 40 | "eip1283Transition": "0x0", 41 | "eip1283DisableTransition": "0x0", 42 | "eip152Transition": "0x0", 43 | "eip1108Transition": "0x0", 44 | "eip1344Transition": "0x0", 45 | "eip1884Transition": "0x0", 46 | "eip2028Transition": "0x0", 47 | "eip2200Transition": "0x0", 48 | "eip2565Transition": "0x0", 49 | "eip2929Transition": "0x0", 50 | "eip2930Transition": "0x0" 51 | }, 52 | "genesis": { 53 | "seal": { 54 | "ethereum": { 55 | "nonce": "0x1234", 56 | "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000" 57 | } 58 | }, 59 | "difficulty": "0x01", 60 | "author": "0x0000000000000000000000000000000000000000", 61 | "timestamp": str(data['eth1_genesis_timestamp']), 62 | "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", 63 | "extraData": "", 64 | "gasLimit": "0x400000" 65 | }, 66 | "accounts": { 67 | # Allocate 1 wei to all possible pre-compiles. 68 | # See https://github.com/ethereum/EIPs/issues/716 "SpuriousDragon RIPEMD bug" 69 | # E.g. Rinkeby allocates it like this. 70 | # See https://github.com/ethereum/go-ethereum/blob/092856267067dd78b527a773f5b240d5c9f5693a/core/genesis.go#L370 71 | **{ 72 | "0x" + i.to_bytes(length=20, byteorder='big').hex(): { 73 | "balance": "1", 74 | } for i in range(256) 75 | }, 76 | data['deposit_contract_address']: { 77 | "balance": "0", 78 | "code": "0x60806040526004361061003f5760003560e01c806301ffc9a71461004457806322895118146100a4578063621fd130146101ba578063c5f2892f14610244575b600080fd5b34801561005057600080fd5b506100906004803603602081101561006757600080fd5b50357fffffffff000000000000000000000000000000000000000000000000000000001661026b565b604080519115158252519081900360200190f35b6101b8600480360360808110156100ba57600080fd5b8101906020810181356401000000008111156100d557600080fd5b8201836020820111156100e757600080fd5b8035906020019184600183028401116401000000008311171561010957600080fd5b91939092909160208101903564010000000081111561012757600080fd5b82018360208201111561013957600080fd5b8035906020019184600183028401116401000000008311171561015b57600080fd5b91939092909160208101903564010000000081111561017957600080fd5b82018360208201111561018b57600080fd5b803590602001918460018302840111640100000000831117156101ad57600080fd5b919350915035610304565b005b3480156101c657600080fd5b506101cf6110b5565b6040805160208082528351818301528351919283929083019185019080838360005b838110156102095781810151838201526020016101f1565b50505050905090810190601f1680156102365780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561025057600080fd5b506102596110c7565b60408051918252519081900360200190f35b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f01ffc9a70000000000000000000000000000000000000000000000000000000014806102fe57507fffffffff0000000000000000000000000000000000000000000000000000000082167f8564090700000000000000000000000000000000000000000000000000000000145b92915050565b6030861461035d576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118056026913960400191505060405180910390fd5b602084146103b6576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252603681526020018061179c6036913960400191505060405180910390fd5b6060821461040f576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260298152602001806118786029913960400191505060405180910390fd5b670de0b6b3a7640000341015610470576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260268152602001806118526026913960400191505060405180910390fd5b633b9aca003406156104cd576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260338152602001806117d26033913960400191505060405180910390fd5b633b9aca00340467ffffffffffffffff811115610535576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040180806020018281038252602781526020018061182b6027913960400191505060405180910390fd5b6060610540826114ba565b90507f649bbc62d0e31342afea4e5cd82d4049e7e1ee912fc0889aa790803be39038c589898989858a8a6105756020546114ba565b6040805160a0808252810189905290819060208201908201606083016080840160c085018e8e80828437600083820152601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690910187810386528c815260200190508c8c808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01690920188810386528c5181528c51602091820193918e019250908190849084905b83811015610648578181015183820152602001610630565b50505050905090810190601f1680156106755780820380516001836020036101000a031916815260200191505b5086810383528881526020018989808284376000838201819052601f9091017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169092018881038452895181528951602091820193918b019250908190849084905b838110156106ef5781810151838201526020016106d7565b50505050905090810190601f16801561071c5780820380516001836020036101000a031916815260200191505b509d505050505050505050505050505060405180910390a1600060028a8a600060801b604051602001808484808284377fffffffffffffffffffffffffffffffff0000000000000000000000000000000090941691909301908152604080517ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0818403018152601090920190819052815191955093508392506020850191508083835b602083106107fc57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016107bf565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610859573d6000803e3d6000fd5b5050506040513d602081101561086e57600080fd5b5051905060006002806108846040848a8c6116fe565b6040516020018083838082843780830192505050925050506040516020818303038152906040526040518082805190602001908083835b602083106108f857805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016108bb565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610955573d6000803e3d6000fd5b5050506040513d602081101561096a57600080fd5b5051600261097b896040818d6116fe565b60405160009060200180848480828437919091019283525050604080518083038152602092830191829052805190945090925082918401908083835b602083106109f457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe090920191602091820191016109b7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610a51573d6000803e3d6000fd5b5050506040513d6020811015610a6657600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610ada57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610a9d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610b37573d6000803e3d6000fd5b5050506040513d6020811015610b4c57600080fd5b50516040805160208101858152929350600092600292839287928f928f92018383808284378083019250505093505050506040516020818303038152906040526040518082805190602001908083835b60208310610bd957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610b9c565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610c36573d6000803e3d6000fd5b5050506040513d6020811015610c4b57600080fd5b50516040518651600291889160009188916020918201918291908601908083835b60208310610ca957805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610c6c565b6001836020036101000a0380198251168184511680821785525050505050509050018367ffffffffffffffff191667ffffffffffffffff1916815260180182815260200193505050506040516020818303038152906040526040518082805190602001908083835b60208310610d4e57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610d11565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610dab573d6000803e3d6000fd5b5050506040513d6020811015610dc057600080fd5b5051604080516020818101949094528082019290925280518083038201815260609092019081905281519192909182918401908083835b60208310610e3457805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610df7565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015610e91573d6000803e3d6000fd5b5050506040513d6020811015610ea657600080fd5b50519050858114610f02576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260548152602001806117486054913960600191505060405180910390fd5b60205463ffffffff11610f60576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004018080602001828103825260218152602001806117276021913960400191505060405180910390fd5b602080546001019081905560005b60208110156110a9578160011660011415610fa0578260008260208110610f9157fe5b0155506110ac95505050505050565b600260008260208110610faf57fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061102557805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101610fe8565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa158015611082573d6000803e3d6000fd5b5050506040513d602081101561109757600080fd5b50519250600282049150600101610f6e565b50fe5b50505050505050565b60606110c26020546114ba565b905090565b6020546000908190815b60208110156112f05781600116600114156111e6576002600082602081106110f557fe5b01548460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061116b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161112e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156111c8573d6000803e3d6000fd5b5050506040513d60208110156111dd57600080fd5b505192506112e2565b600283602183602081106111f657fe5b015460405160200180838152602001828152602001925050506040516020818303038152906040526040518082805190602001908083835b6020831061126b57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161122e565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa1580156112c8573d6000803e3d6000fd5b5050506040513d60208110156112dd57600080fd5b505192505b6002820491506001016110d1565b506002826112ff6020546114ba565b600060401b6040516020018084815260200183805190602001908083835b6020831061135a57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0909201916020918201910161131d565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790527fffffffffffffffffffffffffffffffffffffffffffffffff000000000000000095909516920191825250604080518083037ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8018152601890920190819052815191955093508392850191508083835b6020831061143f57805182527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe09092019160209182019101611402565b51815160209384036101000a7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff01801990921691161790526040519190930194509192505080830381855afa15801561149c573d6000803e3d6000fd5b5050506040513d60208110156114b157600080fd5b50519250505090565b60408051600880825281830190925260609160208201818036833701905050905060c082901b8060071a60f81b826000815181106114f457fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060061a60f81b8260018151811061153757fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060051a60f81b8260028151811061157a57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060041a60f81b826003815181106115bd57fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060031a60f81b8260048151811061160057fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060021a60f81b8260058151811061164357fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060011a60f81b8260068151811061168657fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053508060001a60f81b826007815181106116c957fe5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535050919050565b6000808585111561170d578182fd5b83861115611719578182fd5b505082019391909203915056fe4465706f736974436f6e74726163743a206d65726b6c6520747265652066756c6c4465706f736974436f6e74726163743a207265636f6e7374727563746564204465706f7369744461746120646f6573206e6f74206d6174636820737570706c696564206465706f7369745f646174615f726f6f744465706f736974436f6e74726163743a20696e76616c6964207769746864726177616c5f63726564656e7469616c73206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c7565206e6f74206d756c7469706c65206f6620677765694465706f736974436f6e74726163743a20696e76616c6964207075626b6579206c656e6774684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f20686967684465706f736974436f6e74726163743a206465706f7369742076616c756520746f6f206c6f774465706f736974436f6e74726163743a20696e76616c6964207369676e6174757265206c656e677468a26469706673582212201dd26f37a621703009abf16e77e69c93dc50c79db7f6cc37543e3e0e3decdc9764736f6c634300060b0033", 79 | "storage": { 80 | "0x0000000000000000000000000000000000000000000000000000000000000022": "0xf5a5fd42d16a20302798ef6ed309979b43003d2320d9f0e8ea9831a92759fb4b", 81 | "0x0000000000000000000000000000000000000000000000000000000000000023": "0xdb56114e00fdd4c1f85c892bf35ac9a89289aaecb1ebd0a96cde606a748b5d71", 82 | "0x0000000000000000000000000000000000000000000000000000000000000024": "0xc78009fdf07fc56a11f122370658a353aaa542ed63e44c4bc15ff4cd105ab33c", 83 | "0x0000000000000000000000000000000000000000000000000000000000000025": "0x536d98837f2dd165a55d5eeae91485954472d56f246df256bf3cae19352a123c", 84 | "0x0000000000000000000000000000000000000000000000000000000000000026": "0x9efde052aa15429fae05bad4d0b1d7c64da64d03d7a1854a588c2cb8430c0d30", 85 | "0x0000000000000000000000000000000000000000000000000000000000000027": "0xd88ddfeed400a8755596b21942c1497e114c302e6118290f91e6772976041fa1", 86 | "0x0000000000000000000000000000000000000000000000000000000000000028": "0x87eb0ddba57e35f6d286673802a4af5975e22506c7cf4c64bb6be5ee11527f2c", 87 | "0x0000000000000000000000000000000000000000000000000000000000000029": "0x26846476fd5fc54a5d43385167c95144f2643f533cc85bb9d16b782f8d7db193", 88 | "0x000000000000000000000000000000000000000000000000000000000000002a": "0x506d86582d252405b840018792cad2bf1259f1ef5aa5f887e13cb2f0094f51e1", 89 | "0x000000000000000000000000000000000000000000000000000000000000002b": "0xffff0ad7e659772f9534c195c815efc4014ef1e1daed4404c06385d11192e92b", 90 | "0x000000000000000000000000000000000000000000000000000000000000002c": "0x6cf04127db05441cd833107a52be852868890e4317e6a02ab47683aa75964220", 91 | "0x000000000000000000000000000000000000000000000000000000000000002d": "0xb7d05f875f140027ef5118a2247bbb84ce8f2f0f1123623085daf7960c329f5f", 92 | "0x000000000000000000000000000000000000000000000000000000000000002e": "0xdf6af5f5bbdb6be9ef8aa618e4bf8073960867171e29676f8b284dea6a08a85e", 93 | "0x000000000000000000000000000000000000000000000000000000000000002f": "0xb58d900f5e182e3c50ef74969ea16c7726c549757cc23523c369587da7293784", 94 | "0x0000000000000000000000000000000000000000000000000000000000000030": "0xd49a7502ffcfb0340b1d7885688500ca308161a7f96b62df9d083b71fcc8f2bb", 95 | "0x0000000000000000000000000000000000000000000000000000000000000031": "0x8fe6b1689256c0d385f42f5bbe2027a22c1996e110ba97c171d3e5948de92beb", 96 | "0x0000000000000000000000000000000000000000000000000000000000000032": "0x8d0d63c39ebade8509e0ae3c9c3876fb5fa112be18f905ecacfecb92057603ab", 97 | "0x0000000000000000000000000000000000000000000000000000000000000033": "0x95eec8b2e541cad4e91de38385f2e046619f54496c2382cb6cacd5b98c26f5a4", 98 | "0x0000000000000000000000000000000000000000000000000000000000000034": "0xf893e908917775b62bff23294dbbe3a1cd8e6cc1c35b4801887b646a6f81f17f", 99 | "0x0000000000000000000000000000000000000000000000000000000000000035": "0xcddba7b592e3133393c16194fac7431abf2f5485ed711db282183c819e08ebaa", 100 | "0x0000000000000000000000000000000000000000000000000000000000000036": "0x8a8d7fe3af8caa085a7639a832001457dfb9128a8061142ad0335629ff23ff9c", 101 | "0x0000000000000000000000000000000000000000000000000000000000000037": "0xfeb3c337d7a51a6fbf00b9e34c52e1c9195c969bd4e7a0bfd51d5c5bed9c1167", 102 | "0x0000000000000000000000000000000000000000000000000000000000000038": "0xe71f0aa83cc32edfbefa9f4d3e0174ca85182eec9f3a09f6a6c0df6377a510d7", 103 | "0x0000000000000000000000000000000000000000000000000000000000000039": "0x31206fa80a50bb6abe29085058f16212212a60eec8f049fecb92d8c8e0a84bc0", 104 | "0x000000000000000000000000000000000000000000000000000000000000003a": "0x21352bfecbeddde993839f614c3dac0a3ee37543f9b412b16199dc158e23b544", 105 | "0x000000000000000000000000000000000000000000000000000000000000003b": "0x619e312724bb6d7c3153ed9de791d764a366b389af13c58bf8a8d90481a46765", 106 | "0x000000000000000000000000000000000000000000000000000000000000003c": "0x7cdd2986268250628d0c10e385c58c6191e6fbe05191bcc04f133f2cea72c1c4", 107 | "0x000000000000000000000000000000000000000000000000000000000000003d": "0x848930bd7ba8cac54661072113fb278869e07bb8587f91392933374d017bcbe1", 108 | "0x000000000000000000000000000000000000000000000000000000000000003e": "0x8869ff2c22b28cc10510d9853292803328be4fb0e80495e8bb8d271f5b889636", 109 | "0x000000000000000000000000000000000000000000000000000000000000003f": "0xb5fe28e79f1b850f8658246ce9b6a1e7b49fc06db7143e8fe0b4f2b0c5523a5c", 110 | "0x0000000000000000000000000000000000000000000000000000000000000040": "0x985e929f70af28d0bdd1a90a808f977f597c7c778c489e98d3bd8910d31ac0f7" 111 | } 112 | } 113 | } 114 | } 115 | 116 | for key, value in data['eth1_premine'].items(): 117 | acct = w3.eth.account.from_mnemonic(data['mnemonic'], account_path=key, passphrase='') 118 | weival = value.replace('ETH', '0' * 18) 119 | out["accounts"][acct.address] = {"balance": weival} 120 | 121 | print(json.dumps(out, indent=' ')) 122 | -------------------------------------------------------------------------------- /generate_eth2_conf.py: -------------------------------------------------------------------------------- 1 | import ruamel.yaml as yaml 2 | import sys 3 | 4 | mergenet_config_path = "mergenet.yaml" 5 | if len(sys.argv) > 1: 6 | mergenet_config_path = sys.argv[1] 7 | 8 | with open(mergenet_config_path) as stream: 9 | data = yaml.safe_load(stream) 10 | 11 | mainnet = { 12 | 'CONFIG_NAME': 'mainnet', 13 | 'MAX_COMMITTEES_PER_SLOT': 64, 14 | 'TARGET_COMMITTEE_SIZE': 128, 15 | 'SHUFFLE_ROUND_COUNT': 90, 16 | 'MIN_GENESIS_ACTIVE_VALIDATOR_COUNT': 16384, 17 | 'ETH1_FOLLOW_DISTANCE': 2048, 18 | 'SECONDS_PER_SLOT': 12, 19 | 'SLOTS_PER_EPOCH': 32, 20 | 'EPOCHS_PER_ETH1_VOTING_PERIOD': 64, 21 | 'SLOTS_PER_HISTORICAL_ROOT': 8192, 22 | 'SHARD_COMMITTEE_PERIOD': 256, 23 | 'EPOCHS_PER_HISTORICAL_VECTOR': 65536, 24 | 'EPOCHS_PER_SLASHINGS_VECTOR': 8192, 25 | 'INACTIVITY_PENALTY_QUOTIENT': 67108864, 26 | 'MIN_SLASHING_PENALTY_QUOTIENT': 128, 27 | 'PROPORTIONAL_SLASHING_MULTIPLIER': 1, 28 | 'CHURN_LIMIT_QUOTIENT' : 65536 29 | } 30 | 31 | minimal = { 32 | 'CONFIG_NAME': 'minimal', 33 | 'MAX_COMMITTEES_PER_SLOT': 4, 34 | 'TARGET_COMMITTEE_SIZE': 4, 35 | 'SHUFFLE_ROUND_COUNT': 10, 36 | 'MIN_GENESIS_ACTIVE_VALIDATOR_COUNT': 64, 37 | 'ETH1_FOLLOW_DISTANCE': 16, 38 | 'SECONDS_PER_SLOT': 6, # TODO: maybe just keep this 12? 39 | 'SLOTS_PER_EPOCH': 8, 40 | 'EPOCHS_PER_ETH1_VOTING_PERIOD': 4, 41 | 'SLOTS_PER_HISTORICAL_ROOT': 64, 42 | 'SHARD_COMMITTEE_PERIOD': 64, 43 | 'EPOCHS_PER_HISTORICAL_VECTOR': 64, 44 | 'EPOCHS_PER_SLASHINGS_VECTOR': 64, 45 | 'INACTIVITY_PENALTY_QUOTIENT': 33554432, 46 | 'MIN_SLASHING_PENALTY_QUOTIENT': 64, 47 | 'PROPORTIONAL_SLASHING_MULTIPLIER': 2, 48 | 'CHURN_LIMIT_QUOTIENT' : 32 49 | } 50 | 51 | config = minimal if data['eth2_base_config'] == 'minimal' else mainnet 52 | 53 | print(f"""# Merge devnet preset 54 | 55 | # Extends the minimal preset 56 | PRESET_BASE: "{config['CONFIG_NAME']}" 57 | 58 | # Genesis 59 | # --------------------------------------------------------------- 60 | # [customized] 61 | MIN_GENESIS_ACTIVE_VALIDATOR_COUNT: 64 62 | # Jan 3, 2020 63 | MIN_GENESIS_TIME: 1606824000 64 | # Highest byte set to 0x01 to avoid collisions with mainnet versioning 65 | GENESIS_FORK_VERSION: {data['eth2_fork_version']} 66 | # [customized] Faster to spin up testnets, but does not give validator reasonable warning time for genesis 67 | GENESIS_DELAY: {data['eth2_genesis_delay']} 68 | 69 | 70 | # Forking 71 | # --------------------------------------------------------------- 72 | # Values provided for illustrative purposes. 73 | # Individual tests/testnets may set different values. 74 | 75 | # Altair 76 | ALTAIR_FORK_VERSION: 0x01000001 77 | ALTAIR_FORK_EPOCH: 0 78 | # Merge 79 | MERGE_FORK_VERSION: 0x02000001 80 | MERGE_FORK_EPOCH: 0 81 | # Sharding 82 | SHARDING_FORK_VERSION: 0x03000001 83 | SHARDING_FORK_EPOCH: 18446744073709551615 84 | 85 | # TBD, 2**32 is a placeholder. Merge transition approach is in active R&D. 86 | MIN_ANCHOR_POW_BLOCK_DIFFICULTY: 4294967296 87 | 88 | 89 | # Time parameters 90 | # --------------------------------------------------------------- 91 | # [customized] Faster for testing purposes 92 | SECONDS_PER_SLOT: {config['SECONDS_PER_SLOT']} 93 | # 14 (estimate from Eth1 mainnet) 94 | SECONDS_PER_ETH1_BLOCK: {config['SECONDS_PER_SLOT']} 95 | # 2**8 (= 256) epochs 96 | MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256 97 | # [customized] higher frequency of committee turnover and faster time to acceptable voluntary exit 98 | SHARD_COMMITTEE_PERIOD: {config['SHARD_COMMITTEE_PERIOD']} 99 | # [customized] process deposits more quickly, but insecure 100 | ETH1_FOLLOW_DISTANCE: {config['ETH1_FOLLOW_DISTANCE']} 101 | 102 | 103 | # Validator cycle 104 | # --------------------------------------------------------------- 105 | # 2**2 (= 4) 106 | INACTIVITY_SCORE_BIAS: 4 107 | # 2**4 (= 16) 108 | INACTIVITY_SCORE_RECOVERY_RATE: 16 109 | # 2**4 * 10**9 (= 16,000,000,000) Gwei 110 | EJECTION_BALANCE: 16000000000 111 | # 2**2 (= 4) 112 | MIN_PER_EPOCH_CHURN_LIMIT: 4 113 | # [customized] scale queue churn at much lower validator counts for testing 114 | CHURN_LIMIT_QUOTIENT: {config['CHURN_LIMIT_QUOTIENT']} 115 | 116 | # Deposit contract 117 | # --------------------------------------------------------------- 118 | # Execution layer chain 119 | DEPOSIT_CHAIN_ID: {data['chain_id']} 120 | DEPOSIT_NETWORK_ID: {data['chain_id']} 121 | # Allocated in Execution-layer genesis 122 | DEPOSIT_CONTRACT_ADDRESS: {data['deposit_contract_address']} 123 | """) 124 | -------------------------------------------------------------------------------- /generate_eth2_validator_data.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ETH2_BASE_CONFIG="mainnet" 4 | if grep -q "eth2_base_config: minimal" mergenet.yaml; then 5 | ETH2_BASE_CONFIG="minimal" 6 | fi 7 | 8 | # Inside your setupenv: Generate Genesis Beacon State 9 | if [ "$ETH2_BASE_CONFIG" = "minimal" ]; then 10 | echo "[*] Using minimal config" 11 | eth2-testnet-genesis merge \ 12 | --preset-phase0 minimal --preset-altair minimal --preset-merge minimal \ 13 | --eth1-config "$TESTNET_NAME/public/eth1_config.json" \ 14 | --config "$TESTNET_NAME/public/eth2_config.yaml" \ 15 | --mnemonics genesis_validators.yaml \ 16 | --state-output "$TESTNET_NAME/public/genesis.ssz" \ 17 | --tranches-dir "$TESTNET_NAME/private/tranches" 18 | else 19 | echo "[*] Using mainnet config" 20 | eth2-testnet-genesis merge \ 21 | --eth1-config "$TESTNET_NAME/public/eth1_config.json" \ 22 | --config "$TESTNET_NAME/public/eth2_config.yaml" \ 23 | --mnemonics genesis_validators.yaml \ 24 | --state-output "$TESTNET_NAME/public/genesis.ssz" \ 25 | --tranches-dir "$TESTNET_NAME/private/tranches" 26 | fi 27 | 28 | 29 | # Build validator keystore for nodes 30 | # 31 | # Prysm likes to consume bundled keystores. Use `--prysm-pass` to encrypt the bundled version. 32 | # For the other eth2 clients, a different secret is generated per validator keystore. 33 | # 34 | # You can change the range of validator accounts, to split keys between nodes. 35 | # The mnemonic and key-range should match that of a tranche of validators in the beacon-state genesis. 36 | echo "[*] Building validator keystores" 37 | eth2-val-tools keystores \ 38 | --out-loc "$TESTNET_NAME/private/$VALIDATOR_NODE_NAME" \ 39 | --prysm-pass="foobar" \ 40 | --source-min=0 \ 41 | --source-max=64 \ 42 | --source-mnemonic="lumber kind orange gold firm achieve tree robust peasant april very word ordinary before treat way ivory jazz cereal debate juice evil flame sadness" 43 | -------------------------------------------------------------------------------- /genesis_validators.yaml: -------------------------------------------------------------------------------- 1 | # a 24 word BIP 39 mnemonic 2 | - mnemonic: "lumber kind orange gold firm achieve tree robust peasant april very word ordinary before treat way ivory jazz cereal debate juice evil flame sadness" 3 | count: 64 # 64 for minimal config, 16384 for mainnet config 4 | # more tranches can be specified for multi-user setup, 5 | # see https://github.com/protolambda/eth2-testnet-genesis README 6 | 7 | -------------------------------------------------------------------------------- /mergenet.yaml: -------------------------------------------------------------------------------- 1 | mnemonic: "enforce patient ridge volume question system myself moon world glass later hello tissue east chair suspect remember check chicken bargain club exit pilot sand" 2 | eth1_premine: 3 | "m/44'/60'/0'/0/0": 10000000ETH 4 | "m/44'/60'/0'/0/1": 10000000ETH 5 | "m/44'/60'/0'/0/2": 10000000ETH 6 | chain_id: 700 7 | deposit_contract_address: "0x4242424242424242424242424242424242424242" 8 | # either 'minimal' or 'mainnet' 9 | eth2_base_config: minimal 10 | eth2_fork_version: "0x00000700" 11 | eth1_genesis_timestamp: GENESIS_TIMESTAMP 12 | # Tweak this. actual_genesis_timestamp = eth1_genesis_timestamp + eth2_genesis_delay 13 | eth2_genesis_delay: 600 14 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | web3 2 | ruamel.yaml 3 | -------------------------------------------------------------------------------- /rpc_examples/README.md: -------------------------------------------------------------------------------- 1 | # JSON RPC Examples 2 | 3 | This directory contains scripts and examples of the JSON RPC encoding for 4 | "execution" clients. 5 | 6 | The examples were generated using scripts also available in this directory. 7 | Whilst these examples were generated with Geth (Catalyst), they *should* be 8 | able to be run against any execution client. 9 | 10 | This information should help application and consensus clients write unit tests 11 | and understand the RPC format. 12 | 13 | ## Example: `consensus_assembleBlock` 14 | 15 | ### Request 16 | 17 | ```json 18 | { 19 | "jsonrpc": "2.0", 20 | "method": "consensus_assembleBlock", 21 | "params": [ 22 | { 23 | "parentHash": "0xa68f81fa333010c7f6b84536793a722aa20b3d7eb73b54ca8ea2a0fd5834ddaf", 24 | "timestamp": "0x607e8240" 25 | } 26 | ], 27 | "id": 42 28 | } 29 | ``` 30 | 31 | ### Response 32 | 33 | ```json 34 | { 35 | "jsonrpc": "2.0", 36 | "id": 42, 37 | "result": { 38 | "blockHash": "0x927be870eaa59bac61d9e118904d898de2a20cba1dea5dd8856c2cc7a38364a2", 39 | "parentHash": "0xa68f81fa333010c7f6b84536793a722aa20b3d7eb73b54ca8ea2a0fd5834ddaf", 40 | "miner": "0x1000000000000000000000000000000000000000", 41 | "stateRoot": "0x0aef2cef869e5b93c69722bbea2f76d477ccefa1862a5a48450726d7a067db42", 42 | "number": "0x1", 43 | "gasLimit": "0x400000", 44 | "gasUsed": "0x5208", 45 | "timestamp": "0x607e8240", 46 | "receiptsRoot": "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2", 47 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 48 | "transactions": [ 49 | "0xf8698004825208944a776e9369831f50564e430aacdd58b6be78a10b880de0b6b3a76400008082059ca07c3cc5403b459b15ff24a961d58d525c860b432fa3dc98c914342f8089a766bba02d6402409be46cec176d180d04f9f0cc0c00bb20c254a633949aff1b0962f2ab" 50 | ] 51 | } 52 | } 53 | ``` 54 | 55 | > Generate this example yourself with `./consensus_assembleBlock.sh` 56 | 57 | ## Example: `consensus_newBlock` 58 | 59 | ### Request 60 | 61 | ```json 62 | { 63 | "jsonrpc": "2.0", 64 | "method": "consensus_newBlock", 65 | "params": [ 66 | { 67 | "blockHash": "0xe7be756f355b20759c73f849a7d1734134d6df336acd8586135341f2c9ad7a4a", 68 | "parentHash": "0xa68f81fa333010c7f6b84536793a722aa20b3d7eb73b54ca8ea2a0fd5834ddaf", 69 | "miner": "0x1000000000000000000000000000000000000000", 70 | "stateRoot": "0x0aef2cef869e5b93c69722bbea2f76d477ccefa1862a5a48450726d7a067db42", 71 | "number": "0x1", 72 | "gasLimit": "0x400000", 73 | "gasUsed": "0x5208", 74 | "timestamp": "0x607e826f", 75 | "receiptsRoot": "0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2", 76 | "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", 77 | "transactions": [ 78 | "0xf8698004825208944a776e9369831f50564e430aacdd58b6be78a10b880de0b6b3a76400008082059ca07c3cc5403b459b15ff24a961d58d525c860b432fa3dc98c914342f8089a766bba02d6402409be46cec176d180d04f9f0cc0c00bb20c254a633949aff1b0962f2ab" 79 | ] 80 | } 81 | ], 82 | "id": 42 83 | } 84 | ``` 85 | 86 | ### Result 87 | 88 | ```json 89 | { 90 | "jsonrpc": "2.0", 91 | "id": 42, 92 | "result": { 93 | "valid": true 94 | } 95 | } 96 | ``` 97 | 98 | > Generate this example yourself with `./consensus_newBlock.sh` 99 | 100 | ## Example: `consensus_setHead` 101 | 102 | ### Request 103 | 104 | ```json 105 | { 106 | "jsonrpc": "2.0", 107 | "method": "consensus_setHead", 108 | "params": [ 109 | "0xc0caf8693193f5ba1e3f04368377ad63884468b13d72e4b08ade49a9e1203f6f" 110 | ], 111 | "id": 42 112 | } 113 | ``` 114 | 115 | ### Response 116 | 117 | ```json 118 | { 119 | "jsonrpc": "2.0", 120 | "id": 42, 121 | "result": { 122 | "success": true 123 | } 124 | } 125 | ``` 126 | -------------------------------------------------------------------------------- /rpc_examples/consensus_assembleBlock.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Exercise the `consensus_newBlock` request, inspect the response. 4 | # 5 | # Note: this assumes `jq` is installed. 6 | 7 | PARENT_HASH=$(./get_genesis_hash.sh) 8 | TIMESTAMP=$(printf 0x%02x $(date +%s)) 9 | 10 | PARAMS="[{ \"parentHash\": $PARENT_HASH, \"timestamp\": \"$TIMESTAMP\"}]" 11 | 12 | DATA="{\"jsonrpc\":\"2.0\",\"method\":\"consensus_assembleBlock\",\"params\":$PARAMS,\"id\":42}" 13 | 14 | echo Request: 15 | echo $DATA | jq 16 | echo 17 | echo Response: 18 | 19 | curl \ 20 | -s \ 21 | -X \ 22 | POST \ 23 | -H "Content-Type: application/json" \ 24 | --data "$DATA" \ 25 | http://localhost:8545 \ 26 | | \ 27 | jq 28 | -------------------------------------------------------------------------------- /rpc_examples/consensus_newBlock.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Exercise the `consensus_assembleBlock` request, inspect the response. 4 | # 5 | # Note: this assumes `jq` is installed. 6 | 7 | PARENT_HASH=$(./get_genesis_hash.sh) 8 | TIMESTAMP=$(printf 0x%02x $(date +%s)) 9 | PARAMS="[{ \"parentHash\": $PARENT_HASH, \"timestamp\": \"$TIMESTAMP\"}]" 10 | DATA="{\"jsonrpc\":\"2.0\",\"method\":\"consensus_assembleBlock\",\"params\":$PARAMS,\"id\":42}" 11 | 12 | EXECUTION_PAYLOAD=$(curl \ 13 | -s \ 14 | -X \ 15 | POST \ 16 | -H "Content-Type: application/json" \ 17 | --data "$DATA" \ 18 | http://localhost:8545 \ 19 | | \ 20 | jq \ 21 | -c \ 22 | '.["result"]') 23 | 24 | DATA="{\"jsonrpc\":\"2.0\",\"method\":\"consensus_newBlock\",\"params\":[$EXECUTION_PAYLOAD],\"id\":42}" 25 | 26 | echo Request: 27 | echo $DATA | jq 28 | echo 29 | echo Response: 30 | 31 | curl \ 32 | -s \ 33 | -X \ 34 | POST \ 35 | -H "Content-Type: application/json" \ 36 | --data "$DATA" \ 37 | http://localhost:8545 \ 38 | | \ 39 | jq 40 | -------------------------------------------------------------------------------- /rpc_examples/consensus_setHead.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Exercise the `consensus_setHead` request, inspect the response. 4 | # 5 | # Note: this assumes `jq` is installed. 6 | 7 | BLOCK_HASH=$(./rpc_examples/get_genesis_hash.sh) 8 | 9 | PARAMS="[$BLOCK_HASH]" 10 | 11 | DATA="{\"jsonrpc\":\"2.0\",\"method\":\"consensus_setHead\",\"params\":$PARAMS,\"id\":42}" 12 | 13 | echo Request: 14 | echo $DATA | jq 15 | echo 16 | echo Response: 17 | 18 | curl \ 19 | -s \ 20 | -X \ 21 | POST \ 22 | -H "Content-Type: application/json" \ 23 | --data "$DATA" \ 24 | http://localhost:8545 \ 25 | | \ 26 | jq 27 | -------------------------------------------------------------------------------- /rpc_examples/get_genesis_hash.sh: -------------------------------------------------------------------------------- 1 | #! /bin/bash 2 | 3 | # Get the genesis hash via the RPC 4 | # 5 | # Note: this assumes `jq` is installed. 6 | 7 | DATA='{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["earliest", true],"id":1}' 8 | 9 | curl \ 10 | -s \ 11 | -X \ 12 | POST \ 13 | -H "Content-Type: application/json" \ 14 | --data "$DATA" \ 15 | http://localhost:8545 \ 16 | | \ 17 | jq \ 18 | '.["result"]["hash"]' 19 | -------------------------------------------------------------------------------- /run_multiclient_docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # To clean up: 4 | # docker stop bootnode0 catalyst0 besu0 nethermind0 teku0bn teku0vc lighthouse0bn lighthouse0vc prysm0bn prysm0vc forkmon0 postgres0 explorer0 5 | # docker container prune 6 | # sudo rm -rf testnets/$TESTNET_NAME 7 | 8 | set -e 9 | 10 | # mainnet or minimal. For mainnet, you need `2**14` validators. For minimal just 64 11 | ETH2_SPEC_VARIANT=minimal 12 | 13 | # LIGHTHOUSE_DOCKER_IMAGE=sigp/lighthouse:rayonism 14 | # Built with portable,spec-minimal features, 15 | # so the image can be used everywhere, and the minimal config can be used for testing 16 | LIGHTHOUSE_DOCKER_IMAGE=protolambda/lighthouse:rayonism 17 | 18 | TEKU_DOCKER_IMAGE=mkalinin/teku:rayonism 19 | 20 | #PRYSM_BEACON_IMAGE=gcr.io/prysmaticlabs/prysm/beacon-chain:merge-mainnet 21 | #PRYSM_VALIDATOR_IMAGE=gcr.io/prysmaticlabs/prysm/validator:merge-mainnet 22 | PRYSM_BEACON_IMAGE=protolambda/prysm-beacon:rayonism 23 | PRYSM_VALIDATOR_IMAGE=protolambda/prysm-validator:rayonism 24 | 25 | NIMBUS_DOCKER_IMAGE=protolambda/nimbus:rayonism 26 | 27 | # Eth1 nodes 28 | NETHERMIND_IMAGE=nethermind/nethermind:latest 29 | GETH_IMAGE=ethereum/client-go:latest 30 | 31 | #BESU_IMAGE=suburbandad/besu:rayonism 32 | BESU_IMAGE=protolambda/besu:rayonism # has newBlock transaction decoding bug-fix 33 | 34 | # Tools 35 | BOOTNODE_IMAGE=protolambda/eth2-bootnode:latest 36 | FORKMON_IMAGE=protolambda/eth2-fork-mon:latest 37 | POSTGRES_IMAGE=postgres:12.0 38 | EXPLORER_IMAGE=protolambda/merge-explorer:latest 39 | 40 | EXPLORER_TABLES_SQL_PATH=$(readlink -f ../eth2-beaconchain-explorer/tables.sql) 41 | if test -f "$EXPLORER_TABLES_SQL_PATH"; then 42 | echo "Found SQL tables, enabling block explorer" 43 | else 44 | echo "No block explorer enabled, need SQL tables definition" 45 | exit 1 46 | fi 47 | 48 | 49 | # TODO: not yet working. Nimbus requires custom docker builds for testnet configuration changes 50 | # (need a nimbus dev to look at this) 51 | NIMBUS_ENABLED=0 52 | 53 | if [ "$ETH2_SPEC_VARIANT" == "minimal" ]; then 54 | # PRYSM_BEACON_IMAGE=gcr.io/prysmaticlabs/prysm/beacon-chain:merge-minimal 55 | # PRYSM_VALIDATOR_IMAGE=gcr.io/prysmaticlabs/prysm/validator:merge-minimal 56 | PRYSM_BEACON_IMAGE=protolambda/prysm-beacon:rayonism-minimal 57 | PRYSM_VALIDATOR_IMAGE=protolambda/prysm-validator:rayonism-minimal 58 | # TODO: failed attempt at nimbus minimal build. Need to try configure testnet for minimal-mode config outside of docker. 59 | NIMBUS_DOCKER_IMAGE=protolambda/nimbus:rayonism-minimal 60 | fi 61 | 62 | VALIDATORS_MNEMONIC="lumber kind orange gold firm achieve tree robust peasant april very word ordinary before treat way ivory jazz cereal debate juice evil flame sadness" 63 | ETH1_MNEMONIC="enforce patient ridge volume question system myself moon world glass later hello tissue east chair suspect remember check chicken bargain club exit pilot sand" 64 | PRYSM_BULK_KEYSTORE_PASS="foobar" 65 | 66 | # Ensure necessary env vars are present. 67 | if [ -z "$TESTNET_NAME" ]; then 68 | echo TESTNET_NAME is not set, exiting 69 | exit 1 70 | fi 71 | 72 | TESTNET_PATH="${PWD}/testnets/$TESTNET_NAME" 73 | mkdir -p "$TESTNET_PATH" 74 | 75 | # Pull client images 76 | docker pull $LIGHTHOUSE_DOCKER_IMAGE 77 | docker pull $TEKU_DOCKER_IMAGE 78 | docker pull $PRYSM_BEACON_IMAGE 79 | docker pull $PRYSM_VALIDATOR_IMAGE 80 | docker pull $NETHERMIND_IMAGE 81 | docker pull $GETH_IMAGE 82 | docker pull $BESU_IMAGE 83 | 84 | # Basic testnet tooling 85 | docker pull $BOOTNODE_IMAGE 86 | docker pull $FORKMON_IMAGE 87 | 88 | # Block Explorer 89 | docker pull $POSTGRES_IMAGE 90 | docker pull $EXPLORER_IMAGE 91 | 92 | 93 | if [ $NIMBUS_ENABLED != 0 ]; then 94 | docker pull $NIMBUS_DOCKER_IMAGE 95 | fi 96 | 97 | # Create venv for scripts 98 | python -m venv venv 99 | . venv/bin/activate 100 | pip install -r requirements.txt 101 | 102 | # Configure testnet 103 | mkdir -p "$TESTNET_PATH/public" 104 | mkdir -p "$TESTNET_PATH/private" 105 | mkdir -p "$TESTNET_PATH/nodes" 106 | 107 | # Starting bootnode 108 | echo "starting discv5 bootnode" 109 | NODE_NAME=bootnode0 110 | mkdir "$TESTNET_PATH/nodes/$NODE_NAME" 111 | docker run \ 112 | --name "$NODE_NAME" \ 113 | --rm \ 114 | -u $(id -u):$(id -g) \ 115 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/data" \ 116 | --net host \ 117 | -itd $BOOTNODE_IMAGE \ 118 | --api-addr "0.0.0.0:10000" \ 119 | --enr-ip "127.0.0.1" \ 120 | --enr-udp "11000" \ 121 | --listen-ip "0.0.0.0" \ 122 | --listen-udp "11000" \ 123 | --fork-version "0x00000700" \ 124 | --node-db "/data" \ 125 | --priv="c481fa289efe87b258365f057e6c3afa51dbbbf31d9c38246b36d0a48da326ee" 126 | 127 | # you can fetch this from `http://localhost:10000/enr" 128 | BOOTNODE_ENR="enr:-Ku4QOhH76YiJtgBrVBAmiotsLxS9lpdxbtYkpTdLen7CZCyTMCjcSuwcRnFggwn-IHbSEL2RC6kC-2BUHBf5yiVI3sBh2F0dG5ldHOIAAAAAAAAAACEZXRoMpD1pf1CAAAAAP__________gmlkgnY0gmlwhH8AAAGJc2VjcDI1NmsxoQN0nREs-mofKzp_XQ1M1xFrOkr9gMMgCdLFbvH7aPQHT4N1ZHCCKvg" 129 | 130 | echo "Preparing keystores" 131 | 132 | eth2-val-tools keystores \ 133 | --out-loc "$TESTNET_PATH/private/validator0" \ 134 | --prysm-pass="$PRYSM_BULK_KEYSTORE_PASS" \ 135 | --source-min=0 \ 136 | --source-max=22 \ 137 | --source-mnemonic="$VALIDATORS_MNEMONIC" 138 | 139 | eth2-val-tools keystores \ 140 | --out-loc "$TESTNET_PATH/private/validator1" \ 141 | --prysm-pass="$PRYSM_BULK_KEYSTORE_PASS" \ 142 | --source-min=22 \ 143 | --source-max=44 \ 144 | --source-mnemonic="$VALIDATORS_MNEMONIC" 145 | 146 | eth2-val-tools keystores \ 147 | --out-loc "$TESTNET_PATH/private/validator2" \ 148 | --prysm-pass="$PRYSM_BULK_KEYSTORE_PASS" \ 149 | --source-min=44 \ 150 | --source-max=64 \ 151 | --source-mnemonic="$VALIDATORS_MNEMONIC" 152 | 153 | # TODO: split in 4 instead, so nimbus can have keys. 154 | 155 | TIME_NOW=$(date +%s) 156 | # 60 seconds to start all containers and get them connected. 157 | GENESIS_DELAY=60 158 | ETH1_GENESIS_TIMESTAMP=$((TIME_NOW + GENESIS_DELAY)) 159 | ETH2_GENESIS_DELAY=0 160 | ETH2_GENESIS_TIMESTAMP=$((ETH1_GENESIS_TIMESTAMP + ETH2_GENESIS_DELAY)) 161 | 162 | echo "configuring testnet... 163 | Eth1 genesis: $TIME_NOW (now) + $GENESIS_DELAY (delay) = $ETH1_GENESIS_TIMESTAMP 164 | Eth2 genesis: $ETH1_GENESIS_TIMESTAMP (eth1) + $ETH2_GENESIS_DELAY (eth2 delay) = $ETH2_GENESIS_TIMESTAMP" 165 | 166 | cat > "$TESTNET_PATH/private/mergenet.yaml" << EOT 167 | mnemonic: ${ETH1_MNEMONIC} 168 | eth1_premine: 169 | "m/44'/60'/0'/0/0": 10000000ETH 170 | "m/44'/60'/0'/0/1": 10000000ETH 171 | "m/44'/60'/0'/0/2": 10000000ETH 172 | chain_id: 700 173 | deposit_contract_address: "0x4242424242424242424242424242424242424242" 174 | # either 'minimal' or 'mainnet' 175 | eth2_base_config: ${ETH2_SPEC_VARIANT} 176 | eth2_fork_version: "0x00000700" 177 | eth1_genesis_timestamp: ${ETH1_GENESIS_TIMESTAMP} 178 | # Tweak this. actual_genesis_timestamp = eth1_genesis_timestamp + eth2_genesis_delay 179 | eth2_genesis_delay: ${ETH2_GENESIS_DELAY} 180 | EOT 181 | 182 | 183 | echo "configuring chains" 184 | # Configure Eth1 chain 185 | python generate_eth1_conf.py "$TESTNET_PATH/private/mergenet.yaml" > "$TESTNET_PATH/public/eth1_config.json" 186 | # Configure Eth1 chain for Nethermind 187 | python generate_eth1_nethermind_conf.py "$TESTNET_PATH/private/mergenet.yaml" > "$TESTNET_PATH/public/eth1_nethermind_config.json" 188 | # Configure Eth2 chain 189 | python generate_eth2_conf.py "$TESTNET_PATH/private/mergenet.yaml" > "$TESTNET_PATH/public/eth2_config.yaml" 190 | 191 | echo "configuring genesis validators" 192 | cat > "$TESTNET_PATH/private/genesis_validators.yaml" << EOT 193 | # a 24 word BIP 39 mnemonic 194 | - mnemonic: "${VALIDATORS_MNEMONIC}" 195 | count: 64 # 64 for minimal config, 16384 for mainnet config 196 | EOT 197 | 198 | echo "generating genesis BeaconState" 199 | eth2-testnet-genesis merge \ 200 | --eth1-config "$TESTNET_PATH/public/eth1_config.json" \ 201 | --eth2-config "$TESTNET_PATH/public/eth2_config.yaml" \ 202 | --mnemonics "$TESTNET_PATH/private/genesis_validators.yaml" \ 203 | --state-output "$TESTNET_PATH/public/genesis.ssz" \ 204 | --tranches-dir "$TESTNET_PATH/private/tranches" 205 | 206 | echo "preparing geth initial state" 207 | NODE_NAME=catalyst0 208 | mkdir "$TESTNET_PATH/nodes/$NODE_NAME" 209 | docker run \ 210 | --name "$NODE_NAME" \ 211 | --rm \ 212 | -u $(id -u):$(id -g) \ 213 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/gethdata" \ 214 | -v "$TESTNET_PATH/public/eth1_config.json:/networkdata/eth1_config.json" \ 215 | --net host \ 216 | $GETH_IMAGE \ 217 | --catalyst \ 218 | --datadir "/gethdata/chaindata" \ 219 | init "/networkdata/eth1_config.json" 220 | 221 | # Run eth1 nodes 222 | 223 | # Go-ethereum 224 | # Note: networking is disabled on Geth in merge mode (at least for now) 225 | echo "starting geth node" 226 | NODE_NAME=catalyst0 227 | docker run \ 228 | --name "$NODE_NAME" \ 229 | --net host \ 230 | -u $(id -u):$(id -g) \ 231 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/gethdata" \ 232 | -itd $GETH_IMAGE \ 233 | --catalyst \ 234 | --http --http.api net,eth,consensus \ 235 | --http.port 8500 \ 236 | --http.addr 0.0.0.0 \ 237 | --http.corsdomain "*" \ 238 | --ws --ws.api net,eth,consensus \ 239 | --ws.port 8600 \ 240 | --ws.addr 0.0.0.0 \ 241 | --port 30303 \ 242 | --nodiscover \ 243 | --miner.etherbase 0x1000000000000000000000000000000000000000 \ 244 | --datadir "/gethdata/chaindata" 245 | 246 | # Nethermind 247 | # Note: networking is active, the transaction pool propagation is active on nethermind 248 | echo "starting nethermind node" 249 | NODE_NAME=nethermind0 250 | # Note: unfortunately, running nethermind as non-root user in docker is a pain 251 | mkdir "$TESTNET_PATH/nodes/$NODE_NAME" 252 | docker run \ 253 | --name $NODE_NAME \ 254 | --net host \ 255 | -v "$TESTNET_PATH/public/eth1_nethermind_config.json:/networkdata/eth1_nethermind_config.json" \ 256 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/netherminddata" \ 257 | -itd $NETHERMIND_IMAGE \ 258 | -c catalyst \ 259 | --datadir "/netherminddata" \ 260 | --Init.ChainSpecPath "/networkdata/eth1_nethermind_config.json" \ 261 | --Init.WebSocketsEnabled true \ 262 | --JsonRpc.Enabled true \ 263 | --JsonRpc.EnabledModules "net,eth,consensus" \ 264 | --JsonRpc.Port 8501 \ 265 | --JsonRpc.WebSocketsPort 8601 \ 266 | --JsonRpc.Host 0.0.0.0 \ 267 | --Network.DiscoveryPort 30301 \ 268 | --Network.P2PPort 30301 \ 269 | --Merge.BlockAuthorAccount 0x1000000000000000000000000000000000000000 270 | 271 | # Besu 272 | echo "starting besu node" 273 | NODE_NAME=besu0 274 | mkdir "$TESTNET_PATH/nodes/$NODE_NAME" 275 | docker run \ 276 | --name $NODE_NAME \ 277 | --net host \ 278 | -v "$TESTNET_PATH/public/eth1_config.json:/networkdata/eth1_config.json" \ 279 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/besudata" \ 280 | -u $(id -u):$(id -g) \ 281 | -itd $BESU_IMAGE \ 282 | --logging trace \ 283 | --data-path="/besudata" \ 284 | --genesis-file="/networkdata/eth1_config.json" \ 285 | --rpc-http-enabled --rpc-http-api=ETH,NET,CONSENSUS \ 286 | --rpc-http-host=0.0.0.0 \ 287 | --rpc-http-port=8502 \ 288 | --rpc-http-cors-origins="*" \ 289 | --rpc-ws-enabled --rpc-ws-api=ETH,NET,CONSENSUS \ 290 | --rpc-ws-host=0.0.0.0 \ 291 | --rpc-ws-port=8602 \ 292 | --p2p-port=30302 \ 293 | --Xmerge-support=true \ 294 | --discovery-enabled=false \ 295 | --miner-coinbase="0x1000000000000000000000000000000000000000" 296 | 297 | # Run eth2 beacon nodes 298 | 299 | # Prysm 300 | echo "starting prysm beacon node" 301 | NODE_NAME=prysm0bn 302 | mkdir "$TESTNET_PATH/nodes/$NODE_NAME" 303 | docker run \ 304 | --name $NODE_NAME \ 305 | --net host \ 306 | -u $(id -u):$(id -g) \ 307 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/beacondata" \ 308 | -v "$TESTNET_PATH/public/eth2_config.yaml:/networkdata/eth2_config.yaml" \ 309 | -v "$TESTNET_PATH/public/genesis.ssz:/networkdata/genesis.ssz" \ 310 | -itd $PRYSM_BEACON_IMAGE \ 311 | --accept-terms-of-use=true \ 312 | --datadir="/beacondata" \ 313 | --min-sync-peers=0 \ 314 | --contract-deployment-block 0 \ 315 | --http-web3provider="http://127.0.0.1:8500" \ 316 | --bootstrap-node="$BOOTNODE_ENR" \ 317 | --chain-config-file="/networkdata/eth2_config.yaml" \ 318 | --genesis-state="/networkdata/genesis.ssz" \ 319 | --p2p-host-ip="0.0.0.0" \ 320 | --p2p-max-peers=30 \ 321 | --p2p-udp-port=9000 --p2p-tcp-port=9000 \ 322 | --monitoring-host=0.0.0.0 --monitoring-port=8000 \ 323 | --rpc-host=0.0.0.0 --rpc-port=4100 \ 324 | --grpc-gateway-host=0.0.0.0 \ 325 | --grpc-gateway-port=4000 \ 326 | --verbosity="debug" \ 327 | --enable-debug-rpc-endpoints \ 328 | --min-sync-peers 1 \ 329 | --rpc-max-page-size 500 \ 330 | --slots-per-archive-point=64 331 | # Note: --slots-per-archive-point=64 is to improve local chain explorer performance by storing more state snapshots 332 | 333 | # Teku 334 | echo "starting teku beacon node" 335 | NODE_NAME=teku0bn 336 | mkdir "$TESTNET_PATH/nodes/$NODE_NAME" 337 | docker run \ 338 | --name $NODE_NAME \ 339 | --net host \ 340 | -u $(id -u):$(id -g) \ 341 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/beacondata" \ 342 | -v "$TESTNET_PATH/public/eth2_config.yaml:/networkdata/eth2_config.yaml" \ 343 | -v "$TESTNET_PATH/public/genesis.ssz:/networkdata/genesis.ssz" \ 344 | -itd $TEKU_DOCKER_IMAGE \ 345 | --network "/networkdata/eth2_config.yaml" \ 346 | --data-path "/beacondata" \ 347 | --p2p-enabled=true \ 348 | --logging=TRACE \ 349 | --initial-state "/networkdata/genesis.ssz" \ 350 | --eth1-endpoint "http://127.0.0.1:8501" \ 351 | --p2p-discovery-bootnodes "$BOOTNODE_ENR" \ 352 | --metrics-enabled=true --metrics-interface=0.0.0.0 --metrics-port=8001 \ 353 | --p2p-discovery-enabled=true \ 354 | --p2p-peer-lower-bound=1 \ 355 | --p2p-port=9001 \ 356 | --rest-api-enabled=true \ 357 | --rest-api-docs-enabled=true \ 358 | --rest-api-interface=0.0.0.0 \ 359 | --rest-api-port=4001 \ 360 | --Xdata-storage-non-canonical-blocks-enabled=true 361 | 362 | # Lighthouse 363 | echo "starting lighthouse beacon node" 364 | NODE_NAME=lighthouse0bn 365 | mkdir "$TESTNET_PATH/nodes/$NODE_NAME" 366 | docker run \ 367 | --name $NODE_NAME \ 368 | --net host \ 369 | -u $(id -u):$(id -g) \ 370 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/beacondata" \ 371 | -v "$TESTNET_PATH/public/eth2_config.yaml:/networkdata/eth2_config.yaml" \ 372 | -v "$TESTNET_PATH/public/genesis.ssz:/networkdata/genesis.ssz" \ 373 | -itd $LIGHTHOUSE_DOCKER_IMAGE \ 374 | lighthouse \ 375 | --datadir "/beacondata" \ 376 | --testnet-deposit-contract-deploy-block 0 \ 377 | --testnet-genesis-state "/networkdata/genesis.ssz" \ 378 | --testnet-yaml-config "/networkdata/eth2_config.yaml" \ 379 | --debug-level=trace \ 380 | beacon_node \ 381 | --eth1 --eth1-endpoints "http://127.0.0.1:8502" \ 382 | --boot-nodes "$BOOTNODE_ENR" \ 383 | --http \ 384 | --http-address 0.0.0.0 \ 385 | --http-port 4002 \ 386 | --metrics \ 387 | --metrics-address 0.0.0.0 \ 388 | --metrics-port 8002 \ 389 | --listen-address 0.0.0.0 \ 390 | --port 9002 391 | 392 | if [ $NIMBUS_ENABLED != 0 ]; then 393 | # Nimbus # TODO: another eth1 node for nimbus to connect to, with websocket RPC exposed (nimbus doesn't support http rpc for eth1 connection) 394 | echo "starting nimbus beacon node" 395 | NODE_NAME=nimbus0bn 396 | mkdir -p "$TESTNET_PATH/nodes/$NODE_NAME/no_bn_keys" 397 | mkdir -p "$TESTNET_PATH/nodes/$NODE_NAME/no_bn_secrets" 398 | docker run \ 399 | --name $NODE_NAME \ 400 | --net host \ 401 | -u $(id -u):$(id -g) \ 402 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/beacondata" \ 403 | -v "$TESTNET_PATH/public/nimbus_config.json:/networkdata/nimbus_config.json" \ 404 | -v "$TESTNET_PATH/public/genesis.ssz:/networkdata/genesis.ssz" \ 405 | beacon_node \ 406 | --network="/networkdata/nimbus_config.json" \ 407 | --max-peers="{{hi_peer_count}}" \ 408 | --data-dir="/beacondata" \ 409 | --web3-url="ws://127.0.0.1:8503/ws" \ 410 | --bootstrap-node="$BOOTNODE_ENR" \ 411 | --udp-port=9003 \ 412 | --tcp-port=9003 \ 413 | --listen-address=0.0.0.0 \ 414 | --graffiti="nimbus" \ 415 | --nat="extip:127.0.0.1" \ 416 | --log-level="debug" \ 417 | --log-file="/dev/null" \ 418 | --rpc --rpc-port=4003 --rpc-address=0.0.0.0 \ 419 | --metrics --metrics-port=8003 --metrics-address=0.0.0.0 \ 420 | --validators-dir="/beacondata/no_bn_keys" \ 421 | --secrets-dir="/beacondata/no_bn_secrets" 422 | fi 423 | 424 | # validators 425 | 426 | # Prysm 427 | echo "starting Prysm validator client" 428 | NODE_NAME=prysm0vc 429 | NODE_PATH="$TESTNET_PATH/nodes/$NODE_NAME" 430 | if [ -d "$NODE_PATH" ] 431 | then 432 | echo "$NODE_NAME already has existing data" 433 | else 434 | echo "creating data for $NODE_NAME" 435 | mkdir -p "$NODE_PATH/wallet/direct/accounts" 436 | cp "$TESTNET_PATH/private/validator0/prysm/all-accounts.keystore.json" "$NODE_PATH/wallet/direct/accounts/all-accounts.keystore.json" 437 | cp "$TESTNET_PATH/private/validator0/prysm/keymanageropts.json" "$NODE_PATH/wallet/direct/keymanageropts.json" 438 | echo -n "$PRYSM_BULK_KEYSTORE_PASS" > "$NODE_PATH/wallet_pass.txt" 439 | fi 440 | 441 | docker run \ 442 | --name $NODE_NAME \ 443 | --net host \ 444 | -u $(id -u):$(id -g) \ 445 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/validatordata" \ 446 | -v "$TESTNET_PATH/public/eth2_config.yaml:/networkdata/eth2_config.yaml" \ 447 | -itd $PRYSM_VALIDATOR_IMAGE \ 448 | --accept-terms-of-use=true \ 449 | --datadir="/validatordata" \ 450 | --chain-config-file="/networkdata/eth2_config.yaml" \ 451 | --beacon-rpc-provider=localhost:4100 \ 452 | --graffiti="prysm" \ 453 | --monitoring-host=0.0.0.0 --monitoring-port=8100 \ 454 | --wallet-dir=/validatordata/wallet \ 455 | --wallet-password-file="/validatordata/wallet_pass.txt" 456 | 457 | 458 | # Teku 459 | echo "starting teku validator client" 460 | NODE_NAME=teku0vc 461 | NODE_PATH="$TESTNET_PATH/nodes/$NODE_NAME" 462 | if [ -d "$NODE_PATH" ] 463 | then 464 | echo "$NODE_NAME already has existing data" 465 | else 466 | echo "creating data for $NODE_NAME" 467 | mkdir -p "$NODE_PATH" 468 | cp -r "$TESTNET_PATH/private/validator1/teku-keys" "$NODE_PATH/keys" 469 | cp -r "$TESTNET_PATH/private/validator1/teku-secrets" "$NODE_PATH/secrets" 470 | fi 471 | 472 | docker run \ 473 | --name $NODE_NAME \ 474 | --net host \ 475 | -u $(id -u):$(id -g) \ 476 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/validatordata" \ 477 | -v "$TESTNET_PATH/public/eth2_config.yaml:/networkdata/eth2_config.yaml" \ 478 | -v "$TESTNET_PATH/public/genesis.ssz:/networkdata/genesis.ssz" \ 479 | -itd $TEKU_DOCKER_IMAGE \ 480 | validator-client \ 481 | --network "/networkdata/eth2_config.yaml" \ 482 | --data-path "/validatordata" \ 483 | --beacon-node-api-endpoint "http://127.0.0.1:4001" \ 484 | --validators-graffiti="teku" \ 485 | --validator-keys "/validatordata/keys:/validatordata/secrets" 486 | 487 | 488 | # Lighthouse 489 | echo "starting lighthouse validator client" 490 | NODE_NAME=lighthouse0vc 491 | NODE_PATH="$TESTNET_PATH/nodes/$NODE_NAME" 492 | if [ -d "$NODE_PATH" ] 493 | then 494 | echo "$NODE_NAME already has existing data" 495 | else 496 | echo "creating data for $NODE_NAME" 497 | mkdir -p "$NODE_PATH" 498 | cp -r "$TESTNET_PATH/private/validator2/keys" "$NODE_PATH/keys" 499 | cp -r "$TESTNET_PATH/private/validator2/secrets" "$NODE_PATH/secrets" 500 | fi 501 | 502 | docker run \ 503 | --name $NODE_NAME \ 504 | --net host \ 505 | -u $(id -u):$(id -g) \ 506 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/validatordata" \ 507 | -v "$TESTNET_PATH/public/eth2_config.yaml:/networkdata/eth2_config.yaml" \ 508 | -v "$TESTNET_PATH/public/genesis.ssz:/networkdata/genesis.ssz" \ 509 | -itd $LIGHTHOUSE_DOCKER_IMAGE \ 510 | lighthouse \ 511 | --testnet-deposit-contract-deploy-block 0 \ 512 | --testnet-genesis-state "/networkdata/genesis.ssz" \ 513 | --testnet-yaml-config "/networkdata/eth2_config.yaml" \ 514 | validator_client \ 515 | --init-slashing-protection \ 516 | --beacon-nodes "http://127.0.0.1:4002" \ 517 | --graffiti="lighthouse" \ 518 | --validators-dir "/validatordata/keys" \ 519 | --secrets-dir "/validatordata/secrets" 520 | 521 | 522 | # Nimbus 523 | if [ $NIMBUS_ENABLED != 0 ]; then # TODO enable nimbus 524 | echo "starting Nimbus validator client" 525 | NODE_NAME=nimbus0vc 526 | NODE_PATH="$TESTNET_PATH/nodes/$NODE_NAME" 527 | if [ -d "$NODE_PATH" ] 528 | then 529 | echo "$NODE_NAME already has existing data" 530 | else 531 | echo "creating data for $NODE_NAME" 532 | mkdir -p "$NODE_PATH" 533 | cp -r "$TESTNET_PATH/private/validator3/nimbus-keys" "$NODE_PATH/keys" 534 | cp -r "$TESTNET_PATH/private/validator3/secrets" "$NODE_PATH/secrets" 535 | fi 536 | 537 | docker run \ 538 | --name $NODE_NAME \ 539 | --net host \ 540 | -u $(id -u):$(id -g) \ 541 | -v "$TESTNET_PATH/nodes/$NODE_NAME:/validatordata" \ 542 | -itd $NIMBUS_DOCKER_IMAGE \ 543 | validator_client \ 544 | --log-level="debug" \ 545 | --log-file="/dev/null" \ 546 | --data-dir="/validatordata" \ 547 | --non-interactive=true \ 548 | --graffiti="nimbus" \ 549 | --rpc-port=4003 \ 550 | --rpc-address=127.0.0.1 \ 551 | --validators-dir="/validatordata/keys" \ 552 | --secrets-dir="/validatordata/secrets" 553 | fi 554 | 555 | echo "Setting up fork monitor" 556 | 557 | # Fork monitor setup 558 | SLOTS_PER_EPOCH=32 559 | SECONDS_PER_SLOT=12 560 | ETH2_MIN_GENESIS_ACTIVE_VALIDATOR_COUNT=16384 561 | if [ "$ETH2_SPEC_VARIANT" == "minimal" ]; then 562 | SLOTS_PER_EPOCH=8 563 | SECONDS_PER_SLOT=6 564 | ETH2_MIN_GENESIS_ACTIVE_VALIDATOR_COUNT=64 565 | fi 566 | 567 | NODE_NAME=forkmon0 568 | NODE_PATH="$TESTNET_PATH/nodes/$NODE_NAME" 569 | mkdir -p "$NODE_PATH" 570 | cat > "$NODE_PATH/config.yaml" << EOT 571 | # disabled 572 | weak_subjectivity_provider_endpoint: "" 573 | # disabled 574 | etherscan_api_key: "" 575 | http_timeout_milliseconds: 2000 576 | endpoints: 577 | # Prysm 578 | - addr: http://127.0.0.1:4000 579 | eth1: Geth 580 | # Teku 581 | - addr: http://127.0.0.1:4001 582 | eth1: Nethermind 583 | # Lighthouse 584 | - addr: http://127.0.0.1:4002 585 | eth1: Besu 586 | # Dir for web assets 587 | outputDir: /public 588 | eth2: 589 | seconds_per_slot: ${SECONDS_PER_SLOT} 590 | genesis_time: ${ETH2_GENESIS_TIMESTAMP} 591 | slots_per_epoch: ${SLOTS_PER_EPOCH} 592 | network: Local 593 | EOT 594 | 595 | docker run \ 596 | --name $NODE_NAME \ 597 | --net host \ 598 | -u $(id -u):$(id -g) \ 599 | -v "$NODE_PATH:/data" \ 600 | -itd $FORKMON_IMAGE \ 601 | -config-file=/data/config.yaml 602 | 603 | echo "fork monitor running at: http://127.0.0.1:8080/" 604 | 605 | 606 | echo "Setting up postgres database for explorer" 607 | NODE_NAME=postgres0 608 | NODE_PATH="$TESTNET_PATH/nodes/$NODE_NAME" 609 | mkdir -p "$NODE_PATH" 610 | # Run the database in the background 611 | docker run \ 612 | --name $NODE_NAME \ 613 | --net host \ 614 | -e POSTGRES_PASSWORD=pass \ 615 | -e POSTGRES_USER=postgres \ 616 | -e POSTGRES_PORT=5432 \ 617 | -e POSTGRES_DB=db \ 618 | -e PGDATA=/postgresql/data \ 619 | -u $(id -u):$(id -g) \ 620 | -v "$NODE_PATH:/postgresql/data" \ 621 | -itd $POSTGRES_IMAGE 622 | 623 | # Wait for postgres docker container to get online 624 | sleep 5 625 | 626 | echo "Initializing the postgres tables..." 627 | docker run -it --rm \ 628 | --net=host \ 629 | -u $(id -u):$(id -g) \ 630 | -v "$EXPLORER_TABLES_SQL_PATH:/src/tables.sql" \ 631 | -it $POSTGRES_IMAGE \ 632 | psql -f /src/tables.sql -d db -h 0.0.0.0 -p 5432 -U postgres 633 | 634 | 635 | echo "Setting up explorer" 636 | 637 | NODE_NAME=explorer0 638 | NODE_PATH="$TESTNET_PATH/nodes/$NODE_NAME" 639 | mkdir -p "$NODE_PATH" 640 | cat > "$NODE_PATH/imprint.html" << EOT 641 | {{ define "js"}} 642 | {{end}} 643 | 644 | {{ define "css"}} 645 | {{end}} 646 | 647 | {{ define "content"}} 648 | {{with .Data}} 649 |