A minimal Go implementation of the ETH 2.0 spec, by @protolambda.
The goal of this project is to have a Go version of the Python based spec:
- executable version
- comparable with Python version (through diffing debug JSON dumps of state)
- generate test vectors for conformance testing
- fast enough for fuzzing
- avoids quadratic complexity implementations of spec
- minimal and easy to understand
The beacon-chain consists of 3 transition types:
Slot transition (often, but very minimal change)
Block transition (occasional, can fork)
Epoch transition (every 64 slots, big change)
- RewardsAndPenalties (applies deltas)
- Crosslink rewards/penalties
- Justificant rewards/penalties
- normal rewards/penalties
- delayed finalization measures
- ValidatorRegistry (shuffling, update)
Note that sub transitions have a common signature:
func(state *beacon.BeaconState, block *beacon.BeaconBlock) error (mutates state, error because they can be rejected)
func(state *beacon.BeaconState) (mutates state)
A genesis state is created with
From here, a set of slot transitions, a block transition, and possibly an epoch transition, are applied for every block
Data types are defined in
Container types are defined in
SSZ, BLS, hashing, merkleization, and other utils can be found in
This repo is still a work-in-progress.
To test creation of some Beacon chain genesis data, you can run
More states and transition testing is coming SOON
Use the repo for conformance test generation, fuzzing, and implement a minimal (but fast) ETH 2.0 client around it.
Contributions are welcome. If they are not small changes, please make a GH issue and/or contact me first.
This project is based on my work for a bountied challenge by Justin Drake to write the ETH 2.0 spec in 1024 lines. A ridiculous challenge, but it was fun, and proved to be useful: every line of code in the spec got extra attention, and it was a fun way to get started on an executable spec. Aside from this bounty, the work is unfunded (as of now), and developed in my spare time.
MIT, see license file.