Skip to content

Commit 7a06df6

Browse files
authored
Merge pull request #987 from ethereum/dev
v0.6.0 Release
2 parents 7db21e3 + 1845088 commit 7a06df6

File tree

107 files changed

+6797
-3133
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

107 files changed

+6797
-3133
lines changed

.circleci/config.yml

Lines changed: 87 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,97 @@
1-
# Python CircleCI 2.0 configuration file
2-
version: 2
1+
version: 2.1
2+
commands:
3+
restore_cached_venv:
4+
description: "Restores a cached venv"
5+
parameters:
6+
reqs_checksum:
7+
type: string
8+
default: "1234"
9+
venv_name:
10+
type: string
11+
default: "default-name"
12+
steps:
13+
- restore_cache:
14+
keys:
15+
- << parameters.venv_name >>-venv-<< parameters.reqs_checksum >>
16+
# fallback to using the latest cache if no exact match is found
17+
- << parameters.venv_name >>-venv-
18+
save_cached_venv:
19+
description: "Saves a venv into a cache"
20+
parameters:
21+
reqs_checksum:
22+
type: string
23+
default: "1234"
24+
venv_path:
25+
type: string
26+
default: "venv"
27+
venv_name:
28+
type: string
29+
default: "default-name"
30+
steps:
31+
- save_cache:
32+
key: << parameters.venv_name >>-venv-<< parameters.reqs_checksum >>
33+
paths: << parameters.venv_path >>
334
jobs:
4-
build:
35+
checkout_specs:
536
docker:
637
- image: circleci/python:3.6
7-
working_directory: ~/repo
8-
38+
working_directory: ~/specs-repo
939
steps:
10-
- checkout
11-
# Download and cache dependencies
40+
# Restore git repo at point close to target branch/revision, to speed up checkout
1241
- restore_cache:
1342
keys:
14-
- v1-dependencies-{{ checksum "requirements.txt" }}
15-
# fallback to using the latest cache if no exact match is found
16-
- v1-dependencies-
17-
18-
- run:
19-
name: install dependencies
20-
command: |
21-
python3 -m venv venv
22-
. venv/bin/activate
23-
pip install -r requirements.txt
43+
- v1-specs-repo-{{ .Branch }}-{{ .Revision }}
44+
- v1-specs-repo-{{ .Branch }}-
45+
- v1-specs-repo-
46+
- checkout
2447
- run:
25-
name: build phase0 spec
26-
command: make build/phase0
27-
48+
name: Clean up git repo to reduce cache size
49+
command: git gc
50+
# Save the git checkout as a cache, to make cloning next time faster.
2851
- save_cache:
52+
key: v1-specs-repo-{{ .Branch }}-{{ .Revision }}
2953
paths:
30-
- ./venv
31-
key: v1-dependencies-{{ checksum "requirements.txt" }}
32-
54+
- ~/specs-repo
55+
install_test:
56+
docker:
57+
- image: circleci/python:3.6
58+
working_directory: ~/specs-repo
59+
steps:
60+
- restore_cache:
61+
key: v1-specs-repo-{{ .Branch }}-{{ .Revision }}
62+
- restore_cached_venv:
63+
venv_name: v1-test_libs
64+
reqs_checksum: '{{ checksum "test_libs/pyspec/setup.py" }}'
65+
- run:
66+
name: Install pyspec requirements
67+
command: make install_test
68+
- save_cached_venv:
69+
venv_name: v1-test_libs
70+
reqs_checksum: '{{ checksum "test_libs/pyspec/setup.py" }}'
71+
venv_path: ./test_libs/venv
72+
test:
73+
docker:
74+
- image: circleci/python:3.6
75+
working_directory: ~/specs-repo
76+
steps:
77+
- restore_cache:
78+
key: v1-specs-repo-{{ .Branch }}-{{ .Revision }}
79+
- restore_cached_venv:
80+
venv_name: v1-test_libs
81+
reqs_checksum: '{{ checksum "test_libs/pyspec/setup.py" }}'
3382
- run:
34-
name: run tests
35-
command: |
36-
. venv/bin/activate
37-
pytest tests
38-
39-
- store_artifacts:
40-
path: test-reports
41-
destination: test-reports
83+
name: Run py-tests
84+
command: make citest
85+
- store_test_results:
86+
path: test_libs/pyspec/test-reports
87+
workflows:
88+
version: 2.1
89+
test_spec:
90+
jobs:
91+
- checkout_specs
92+
- install_test:
93+
requires:
94+
- checkout_specs
95+
- test:
96+
requires:
97+
- install_test

.gitignore

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,22 @@
11
*.pyc
22
/__pycache__
3-
/venv
3+
venv
4+
.venvs
5+
.venv
46
/.pytest_cache
7+
*.egg
8+
*.egg-info
9+
eggs
10+
.eggs
511

612
build/
713
output/
14+
15+
eth2.0-spec-tests/
16+
.pytest_cache
17+
18+
# Dynamically built from Markdown spec
19+
test_libs/pyspec/eth2spec/phase0/spec.py
20+
21+
# vscode
22+
.vscode/**

Makefile

Lines changed: 77 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,91 @@
11
SPEC_DIR = ./specs
22
SCRIPT_DIR = ./scripts
3-
BUILD_DIR = ./build
4-
UTILS_DIR = ./utils
3+
TEST_LIBS_DIR = ./test_libs
4+
PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec
5+
CONFIG_HELPERS_DIR = $(TEST_LIBS_DIR)/config_helpers
6+
YAML_TEST_DIR = ./eth2.0-spec-tests/tests
7+
GENERATOR_DIR = ./test_generators
8+
CONFIGS_DIR = ./configs
59

10+
# Collect a list of generator names
11+
GENERATORS = $(sort $(dir $(wildcard $(GENERATOR_DIR)/*/)))
12+
# Map this list of generator paths to a list of test output paths
13+
YAML_TEST_TARGETS = $(patsubst $(GENERATOR_DIR)/%, $(YAML_TEST_DIR)/%, $(GENERATORS))
14+
GENERATOR_VENVS = $(patsubst $(GENERATOR_DIR)/%, $(GENERATOR_DIR)/%venv, $(GENERATORS))
615

7-
.PHONY: clean all test
16+
PY_SPEC_PHASE_0_TARGETS = $(PY_SPEC_DIR)/eth2spec/phase0/spec.py
17+
PY_SPEC_ALL_TARGETS = $(PY_SPEC_PHASE_0_TARGETS)
818

919

10-
all: $(BUILD_DIR)/phase0
20+
.PHONY: clean all test citest gen_yaml_tests pyspec phase0 install_test
1121

22+
all: $(PY_SPEC_ALL_TARGETS) $(YAML_TEST_DIR) $(YAML_TEST_TARGETS)
1223

1324
clean:
14-
rm -rf $(BUILD_DIR)
25+
rm -rf $(YAML_TEST_DIR)
26+
rm -rf $(GENERATOR_VENVS)
27+
rm -rf $(TEST_LIBS_DIR)/venv
28+
rm -rf $(PY_SPEC_DIR)/.pytest_cache
29+
rm -rf $(PY_SPEC_ALL_TARGETS)
1530

31+
# "make gen_yaml_tests" to run generators
32+
gen_yaml_tests: $(PY_SPEC_ALL_TARGETS) $(YAML_TEST_TARGETS)
1633

17-
# runs a limited set of tests against a minimal config
18-
# run pytest with `-m` option to full suite
19-
test:
20-
pytest -m minimal_config tests/
34+
# installs the packages to run pyspec tests
35+
install_test:
36+
cd $(TEST_LIBS_DIR); python3 -m venv venv; . venv/bin/activate; \
37+
cd ..; cd $(CONFIG_HELPERS_DIR); pip3 install -e .; \
38+
cd ../..; cd $(PY_SPEC_DIR); pip3 install -e .[dev];
2139

40+
test: $(PY_SPEC_ALL_TARGETS)
41+
cd $(TEST_LIBS_DIR); . venv/bin/activate; \
42+
cd ..; cd $(PY_SPEC_DIR); python -m pytest .;
2243

23-
$(BUILD_DIR)/phase0:
44+
citest: $(PY_SPEC_ALL_TARGETS)
45+
cd $(TEST_LIBS_DIR); . venv/bin/activate; \
46+
cd ..; cd $(PY_SPEC_DIR); mkdir -p test-reports/eth2spec; python -m pytest --junitxml=test-reports/eth2spec/test_results.xml .
47+
48+
# "make pyspec" to create the pyspec for all phases.
49+
pyspec: $(PY_SPEC_ALL_TARGETS)
50+
51+
# "make phase0" to create pyspec for phase0
52+
phase0: $(PY_SPEC_PHASE_0_TARGETS)
53+
54+
55+
$(PY_SPEC_DIR)/eth2spec/phase0/spec.py:
56+
python3 $(SCRIPT_DIR)/phase0/build_spec.py $(SPEC_DIR)/core/0_beacon-chain.md $@
57+
58+
59+
CURRENT_DIR = ${CURDIR}
60+
61+
# The function that builds a set of suite files, by calling a generator for the given type (param 1)
62+
define build_yaml_tests
63+
# Started!
64+
# Create output directory
65+
# Navigate to the generator
66+
# Create a virtual environment, if it does not exist already
67+
# Activate the venv, this is where dependencies are installed for the generator
68+
# Install all the necessary requirements
69+
# Run the generator. The generator is assumed to have an "main.py" file.
70+
# We output to the tests dir (generator program should accept a "-o <filepath>" argument.
71+
echo "generator $(1) started"; \
72+
mkdir -p $(YAML_TEST_DIR)$(1); \
73+
cd $(GENERATOR_DIR)$(1); \
74+
if ! test -d venv; then python3 -m venv venv; fi; \
75+
. venv/bin/activate; \
76+
pip3 install -r requirements.txt; \
77+
python3 main.py -o $(CURRENT_DIR)/$(YAML_TEST_DIR)$(1) -c $(CURRENT_DIR)/$(CONFIGS_DIR); \
78+
echo "generator $(1) finished"
79+
endef
80+
81+
# The tests dir itself is simply build by creating the directory (recursively creating deeper directories if necessary)
82+
$(YAML_TEST_DIR):
83+
$(info creating directory, to output yaml targets to: ${YAML_TEST_TARGETS})
2484
mkdir -p $@
25-
python3 $(SCRIPT_DIR)/phase0/build_spec.py $(SPEC_DIR)/core/0_beacon-chain.md $@/spec.py
26-
mkdir -p $@/utils
27-
cp $(UTILS_DIR)/phase0/* $@/utils
28-
cp $(UTILS_DIR)/phase0/state_transition.py $@
29-
touch $@/__init__.py $@/utils/__init__.py
85+
$(YAML_TEST_DIR)/:
86+
$(info ignoring duplicate yaml tests dir)
87+
88+
# For any target within the tests dir, build it using the build_yaml_tests function.
89+
# (creation of output dir is a dependency)
90+
$(YAML_TEST_DIR)%: $(PY_SPEC_ALL_TARGETS) $(YAML_TEST_DIR)
91+
$(call build_yaml_tests,$*)

README.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,47 @@
22

33
[![Join the chat at https://gitter.im/ethereum/sharding](https://badges.gitter.im/ethereum/sharding.svg)](https://gitter.im/ethereum/sharding?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44

5-
To learn more about sharding and eth2.0/Serenity, see the [sharding FAQ](https://github.com/ethereum/wiki/wiki/Sharding-FAQs) and the [research compendium](https://notes.ethereum.org/s/H1PGqDhpm).
5+
To learn more about sharding and eth2.0/Serenity, see the [sharding FAQ](https://github.com/ethereum/wiki/wiki/Sharding-FAQ) and the [research compendium](https://notes.ethereum.org/s/H1PGqDhpm).
66

77
This repo hosts the current eth2.0 specifications. Discussions about design rationale and proposed changes can be brought up and discussed as issues. Solidified, agreed upon changes to spec can be made through pull requests.
88

9-
# Specs
9+
10+
## Specs
1011

1112
Core specifications for eth2.0 client validation can be found in [specs/core](specs/core). These are divided into phases. Each subsequent phase depends upon the prior. The current phases specified are:
12-
* [Phase 0 -- The Beacon Chain](specs/core/0_beacon-chain.md)
13-
* [Phase 1 -- Shard Data Chains](specs/core/1_shard-data-chains.md)
1413

15-
Accompanying documents can be found in [specs](specs) and include
14+
### Phase 0
15+
* [The Beacon Chain](specs/core/0_beacon-chain.md)
16+
* [Fork Choice](specs/core/0_fork-choice.md)
17+
* [Deposit Contract](specs/core/0_deposit-contract.md)
18+
* [Honest validator implementation doc](specs/validator/0_beacon-chain-validator.md)
19+
20+
### Phase 1
21+
* [Custody Game](specs/core/1_custody-game.md)
22+
* [Shard Data Chains](specs/core/1_shard-data-chains.md)
23+
24+
### Accompanying documents can be found in [specs](specs) and include:
25+
1626
* [SimpleSerialize (SSZ) spec](specs/simple-serialize.md)
1727
* [BLS signature verification](specs/bls_signature.md)
18-
* [General test format](specs/test-format.md)
19-
* [Honest validator implementation doc](specs/validator/0_beacon-chain-validator.md)
28+
* [General test format](specs/test_formats/README.md)
29+
* [Merkle proof formats](specs/light_client/merkle_proofs.md)
30+
* [Light client syncing protocol](specs/light_client/sync_protocol.md)
31+
32+
33+
### Design goals
2034

21-
## Design goals
2235
The following are the broad design goals for Ethereum 2.0:
2336
* to minimize complexity, even at the cost of some losses in efficiency
2437
* to remain live through major network partitions and when very large portions of nodes go offline
2538
* to select all components such that they are either quantum secure or can be easily swapped out for quantum secure counterparts when available
2639
* to utilize crypto and design techniques that allow for a large participation of validators in total and per unit time
2740
* to allow for a typical consumer laptop with `O(C)` resources to process/validate `O(1)` shards (including any system level validation such as the beacon chain)
41+
42+
43+
## For spec contributors
44+
45+
Documentation on the different components used during spec writing can be found here:
46+
* [YAML Test Generators](test_generators/README.md)
47+
* [Executable Python Spec, with Py-tests](test_libs/pyspec/README.md)
48+

configs/constant_presets/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Constant Presets
2+
3+
This directory contains a set of constants presets used for testing, testnets, and mainnet.
4+
5+
A preset file contains all the constants known for its target.
6+
Later-fork constants can be ignored, e.g. ignore phase1 constants as a client that only supports phase 0 currently.
7+
8+
## Format
9+
10+
Each preset is a key-value mapping.
11+
12+
**Key**: an `UPPER_SNAKE_CASE` (a.k.a. "macro case") formatted string, name of the constant.
13+
**Value**: can be any of:
14+
- an unsigned integer number, can be up to 64 bits (incl.)
15+
- a hexadecimal string, prefixed with `0x`
16+
17+
Presets may contain comments to describe the values.
18+
19+
See `mainnet.yaml` for a complete example.
20+

0 commit comments

Comments
 (0)