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

Added standalone light client patch #2130

Merged
merged 34 commits into from
Dec 17, 2020
Merged
Show file tree
Hide file tree
Changes from 30 commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7c6ede5
Added standalone light client patch
vbuterin Nov 12, 2020
9e3690a
Update specs/lightclient/beacon-chain.md
vbuterin Nov 13, 2020
620b812
Reduce reward by SLOTS_PER_EPOCH
vbuterin Nov 13, 2020
555e131
Small changes to make Justin happy
vbuterin Nov 14, 2020
e7d52d9
Significant polishing and a few substantive fixes
JustinDrake Nov 15, 2020
114e388
Fix bugs—thanks @hwwhww
JustinDrake Nov 15, 2020
1f210fd
Added light client syncing protocol
vbuterin Nov 16, 2020
97dc916
Python syntax highlighted updates
vbuterin Nov 16, 2020
ca88dd6
Removed extraneous data
vbuterin Nov 16, 2020
cbb3856
Fix ToC (cherry-picked from @hwwhww's PR)
JustinDrake Nov 16, 2020
4df3547
Make `lightclient` patch pass the linter (#2133)
hwwhww Nov 17, 2020
f9e9d7c
Update specs/lightclient/sync-protocol.md
vbuterin Nov 17, 2020
117d319
Update specs/lightclient/sync-protocol.md
vbuterin Nov 17, 2020
a5e6d77
Update specs/lightclient/sync-protocol.md
vbuterin Nov 17, 2020
1c146b2
Update specs/lightclient/sync-protocol.md
vbuterin Nov 17, 2020
5e5d03d
Update specs/lightclient/sync-protocol.md
vbuterin Nov 17, 2020
692a0aa
Update specs/lightclient/sync-protocol.md
vbuterin Nov 17, 2020
99219c8
Revamp minimal light client (lots of polish and some bug fixes)
JustinDrake Nov 17, 2020
7ffc9c5
More polish and fixes to the sync protocol
JustinDrake Nov 17, 2020
5e717a4
More polish and fixes
JustinDrake Nov 17, 2020
830efa4
Removed compact validators, make committee balance-based
vbuterin Nov 18, 2020
171b213
Added support for updates that point to finalized ancestors
vbuterin Nov 18, 2020
664bc4b
Polish and fixes including fixed-size sync committees
JustinDrake Nov 18, 2020
d16900a
Fixes from @ralexstokes
JustinDrake Nov 18, 2020
09ec581
Optimised updates as suggested by @vbuterin
JustinDrake Nov 18, 2020
5bfe61f
Embiggened sync committee size and added sub-aggregates
vbuterin Nov 25, 2020
b2d25f7
Nitpicks
JustinDrake Nov 25, 2020
3b7c025
straightforward light client edits
djrtwo Dec 7, 2020
1a30ea9
Merge branch 'dev' into vbuterin-patch-2
hwwhww Dec 7, 2020
acfe49e
executable light client patch: beacon-chain.md (#2141)
hwwhww Dec 15, 2020
e63c964
Add a FIXME comment.
hwwhww Dec 16, 2020
cc9a4cd
add base sanity light client tests
djrtwo Dec 17, 2020
89c5ca6
'light_client' -> 'sync_committee'
djrtwo Dec 17, 2020
aabc010
Merge pull request #2156 from ethereum/lc-tests
djrtwo Dec 17, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ eth2.0-spec-tests/
# Dynamically built from Markdown spec
tests/core/pyspec/eth2spec/phase0/
tests/core/pyspec/eth2spec/phase1/
tests/core/pyspec/eth2spec/lightclient_patch/

# coverage reports
.htmlcov
Expand Down
9 changes: 5 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ GENERATOR_VENVS = $(patsubst $(GENERATOR_DIR)/%, $(GENERATOR_DIR)/%venv, $(GENER
# To check generator matching:
#$(info $$GENERATOR_TARGETS is [${GENERATOR_TARGETS}])

MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/phase0/*.md) $(wildcard $(SPEC_DIR)/phase1/*.md) $(wildcard $(SSZ_DIR)/*.md) $(wildcard $(SPEC_DIR)/networking/*.md) $(wildcard $(SPEC_DIR)/validator/*.md)
MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/phase0/*.md) $(wildcard $(SPEC_DIR)/phase1/*.md) $(wildcard $(SPEC_DIR)/lightclient/*.md) $(wildcard $(SSZ_DIR)/*.md) $(wildcard $(SPEC_DIR)/networking/*.md) $(wildcard $(SPEC_DIR)/validator/*.md)

COV_HTML_OUT=.htmlcov
COV_INDEX_FILE=$(PY_SPEC_DIR)/$(COV_HTML_OUT)/index.html
Expand Down Expand Up @@ -49,6 +49,7 @@ partial_clean:
rm -rf $(DEPOSIT_CONTRACT_TESTER_DIR)/.pytest_cache
rm -rf $(PY_SPEC_DIR)/phase0
rm -rf $(PY_SPEC_DIR)/phase1
rm -rf $(PY_SPEC_DIR)/lightclient
rm -rf $(PY_SPEC_DIR)/$(COV_HTML_OUT)
rm -rf $(PY_SPEC_DIR)/.coverage
rm -rf $(PY_SPEC_DIR)/test-reports
Expand Down Expand Up @@ -85,11 +86,11 @@ install_test:

test: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
python -m pytest -n 4 --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
python -m pytest -n 4 --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov=eth2spec.lightclient_patch.spec -cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec

find_test: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
python -m pytest -k=$(K) --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
python -m pytest -k=$(K) --disable-bls --cov=eth2spec.phase0.spec --cov=eth2spec.phase1.spec --cov=eth2spec.lightclient_patch.spec --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec

citest: pyspec
mkdir -p tests/core/pyspec/test-reports/eth2spec; . venv/bin/activate; cd $(PY_SPEC_DIR); \
Expand All @@ -112,7 +113,7 @@ codespell:
lint: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
flake8 --config $(LINTER_CONFIG_FILE) ./eth2spec \
&& mypy --config-file $(LINTER_CONFIG_FILE) -p eth2spec.phase0 -p eth2spec.phase1
&& mypy --config-file $(LINTER_CONFIG_FILE) -p eth2spec.phase0 -p eth2spec.phase1 -p eth2spec.lightclient_patch

lint_generators: pyspec
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
Expand Down
21 changes: 21 additions & 0 deletions configs/mainnet/lightclient_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Mainnet preset - lightclient patch

CONFIG_NAME: "mainnet"

# Misc
# ---------------------------------------------------------------
# 2**10 (=1,024)
SYNC_COMMITTEE_SIZE: 1024
# 2**6 (=64)
SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE: 64


# Time parameters
# ---------------------------------------------------------------
# 2**8 (= 256)
EPOCHS_PER_SYNC_COMMITTEE_PERIOD: 256


# Signature domains
# ---------------------------------------------------------------
DOMAIN_SYNC_COMMITTEE: 0x07000000
21 changes: 21 additions & 0 deletions configs/minimal/lightclient_patch.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Minimal preset - lightclient patch

CONFIG_NAME: "minimal"

# Misc
# ---------------------------------------------------------------
# [customized]
SYNC_COMMITTEE_SIZE: 64
# [customized]
SYNC_COMMITTEE_PUBKEY_AGGREGATES_SIZE: 16


# Time parameters
# ---------------------------------------------------------------
# 2**8 (= 256)
EPOCHS_PER_SYNC_COMMITTEE_PERIOD: 256


# Signature domains
# ---------------------------------------------------------------
DOMAIN_SYNC_COMMITTEE: 0x07000000
52 changes: 49 additions & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,9 @@ def get_spec(file_name: str) -> SpecObject:
else:
# Handle function definitions & ssz_objects
if pulling_from is not None:
if len(line) > 18 and line[:6] == 'class ' and line[-12:] == '(Container):':
name = line[6:-12]
if len(line) > 18 and line[:6] == 'class ' and (line[-12:] == '(Container):' or '(phase' in line):
end = -12 if line[-12:] == '(Container):' else line.find('(')
name = line[6:end]
# Check consistency with markdown header
assert name == current_name
block_type = CodeBlockType.SSZ
Expand Down Expand Up @@ -156,6 +157,40 @@ def get_spec(file_name: str) -> SpecObject:

CONFIG_NAME = 'mainnet'
'''
LIGHTCLIENT_IMPORT = '''from eth2spec.phase0 import spec as phase0
from eth2spec.config.config_util import apply_constants_config
from typing import (
Any, Dict, Set, Sequence, NewType, Tuple, TypeVar, Callable, Optional
)

from dataclasses import (
dataclass,
field,
)

from lru import LRU

from eth2spec.utils.ssz.ssz_impl import hash_tree_root, copy, uint_to_bytes
from eth2spec.utils.ssz.ssz_typing import (
View, boolean, Container, List, Vector, uint8, uint32, uint64,
Bytes1, Bytes4, Bytes32, Bytes48, Bytes96, Bitlist, Bitvector,
)
from eth2spec.utils import bls

from eth2spec.utils.hash_function import hash

# Whenever lightclient is loaded, make sure we have the latest phase0
from importlib import reload
reload(phase0)


SSZVariableName = str
GeneralizedIndex = NewType('GeneralizedIndex', int)
SSZObject = TypeVar('SSZObject', bound=View)

CONFIG_NAME = 'mainnet'
'''

SUNDRY_CONSTANTS_FUNCTIONS = '''
def ceillog2(x: int) -> uint64:
if x < 1:
Expand Down Expand Up @@ -351,6 +386,7 @@ def combine_spec_objects(spec0: SpecObject, spec1: SpecObject) -> SpecObject:
fork_imports = {
'phase0': PHASE0_IMPORTS,
'phase1': PHASE1_IMPORTS,
'lightclient_patch': LIGHTCLIENT_IMPORT,
}


Expand Down Expand Up @@ -417,6 +453,16 @@ def finalize_options(self):
specs/phase1/shard-fork-choice.md
specs/phase1/validator.md
"""
elif self.spec_fork == "lightclient_patch":
self.md_doc_paths = """
specs/phase0/beacon-chain.md
specs/phase0/fork-choice.md
specs/phase0/validator.md
specs/phase0/weak-subjectivity.md
specs/lightclient/beacon-chain.md
specs/lightclient/lightclient-fork.md
"""
# TODO: add specs/lightclient/sync-protocol.md back when the GeneralizedIndex helpers are included.
else:
raise Exception('no markdown files specified, and spec fork "%s" is unknown', self.spec_fork)

Expand Down Expand Up @@ -539,7 +585,7 @@ def run(self):
"py_ecc==5.0.0",
"milagro_bls_binding==1.5.0",
"dataclasses==0.6",
"remerkleable==0.1.17",
"remerkleable==0.1.18",
"ruamel.yaml==0.16.5",
"lru-dict==1.1.6"
]
Expand Down
Loading