Skip to content

Commit 5f1b88f

Browse files
authored
Merge pull request #3192 from ethereum/dev
release for jan testnets
2 parents faa9fea + 3212c41 commit 5f1b88f

File tree

34 files changed

+721
-539
lines changed

34 files changed

+721
-539
lines changed

.github/workflows/run-tests.yml

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
name: Run spec tests and linter
2+
3+
defaults:
4+
run:
5+
shell: zsh {0}
6+
7+
env:
8+
TEST_PRESET_TYPE: "minimal"
9+
DEFAULT_BRANCH: "dev"
10+
11+
# Run tests on workflow_Dispatch
12+
on:
13+
push:
14+
branches:
15+
- dev
16+
- master
17+
pull_request:
18+
workflow_dispatch:
19+
inputs:
20+
test_preset_type:
21+
default: minimal
22+
description: Type of test to run, either mainnet or minimal
23+
type: string
24+
required: true
25+
commitRef:
26+
description: The branch, tag or SHA to checkout and build from
27+
default: dev
28+
required: true
29+
schedule:
30+
- cron: '0 0 * * *'
31+
32+
jobs:
33+
precleanup:
34+
runs-on: self-hosted
35+
if: always()
36+
steps:
37+
- name: 'Cleanup build folder'
38+
run: |
39+
ls -la ./
40+
rm -rf ./* || true
41+
rm -rf ./.??* || true
42+
ls -la ./
43+
setup-env:
44+
runs-on: self-hosted
45+
needs: precleanup
46+
steps:
47+
- name: Checkout this repo
48+
uses: actions/checkout@v3.2.0
49+
with:
50+
ref: ${{ github.event.inputs.commitRef || env.DEFAULT_BRANCH }}
51+
- uses: actions/cache@v3.2.2
52+
id: cache-git
53+
with:
54+
path: ./*
55+
key: ${{ github.sha }}
56+
57+
table_of_contents:
58+
runs-on: self-hosted
59+
needs: setup-env
60+
steps:
61+
- uses: actions/cache@v3.2.2
62+
id: restore-build
63+
with:
64+
path: ./*
65+
key: ${{ github.sha }}
66+
- name: Check table of contents
67+
run: sudo npm install -g doctoc@2 && make check_toc
68+
69+
codespell:
70+
runs-on: self-hosted
71+
needs: setup-env
72+
steps:
73+
- name: Check codespell
74+
run: pip install 'codespell<3.0.0,>=2.0.0' --user && make codespell
75+
76+
lint:
77+
runs-on: self-hosted
78+
needs: setup-env
79+
steps:
80+
- name: Run linter for pyspec
81+
run: make lint
82+
- name: Run linter for test generators
83+
run: make lint_generators
84+
85+
pyspec-tests:
86+
runs-on: self-hosted
87+
needs: [setup-env,lint,codespell,table_of_contents]
88+
strategy:
89+
matrix:
90+
version: ["phase0", "altair", "bellatrix", "capella", "eip4844"]
91+
steps:
92+
- uses: actions/cache@v3.2.2
93+
id: restore-build
94+
with:
95+
path: ./*
96+
key: ${{ github.sha }}
97+
- name: set TEST_PRESET_TYPE
98+
if: github.event.inputs.test_preset_type != ''
99+
run: |
100+
echo "spec_test_preset_type=${{ github.event.inputs.test_preset_type || env.TEST_PRESET_TYPE }}" >> $GITHUB_ENV
101+
- name: set TEST_PRESET_TYPE
102+
if: ${{ (github.event_name == 'push' && github.ref_name != 'master') || github.event_name == 'pull_request' }}
103+
run: |
104+
echo "spec_test_preset_type=${{ env.TEST_PRESET_TYPE}}" >> $GITHUB_ENV
105+
- name: set TEST_PRESET_TYPE
106+
if: ${{ github.event_name == 'push' && github.ref_name == 'master' }}
107+
run: |
108+
echo "spec_test_preset_type=mainnet" >> $GITHUB_ENV
109+
- name: set TEST_PRESET_TYPE
110+
if: github.event.schedule=='0 0 * * *'
111+
run: |
112+
echo "spec_test_preset_type=mainnet" >> $GITHUB_ENV
113+
- name: Install pyspec requirements
114+
run: make install_test
115+
- name: test-${{ matrix.version }}
116+
run: make citest fork=${{ matrix.version }} TEST_PRESET_TYPE=${{env.spec_test_preset_type}}
117+
- uses: actions/upload-artifact@v3
118+
if: always()
119+
with:
120+
name: test-${{ matrix.version }}
121+
path: tests/core/pyspec/test-reports
122+
123+
cleanup:
124+
runs-on: self-hosted
125+
needs: [setup-env,pyspec-tests,codespell,lint,table_of_contents]
126+
if: always()
127+
steps:
128+
- name: 'Cleanup build folder'
129+
run: |
130+
ls -la ./
131+
rm -rf ./* || true
132+
rm -rf ./.??* || true
133+
ls -la ./

Makefile

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SOLIDITY_DEPOSIT_CONTRACT_SOURCE = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/deposit_cont
1313
SOLIDITY_FILE_NAME = deposit_contract.json
1414
DEPOSIT_CONTRACT_TESTER_DIR = ${SOLIDITY_DEPOSIT_CONTRACT_DIR}/web3_tester
1515
CONFIGS_DIR = ./configs
16-
16+
TEST_PRESET_TYPE ?= minimal
1717
# Collect a list of generator names
1818
GENERATORS = $(sort $(dir $(wildcard $(GENERATOR_DIR)/*/.)))
1919
# Map this list of generator paths to "gen_{generator name}" entries
@@ -96,30 +96,30 @@ generate_tests: $(GENERATOR_TARGETS)
9696

9797
# "make pyspec" to create the pyspec for all phases.
9898
pyspec:
99-
. venv/bin/activate; python3 setup.py pyspecdev
99+
python3 -m venv venv; . venv/bin/activate; python3 setup.py pyspecdev
100100

101101
# installs the packages to run pyspec tests
102102
install_test:
103103
python3 -m venv venv; . venv/bin/activate; python3 -m pip install -e .[lint]; python3 -m pip install -e .[test]
104104

105-
# Testing against `minimal` config by default
105+
# Testing against `minimal` or `mainnet` config by default
106106
test: pyspec
107107
. venv/bin/activate; cd $(PY_SPEC_DIR); \
108-
python3 -m pytest -n 4 --disable-bls --cov=eth2spec.phase0.minimal --cov=eth2spec.altair.minimal --cov=eth2spec.bellatrix.minimal --cov=eth2spec.capella.minimal --cov=eth2spec.eip4844.minimal --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
108+
python3 -m pytest -n 4 --disable-bls --cov=eth2spec.phase0.$(TEST_PRESET_TYPE) --cov=eth2spec.altair.$(TEST_PRESET_TYPE) --cov=eth2spec.bellatrix.$(TEST_PRESET_TYPE) --cov=eth2spec.capella.$(TEST_PRESET_TYPE) --cov=eth2spec.eip4844.$(TEST_PRESET_TYPE) --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
109109

110-
# Testing against `minimal` config by default
110+
# Testing against `minimal` or `mainnet` config by default
111111
find_test: pyspec
112112
. venv/bin/activate; cd $(PY_SPEC_DIR); \
113-
python3 -m pytest -k=$(K) --disable-bls --cov=eth2spec.phase0.minimal --cov=eth2spec.altair.minimal --cov=eth2spec.bellatrix.minimal --cov=eth2spec.capella.minimal --cov=eth2spec.eip4844.minimal --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
113+
python3 -m pytest -k=$(K) --disable-bls --cov=eth2spec.phase0.$(TEST_PRESET_TYPE) --cov=eth2spec.altair.$(TEST_PRESET_TYPE) --cov=eth2spec.bellatrix.$(TEST_PRESET_TYPE) --cov=eth2spec.capella.$(TEST_PRESET_TYPE) --cov=eth2spec.eip4844.$(TEST_PRESET_TYPE) --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
114114

115115
citest: pyspec
116116
mkdir -p $(TEST_REPORT_DIR);
117117
ifdef fork
118118
. venv/bin/activate; cd $(PY_SPEC_DIR); \
119-
python3 -m pytest -n 4 --bls-type=milagro --fork=$(fork) --junitxml=test-reports/test_results.xml eth2spec
119+
python3 -m pytest -n 16 --bls-type=milagro --preset=$(TEST_PRESET_TYPE) --fork=$(fork) --junitxml=test-reports/test_results.xml eth2spec
120120
else
121121
. venv/bin/activate; cd $(PY_SPEC_DIR); \
122-
python3 -m pytest -n 4 --bls-type=milagro --junitxml=test-reports/test_results.xml eth2spec
122+
python3 -m pytest -n 16 --bls-type=milagro --preset=$(TEST_PRESET_TYPE) --junitxml=test-reports/test_results.xml eth2spec
123123
endif
124124

125125

@@ -135,7 +135,7 @@ check_toc: $(MARKDOWN_FILES:=.toc)
135135
rm $*.tmp
136136

137137
codespell:
138-
codespell . --skip ./.git -I .codespell-whitelist
138+
codespell . --skip "./.git,./venv,$(PY_SPEC_DIR)/.mypy_cache" -I .codespell-whitelist
139139

140140
# TODO: add future protocol upgrade patch packages to linting.
141141
# NOTE: we use `pylint` just for catching unused arguments in spec code

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Features are researched and developed in parallel, and then consolidated into se
2525
| Code Name or Topic | Specs | Notes |
2626
| - | - | - |
2727
| Capella (tentative) | <ul><li>Core</li><ul><li>[Beacon chain changes](specs/capella/beacon-chain.md)</li><li>[Capella fork](specs/capella/fork.md)</li></ul><li>Additions</li><ul><li>[Validator additions](specs/capella/validator.md)</li><li>[P2P networking](specs/capella/p2p-interface.md)</li></ul></ul> |
28-
| EIP4844 (tentative) | <ul><li>Core</li><ul><li>[Beacon Chain changes](specs/eip4844/beacon-chain.md)</li><li>[EIP-4844 fork](specs/eip4844/fork.md)</li><li>[Polynomial commitments](specs/eip4844/polynomial-commitments.md)</li></ul><li>Additions</li><ul><li>[Honest validator guide changes](specs/eip4844/validator.md)</li><li>[P2P networking](specs/eip4844/p2p-interface.md)</li></ul></ul> |
28+
| EIP4844 (tentative) | <ul><li>Core</li><ul><li>[Beacon Chain changes](specs/eip4844/beacon-chain.md)</li><li>[EIP-4844 fork](specs/eip4844/fork.md)</li><li>[Polynomial commitments](specs/eip4844/polynomial-commitments.md)</li><li>[Fork choice changes](specs/eip4844/fork-choice.md)</li></ul><li>Additions</li><ul><li>[Honest validator guide changes](specs/eip4844/validator.md)</li><li>[P2P networking](specs/eip4844/p2p-interface.md)</li></ul></ul> |
2929
| Sharding (outdated) | <ul><li>Core</li><ul><li>[Beacon Chain changes](specs/sharding/beacon-chain.md)</li></ul><li>Additions</li><ul><li>[P2P networking](specs/sharding/p2p-interface.md)</li></ul></ul> |
3030
| Custody Game (outdated) | <ul><li>Core</li><ul><li>[Beacon Chain changes](specs/custody_game/beacon-chain.md)</li></ul><li>Additions</li><ul><li>[Honest validator guide changes](specs/custody_game/validator.md)</li></ul></ul> | Dependent on sharding |
3131
| Data Availability Sampling (outdated) | <ul><li>Core</li><ul><li>[Core types and functions](specs/das/das-core.md)</li><li>[Fork choice changes](specs/das/fork-choice.md)</li></ul><li>Additions</li><ul><li>[P2P Networking](specs/das/p2p-interface.md)</li><li>[Sampling process](specs/das/sampling.md)</li></ul></ul> | <ul><li> Dependent on sharding</li><li>[Technical explainer](https://hackmd.io/@HWeNw8hNRimMm2m2GH56Cw/B1YJPGkpD)</li></ul> |

setup.py

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -638,34 +638,6 @@ def preparations(cls):
638638
@classmethod
639639
def sundry_functions(cls) -> str:
640640
return super().sundry_functions() + '\n\n' + '''
641-
#
642-
# Temporarily disable Withdrawals functions for EIP4844 testnets
643-
#
644-
645-
646-
def no_op(fn): # type: ignore
647-
# pylint: disable=unused-argument
648-
def wrapper(*args, **kw): # type: ignore
649-
return None
650-
return wrapper
651-
652-
653-
def get_empty_list_result(fn): # type: ignore
654-
# pylint: disable=unused-argument
655-
def wrapper(*args, **kw): # type: ignore
656-
return []
657-
return wrapper
658-
659-
660-
process_withdrawals = no_op(process_withdrawals)
661-
process_bls_to_execution_change = no_op(process_bls_to_execution_change)
662-
get_expected_withdrawals = get_empty_list_result(get_expected_withdrawals)
663-
664-
665-
#
666-
# End
667-
#
668-
669641
def retrieve_blobs_sidecar(slot: Slot, beacon_block_root: Root) -> PyUnion[BlobsSidecar, str]:
670642
# pylint: disable=unused-argument
671643
return "TEST"'''
@@ -1020,6 +992,7 @@ def finalize_options(self):
1020992
self.md_doc_paths += """
1021993
specs/eip4844/beacon-chain.md
1022994
specs/eip4844/fork.md
995+
specs/eip4844/fork-choice.md
1023996
specs/eip4844/polynomial-commitments.md
1024997
specs/eip4844/p2p-interface.md
1025998
specs/eip4844/validator.md

specs/altair/light-client/full-node.md

Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
- [Introduction](#introduction)
1212
- [Helper functions](#helper-functions)
1313
- [`compute_merkle_proof_for_state`](#compute_merkle_proof_for_state)
14+
- [`block_to_light_client_header`](#block_to_light_client_header)
1415
- [Deriving light client data](#deriving-light-client-data)
1516
- [`create_light_client_bootstrap`](#create_light_client_bootstrap)
1617
- [`create_light_client_update`](#create_light_client_update)
@@ -34,6 +35,19 @@ def compute_merkle_proof_for_state(state: BeaconState,
3435
...
3536
```
3637

38+
### `block_to_light_client_header`
39+
40+
```python
41+
def block_to_light_client_header(block: SignedBeaconBlock) -> BeaconBlockHeader:
42+
return BeaconBlockHeader(
43+
slot=block.message.slot,
44+
proposer_index=block.message.proposer_index,
45+
parent_root=block.message.parent_root,
46+
state_root=block.message.state_root,
47+
body_root=hash_tree_root(block.message.body),
48+
)
49+
```
50+
3751
## Deriving light client data
3852

3953
Full nodes are expected to derive light client data from historic blocks and states and provide it to other clients.
@@ -55,13 +69,7 @@ def create_light_client_bootstrap(state: BeaconState,
5569
assert hash_tree_root(header) == hash_tree_root(block.message)
5670

5771
return LightClientBootstrap(
58-
header=BeaconBlockHeader(
59-
slot=state.latest_block_header.slot,
60-
proposer_index=state.latest_block_header.proposer_index,
61-
parent_root=state.latest_block_header.parent_root,
62-
state_root=hash_tree_root(state),
63-
body_root=state.latest_block_header.body_root,
64-
),
72+
header=block_to_light_client_header(block),
6573
current_sync_committee=state.current_sync_committee,
6674
current_sync_committee_branch=compute_merkle_proof_for_state(state, CURRENT_SYNC_COMMITTEE_INDEX),
6775
)
@@ -103,42 +111,30 @@ def create_light_client_update(state: BeaconState,
103111
assert hash_tree_root(attested_header) == hash_tree_root(attested_block.message) == block.message.parent_root
104112
update_attested_period = compute_sync_committee_period_at_slot(attested_block.message.slot)
105113

114+
update = LightClientUpdate()
115+
116+
update.attested_header = block_to_light_client_header(attested_block)
117+
106118
# `next_sync_committee` is only useful if the message is signed by the current sync committee
107119
if update_attested_period == update_signature_period:
108-
next_sync_committee = attested_state.next_sync_committee
109-
next_sync_committee_branch = compute_merkle_proof_for_state(attested_state, NEXT_SYNC_COMMITTEE_INDEX)
110-
else:
111-
next_sync_committee = SyncCommittee()
112-
next_sync_committee_branch = [Bytes32() for _ in range(floorlog2(NEXT_SYNC_COMMITTEE_INDEX))]
120+
update.next_sync_committee = attested_state.next_sync_committee
121+
update.next_sync_committee_branch = compute_merkle_proof_for_state(
122+
attested_state, NEXT_SYNC_COMMITTEE_INDEX)
113123

114124
# Indicate finality whenever possible
115125
if finalized_block is not None:
116126
if finalized_block.message.slot != GENESIS_SLOT:
117-
finalized_header = BeaconBlockHeader(
118-
slot=finalized_block.message.slot,
119-
proposer_index=finalized_block.message.proposer_index,
120-
parent_root=finalized_block.message.parent_root,
121-
state_root=finalized_block.message.state_root,
122-
body_root=hash_tree_root(finalized_block.message.body),
123-
)
124-
assert hash_tree_root(finalized_header) == attested_state.finalized_checkpoint.root
127+
update.finalized_header = block_to_light_client_header(finalized_block)
128+
assert hash_tree_root(update.finalized_header) == attested_state.finalized_checkpoint.root
125129
else:
126130
assert attested_state.finalized_checkpoint.root == Bytes32()
127-
finalized_header = BeaconBlockHeader()
128-
finality_branch = compute_merkle_proof_for_state(attested_state, FINALIZED_ROOT_INDEX)
129-
else:
130-
finalized_header = BeaconBlockHeader()
131-
finality_branch = [Bytes32() for _ in range(floorlog2(FINALIZED_ROOT_INDEX))]
132-
133-
return LightClientUpdate(
134-
attested_header=attested_header,
135-
next_sync_committee=next_sync_committee,
136-
next_sync_committee_branch=next_sync_committee_branch,
137-
finalized_header=finalized_header,
138-
finality_branch=finality_branch,
139-
sync_aggregate=block.message.body.sync_aggregate,
140-
signature_slot=block.message.slot,
141-
)
131+
update.finality_branch = compute_merkle_proof_for_state(
132+
attested_state, FINALIZED_ROOT_INDEX)
133+
134+
update.sync_aggregate = block.message.body.sync_aggregate
135+
update.signature_slot = block.message.slot
136+
137+
return update
142138
```
143139

144140
Full nodes SHOULD provide the best derivable `LightClientUpdate` (according to `is_better_update`) for each sync committee period covering any epochs in range `[max(ALTAIR_FORK_EPOCH, current_epoch - MIN_EPOCHS_FOR_BLOCK_REQUESTS), current_epoch]` where `current_epoch` is defined by the current wall-clock time. Full nodes MAY also provide `LightClientUpdate` for other sync committee periods.

0 commit comments

Comments
 (0)