prysm

module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 22, 2019 License: GPL-3.0

README

Prysm: Ethereum 'Serenity' 2.0 Go Implementation

Build status ETH2.0_Spec_Version 0.8.1 Discord Gitter

This is the Core repository for Prysm, Prysmatic Labs' Go implementation of the Ethereum protocol 2.0 (Serenity).

Need assistance?

A more detailed set of installation and usage instructions as well as explanations of each component are available on our official documentation portal. If you still have questions, feel free to stop by either our Discord or Gitter and a member of the team or our community will be happy to assist you.

Interested in what's next? Be sure to read our Roadmap Reference Implementation document. This page outlines the basics of sharding as well as the various short-term milestones that we hope to achieve over the coming year.

Come join the testnet!

Participation is now open to the public in our testnet release for Ethereum 2.0 phase 0. Visit prylabs.net for more information on the project itself or to sign up as a validator on the network.

Table of Contents

Dependencies

Prysm can be installed either with Docker (recommended method) or using our build tool, Bazel. The below instructions include sections for performing both.

For Docker installations:

  • The latest release of Docker

For Bazel installations:

  • The latest release of Bazel
  • A modern UNIX operating system (MacOS included)

Installation

Build via Docker
  1. Ensure you are running the most recent version of Docker by issuing the command:
docker -v
  1. To pull the Prysm images from the server, issue the following commands:
docker pull gcr.io/prysmaticlabs/prysm/validator:latest
docker pull gcr.io/prysmaticlabs/prysm/beacon-chain:latest

This process will also install any related dependencies.

Build via Bazel
  1. Open a terminal window. Ensure you are running the most recent version of Bazel by issuing the command:
bazel version
  1. Clone this repository and enter the directory:
git clone https://github.com/prysmaticlabs/prysm
cd prysm
  1. Build both the beacon chain node implementation and the validator client:
bazel build //beacon-chain:beacon-chain
bazel build //validator:validator

Bazel will automatically pull and install any dependencies as well, including Go and necessary compilers.

Note that to build with the appropriate configuration for the Prysm testnet you should run:

bazel build --define ssz=minimal //beacon-chain:beacon-chain
bazel build --define ssz=minimal //validator:validator

The binaries will be created in an architecture-dependent subdirectory of bazel-bin and this information is supplied as part of bazel's build process. For example:

$ bazel build --define ssz=minimal //beacon-chain:beacon-chain
...
Target //beacon-chain:beacon-chain up-to-date:
  bazel-bin/beacon-chain/linux_amd64_stripped/beacon-chain
...

Here it can be seen the beacon chain binary has been created at bazel-bin/beacon-chain/linux_amd64_stripped/beacon-chain

Running an Ethereum 2.0 Beacon Node

To understand the role that both the beacon node and validator play in Prysm, see this section of our documentation.

Running via Docker

Docker on Linux/Mac:

To start your beacon node, issue the following command:

docker run -v $HOME/prysm-data:/data -p 4000:4000 \
  gcr.io/prysmaticlabs/prysm/beacon-chain:latest \
  --name beacon-node \
  --datadir=/data

You can stop the beacon node using Ctrl+c or with the following command:

docker stop beacon-node

Then it can be restarted again with

docker start -ai beacon-node

If you run into issues you can always delete the container like this:

docker rm beacon-node

and re-create it again and even reset the chain database adding the parameter --clear-db as specified here:

docker run -it -v $HOME/prysm-data:/data -p 4000:4000 \
  gcr.io/prysmaticlabs/prysm/beacon-chain:latest \
  --name beacon-node \
  --datadir=/data \
  --clear-db

Docker on Windows:

  1. You will need to share the local drive you wish to mount to to container (e.g. C:).

    1. Enter Docker settings (right click the tray icon)
    2. Click 'Shared Drives'
    3. Select a drive to share
    4. Click 'Apply'
  2. You will next need to create a directory named /tmp/prysm-data/ within your selected shared Drive. This folder will be used as a local data directory for Beacon Node chain data as well as account and keystore information required by the validator. Docker will not create this directory if it does not exist already. For the purposes of these instructions, it is assumed that C: is your prior-selected shared Drive.

  3. To run the beacon node, issue the following command:

docker run -it -v c:/tmp/prysm-data:/data -p 4000:4000 gcr.io/prysmaticlabs/prysm/beacon-chain:latest --datadir=/data --clear-db
Running via Bazel
  1. To start your Beacon Node with Bazel, issue the following command:
bazel run //beacon-chain -- --clear-db --datadir=/tmp/prysm-data

This will sync up the Beacon Node with the latest head block in the network.

Staking ETH: Running a Validator Client

Once your beacon node is up and completely synced (otherwise you will lose validator funds since the validator will not be able to operate), the chain will be waiting for you to deposit 3.2 Goerli ETH into the Validator Deposit Contract to activate your validator (discussed in the section below). First though, you will need to create a validator client to connect to this node in order to stake and participate. Each validator represents 3.2 Goerli ETH being staked in the system, and it is possible to spin up as many as you desire in order to have more stake in the network.

Activating Your Validator: Depositing 3.2 Goerli ETH

Using your validator deposit data from the previous step, follow the instructions found on https://prylabs.net/participate to make a deposit.

It will take a while for the nodes in the network to process your deposit, but once your node is active, the validator will begin doing its responsibility. In your validator client, you will be able to frequently see your validator balance as it goes up over time. Note that, should your node ever go offline for a long period, you'll start gradually losing your deposit until you are removed from the system.

Starting the validator with Bazel
  1. Open another terminal window. Enter your Prysm directory and run the validator by issuing the following command:
cd prysm
bazel run //validator

Congratulations, you are now running Ethereum 2.0 Phase 0!

Testing Prysm

To run the unit tests of our system, issue the command:

bazel test //...

To run our linter, make sure you have golangci-lint installed and then issue the command:

golangci-lint run

Contributing

We have put all of our contribution guidelines into CONTRIBUTING.md! Check it out to get started.

License

GNU General Public License v3.0

Directories

Path Synopsis
Package beacon-chain defines all the utilities needed for a beacon chain node.
Package beacon-chain defines all the utilities needed for a beacon chain node.
blockchain
Package blockchain defines the life-cycle and status of the beacon chain as well as the Ethereum Serenity beacon chain fork-choice rule based on Casper Proof of Stake finality.
Package blockchain defines the life-cycle and status of the beacon chain as well as the Ethereum Serenity beacon chain fork-choice rule based on Casper Proof of Stake finality.
blockchain/forkchoice
Package forkchoice implements the Latest Message Driven GHOST (Greediest Heaviest Observed Sub-Tree) algorithm as the Ethereum Serenity beacon chain fork choice rule.
Package forkchoice implements the Latest Message Driven GHOST (Greediest Heaviest Observed Sub-Tree) algorithm as the Ethereum Serenity beacon chain fork choice rule.
core/blocks
Package blocks contains block processing libraries.
Package blocks contains block processing libraries.
core/epoch
Package epoch contains epoch processing libraries.
Package epoch contains epoch processing libraries.
core/helpers
Package helpers contains helper functions outlined in ETH2.0 spec beacon chain spec
Package helpers contains helper functions outlined in ETH2.0 spec beacon chain spec
core/state
Package state implements the whole state transition function which consists of per slot, per-epoch transitions.
Package state implements the whole state transition function which consists of per slot, per-epoch transitions.
core/validators
Package validators contains libraries to shuffle validators and retrieve active validator indices from a given slot or an attestation.
Package validators contains libraries to shuffle validators and retrieve active validator indices from a given slot or an attestation.
db
db/filters
Package filters specifies utilities for building a set of data attribute filters to be used when filtering data through database queries in practice.
Package filters specifies utilities for building a set of data attribute filters to be used when filtering data through database queries in practice.
node
Package node defines the services that a beacon chain node would perform.
Package node defines the services that a beacon chain node would perform.
operations
Package operations defines the life-cycle of beacon block operations.
Package operations defines the life-cycle of beacon block operations.
p2p
Package p2p implements the Ethereum 2.0 networking specification.
Package p2p implements the Ethereum 2.0 networking specification.
p2p/encoder
Package encoder allows for registering custom data encoders for information sent as raw bytes over the wire via p2p to other nodes.
Package encoder allows for registering custom data encoders for information sent as raw bytes over the wire via p2p to other nodes.
powchain
Package powchain defines the services that interact with the ETH1.0 of Ethereum.
Package powchain defines the services that interact with the ETH1.0 of Ethereum.
rpc
Package rpc defines the services that the beacon-chain uses to communicate via gRPC.
Package rpc defines the services that the beacon-chain uses to communicate via gRPC.
rpc/testing
Package internal is a generated GoMock package.
Package internal is a generated GoMock package.
sync
Package sync TODO(3147): Add details on how sync works.
Package sync TODO(3147): Add details on how sync works.
sync/peerstatus
Package peerstatus is a threadsafe global cache to store recent peer status messages for access across multiple services.
Package peerstatus is a threadsafe global cache to store recent peer status messages for access across multiple services.
contracts
proto
beacon/rpc/v1_gateway
Package ethereum_beacon_rpc_v1 is a reverse proxy.
Package ethereum_beacon_rpc_v1 is a reverse proxy.
bls
Package bls implements a go-wrapper around a library implementing the the BLS12-381 curve and signature scheme.
Package bls implements a go-wrapper around a library implementing the the BLS12-381 curve and signature scheme.
bytesutil
Package bytesutil defines helper methods for converting integers to byte slices.
Package bytesutil defines helper methods for converting integers to byte slices.
cmd
Package cmd defines the command line flags for the shared utlities.
Package cmd defines the command line flags for the shared utlities.
debug
Package debug defines useful profiling utils that came originally with go-ethereum.
Package debug defines useful profiling utils that came originally with go-ethereum.
featureconfig
Package featureconfig defines which features are enabled for runtime in order to selctively enable certain features to maintain a stable runtime.
Package featureconfig defines which features are enabled for runtime in order to selctively enable certain features to maintain a stable runtime.
logutil
Package logutil creates a Multi writer instance that write all logs that are written to stdout.
Package logutil creates a Multi writer instance that write all logs that are written to stdout.
mclockutil
Package mclockutil is a wrapper for a monotonic clock source
Package mclockutil is a wrapper for a monotonic clock source
mock
Package mock_p2p is a generated GoMock package.
Package mock_p2p is a generated GoMock package.
params
Package params defines important constants that are essential to the Ethereum 2.0 services.
Package params defines important constants that are essential to the Ethereum 2.0 services.
roughtime
Package roughtime is a wrapper for a roughtime clock source
Package roughtime is a wrapper for a roughtime clock source
sliceutil
Package sliceutil implements set operations for specified data type
Package sliceutil implements set operations for specified data type
testutil
Package testutil defines the testing utils such as asserting logs.
Package testutil defines the testing utils such as asserting logs.
Package slasher defines the service used to retrieve slashings proofs.
Package slasher defines the service used to retrieve slashings proofs.
db
rpc
tools
*
bootnode-query
Bootstrap / DHT query tool
Bootstrap / DHT query tool
*
enr-calculator
This binary is a simple rest API endpoint to calculate the ENR value of a node given its private key,ip address and port.
This binary is a simple rest API endpoint to calculate the ENR value of a node given its private key,ip address and port.
eth1exporter
Prometheus exporter for Ethereum address balances.
Prometheus exporter for Ethereum address balances.
*
interop/convert-keys
Used for converting keys.yaml files from eth2.0-pm for interop testing.
Used for converting keys.yaml files from eth2.0-pm for interop testing.
*
This code was adapted from https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/usage.go
This code was adapted from https://github.com/ethereum/go-ethereum/blob/master/cmd/geth/usage.go
client
Package client represents the functionality to act as a validator.
Package client represents the functionality to act as a validator.
internal
Package internal is a generated GoMock package.
Package internal is a generated GoMock package.
node
Package node defines a validator client which connects to a full beacon node as part of the Ethereum Serenity specification.
Package node defines a validator client which connects to a full beacon node as part of the Ethereum Serenity specification.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL