2018-10-31 11:37:23 +00:00
# Lighthouse: an Ethereum Serenity client
2018-07-06 07:54:07 +00:00
2018-09-18 08:03:32 +00:00
[![Build Status ](https://travis-ci.org/sigp/lighthouse.svg?branch=master )](https://travis-ci.org/sigp/lighthouse) [![Gitter ](https://badges.gitter.im/Join%20Chat.svg )](https://gitter.im/sigp/lighthouse?utm_source=badge& utm_medium=badge& utm_campaign=pr-badge)
2018-07-12 05:01:28 +00:00
2018-10-31 11:37:23 +00:00
A work-in-progress, open-source implementation of the Serenity Beacon
2018-10-10 01:42:11 +00:00
Chain, maintained by Sigma Prime.
2018-10-03 08:37:28 +00:00
2018-10-31 11:37:23 +00:00
The "Serenity" project is also known as "Ethereum 2.0" or "Shasper".
2018-10-03 08:37:28 +00:00
## Introduction
This readme is split into two major sections:
- [Lighthouse Client ](#lighthouse-client ): information about this
2018-10-03 10:29:39 +00:00
implementation.
2018-10-31 11:37:23 +00:00
- [What is Ethereum Serenity ](#what-is-ethereum-serenity ): an introduction to Ethereum Serenity.
2018-10-03 08:37:28 +00:00
If you'd like some background on Sigma Prime, please see the [Lighthouse Update
2018-10-09 07:16:19 +00:00
\#00](https://lighthouse.sigmaprime.io/update-00.html) blog post or the
[company website ](https://sigmaprime.io ).
2018-10-03 08:37:28 +00:00
## Lighthouse Client
2018-10-31 11:37:23 +00:00
Lighthouse is an open-source Ethereum Serenity client that is currently under
development. Designed as a Serenity-only client, Lighthouse will not
2018-10-10 01:42:11 +00:00
re-implement the existing proof-of-work protocol. Maintaining a forward-focus
2018-10-31 11:37:23 +00:00
on Ethereum Serenity ensures that Lighthouse avoids reproducing the high-quality
2018-10-10 01:42:11 +00:00
work already undertaken by existing projects. As such, Lighthouse will connect
to existing clients, such as
2018-10-04 00:54:59 +00:00
[Geth ](https://github.com/ethereum/go-ethereum ) or
2018-10-09 07:16:19 +00:00
[Parity-Ethereum ](https://github.com/paritytech/parity-ethereum ), via RPC to enable
present-Ethereum functionality.
2018-10-03 08:37:28 +00:00
### Goals
2019-01-07 00:52:15 +00:00
The purpose of this project is to work alongside the Ethereum community to
implement a secure, trustworthy, open-source Ethereum Serenity client in Rust.
* **Security**: Lighthouse's main goal is to implement everything with a
security-first mindset. The goal is to ensure that all components of lighthouse
are thoroughly tested, checked and secure.
* **Trust** : As Ethereum Serenity is a Proof-of-Stake system, which
involves the interaction of the Ethereum protocol and user funds. Thus, a goal
of Lighthouse is to provide a client that is trustworthy.
All code can be tested and verified the goal of Lighthouse is to provide code
that is trusted.
* **Transparency**: Lighthouse aims at being as transparent as possible. This goal is for
Lighthouse to embrace the open-source community and allow for all to understand
the decisions, direction and changes in all aspects.
* **Error Resilience**: As Lighthouse embraces the "never `panic` " mindset, the
goal is to be resilient to errors that may occur. Providing a client that has
tolerance against errors provides further properties for a secure, trustworthy
client that Lighthouse aims to provide.
2018-10-03 08:37:28 +00:00
2018-10-10 01:42:11 +00:00
In addition to implementing a new client, the project seeks to maintain and
improve the Ethereum protocol wherever possible.
2018-10-03 08:37:28 +00:00
### Components
2018-10-04 00:11:02 +00:00
The following list describes some of the components actively under development
by the team:
2018-10-03 08:37:28 +00:00
2018-10-09 07:16:19 +00:00
- **BLS cryptography**: Lighthouse presently use the [Apache
2018-10-03 08:37:28 +00:00
Milagro](https://milagro.apache.org/) cryptography library to create and
2018-10-31 11:37:23 +00:00
verify BLS aggregate signatures. BLS signatures are core to Serenity as they
2018-10-10 01:42:11 +00:00
allow the signatures of many validators to be compressed into a constant 96
bytes and efficiently verified. The Lighthouse project is presently
maintaining its own [BLS aggregates
library](https://github.com/sigp/signature-schemes), gratefully forked from
[@lovesh ](https://github.com/lovesh ).
2018-10-09 07:16:19 +00:00
- **DoS-resistant block pre-processing**: Processing blocks in proof-of-stake
2018-10-03 08:37:28 +00:00
is more resource intensive than proof-of-work. As such, clients need to
2018-10-10 01:42:11 +00:00
ensure that bad blocks can be rejected as efficiently as possible. At
present, blocks having 10 million ETH staked can be processed in 0.006
seconds, and invalid blocks are rejected even more quickly. See [issue
#103 ](https://github.com/ethereum/beacon_chain/issues/103) on
[ethereum/beacon_chain ](https://github.com/ethereum/beacon_chain ).
2018-10-03 08:37:28 +00:00
.
2018-10-31 11:37:23 +00:00
- **P2P networking**: Serenity will likely use the [libp2p
2018-10-04 00:11:02 +00:00
framework](https://libp2p.io/). Lighthouse aims to work alongside
2018-10-09 07:16:19 +00:00
[Parity ](https://www.parity.io/ ) to ensure
[libp2p-rust ](https://github.com/libp2p/rust-libp2p ) is fit-for-purpose.
- **Validator duties** : The project involves development of "validator
2018-10-10 01:42:11 +00:00
services" for users who wish to stake ETH. To fulfill their duties,
validators require a consistent view of the chain and the ability to vote
upon blocks from both shard and beacon chains.
- **New serialization formats**: Lighthouse is working alongside researchers
from the Ethereum Foundation to develop *simpleserialize* (SSZ), a
purpose-built serialization format for sending information across a network.
Check out the [SSZ
2018-10-03 08:37:28 +00:00
implementation](https://github.com/sigp/lighthouse/tree/master/beacon_chain/utils/ssz)
2018-10-09 07:16:19 +00:00
and this
2018-10-03 08:37:28 +00:00
[research ](https://github.com/sigp/serialization_sandbox/blob/report/report/serialization_report.md )
2018-10-09 07:16:19 +00:00
on serialization formats for more information.
- **Casper FFG fork-choice**: The [Casper
2018-10-03 08:37:28 +00:00
FFG](https://arxiv.org/abs/1710.09437) fork-choice rules allow the chain to
select a canonical chain in the case of a fork.
2018-10-09 07:16:19 +00:00
- **Efficient state transition logic**: State transition logic governs
updates to the validator set as validators log in/out, penalizes/rewards
2018-10-04 00:11:02 +00:00
validators, rotates validators across shards, and implements other core tasks.
2018-10-10 01:42:11 +00:00
- **Fuzzing and testing environments**: Implementation of lab environments with
continuous integration (CI) workflows, providing automated security analysis.
2018-10-04 00:11:02 +00:00
2018-10-09 07:16:19 +00:00
In addition to these components we are also working on database schemas, RPC
2018-10-04 00:11:02 +00:00
frameworks, specification development, database optimizations (e.g.,
2018-10-09 07:16:19 +00:00
bloom-filters), and tons of other interesting stuff (at least we think so).
2018-10-03 08:37:28 +00:00
### Contributing
**Lighthouse welcomes contributors with open-arms.**
2018-10-09 07:16:19 +00:00
Layer-1 infrastructure is a critical component for the ecosystem and relies
2018-10-31 11:37:23 +00:00
heavily on contributions from the community. Building Ethereum Serenity is a huge
2018-10-10 01:42:11 +00:00
task and we refuse to conduct an inappropriate ICO or charge licensing fees.
Instead, we fund development through grants and support from Sigma Prime.
2018-10-03 08:37:28 +00:00
2018-10-31 11:37:23 +00:00
If you would like to learn more about Ethereum Serenity and/or
2018-10-09 07:16:19 +00:00
[Rust ](https://www.rust-lang.org/ ), we are more than happy to on-board you
and assign you some tasks. We aim to be as accepting and understanding as
2018-10-03 08:37:28 +00:00
possible; we are more than happy to up-skill contributors in exchange for their
2018-10-09 07:16:19 +00:00
assistance with the project.
2018-10-03 08:37:28 +00:00
2018-10-09 07:16:19 +00:00
Alternatively, if you are an ETH/Rust veteran, we'd love your input. We're
always looking for the best way to implement things and welcome all
respectful criticisms.
2018-10-03 08:37:28 +00:00
If you'd like to contribute, try having a look through the [open
issues](https://github.com/sigp/lighthouse/issues) (tip: look for the [good
first
issue](https://github.com/sigp/lighthouse/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22)
2018-10-09 07:16:19 +00:00
tag) and ping us on the [gitter ](https://gitter.im/sigp/lighthouse ) channel. We need
2018-10-03 08:37:28 +00:00
your support!
### Running
2018-10-09 07:16:19 +00:00
**NOTE: The cryptography libraries used in this implementation are
experimental. As such all cryptography is assumed to be insecure.**
2018-07-06 07:54:07 +00:00
2018-10-10 01:42:11 +00:00
This code-base is still very much under-development and does not provide any
user-facing functionality. For developers and researchers, there are several
tests and benchmarks which may be of interest.
2018-07-06 07:54:07 +00:00
2018-11-09 05:02:25 +00:00
A few basic steps are needed to get set up:
2018-08-02 09:29:33 +00:00
2018-11-03 13:19:27 +00:00
1. Install [rustup ](https://rustup.rs/ ). It's a toolchain manager for Rust (Linux | macos | Windows). For installation run the below command in your terminal
2018-10-24 09:14:12 +00:00
```
$ curl https://sh.rustup.rs -sSf | sh
2018-10-03 08:37:28 +00:00
```
2018-11-25 11:00:48 +00:00
2. To configure your current shell run:
2018-10-24 09:14:12 +00:00
```
$ source $HOME/.cargo/env
2018-10-03 08:37:28 +00:00
```
2018-10-24 09:14:12 +00:00
2018-11-25 11:01:07 +00:00
3. Use the command `rustup show` to get information about the Rust installation. You should see that the active toolchain is the stable version.
2018-11-25 11:01:22 +00:00
4. Run `rustc --version` to check the installation and version of rust.
- Updates can be performed using` rustup update` .
2018-10-24 09:14:12 +00:00
5. Navigate to the working directory.
2018-11-03 13:19:27 +00:00
6. Run the test by using command `cargo test --all` . By running, it will pass all the required test cases. If you are doing it for the first time, then you can grab a coffee meantime. Usually, it takes time to build, compile and pass all test cases. If there is no error then, it means everything is working properly and it's time to get hand's dirty. In case, if there is an error, then please raise the [issue ](https://github.com/sigp/lighthouse/issues ). We will help you.
2018-11-25 11:01:38 +00:00
7. As an alternative to, or instead of the above step, you may also run benchmarks by using the command `cargo bench --all`
2018-10-24 09:14:12 +00:00
##### Note:
2018-10-09 07:16:19 +00:00
Lighthouse presently runs on Rust `stable` , however, benchmarks currently require the
2018-10-03 08:37:28 +00:00
`nightly` version.
2018-08-02 09:29:33 +00:00
2018-10-03 08:37:28 +00:00
### Engineering Ethos
2018-08-02 09:29:33 +00:00
2018-10-09 07:16:19 +00:00
Lighthouse aims to produce many small easily-tested components, each separated
2018-10-03 08:37:28 +00:00
into individual crates wherever possible.
2018-08-02 09:29:33 +00:00
2018-10-03 08:37:28 +00:00
Generally, tests can be kept in the same file, as is typical in Rust.
2018-10-10 01:42:11 +00:00
Integration tests should be placed in the `tests` directory in the crate's
root. Particularity large (line-count) tests should be placed into a separate
file.
2018-08-02 09:29:33 +00:00
2018-10-10 01:42:11 +00:00
A function is not considered complete until a test exists for it. We produce
tests to protect against regression (accidentally breaking things) and to
provide examples that help readers of the code base understand how functions
should (or should not) be used.
2018-08-02 09:29:33 +00:00
2018-10-10 01:42:11 +00:00
Each pull request is to be reviewed by at least one "core developer" (i.e.,
someone with write-access to the repository). This helps to ensure bugs are
detected, consistency is maintained, and responsibility of errors is dispersed.
2018-07-06 07:54:07 +00:00
2018-10-09 07:16:19 +00:00
Discussion must be respectful and intellectual. Have fun and make jokes, but
always respect the limits of other people.
2018-07-06 07:54:07 +00:00
2018-10-03 08:37:28 +00:00
### Directory Structure
Here we provide an overview of the directory structure:
2018-10-09 07:19:36 +00:00
- `/beacon_chain` : contains logic derived directly from the specification.
2018-10-03 08:37:28 +00:00
E.g., shuffling algorithms, state transition logic and structs, block
validation, BLS crypto, etc.
2018-10-09 07:19:36 +00:00
- `/lighthouse` : contains logic specific to this client implementation. E.g.,
2018-10-03 08:37:28 +00:00
CLI parsing, RPC end-points, databases, etc.
2018-07-06 07:54:07 +00:00
## Contact
2018-10-09 07:16:19 +00:00
The best place for discussion is the [sigp/lighthouse gitter ](https://gitter.im/sigp/lighthouse ).
2018-10-03 08:37:28 +00:00
Ping @paulhauner or @AgeManning to get the quickest response.
2018-10-31 11:37:23 +00:00
# What is Ethereum Serenity
2018-10-03 08:37:28 +00:00
2018-10-31 11:37:23 +00:00
Ethereum Serenity refers to a new blockchain system currently under development by
the Ethereum Foundation and the Ethereum community. The Serenity blockchain
2018-10-10 01:42:11 +00:00
consists of 1,025 proof-of-stake blockchains. This includes the "beacon chain"
and 1,024 "shard chains".
2018-10-03 08:37:28 +00:00
2018-10-31 11:37:23 +00:00
Ethereum Serenity is also known as "Ethereum 2.0" and "Shasper". We prefer
Serenity as it more accurately reflects the established Ethereum roadmap (plus
we think it's a nice name).
2018-10-03 08:37:28 +00:00
## Beacon Chain
2018-10-10 01:42:11 +00:00
The concept of a beacon chain differs from existing blockchains, such as
Bitcoin and Ethereum, in that it doesn't process transactions per se. Instead,
it maintains a set of bonded (staked) validators and coordinates these to
provide services to a static set of *sub-blockchains* (i.e. shards). Each of
these shard blockchains processes normal transactions (e.g. "Transfer 5 ETH
from A to B") in parallel whilst deferring consensus mechanisms to the beacon
chain.
2018-10-03 08:37:28 +00:00
2018-10-04 00:11:02 +00:00
Major services provided by the beacon chain to its shards include the following:
2018-10-03 08:37:28 +00:00
- A source of entropy, likely using a [RANDAO + VDF
scheme](https://ethresear.ch/t/minimal-vdf-randomness-beacon/3566).
2018-10-03 10:29:39 +00:00
- Validator management, including:
2018-10-03 08:37:28 +00:00
- Inducting and ejecting validators.
2018-10-09 07:16:19 +00:00
- Assigning randomly-shuffled subsets of validators to particular shards.
- Penalizing and rewarding validators.
2018-10-03 08:37:28 +00:00
- Proof-of-stake consensus for shard chain blocks.
## Shard Chains
2018-10-09 07:16:19 +00:00
Shards are analogous to CPU cores - they're a resource where transactions can
2018-10-03 08:37:28 +00:00
execute in series (one-after-another). Presently, Ethereum is single-core and
2018-10-10 01:42:11 +00:00
can only _fully_ process one transaction at a time. Sharding allows processing
of multiple transactions simultaneously, greatly increasing the per-second
2018-10-03 08:37:28 +00:00
transaction capacity of Ethereum.
2018-10-10 01:42:11 +00:00
Each shard uses a proof-of-stake consensus mechanism and shares its validators
(stakers) with other shards. The beacon chain rotates validators
pseudo-randomly between different shards. Shards will likely be the basis of
layer-2 transaction processing schemes, however, that is not in scope of this
discussion.
2018-10-03 08:37:28 +00:00
## The Proof-of-Work Chain
2018-10-10 01:42:11 +00:00
The present-Ethereum proof-of-work (PoW) chain will host a smart contract that
enables accounts to deposit 32 ETH, a BLS public key, and some [other
2018-10-09 07:16:19 +00:00
parameters](https://github.com/ethereum/eth2.0-specs/blob/master/specs/casper_sharding_v2.1.md#pow-chain-changes),
allowing them to become beacon chain validators. Each beacon chain will
reference a PoW block hash allowing PoW clients to use the beacon chain as a
2018-10-04 00:11:02 +00:00
source of [Casper FFG finality ](https://arxiv.org/abs/1710.09437 ), if desired.
2018-10-03 08:37:28 +00:00
2018-10-09 07:16:19 +00:00
It is a requirement that ETH can move freely between shard chains, as well as between
2018-10-31 11:37:23 +00:00
Serenity and present-Ethereum blockchains. The exact mechanics of these transfers remain
2018-10-09 07:16:19 +00:00
an active topic of research and their details are yet to be confirmed.
2018-10-04 00:49:28 +00:00
2018-10-31 11:37:23 +00:00
## Ethereum Serenity Progress
2018-10-03 08:37:28 +00:00
2018-10-31 11:37:23 +00:00
Ethereum Serenity is not fully specified and a working implementation does not yet
2018-10-10 01:42:11 +00:00
exist. Some teams have demos available which indicate progress, but do not
constitute a complete product. We look forward to providing user functionality
once we are ready to provide a minimum-viable user experience.
2018-10-03 08:37:28 +00:00
2018-10-31 11:37:23 +00:00
The work-in-progress Serenity specification lives
2018-10-03 08:37:28 +00:00
[here ](https://github.com/ethereum/eth2.0-specs/blob/master/specs/casper_sharding_v2.1.md )
in the [ethereum/eth2.0-specs ](https://github.com/ethereum/eth2.0-specs )
2018-10-04 00:11:02 +00:00
repository. The spec is still in a draft phase, however there are several teams
2018-10-31 11:37:23 +00:00
basing their Serenity implementations upon it while the Ethereum Foundation research
2018-10-09 07:16:19 +00:00
team continue to fill in the gaps. There is active discussion about the specification in the
2018-10-04 00:11:02 +00:00
[ethereum/sharding ](https://gitter.im/ethereum/sharding ) gitter channel. A
proof-of-concept implementation in Python is available at
2018-10-03 08:37:28 +00:00
[ethereum/beacon_chain ](https://github.com/ethereum/beacon_chain ).
2018-10-09 07:16:19 +00:00
Presently, the specification focuses almost exclusively on the beacon chain,
as it is the focus of current development efforts. Progress on shard chain
2018-10-03 08:37:28 +00:00
specification will soon follow.
2018-12-19 01:54:31 +00:00
# Donations
If you support the cause, we could certainly use donations to help fund development:
`0x25c4a76E7d118705e7Ea2e9b7d8C59930d8aCD3b`