2018-11-01 11:02:01 +00:00
# Prysmatic Labs Ethereum Serenity Implementation
2018-03-06 03:20:36 +00:00
2018-10-04 01:16:44 +00:00
[![Build status ](https://badge.buildkite.com/b555891daf3614bae4284dcf365b2340cefc0089839526f096.svg )](https://buildkite.com/prysmatic-labs/prysm)
2018-03-06 03:24:11 +00:00
2018-11-01 11:02:01 +00:00
This is the main repository for the beacon chain and sharding implementation for Ethereum Serenity [Prysmatic Labs ](https://prysmaticlabs.com ).
2015-07-28 22:16:16 +00:00
2018-08-08 12:01:24 +00:00
Before you begin, check out our [Contribution Guidelines ](#contributing ) and join our active chat room on Discord or Gitter below:
2018-01-15 17:41:27 +00:00
2018-08-08 12:01:24 +00:00
[![Discord ](https://user-images.githubusercontent.com/7288322/34471967-1df7808a-efbb-11e7-9088-ed0b04151291.png )](https://discord.gg/KSA7rPr)
2018-07-22 12:36:13 +00:00
[![Gitter ](https://badges.gitter.im/Join%20Chat.svg )](https://gitter.im/prysmaticlabs/geth-sharding?utm_source=badge& utm_medium=badge& utm_campaign=pr-badge)
2018-01-15 17:41:27 +00:00
2018-09-02 02:25:06 +00:00
Also, read our [Sharding Reference Implementation Doc ](https://github.com/prysmaticlabs/prysm/blob/master/docs/SHARDING.md ). This doc provides a background on the sharding implementation we follow at Prysmatic Labs.
2018-05-29 22:26:13 +00:00
2018-03-06 03:20:36 +00:00
# Table of Contents
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
- [Running Our Demo Release ](#running-our-demo-release )
- [Installation ](#installation )
- [Run Our Pre-Compiled Binaries ](#run-our-pre-compiled-binaries )
- [Run Via Bazel (Recommended) ](#run-via-bazel-recommended )
- [Running The Beacon Chain ](#running-the-beacon-chain )
- [Running an ETH2.0 Validator Client ](#running-an-eth2.0-validator-client )
- [Running Via Docker ](#running-via-docker )
2018-11-01 10:59:52 +00:00
- [Running Under Windows ](#running-under-windows )
2018-03-06 03:20:36 +00:00
- [Testing ](#testing )
2018-05-29 22:26:13 +00:00
- [Contributing ](#contributing )
2018-03-06 03:20:36 +00:00
- [License ](#license )
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
# Running Our Demo Release
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
To run our current release, v0.0.0, as a local demo, you'll need to run a beacon chain node and a validator client.
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
In this local demo, you can start a beacon chain from genesis, connect as a validator client through a public key, and propose/vote on beacon blocks during each cycle. For more information on the full scope of the public demo, see the demo information [here ](https://github.com/prysmaticlabs/prysm/blob/master/docs/DEMO_INFORMATION.md ).
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
## Installation
2018-07-18 02:17:54 +00:00
2018-10-03 03:54:35 +00:00
You can either choose to run our system via:
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
- Downloading our Precompiled Binaries from our latest [release ](https://github.com/prysmaticlabs/prysm/releases )
- Use Docker
- Use Our Build Tool, Bazel ** (Recommended)**
## Run Our Pre-Compiled Binaries
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
First, download our latest [release ](https://github.com/prysmaticlabs/prysm/releases ) for your operating system. Then:
2018-01-15 17:41:27 +00:00
2018-03-05 20:50:34 +00:00
```
2018-10-03 03:54:35 +00:00
chmod +x ./beacon-chain
chmod +x ./validator
2018-03-05 20:50:34 +00:00
```
2018-02-19 02:03:41 +00:00
2018-10-03 03:54:35 +00:00
## Run Via Bazel (Recommended)
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
First, clone our repository:
2018-03-06 02:14:39 +00:00
```
2018-10-03 03:54:35 +00:00
git clone https://github.com/prysmaticlabs/prysm
2018-08-15 01:21:49 +00:00
```
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
Download the Bazel build tool by Google [here ](https://docs.bazel.build/versions/master/install.html ) and ensure it works by typing:
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
```
bazel version
```
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
Bazel manages all of the dependencies for you (including go and necessary compilers) so you are all set to build prysm.
2018-01-15 17:41:27 +00:00
2018-07-12 17:12:11 +00:00
2018-10-03 03:54:35 +00:00
### Building
2018-07-12 17:12:11 +00:00
2018-10-03 03:54:35 +00:00
Then, build both parts of our system: a beacon chain node implementation, and a validator client:
2018-07-12 17:12:11 +00:00
```
2018-08-21 15:57:05 +00:00
bazel build //beacon-chain:beacon-chain
2018-08-22 19:15:21 +00:00
bazel build //validator:validator
2018-07-12 17:12:11 +00:00
```
2018-03-05 20:50:34 +00:00
2018-10-03 03:54:35 +00:00
## Running The Beacon Chain
2018-08-15 01:21:49 +00:00
2019-01-09 03:03:57 +00:00
To start the system, you will need a special data directory where all the beacon chain data will be persisted to.
2018-10-03 17:54:43 +00:00
Then, you can run the node as follows:
2018-08-15 01:21:49 +00:00
2018-10-03 03:54:35 +00:00
With the binary executable:
2018-08-15 01:21:49 +00:00
```
2018-10-03 03:54:35 +00:00
./beacon-chain \
2018-08-15 01:21:49 +00:00
--datadir /path/to/your/datadir \
2018-08-20 15:50:11 +00:00
--rpc-port 4000 \
2018-11-30 08:15:39 +00:00
--demo-config \
--p2p-port 9000
2018-08-15 01:21:49 +00:00
```
2018-03-06 03:20:36 +00:00
2018-10-03 03:54:35 +00:00
With bazel:
2018-01-15 17:41:27 +00:00
```
2018-08-15 01:21:49 +00:00
bazel run //beacon-chain --\
--datadir /path/to/your/datadir \
2018-08-16 23:20:52 +00:00
--rpc-port 4000 \
2018-11-30 08:15:39 +00:00
--demo-config \
--p2p-port 9000
2018-01-15 17:41:27 +00:00
```
2018-08-15 01:21:49 +00:00
2018-10-03 03:54:35 +00:00
We also have a `--demo-config` flag that configures some internal parameters for you to run a local demo version of the system.
2018-08-20 15:50:11 +00:00
2018-10-03 17:54:43 +00:00
If you want to see what's happening in the system underneath the hood, add a `--verbosity debug` flag to show every single thing the beacon chain node does during its run time. If you want to rerun the beacon chain, delete and create a new data directory for the system to start from scratch.
2018-08-20 15:50:11 +00:00
2018-10-03 03:54:35 +00:00
![beaconsystem ](https://i.imgur.com/vsUfLFu.png )
2018-08-21 15:57:05 +00:00
2018-10-03 03:54:35 +00:00
## Running an ETH2.0 Validator Client
2018-08-20 15:50:11 +00:00
2018-10-03 03:54:35 +00:00
Once your beacon node is up, you'll need to attach a validator client as a separate process. This validator is in charge of running Casper+Sharding responsibilities (shard state execution to be designed in phase 2). This validator will listen for incoming beacon blocks and shard assignments and determine when its time to perform attester/proposer responsibilities accordingly.
2018-08-20 15:50:11 +00:00
2018-10-03 03:54:35 +00:00
To get started, you'll need to use a public key from the initial validator set of the beacon node. Here are a few you can try out:
```
2019-01-09 03:03:57 +00:00
bc36789e7a1e281436464229828f817d6612f7b477d66591ff96a9e064bcc98a
5fe7f977e71dba2ea1a68e21057beebb9be2ac30c6410aa38d4f3fbe41dcffd2
f2ee15ea639b73fa3db9b34a245bdfa015c260c598b211bf05a1ecc4b3e3b4f2
69c322e3248a5dfc29d73c5b0553b0185a35cd5bb6386747517ef7e53b15e287
f343681465b9efe82c933c3e8748c70cb8aa06539c361de20f72eac04e766393
dbb8d0f4c497851a5043c6363657698cb1387682cac2f786c731f8936109d795
d0591206d9e81e07f4defc5327957173572bcd1bca7838caa7be39b0c12b1873
ee2a4bc7db81da2b7164e56b3649b1e2a09c58c455b15dabddd9146c7582cebc
d33e25809fcaa2b6900567812852539da8559dc8b76a7ce3fc5ddd77e8d19a69
b2e7b7a21d986ae84d62a7de4a916f006c4e42a596358b93bad65492d174c4ff
2018-10-03 03:54:35 +00:00
```
2018-01-15 17:41:27 +00:00
2018-08-15 01:21:49 +00:00
Run as follows:
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
With the binary executable:
```
./validator \
--beacon-rpc-provider http://localhost:4000 \
2018-10-03 19:33:29 +00:00
--datadir /path/to/uniquevalidatordatadir \
2019-01-09 03:03:57 +00:00
--pubkey f2ee15ea639b73fa3db9b34a245bdfa015c260c598b211bf05a1ecc4b3e3b4f2
2018-10-03 03:54:35 +00:00
```
With Bazel:
2018-01-15 17:41:27 +00:00
```
2018-08-22 19:15:21 +00:00
bazel run //validator --\
2018-08-15 01:21:49 +00:00
--beacon-rpc-provider http://localhost:4000 \
2018-10-03 19:33:29 +00:00
--datadir /path/to/uniquevalidatordatadir \
2019-01-09 03:03:57 +00:00
--pubkey f2ee15ea639b73fa3db9b34a245bdfa015c260c598b211bf05a1ecc4b3e3b4f2
2018-01-15 17:41:27 +00:00
```
2018-03-05 20:53:25 +00:00
2018-01-15 17:41:27 +00:00
2018-10-03 03:54:35 +00:00
This will connect you to your running beacon node and listen for shard/slot assignments! The beacon node will update you at every cycle transition and shuffle your validator into different shards and slots in order to vote on or propose beacon blocks.
2018-07-22 17:31:43 +00:00
2018-10-03 19:33:29 +00:00
if you want to run multiple validator clients, **each one needs to have its own data directory where it will persist information, so create a new one each time** and pass it into the validator command with the flag `--datadir /path/to/validatordatadir` .
2018-10-03 17:54:43 +00:00
2018-10-03 03:54:35 +00:00
## Running Via Docker
2018-07-22 17:31:43 +00:00
2018-10-03 03:54:35 +00:00
```
2019-01-09 03:03:57 +00:00
docker run -p 4000:4000 -v gcr.io/prysmaticlabs/prysm/beacon-chain:latest \
2018-10-03 03:54:35 +00:00
--rpc-port 4000 \
2018-11-30 08:15:39 +00:00
--demo-config \
--p2p-port 9000
2018-10-03 03:54:35 +00:00
```
Then, to run a validator client, use:
2018-07-22 17:31:43 +00:00
```
2018-10-03 03:54:35 +00:00
docker run gcr.io/prysmaticlabs/prysm/validator:latest \
--beacon-rpc-provider http://{YOUR_LOCAL_IP}:4000 \
2019-01-09 03:03:57 +00:00
--pubkey f2ee15ea639b73fa3db9b34a245bdfa015c260c598b211bf05a1ecc4b3e3b4f2
2018-10-03 03:54:35 +00:00
```
This will connect you to your running beacon node and listen for shard/slot assignments! The beacon node will update you at every cycle transition and shuffle your validator into different shards and slots in order to vote on or propose beacon blocks.
## Running While Connected to a Mainchain Ethereum 1.0 Node
2018-07-22 17:31:43 +00:00
2018-10-03 03:54:35 +00:00
If you want to run the system with a real Web3 endpoint to listen for incoming Ethereum 1.0 block hashes, follow the instructions on setting up a geth node [here ](https://github.com/prysmaticlabs/prysm/blob/master/docs/MAINCHAIN.md ).
2018-07-22 17:31:43 +00:00
2018-11-01 10:59:52 +00:00
## Running Under Windows
The best way to run under Windows is to clone the repository and then run the node with go run from the Windows command line. Go 1.10 fails due to documented permission errors so be sure you are running Go 1.11 or later. Go through the source code and resolve any dependencies. Create two empty files for use as data directories by the beacon chain and validator respectively. The contents of these files should be deleted each time you run the software. After cloning the Prsym repository, run the node as follows:
```
go run ./beacon-chain main.go \
--datadir /path/to/your/datadir \
--rpc-port 4000 \
2018-11-30 08:15:39 +00:00
--demo-config \
--p2p-port 9000
2018-11-01 10:59:52 +00:00
```
After the beacon chain is up and running, run the validator client as a separate process as follows:
```
go run ./validator/main.go \
--beacon-rpc-provider http://localhost:4000 \
--datadir /path/to/uniquevalidatordatadir \
2019-01-09 03:03:57 +00:00
--pubkey f2ee15ea639b73fa3db9b34a245bdfa015c260c598b211bf05a1ecc4b3e3b4f2
2018-11-01 10:59:52 +00:00
```
2018-07-22 17:31:43 +00:00
2018-03-06 03:20:36 +00:00
# Testing
2018-01-15 17:41:27 +00:00
2018-03-05 20:50:34 +00:00
To run the unit tests of our system do:
2018-01-15 17:41:27 +00:00
```
2018-08-15 01:21:49 +00:00
bazel test //...
2018-01-15 17:41:27 +00:00
```
2018-10-03 03:54:35 +00:00
To run our linter, make sure you have [gometalinter ](https://github.com/alecthomas/gometalinter ) installed and then run:
2018-07-12 17:12:11 +00:00
```
2018-08-15 01:21:49 +00:00
gometalinter ./...
2018-07-12 17:12:11 +00:00
```
2018-01-15 17:41:27 +00:00
2018-05-29 22:26:13 +00:00
# Contributing
2018-01-15 17:41:27 +00:00
2018-09-02 02:25:06 +00:00
We have put all of our contribution guidelines into [CONTRIBUTING.md ](https://github.com/prysmaticlabs/prysm/blob/master/CONTRIBUTING.md )! Check it out to get started.
2018-01-15 17:41:27 +00:00
2018-05-29 22:26:13 +00:00
![nyancat ](https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcRBSus2ozk_HuGdHMHKWjb1W5CmwwoxmYIjIBmERE1u-WeONpJJXg )
2018-03-06 03:20:36 +00:00
# License
2018-01-15 17:41:27 +00:00
2018-07-12 17:12:11 +00:00
[GNU General Public License v3.0 ](https://www.gnu.org/licenses/gpl-3.0.en.html )