prysm-pulse/k8s
Raul Jordan eb900a8193
Refactor Initial Sync, Enable Catching Up to Chain (#2111)
* refactor initial sync to prevent reorg infinite loops

* lint

* fixed build

* passing tests

* tests passing

* terence suggestion

* new attempt

* clean up and refactor sync service

* complete the new initial sync logic

* revert head

* init sync working

* config for blockchain receive block

* all works

* builds

* fix a few more tests

* init sync tests pass

* revert scripts

* revert accounts changes

* lint

* lint2

* travis lint

* fix build

* fix single use argument

* any peer

* imports spacing

* imports

* ready for a rolling restart

* add todo

* fork choice in blocks when exiting sync

* readd finalized state root to requests

* successful build

* revert blockchain config

* old config reversion

* initial sync tests pass

* initial sync full test works

* lint

* use the new block processing api

* new proto defs

* init sync functions again

* remove sync polling

* tests fixed

* fixed catching up with chain

* tests pass

* spacing

* lint

* goimports

* add changes

* add lock and conditional to prevent multiple goroutines

* make reg sync synchronous

* add

* fixed the parent block issue

* fix errors in chain service

* tests pass

* check nil block

* typo

* fix nil state

* merge & conflicts

* revert synchronus reg sync

* add more spans to state db

* fix lint

* lint
2019-04-03 10:13:19 -05:00
..
beacon-chain Refactor Initial Sync, Enable Catching Up to Chain (#2111) 2019-04-03 10:13:19 -05:00
geth Faucet enhancements + cluster private key management system (#1679) 2019-03-07 11:14:57 -05:00
monitoring Faucet enhancements + cluster private key management system (#1679) 2019-03-07 11:14:57 -05:00
tools Kubernetes - Part 3 of ?? (#981) 2018-11-28 00:27:21 -05:00
BUILD.bazel Faucet enhancements + cluster private key management system (#1679) 2019-03-07 11:14:57 -05:00
letsencrypt-issuer.yaml k8s goerli config (#1517) 2019-02-08 15:30:38 -05:00
priority.yaml Kubernetes - Part 1 of ?? (#348) 2018-07-30 10:04:47 -04:00
prylabs-wildcard-gateway.yaml Faucet enhancements + cluster private key management system (#1679) 2019-03-07 11:14:57 -05:00
README.md Update References to Deposit Contract, Update Flags (#1576) 2019-02-13 13:08:28 -06:00

Kubernetes Configuration for Ethereum Serenity

Requirements

  • Kubernetes v1.11+ (for PriorityClass)
  • Minikube (for now)

Starting minikube with v1.11

As of minikube 0.28.2, the default version of kubernetes is 1.10.0. In order to start a local cluster with v1.11.0, run the following:

minikube start --kubernetes-version=v1.11.0 --cpus 4

Istio

Be sure to update the loadBalancerIP and includeIPRanges as needed. Refer to this guide if necessary.

First download the release

curl -L https://git.io/getLatestIstio | sh -
helm install install/kubernetes/helm/istio --name istio --namespace istio-system --set grafana.enabled=true --set tracing.enabled=true --set gateways.istio-ingressgateway.loadBalancerIP=35.224.249.2 --set global.proxy.includeIPRanges="10.52.0.0/14\,10.55.240.0/20" --set kiali.enabled=true --set telemetry-gateway.grafanaEnabled=true 

Geth's Genesis file

This file is the default provided by geth-genesis secret.

{                                                                               
    "config": {                                                                 
        "chainId": 1337,                                                        
        "homesteadBlock": 0,                                                    
        "eip155Block": 0,                                                       
        "eip158Block": 0                                                        
    },                                                                          
    "difficulty": "0x0",                                                      
    "gasLimit": "0x2100000",                                                    
    "alloc": {                                                                  
       "717c3a6e4cbd476c2312612155eb233bf498dd5b":                              
         { "balance": "0x1337000000000000000000" }                             
    }                                                                           
}

The private key for the allocation above is:

783da8ef5343c3019748506305d400bca8c324a5819f3a7f7fbf0c0a0d799b09

NOTE: Obviously, do not use this wallet key for anything with real money on it!

To update the genesis secret, change value in geth/genesis.secret.yaml to the base64 encoded string for the genesis.json.

Example:

cat /tmp/genesis.json | json-minify | base64

Deploying Geth Mainchain

First, launch the bootnode so that geth nodes can discover each other.

bazel run //k8s/geth:bootnode.deploy.apply

Then launch everything else.

bazel run //k8s:everything.apply

This creates a few nodes and one miner with CPU restrictions. After ~30 minutes, the miner has generated the DAG and begins mining. The miners have a stateful volume for their DAGs so that they do not have to regenerate them on restart.

Note: DAG generation time can be improved by giving the miner more CPU in the deployment yaml.

Bootstrapping the Beacon Chain

TODO: This process is currently manual and needs to be improved!

Using the private key above and the deployContract tool, deploy the validator registration contract.

# get the address the node service
minikube service geth-nodes --url

Example response:

http://192.168.99.100:30051
http://192.168.99.100:31745

Using the first port provided (RPC). Run the deployContract tool

bazel run //contracts/deposit-contract/deployContract --\
  --privKey=783da8ef5343c3019748506305d400bca8c324a5819f3a7f7fbf0c0a0d799b09 \
  --httpPath=http://192.168.99.100:30051

Example output:

INFO main: New contract deployed address=0x541AfaC5266c534de039B4A1a53519e76ea82846

Set this value for the deposit contract addr flag in k8s/beacon-chain/beacon-chain.deploy.yaml.

Ensure that the beacon-chain and client docker images are up to date.

bazel run //beacon-chain:push_image
bazel run //client:push_image

Start the beacon chain nodes

bazel run //k8s/beacon-chain:everything.apply

Start the clients

bazel run //k8s/client:everything.apply

Accessing Geth Services

Check out the ethstats dashboard by querying minikube for the service URL.

minikube service geth-ethstats --url

Accessing the geth nodes.

minikube service geth-nodes --url

# Example output
http://192.168.99.100:30451
http://192.168.99.100:32164

The first URL will be the rpc endpoint and the second URL will be the websocket endpoint.

So we can use these values locally to connect to our local cluster.

bazel run //beacon-chain -- --web3provider=ws://192.168.99.100:32164