Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport (partial) v0.6.1 to dev #1003

Merged
merged 66 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
98e6a24
Merge pull request #981 from ethereum/only_setup_py
djrtwo Apr 24, 2019
451c283
Revert "Only use `setup.py`"
djrtwo Apr 24, 2019
7a06df6
Merge pull request #987 from ethereum/dev
djrtwo Apr 24, 2019
6a5405c
Update 0_fork-choice.md
terencechain Apr 24, 2019
0606689
Update 0_deposit-contract.md
terencechain Apr 24, 2019
768f3ed
remove validator link refs from fork choice doc
djrtwo Apr 24, 2019
ff59a3e
Copy from ethereum/eth2.0-specs#936
hwwhww Apr 25, 2019
c769eeb
Modify the description
hwwhww Apr 25, 2019
343454f
Adjust headers
hwwhww Apr 25, 2019
6a92267
`_deltas` functions should return tuple instead of list
hwwhww Apr 25, 2019
fc7d57e
PEP8-ish clean up
hwwhww Apr 25, 2019
4c5a57d
fix test-generators
protolambda Apr 26, 2019
649dbfd
bugfix: missing validator
hwwhww Apr 26, 2019
0de772f
Add tests/epoch_processing/test_process_registry_updates.py
hwwhww Apr 26, 2019
70cd3d2
Add `test_ejection`
hwwhww Apr 26, 2019
15ad1fc
update configs
protolambda Apr 26, 2019
44789bd
Merge pull request #993 from terencechain/patch-67
djrtwo Apr 26, 2019
7b7f641
Merge pull request #994 from terencechain/patch-68
djrtwo Apr 26, 2019
2e79053
fix minor typo
djrtwo Apr 26, 2019
02e0118
Merge branch 'master' into deposit_contract_description
djrtwo Apr 26, 2019
7c549a9
Merge pull request #995 from ethereum/deposit_contract_description
djrtwo Apr 26, 2019
f76ade9
update registry tests to return the blocks that transiiton the pre_st…
djrtwo Apr 26, 2019
b31c21b
Merge pull request #1001 from ethereum/registry_test
djrtwo Apr 26, 2019
48bdfd8
Merge branch 'master' into hwwhww/clean_up
djrtwo Apr 26, 2019
a146f25
Merge pull request #997 from ethereum/hwwhww/clean_up
djrtwo Apr 26, 2019
b69423f
Merge pull request #996 from ethereum/return_tuple
djrtwo Apr 26, 2019
9dd4b21
Fix two effective_balance bugs
JustinDrake Apr 26, 2019
772a380
Update README.md
JSON Apr 28, 2019
c2555f7
Update README.md
JSON Apr 28, 2019
77d7aa7
Attestation committee refactor
vbuterin Apr 29, 2019
90cacf5
Merge pull request #1007 from ethereum/v060-fixes
djrtwo Apr 29, 2019
2348595
Merge pull request #1006 from JSON/patch-1
djrtwo Apr 29, 2019
dc458bf
Merge pull request #1004 from ethereum/JustinDrake-patch-10
djrtwo Apr 29, 2019
c13c4c5
Calculate historical start shards from state
vbuterin Apr 30, 2019
59d7be6
Fix `is_double_vote` and `is_surround_vote`
hwwhww Apr 30, 2019
bcd7a83
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
92140d1
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
b19e7db
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
09ed9ae
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
66403ad
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
73603f4
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
adfa014
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
a23c9f7
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
60888c0
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
a40f37b
Update 0_beacon-chain.md
JustinDrake Apr 30, 2019
c5d6c04
Update 0_beacon-chain.md
terencechain Apr 30, 2019
b3373a2
fix up some PR feedback and testing for #1009
djrtwo Apr 30, 2019
2e5ab13
Simplify presentation
JustinDrake May 1, 2019
a6e76ef
Fix
JustinDrake May 1, 2019
a0158c6
Expose get_commitee
JustinDrake May 1, 2019
bbcf5f0
Add 32-byte graffiti
JustinDrake May 1, 2019
427a53c
Remove get_state_root from state transition doc
JustinDrake May 1, 2019
b6b4d3c
Add get_state_root in tests
JustinDrake May 1, 2019
4079027
Update 0_beacon-chain.md
JustinDrake May 1, 2019
f62126d
Update 0_beacon-chain.md
JustinDrake May 1, 2019
5f341ae
Move `get_state_root` to `pyspec/tests/helpers.py`
hwwhww May 1, 2019
a25103c
Merge pull request #1013 from terencechain/patch-69
djrtwo May 1, 2019
e85678a
restore compute_committee
JustinDrake May 1, 2019
9d1ec58
Merge pull request #1022 from ethereum/revert-981-only_setup_py
protolambda May 1, 2019
8f2c7a3
revert cache to compute_committee
djrtwo May 1, 2019
002e279
alter get_winning_crosslink.. to have same function signature as get_…
djrtwo May 1, 2019
ef72b7e
Merge branch 'master' into vbuterin-patch-2
djrtwo May 1, 2019
2ed8d99
Merge pull request #1009 from ethereum/vbuterin-patch-2
djrtwo May 1, 2019
1bb9397
Merge pull request #1014 from ethereum/JustinDrake-patch-10
djrtwo May 1, 2019
6242e54
Merge branch 'JustinDrake-patch-11' of github.com:ethereum/eth2.0-spe…
djrtwo May 1, 2019
715dc32
Merge pull request #1015 from ethereum/JustinDrake-patch-11
djrtwo May 1, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
14 changes: 7 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,15 +60,15 @@ jobs:
- restore_cache:
key: v1-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_cached_venv:
venv_name: v1-test_libs
reqs_checksum: '{{ checksum "test_libs/pyspec/setup.py" }}'
venv_name: v1-pyspec
reqs_checksum: '{{ checksum "test_libs/pyspec/requirements.txt" }}-{{ checksum "test_libs/pyspec/requirements-testing.txt" }}'
- run:
name: Install pyspec requirements
command: make install_test
- save_cached_venv:
venv_name: v1-test_libs
reqs_checksum: '{{ checksum "test_libs/pyspec/setup.py" }}'
venv_path: ./test_libs/venv
venv_name: v1-pyspec
reqs_checksum: '{{ checksum "test_libs/pyspec/requirements.txt" }}-{{ checksum "test_libs/pyspec/requirements-testing.txt" }}'
venv_path: ./test_libs/pyspec/venv
test:
docker:
- image: circleci/python:3.6
Expand All @@ -77,8 +77,8 @@ jobs:
- restore_cache:
key: v1-specs-repo-{{ .Branch }}-{{ .Revision }}
- restore_cached_venv:
venv_name: v1-test_libs
reqs_checksum: '{{ checksum "test_libs/pyspec/setup.py" }}'
venv_name: v1-pyspec
reqs_checksum: '{{ checksum "test_libs/pyspec/requirements.txt" }}-{{ checksum "test_libs/pyspec/requirements-testing.txt" }}'
- run:
name: Run py-tests
command: make citest
Expand Down
7 changes: 0 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@ venv
.venvs
.venv
/.pytest_cache
*.egg
*.egg-info
eggs
.eggs

build/
output/
Expand All @@ -17,6 +13,3 @@ eth2.0-spec-tests/

# Dynamically built from Markdown spec
test_libs/pyspec/eth2spec/phase0/spec.py

# vscode
.vscode/**
14 changes: 4 additions & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ SPEC_DIR = ./specs
SCRIPT_DIR = ./scripts
TEST_LIBS_DIR = ./test_libs
PY_SPEC_DIR = $(TEST_LIBS_DIR)/pyspec
CONFIG_HELPERS_DIR = $(TEST_LIBS_DIR)/config_helpers
YAML_TEST_DIR = ./eth2.0-spec-tests/tests
GENERATOR_DIR = ./test_generators
CONFIGS_DIR = ./configs
Expand All @@ -24,26 +23,21 @@ all: $(PY_SPEC_ALL_TARGETS) $(YAML_TEST_DIR) $(YAML_TEST_TARGETS)
clean:
rm -rf $(YAML_TEST_DIR)
rm -rf $(GENERATOR_VENVS)
rm -rf $(TEST_LIBS_DIR)/venv
rm -rf $(PY_SPEC_DIR)/.pytest_cache
rm -rf $(PY_SPEC_DIR)/venv $(PY_SPEC_DIR)/.pytest_cache
rm -rf $(PY_SPEC_ALL_TARGETS)

# "make gen_yaml_tests" to run generators
gen_yaml_tests: $(PY_SPEC_ALL_TARGETS) $(YAML_TEST_TARGETS)

# installs the packages to run pyspec tests
install_test:
cd $(TEST_LIBS_DIR); python3 -m venv venv; . venv/bin/activate; \
cd ..; cd $(CONFIG_HELPERS_DIR); pip3 install -e .; \
cd ../..; cd $(PY_SPEC_DIR); pip3 install -e .[dev];
cd $(PY_SPEC_DIR); python3 -m venv venv; . venv/bin/activate; pip3 install -r requirements-testing.txt;

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

citest: $(PY_SPEC_ALL_TARGETS)
cd $(TEST_LIBS_DIR); . venv/bin/activate; \
cd ..; cd $(PY_SPEC_DIR); mkdir -p test-reports/eth2spec; python -m pytest --junitxml=test-reports/eth2spec/test_results.xml .
cd $(PY_SPEC_DIR); mkdir -p test-reports/eth2spec; . venv/bin/activate; python -m pytest --junitxml=test-reports/eth2spec/test_results.xml .

# "make pyspec" to create the pyspec for all phases.
pyspec: $(PY_SPEC_ALL_TARGETS)
Expand Down
14 changes: 9 additions & 5 deletions configs/constant_presets/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ MAX_INDICES_PER_ATTESTATION: 4096
MIN_PER_EPOCH_CHURN_LIMIT: 4
# 2**16 (= 65,536)
CHURN_LIMIT_QUOTIENT: 65536
# Normalizes base rewards
BASE_REWARDS_PER_EPOCH: 5
# See issue 563
SHUFFLE_ROUND_COUNT: 90

Expand All @@ -36,7 +38,7 @@ MAX_EFFECTIVE_BALANCE: 32000000000
# 2**4 * 10**9 (= 16,000,000,000) Gwei
EJECTION_BALANCE: 16000000000
# 2**0 * 10**9 (= 1,000,000,000) Gwei
HIGH_BALANCE_INCREMENT: 1000000000
EFFECTIVE_BALANCE_INCREMENT: 1000000000


# Initial values
Expand Down Expand Up @@ -71,6 +73,8 @@ MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256
PERSISTENT_COMMITTEE_PERIOD: 2048
# 2**6 (= 64) epochs ~7 hours
MAX_CROSSLINK_EPOCHS: 64
# 2**2 (= 4) epochs 25.6 minutes
MIN_EPOCHS_TO_INACTIVITY_PENALTY: 4


# State list lengths
Expand All @@ -91,14 +95,14 @@ BASE_REWARD_QUOTIENT: 32
WHISTLEBLOWING_REWARD_QUOTIENT: 512
# 2**3 (= 8)
PROPOSER_REWARD_QUOTIENT: 8
# 2**24 (= 16,777,216)
INACTIVITY_PENALTY_QUOTIENT: 16777216
# 2**25 (= 33,554,432)
INACTIVITY_PENALTY_QUOTIENT: 33554432
# 2**5 (= 32)
MIN_SLASHING_PENALTY_QUOTIENT: 32


# Max operations per block
# ---------------------------------------------------------------
# 2**5 (= 32)
MIN_PENALTY_QUOTIENT: 32
# 2**4 (= 16)
MAX_PROPOSER_SLASHINGS: 16
# 2**0 (= 1)
Expand Down
15 changes: 9 additions & 6 deletions configs/constant_presets/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

# [customized] Just 8 shards for testing purposes
SHARD_COUNT: 8

# [customized] unsecure, but fast
TARGET_COMMITTEE_SIZE: 4
# 2**12 (= 4,096)
Expand All @@ -15,6 +14,8 @@ MAX_INDICES_PER_ATTESTATION: 4096
MIN_PER_EPOCH_CHURN_LIMIT: 4
# 2**16 (= 65,536)
CHURN_LIMIT_QUOTIENT: 65536
# Normalizes base rewards
BASE_REWARDS_PER_EPOCH: 5
# [customized] Faster, but unsecure.
SHUFFLE_ROUND_COUNT: 10

Expand All @@ -36,7 +37,7 @@ MAX_EFFECTIVE_BALANCE: 32000000000
# 2**4 * 10**9 (= 16,000,000,000) Gwei
EJECTION_BALANCE: 16000000000
# 2**0 * 10**9 (= 1,000,000,000) Gwei
HIGH_BALANCE_INCREMENT: 1000000000
EFFECTIVE_BALANCE_INCREMENT: 1000000000


# Initial values
Expand Down Expand Up @@ -71,6 +72,8 @@ MIN_VALIDATOR_WITHDRAWABILITY_DELAY: 256
PERSISTENT_COMMITTEE_PERIOD: 2048
# 2**6 (= 64) epochs ~7 hours
MAX_CROSSLINK_EPOCHS: 64
# 2**2 (= 4) epochs 25.6 minutes
MIN_EPOCHS_TO_INACTIVITY_PENALTY: 4


# State list lengths
Expand All @@ -91,14 +94,14 @@ BASE_REWARD_QUOTIENT: 32
WHISTLEBLOWING_REWARD_QUOTIENT: 512
# 2**3 (= 8)
PROPOSER_REWARD_QUOTIENT: 8
# 2**24 (= 16,777,216)
INACTIVITY_PENALTY_QUOTIENT: 16777216
# 2**25 (= 33,554,432)
INACTIVITY_PENALTY_QUOTIENT: 33554432
# 2**5 (= 32)
MIN_SLASHING_PENALTY_QUOTIENT: 32


# Max operations per block
# ---------------------------------------------------------------
# 2**5 (= 32)
MIN_PENALTY_QUOTIENT: 32
# 2**4 (= 16)
MAX_PROPOSER_SLASHINGS: 16
# 2**0 (= 1)
Expand Down
30 changes: 10 additions & 20 deletions scripts/phase0/build_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
def build_phase0_spec(sourcefile, outfile):
code_lines = []
code_lines.append("""

from typing import (
Any,
Callable,
Dict,
List,
NewType,
Expand All @@ -17,19 +15,16 @@ def build_phase0_spec(sourcefile, outfile):
from eth2spec.utils.minimal_ssz import *
from eth2spec.utils.bls_stub import *


""")
""")
for i in (1, 2, 3, 4, 8, 32, 48, 96):
code_lines.append("def int_to_bytes%d(x): return x.to_bytes(%d, 'little')" % (i, i))

code_lines.append("""

# stub, will get overwritten by real var
SLOTS_PER_EPOCH = 64


def slot_to_epoch(x): return x // SLOTS_PER_EPOCH


Slot = NewType('Slot', int) # uint64
Epoch = NewType('Epoch', int) # uint64
Shard = NewType('Shard', int) # uint64
Expand All @@ -38,31 +33,26 @@ def slot_to_epoch(x): return x // SLOTS_PER_EPOCH
Bytes32 = NewType('Bytes32', bytes) # bytes32
BLSPubkey = NewType('BLSPubkey', bytes) # bytes48
BLSSignature = NewType('BLSSignature', bytes) # bytes96
Any = None
Store = None
""")
""")

code_lines += function_puller.get_spec(sourcefile)

code_lines.append("""
# Monkey patch validator get committee code
# Monkey patch validator compute committee code
_compute_committee = compute_committee
committee_cache = {}


def compute_committee(validator_indices: List[ValidatorIndex],
seed: Bytes32,
index: int,
total_committees: int) -> List[ValidatorIndex]:

param_hash = (hash_tree_root(validator_indices), seed, index, total_committees)
def compute_committee(indices: List[ValidatorIndex], seed: Bytes32, index: int, count: int) -> List[ValidatorIndex]:
param_hash = (hash_tree_root(indices), seed, index, count)

if param_hash in committee_cache:
# print("Cache hit, epoch={0}".format(epoch))
print("Cache hit, param_hash: ", param_hash)
return committee_cache[param_hash]
else:
# print("Cache miss, epoch={0}".format(epoch))
ret = _compute_committee(validator_indices, seed, index, total_committees)
print("Cache miss, param_hash: ", param_hash)
ret = _compute_committee(indices, seed, index, count)
committee_cache[param_hash] = ret
return ret

Expand All @@ -88,7 +78,7 @@ def apply_constants_preset(preset: Dict[str, Any]):

# Deal with derived constants
global_vars['GENESIS_EPOCH'] = slot_to_epoch(GENESIS_SLOT)

# Initialize SSZ types again, to account for changed lengths
init_SSZ_types()
""")
Expand Down
7 changes: 4 additions & 3 deletions scripts/phase0/function_puller.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,10 @@ def get_spec(file_name: str) -> List[str]:
code_lines.append('')
for type_line in ssz_type:
code_lines.append(' ' + type_line)
code_lines.append('')
code_lines.append('\n')
code_lines.append('ssz_types = [' + ', '.join([f'\'{ssz_type_name}\'' for (ssz_type_name, _) in type_defs]) + ']')
code_lines.append('')
code_lines.append('def get_ssz_type_by_name(name: str) -> SSZType: return globals()[name]')
code_lines.append('\n')
code_lines.append('def get_ssz_type_by_name(name: str) -> SSZType:')
code_lines.append(' return globals()[name]')
code_lines.append('')
return code_lines