prysm-phase1

module
v0.3.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2020 License: GPL-3.0

README

Prysm: An Ethereum 2.0 Client Written in Go

Build status ETH2.0_Spec_Version 0.9.3 Discord Gitter

This is the core repository for Prysm, a Golang implementation of the Ethereum 2.0 client specifications developed by Prysmatic Labs.

Need assistance?

A more detailed set of installation and usage instructions as well as breakdowns of each individual component are available in the 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.

Come join the testnet!

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

Table of Contents

Dependencies

Prysm can be installed either with Docker (recommended) 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
  • The latest release of cmake
  • The latest release of git
  • A modern UNIX operating system (macOS included)

Installing Prysm

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, 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 Prysm's main repository and enter the directory:
git clone https://github.com/prysmaticlabs/prysm
cd prysm
  1. Build both the beacon chain node 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.

Connecting to the testnet: running a beacon node

Below are instructions for initialising a beacon node and connecting to the public testnet. To further understand the role that the beacon node plays in Prysm, see this section of the documentation.

NOTE: It is recommended to open up port 13000 on your local router to improve connectivity and receive more peers from the network. To do so, navigate to 192.168.0.1 in your browser and login if required. Follow along with the interface to modify your routers firewall settings. When this task is completed, append the parameter--p2p-host-ip=$(curl -s ident.me) to your selected beacon startup command presented in this section to use the newly opened port.

Running via Docker
Docker on Linux/macOS:

To start your beacon node, issue the following command:

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

The beacon node can be halted by either using Ctrl+c or with the command:

docker stop beacon-node

To restart the beacon node, issue the following command:

docker start -ai beacon-node

To delete a corrupted container, issue the following command:

docker rm beacon-node

To recreate a deleted container and refresh the chain database, issue the start command with an additional --clear-db parameter:

docker run -it -v $HOME/prysm:/data -p 4000:4000 -p 13000:13000 --name beacon-node \
  gcr.io/prysmaticlabs/prysm/beacon-chain:latest \
  --datadir=/data \
  --clear-db
Docker on Windows:
  1. You will need to 'share' the local drive you wish to mount to (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 /prysm/ 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:/prysm/:/data -p 4000:4000 -p 13000:13000 --name beacon-node gcr.io/prysmaticlabs/prysm/beacon-chain:latest --datadir=/data --clear-db
Running via Bazel

To start your Beacon Node with Bazel, issue the following command:

bazel run //beacon-chain -- --clear-db --datadir=$HOME/prysm

This will sync up the beacon node with the latest head block in the network.

NOTE: The beacon node must be completely synced before attempting to initialise a validator client, otherwise the validator will not be able to complete the deposit and funds will lost.

Staking ETH: Running a validator client

Once your beacon node is up, the chain will be waiting for you to deposit 3.2 Goerli ETH into a validator deposit contract in order to activate your validator (discussed in the section below). First though, you will need to create this validator and connect to this node to participate in consensus.

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 Göerli ETH

To begin setting up a validator, follow the instructions found on prylabs.net to use the Göerli ETH faucet and make a deposit. For step-by-step assistance with the deposit page, see the Activating a Validator section of this documentation.

It will take a while for the nodes in the network to process a deposit. Once the node is active, the validator will immediately begin performing its responsibilities.

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, a validator will start gradually losing its deposit until it is removed from the network entirely.

Congratulations, you are now running Ethereum 2.0 Phase 0!

Setting up a local ETH2 development chain

This section outlines the process of setting up Prysm for local testing with other Ethereum 2.0 client implementations. See the INTEROP.md file for advanced configuration options. For more background information on interoperability development, see this blog post.

Installation and dependencies

To begin setting up a local ETH2 development chain, follow the Bazel instructions found in the dependencies and installation sections respectively.

Running a local beacon node and validator client

The example below will generate a beacon genesis state and initiate Prysm with 64 validators with the genesis time set to your machines UNIX time.

Open up two terminal windows. In the first, issue the command:

bazel run //beacon-chain -- \
--custom-genesis-delay=0 \
--bootstrap-node= \
--deposit-contract $(curl https://prylabs.net/contract) \
--clear-db \
--interop-num-validators 64 \
--interop-eth1data-votes

Wait a moment for the beacon chain to start. In the other terminal, issue the command:

bazel run //validator -- --keymanager=interop --keymanageropts='{"keys":64}'

This command will kickstart the system with your 64 validators performing their duties accordingly.

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

Want to get involved? Check out our Contribution Guide to learn more!

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.
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.
db/iface
Package iface exists to prevent circular dependencies when implementing the database interface.
Package iface exists to prevent circular dependencies when implementing the database interface.
forkchoice
Package forkchoice implements the service to support fork choice for the eth2 beacon chain.
Package forkchoice implements the service to support fork choice for the eth2 beacon chain.
forkchoice/protoarray
Package protoarray implements proto array fork choice as outlined: https://github.com/protolambda/lmd-ghost#array-based-stateful-dag-proto_array This was motivated by the following light house implementation: https://github.com/sigp/lighthouse/pull/804
Package protoarray implements proto array fork choice as outlined: https://github.com/protolambda/lmd-ghost#array-based-stateful-dag-proto_array This was motivated by the following light house implementation: https://github.com/sigp/lighthouse/pull/804
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/slashings
Package slashings defines the operations management of slashings.
Package slashings defines the operations management of slashings.
operations/voluntaryexits
Package voluntaryexits defines the operations management of voluntary exits.
Package voluntaryexits defines the operations management of voluntary exits.
p2p
Package p2p implements the Ethereum 2.0 networking specification.
Package p2p implements the Ethereum 2.0 networking specification.
p2p/connmgr
Package connmgr : This file is forked from github.com/libp2p/go-libp2p-core/connmgr/connmgr.go
Package connmgr : This file is forked from github.com/libp2p/go-libp2p-core/connmgr/connmgr.go
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.
p2p/peers
Package peers provides information about peers at the Ethereum protocol level.
Package peers provides information about peers at the Ethereum protocol level.
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 testing is a generated GoMock package.
Package testing 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.
contracts
proto
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 selectively enable certain features to maintain a stable runtime.
Package featureconfig defines which features are enabled for runtime in order to selectively 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 is a generated GoMock package.
Package mock 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 Currently types which are tested and supported are: []uint32 []int32 []string []float32 []uint64 []int64 []string []float64 Intersection, Union, Not , IsIn are the operations which are supported on slices
Package sliceutil implements set operations for specified data type Currently types which are tested and supported are: []uint32 []int32 []string []float32 []uint64 []int64 []string []float64 Intersection, Union, Not , IsIn are the operations which are supported on slices
testutil
Package testutil defines the testing utils such as asserting logs.
Package testutil defines the testing utils such as asserting logs.
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
beaconclient
Package beaconclient defines a service that interacts with a beacon node via a gRPC client to listen for streamed blocks, attestations, and to submit proposer/attester slashings to the node in case they are detected.
Package beaconclient defines a service that interacts with a beacon node via a gRPC client to listen for streamed blocks, attestations, and to submit proposer/attester slashings to the node in case they are detected.
db
detection
Package detection defines a service that reacts to incoming blocks/attestations by running slashing detection for double proposals, double votes, and surround votes according to the eth2 specification.
Package detection defines a service that reacts to incoming blocks/attestations by running slashing detection for double proposals, double votes, and surround votes according to the eth2 specification.
rpc
tools
blocktree
* * Block tree graph viz * * Given a DB, start slot and end slot.
* * Block tree graph viz * * Given a DB, start slot and end slot.
bootnode
* * Bootnode * * A node which implements the DiscoveryV5 protocol for peer * discovery.
* * Bootnode * * A node which implements the DiscoveryV5 protocol for peer * discovery.
bootnode-query
Bootstrap / DHT query tool Usage: bazel run //tools/boostrap-query -- $BOOTNODE_ADDRESS This tool queries the bootstrap / DHT node for peers then attempts to dial and ping each of them.
Bootstrap / DHT query tool Usage: bazel run //tools/boostrap-query -- $BOOTNODE_ADDRESS This tool queries the bootstrap / DHT node for peers then attempts to dial and ping each of them.
contract-addr
* * This tool exists to serve currently configured contract address in k8s.
* * This tool exists to serve currently configured contract address in k8s.
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.
forkchecker
* * Fork choice checker * * A gRPC client that polls beacon node at every slot to log or compare nodes current head.
* * Fork choice checker * * A gRPC client that polls beacon node at every slot to log or compare nodes current head.
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.
relaynode
* * Relay node * * A simple libp2p relay node peers to connect inbound traffic behind a NAT or * other network restriction.
* * Relay node * * A simple libp2p relay node peers to connect inbound traffic behind a NAT or * other network restriction.
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.
db
db/iface
Package iface exists to prevent circular dependencies when implementing the database interface.
Package iface exists to prevent circular dependencies when implementing the database interface.
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