Skip to content

Commit 7748c70

Browse files
authored
Merge pull request ethereum#2057 from ethereum/dev
release v0.12.3
2 parents 447b74d + 68bcc19 commit 7748c70

File tree

89 files changed

+1920
-1023
lines changed

Some content is hidden

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

89 files changed

+1920
-1023
lines changed

.circleci/config.yml

+59-52
Original file line numberDiff line numberDiff line change
@@ -44,32 +44,19 @@ commands:
4444
venv_name: v22-pyspec
4545
reqs_checksum: cache-{{ checksum "setup.py" }}
4646
venv_path: ./venv
47-
restore_deposit_contract_compiler_cached_venv:
48-
description: "Restore the venv from cache for the deposit contract compiler"
49-
steps:
50-
- restore_cached_venv:
51-
venv_name: v23-deposit-contract-compiler
52-
reqs_checksum: cache-{{ checksum "deposit_contract/compiler/requirements.txt" }}
53-
save_deposit_contract_compiler_cached_venv:
54-
description: "Save the venv to cache for later use of the deposit contract compiler"
55-
steps:
56-
- save_cached_venv:
57-
venv_name: v23-deposit-contract-compiler
58-
reqs_checksum: cache-{{ checksum "deposit_contract/compiler/requirements.txt" }}
59-
venv_path: ./deposit_contract/compiler/venv
6047
restore_deposit_contract_tester_cached_venv:
6148
description: "Restore the venv from cache for the deposit contract tester"
6249
steps:
6350
- restore_cached_venv:
64-
venv_name: v22-deposit-contract-tester
65-
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "deposit_contract/tester/requirements.txt" }}
51+
venv_name: v23-deposit-contract-tester
52+
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "solidity_deposit_contract/web3_tester/requirements.txt" }}
6653
save_deposit_contract_tester_cached_venv:
6754
description: "Save the venv to cache for later use of the deposit contract tester"
6855
steps:
6956
- save_cached_venv:
70-
venv_name: v22-deposit-contract-tester
71-
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "deposit_contract/tester/requirements.txt" }}
72-
venv_path: ./deposit_contract/tester/venv
57+
venv_name: v23-deposit-contract-tester
58+
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "solidity_deposit_contract/web3_tester/requirements.txt" }}
59+
venv_path: ./solidity_deposit_contract/web3_tester/venv
7360
jobs:
7461
checkout_specs:
7562
docker:
@@ -143,22 +130,54 @@ jobs:
143130
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
144131
- restore_pyspec_cached_venv
145132
- run:
146-
name: Run linter
133+
name: Run linter for pyspec
147134
command: make lint
148-
install_deposit_contract_compiler:
135+
- run:
136+
name: Run linter for test generators
137+
command: make lint_generators
138+
build_deposit_contract:
149139
docker:
150-
# The deposit contract compiler is pinned to python 3.7 because of the vyper version pin.
151-
- image: circleci/python:3.7
152-
working_directory: ~/specs-repo
140+
- image: ethereum/solc:0.6.11-alpine
141+
steps:
142+
- checkout
143+
- run:
144+
name: Install build essentials
145+
command: |
146+
apk update
147+
apk add git make
148+
- run:
149+
name: Compile the contract
150+
command: |
151+
make compile_deposit_contract
152+
git diff --color --exit-code
153+
- persist_to_workspace:
154+
root: .
155+
paths:
156+
- ./solidity_deposit_contract/deposit_contract.json
157+
- ./build/combined.json
158+
- ./solidity_deposit_contract/lib
159+
test_deposit_contract:
160+
docker:
161+
- image: nixorg/nix:circleci
153162
steps:
163+
- checkout
154164
- restore_cache:
155-
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
156-
- restore_deposit_contract_compiler_cached_venv
165+
key: nix-store-test-v2
166+
- attach_workspace:
167+
at: /tmp/
157168
- run:
158-
name: Install deposit contract compiler requirements
159-
command: make install_deposit_contract_compiler
160-
- save_deposit_contract_compiler_cached_venv
161-
install_deposit_contract_tester:
169+
name: Test the contract
170+
command: |
171+
mkdir build
172+
cp -r /tmp/build/* build
173+
cp -r /tmp/solidity_deposit_contract/lib/* ./solidity_deposit_contract/lib
174+
cp -r /tmp/solidity_deposit_contract/deposit_contract.json ./solidity_deposit_contract/deposit_contract.json
175+
nix-shell --command 'make test_deposit_contract' ./solidity_deposit_contract/shell.nix
176+
- save_cache:
177+
key: nix-store-test-v2
178+
paths:
179+
- /nix
180+
install_deposit_contract_web3_tester:
162181
docker:
163182
- image: circleci/python:3.8
164183
working_directory: ~/specs-repo
@@ -168,20 +187,9 @@ jobs:
168187
- restore_deposit_contract_tester_cached_venv
169188
- run:
170189
name: Install deposit contract tester requirements
171-
command: make install_deposit_contract_tester
190+
command: make install_deposit_contract_web3_tester
172191
- save_deposit_contract_tester_cached_venv
173-
test_compile_deposit_contract:
174-
docker:
175-
- image: circleci/python:3.7
176-
working_directory: ~/specs-repo
177-
steps:
178-
- restore_cache:
179-
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
180-
- restore_deposit_contract_compiler_cached_venv
181-
- run:
182-
name: Run deposit contract compile test
183-
command: make test_compile_deposit_contract
184-
test_deposit_contract:
192+
test_deposit_contract_web3_tests:
185193
docker:
186194
- image: circleci/python:3.8
187195
working_directory: ~/specs-repo
@@ -190,9 +198,8 @@ jobs:
190198
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
191199
- restore_deposit_contract_tester_cached_venv
192200
- run:
193-
name: Run deposit contract test
194-
command: make test_deposit_contract
195-
201+
name: Run deposit contract test with web3.py
202+
command: make test_deposit_contract_web3_tests
196203
workflows:
197204
version: 2.1
198205
test_spec:
@@ -209,15 +216,15 @@ workflows:
209216
- lint:
210217
requires:
211218
- test
212-
- install_deposit_contract_compiler:
219+
- install_deposit_contract_web3_tester:
213220
requires:
214221
- checkout_specs
215-
- test_compile_deposit_contract:
222+
- test_deposit_contract_web3_tests:
216223
requires:
217-
- install_deposit_contract_compiler
218-
- install_deposit_contract_tester:
219-
requires:
220-
- checkout_specs
224+
- install_deposit_contract_web3_tester
225+
build_and_test_deposit_contract:
226+
jobs:
227+
- build_deposit_contract
221228
- test_deposit_contract:
222229
requires:
223-
- install_deposit_contract_tester
230+
- build_deposit_contract

.gitattributes

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
*.vy linguist-language=Python
1+
*.sol linguist-language=Solidity

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "lib/ds-test"]
2+
path = solidity_deposit_contract/lib/ds-test
3+
url = https://github.com/dapphub/ds-test

Makefile

+31-18
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
SPEC_DIR = ./specs
22
SSZ_DIR = ./ssz
33
TEST_LIBS_DIR = ./tests/core
4+
TEST_GENERATORS_DIR = ./tests/generators
45
PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec
56
TEST_VECTOR_DIR = ../eth2.0-spec-tests/tests
67
GENERATOR_DIR = ./tests/generators
7-
DEPOSIT_CONTRACT_COMPILER_DIR = ./deposit_contract/compiler
8-
DEPOSIT_CONTRACT_TESTER_DIR = ./deposit_contract/tester
8+
SOLIDITY_DEPOSIT_CONTRACT_DIR = ./solidity_deposit_contract
9+
SOLIDITY_DEPOSIT_CONTRACT_SOURCE = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/deposit_contract.sol
10+
SOLIDITY_FILE_NAME = deposit_contract.json
11+
DEPOSIT_CONTRACT_TESTER_DIR = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/web3_tester
912
CONFIGS_DIR = ./configs
1013

1114
# Collect a list of generator names
@@ -25,6 +28,11 @@ COV_INDEX_FILE=$(PY_SPEC_DIR)/$(COV_HTML_OUT)/index.html
2528
CURRENT_DIR = ${CURDIR}
2629
LINTER_CONFIG_FILE = $(CURRENT_DIR)/linter.ini
2730

31+
export DAPP_SKIP_BUILD:=1
32+
export DAPP_SRC:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)
33+
export DAPP_LIB:=$(SOLIDITY_DEPOSIT_CONTRACT_DIR)/lib
34+
export DAPP_JSON:=build/combined.json
35+
2836
.PHONY: clean partial_clean all test citest lint generate_tests pyspec install_test open_cov \
2937
install_deposit_contract_tester test_deposit_contract install_deposit_contract_compiler \
3038
compile_deposit_contract test_compile_deposit_contract check_toc
@@ -38,15 +46,14 @@ partial_clean:
3846
rm -rf .pytest_cache
3947
rm -f .coverage
4048
rm -rf $(PY_SPEC_DIR)/.pytest_cache
41-
rm -rf $(DEPOSIT_CONTRACT_COMPILER_DIR)/.pytest_cache
4249
rm -rf $(DEPOSIT_CONTRACT_TESTER_DIR)/.pytest_cache
4350
rm -rf $(PY_SPEC_DIR)/phase0
4451
rm -rf $(PY_SPEC_DIR)/phase1
4552
rm -rf $(PY_SPEC_DIR)/$(COV_HTML_OUT)
4653
rm -rf $(PY_SPEC_DIR)/.coverage
4754
rm -rf $(PY_SPEC_DIR)/test-reports
4855
rm -rf eth2spec.egg-info dist build
49-
56+
rm -rf build
5057

5158
clean: partial_clean
5259
rm -rf venv
@@ -86,7 +93,7 @@ find_test: pyspec
8693

8794
citest: pyspec
8895
mkdir -p tests/core/pyspec/test-reports/eth2spec; . venv/bin/activate; cd $(PY_SPEC_DIR); \
89-
python -m pytest -n 4 --disable-bls --junitxml=eth2spec/test_results.xml eth2spec
96+
python -m pytest -n 4 --bls-type=milagro --junitxml=eth2spec/test_results.xml eth2spec
9097

9198
open_cov:
9299
((open "$(COV_INDEX_FILE)" || xdg-open "$(COV_INDEX_FILE)") &> /dev/null) &
@@ -107,23 +114,29 @@ lint: pyspec
107114
flake8 --config $(LINTER_CONFIG_FILE) ./eth2spec \
108115
&& mypy --config-file $(LINTER_CONFIG_FILE) -p eth2spec.phase0 -p eth2spec.phase1
109116

110-
install_deposit_contract_tester:
111-
cd $(DEPOSIT_CONTRACT_TESTER_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt
117+
lint_generators: pyspec
118+
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
119+
flake8 --config $(LINTER_CONFIG_FILE)
112120

113-
test_deposit_contract:
114-
cd $(DEPOSIT_CONTRACT_TESTER_DIR); . venv/bin/activate; \
115-
python -m pytest .
121+
compile_deposit_contract:
122+
@cd $(SOLIDITY_DEPOSIT_CONTRACT_DIR)
123+
@git submodule update --recursive --init
124+
@solc --metadata-literal --optimize --optimize-runs 5000000 --bin --abi --combined-json=abi,bin,bin-runtime,srcmap,srcmap-runtime,ast,metadata,storage-layout --overwrite -o build $(SOLIDITY_DEPOSIT_CONTRACT_SOURCE) $(SOLIDITY_DEPOSIT_CONTRACT_DIR)/tests/deposit_contract.t.sol
125+
@/bin/echo -n '{"abi": ' > $(SOLIDITY_FILE_NAME)
126+
@cat build/DepositContract.abi >> $(SOLIDITY_FILE_NAME)
127+
@/bin/echo -n ', "bytecode": "0x' >> $(SOLIDITY_FILE_NAME)
128+
@cat build/DepositContract.bin >> $(SOLIDITY_FILE_NAME)
129+
@/bin/echo -n '"}' >> $(SOLIDITY_FILE_NAME)
116130

117-
install_deposit_contract_compiler:
118-
cd $(DEPOSIT_CONTRACT_COMPILER_DIR); python3.7 -m venv venv; . venv/bin/activate; pip3.7 install -r requirements.txt
131+
test_deposit_contract:
132+
dapp test -v --fuzz-runs 5
119133

120-
compile_deposit_contract:
121-
cd $(DEPOSIT_CONTRACT_COMPILER_DIR); . venv/bin/activate; \
122-
python3.7 deposit_contract/compile.py ../contracts/validator_registration.vy
134+
install_deposit_contract_web3_tester:
135+
cd $(DEPOSIT_CONTRACT_TESTER_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements.txt
123136

124-
test_compile_deposit_contract:
125-
cd $(DEPOSIT_CONTRACT_COMPILER_DIR); . venv/bin/activate; \
126-
python3.7 -m pytest .
137+
test_deposit_contract_web3_tests:
138+
cd $(DEPOSIT_CONTRACT_TESTER_DIR); . venv/bin/activate; \
139+
python -m pytest .
127140

128141
# Runs a generator, identified by param 1
129142
define run_generator

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Ethereum 2.0 Specifications
22

3-
[![Join the chat at https://discord.gg/hpFs23p](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://discord.gg/hpFs23p) [![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)
3+
[![Join the chat at https://discord.gg/qGpsxSA](https://img.shields.io/badge/chat-on%20discord-blue.svg)](https://discord.gg/qGpsxSA) [![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

55
To learn more about sharding and Ethereum 2.0 (Serenity), see the [sharding FAQ](https://eth.wiki/sharding/Sharding-FAQs) and the [research compendium](https://notes.ethereum.org/s/H1PGqDhpm).
66

configs/README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Over time, the need to sync an older state may be deprecated.
1515
In this case, the prefix on the new constant may be removed, and the old constant will keep a special name before completely being removed.
1616

1717
A previous iteration of forking made use of "timelines", but this collides with the definitions used in the spec (constants for special forking slots, etc.), and was not integrated sufficiently in any of the spec tools or implementations.
18-
Instead, the config essentially doubles as fork definition now, e.g. changing the value for `PHASE_1_GENESIS_SLOT` changes the fork.
18+
Instead, the config essentially doubles as fork definition now, e.g. changing the value for `PHASE_1_FORK_SLOT` changes the fork.
1919

2020
Another reason to prefer forking through constants is the ability to program a forking moment based on context, instead of being limited to a static slot number.
2121

configs/mainnet/phase0.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
# Note: the intention of this file (for now) is to illustrate what a mainnet configuration could look like.
33
# Some of these constants may still change before the launch of Phase 0.
44

5+
CONFIG_NAME: "mainnet"
56

67
# Misc
78
# ---------------------------------------------------------------
@@ -27,6 +28,8 @@ HYSTERESIS_QUOTIENT: 4
2728
HYSTERESIS_DOWNWARD_MULTIPLIER: 1
2829
# 5 (plus 1.25)
2930
HYSTERESIS_UPWARD_MULTIPLIER: 5
31+
# 3
32+
PROPORTIONAL_SLASHING_MULTIPLIER: 3
3033

3134

3235
# Fork Choice
@@ -99,8 +102,6 @@ SLOTS_PER_HISTORICAL_ROOT: 8192
99102
MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256
100103
# 2**8 (= 256) epochs ~27 hours
101104
SHARD_COMMITTEE_PERIOD: 256
102-
# 2**6 (= 64) epochs ~7 hours
103-
MAX_EPOCHS_PER_CROSSLINK: 64
104105
# 2**2 (= 4) epochs 25.6 minutes
105106
MIN_EPOCHS_TO_INACTIVITY_PENALTY: 4
106107

configs/mainnet/phase1.yaml

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
# Mainnet preset - phase 1
22

3+
CONFIG_NAME: "mainnet"
34

45
# phase1-fork
56
# ---------------------------------------------------------------
67
PHASE_1_FORK_VERSION: 0x01000000
78
# [STUB]
8-
PHASE_1_GENESIS_SLOT: 32
9+
PHASE_1_FORK_SLOT: 0
910
INITIAL_ACTIVE_SHARDS: 64
1011

1112

@@ -69,8 +70,6 @@ EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS: 32768
6970
EPOCHS_PER_CUSTODY_PERIOD: 16384
7071
# 2**11 (= 2,048) epochs, ~9 days
7172
CUSTODY_PERIOD_TO_RANDAO_PADDING: 2048
72-
# 2**14 (= 16,384) epochs
73-
CUSTODY_RESPONSE_DEADLINE: 16384
7473
# 2**15 (= 32,768) epochs, ~146 days
7574
MAX_CHUNK_CHALLENGE_DELAY: 32768
7675

configs/minimal/phase0.yaml

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# Minimal preset
22

3+
CONFIG_NAME: "minimal"
34

45
# Misc
56
# ---------------------------------------------------------------
@@ -26,7 +27,8 @@ HYSTERESIS_QUOTIENT: 4
2627
HYSTERESIS_DOWNWARD_MULTIPLIER: 1
2728
# 5 (plus 1.25)
2829
HYSTERESIS_UPWARD_MULTIPLIER: 5
29-
30+
# 3
31+
PROPORTIONAL_SLASHING_MULTIPLIER: 3
3032

3133

3234
# Fork Choice
@@ -99,8 +101,6 @@ SLOTS_PER_HISTORICAL_ROOT: 64
99101
MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256
100102
# [customized] higher frequency of committee turnover and faster time to acceptable voluntary exit
101103
SHARD_COMMITTEE_PERIOD: 64
102-
# [customized] fast catchup crosslinks
103-
MAX_EPOCHS_PER_CROSSLINK: 4
104104
# 2**2 (= 4) epochs
105105
MIN_EPOCHS_TO_INACTIVITY_PENALTY: 4
106106

configs/minimal/phase1.yaml

+6-7
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
# Minimal preset - phase 1
22

3+
CONFIG_NAME: "minimal"
34

45
# phase1-fork
56
# ---------------------------------------------------------------
67
# [customized] for testnet distinction
78
PHASE_1_FORK_VERSION: 0x01000001
8-
# [customized] for testing
9-
PHASE_1_GENESIS_SLOT: 8
9+
# [STUB]
10+
PHASE_1_FORK_SLOT: 0
1011
# [customized] reduced for testing
1112
INITIAL_ACTIVE_SHARDS: 2
1213

@@ -66,15 +67,13 @@ DOMAIN_LIGHT_AGGREGATE_AND_PROOF: 0x85000000
6667
# 2**1 (= 2) epochs
6768
RANDAO_PENALTY_EPOCHS: 2
6869
# [customized] quicker for testing
69-
EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS: 128
70+
EARLY_DERIVED_SECRET_PENALTY_MAX_FUTURE_EPOCHS: 64
7071
# [customized] quicker for testing
71-
EPOCHS_PER_CUSTODY_PERIOD: 64
72+
EPOCHS_PER_CUSTODY_PERIOD: 32
7273
# [customized] quicker for testing
7374
CUSTODY_PERIOD_TO_RANDAO_PADDING: 8
74-
# [customized] quicker for testing
75-
CUSTODY_RESPONSE_DEADLINE: 128
7675
# [customize for faster testing]
77-
MAX_CHUNK_CHALLENGE_DELAY: 128
76+
MAX_CHUNK_CHALLENGE_DELAY: 64
7877

7978

8079
# Misc parameters

0 commit comments

Comments
 (0)