Skip to content

Commit 9a0b3ef

Browse files
authored
Merge pull request #4078 from ethereum/dev
Release v1.5.0-beta.0
2 parents 7deecbb + da17461 commit 9a0b3ef

Some content is hidden

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

47 files changed

+2201
-713
lines changed

.circleci/config.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ commands:
3535
description: "Restore the cache with pyspec keys"
3636
steps:
3737
- restore_cached_venv:
38-
venv_name: v30-pyspec
38+
venv_name: v32-pyspec
3939
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "requirements_preinstallation.txt" }}
4040
save_pyspec_cached_venv:
4141
description: Save a venv into a cache with pyspec keys"
4242
steps:
4343
- save_cached_venv:
44-
venv_name: v30-pyspec
44+
venv_name: v32-pyspec
4545
reqs_checksum: cache-{{ checksum "setup.py" }}-{{ checksum "requirements_preinstallation.txt" }}
4646
venv_path: ./venv
4747
jobs:

Makefile

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ ALL_EXECUTABLE_SPEC_NAMES = \
1616

1717
# A list of fake targets.
1818
.PHONY: \
19-
check_toc \
2019
clean \
2120
coverage \
2221
detect_errors \
@@ -39,7 +38,6 @@ NORM = $(shell tput sgr0)
3938

4039
# Print target descriptions.
4140
help:
42-
@echo "make $(BOLD)check_toc$(NORM) -- check table of contents"
4341
@echo "make $(BOLD)clean$(NORM) -- delete all untracked files"
4442
@echo "make $(BOLD)coverage$(NORM) -- run pyspec tests with coverage"
4543
@echo "make $(BOLD)detect_errors$(NORM) -- detect generator errors"
@@ -85,7 +83,7 @@ $(ETH2SPEC): setup.py | $(VENV)
8583

8684
# Force rebuild/install the eth2spec package.
8785
eth2spec:
88-
$(MAKE) --always-make $(ETH2SPEC)
86+
@$(MAKE) --always-make $(ETH2SPEC)
8987

9088
# Create the pyspec for all phases.
9189
pyspec: $(VENV) setup.py
@@ -99,6 +97,8 @@ pyspec: $(VENV) setup.py
9997
TEST_REPORT_DIR = $(PYSPEC_DIR)/test-reports
10098

10199
# Run pyspec tests.
100+
# Note: for debugging output to show, print to stderr.
101+
#
102102
# To run a specific test, append k=<test>, eg:
103103
# make test k=test_verify_kzg_proof
104104
# To run tests for a specific fork, append fork=<fork>, eg:
@@ -117,6 +117,7 @@ test: $(ETH2SPEC) pyspec
117117
@mkdir -p $(TEST_REPORT_DIR)
118118
@$(PYTHON_VENV) -m pytest \
119119
-n auto \
120+
--capture=no \
120121
$(MAYBE_TEST) \
121122
$(MAYBE_FORK) \
122123
$(PRESET) \
@@ -193,10 +194,6 @@ MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/*/*.md) \
193194
$(wildcard $(SPEC_DIR)/_features/*/*/*.md) \
194195
$(wildcard $(SSZ_DIR)/*.md)
195196

196-
# Check all files and error if any ToC were modified.
197-
check_toc: $(MARKDOWN_FILES:=.toc)
198-
@[ "$$(find . -name '*.md.tmp' -print -quit)" ] && exit 1 || exit 0
199-
200197
# Generate ToC sections & save copy of original if modified.
201198
%.toc:
202199
@cp $* $*.tmp; \
@@ -209,8 +206,12 @@ check_toc: $(MARKDOWN_FILES:=.toc)
209206
echo "\033[1;34m See $*.tmp\033[0m"; \
210207
fi
211208

209+
# Check all files and error if any ToC were modified.
210+
_check_toc: $(MARKDOWN_FILES:=.toc)
211+
@[ "$$(find . -name '*.md.tmp' -print -quit)" ] && exit 1 || exit 0
212+
212213
# Check for mistakes.
213-
lint: $(ETH2SPEC) pyspec check_toc
214+
lint: $(ETH2SPEC) pyspec _check_toc
214215
@$(CODESPELL_VENV) . --skip "./.git,$(VENV),$(PYSPEC_DIR)/.mypy_cache" -I .codespell-whitelist
215216
@$(PYTHON_VENV) -m flake8 --config $(FLAKE8_CONFIG) $(PYSPEC_DIR)/eth2spec
216217
@$(PYTHON_VENV) -m flake8 --config $(FLAKE8_CONFIG) $(TEST_GENERATORS_DIR)
@@ -235,17 +236,19 @@ gen_list:
235236
done
236237

237238
# Run one generator.
239+
# This will forcibly rebuild eth2spec just in case.
238240
# To check modules for a generator, append modcheck=true, eg:
239241
# make gen_genesis modcheck=true
240242
gen_%: MAYBE_MODCHECK := $(if $(filter true,$(modcheck)),--modcheck)
241-
gen_%: $(ETH2SPEC) pyspec
243+
gen_%: eth2spec
242244
@mkdir -p $(TEST_VECTOR_DIR)
243245
@$(PYTHON_VENV) $(GENERATOR_DIR)/$*/main.py \
244246
--output $(TEST_VECTOR_DIR) \
245247
$(MAYBE_MODCHECK)
246248

247249
# Run all generators then check for errors.
248-
gen_all: $(GENERATOR_TARGETS) detect_errors
250+
gen_all: $(GENERATOR_TARGETS)
251+
@$(MAKE) detect_errors
249252

250253
# Detect errors in generators.
251254
detect_errors: $(TEST_VECTOR_DIR)

configs/mainnet.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,15 +115,13 @@ DEPOSIT_CONTRACT_ADDRESS: 0x00000000219ab540356cBB839Cbe05303d7705Fa
115115
# Networking
116116
# ---------------------------------------------------------------
117117
# `10 * 2**20` (= 10485760, 10 MiB)
118-
GOSSIP_MAX_SIZE: 10485760
118+
MAX_PAYLOAD_SIZE: 10485760
119119
# `2**10` (= 1024)
120120
MAX_REQUEST_BLOCKS: 1024
121121
# `2**8` (= 256)
122122
EPOCHS_PER_SUBNET_SUBSCRIPTION: 256
123123
# `MIN_VALIDATOR_WITHDRAWABILITY_DELAY + CHURN_LIMIT_QUOTIENT // 2` (= 33024, ~5 months)
124124
MIN_EPOCHS_FOR_BLOCK_REQUESTS: 33024
125-
# `10 * 2**20` (=10485760, 10 MiB)
126-
MAX_CHUNK_SIZE: 10485760
127125
# 5s
128126
TTFB_TIMEOUT: 5
129127
# 10s

configs/minimal.yaml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,15 +116,13 @@ DEPOSIT_CONTRACT_ADDRESS: 0x1234567890123456789012345678901234567890
116116
# Networking
117117
# ---------------------------------------------------------------
118118
# `10 * 2**20` (= 10485760, 10 MiB)
119-
GOSSIP_MAX_SIZE: 10485760
119+
MAX_PAYLOAD_SIZE: 10485760
120120
# `2**10` (= 1024)
121121
MAX_REQUEST_BLOCKS: 1024
122122
# `2**8` (= 256)
123123
EPOCHS_PER_SUBNET_SUBSCRIPTION: 256
124124
# [customized] `MIN_VALIDATOR_WITHDRAWABILITY_DELAY + CHURN_LIMIT_QUOTIENT // 2` (= 272)
125125
MIN_EPOCHS_FOR_BLOCK_REQUESTS: 272
126-
# `10 * 2**20` (=10485760, 10 MiB)
127-
MAX_CHUNK_SIZE: 10485760
128126
# 5s
129127
TTFB_TIMEOUT: 5
130128
# 10s

docker/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Handy commands:
1010

1111
Ideally manual running of docker containers is for advanced users, we recommend the script based approach described below for most users.
1212

13-
The `scripts/build_run_docker_tests.sh` script will cover most usecases. The script allows the user to configure the fork(altair/bellatrix/capella..), `$IMAGE_NAME` (specifies the container to use), preset type (mainnet/minimal), and test all forks flags. Ideally, this is the main way that users interact with the spec tests instead of running it locally with varying versions of dependencies.
13+
The `scripts/build_run_docker_tests.sh` script will cover most use cases. The script allows the user to configure the fork(altair/bellatrix/capella..), `$IMAGE_NAME` (specifies the container to use), preset type (mainnet/minimal), and test all forks flags. Ideally, this is the main way that users interact with the spec tests instead of running it locally with varying versions of dependencies.
1414

1515
E.g:
1616
- `./build_run_docker_tests.sh --p mainnet` will run the mainnet preset tests

setup.py

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
import copy
1313
from collections import OrderedDict
1414
import json
15-
from functools import reduce
15+
from functools import lru_cache
1616

1717
from pysetup.constants import (
1818
# code names
@@ -70,22 +70,26 @@ def installPackage(package: str):
7070
from marko.ext.gfm.elements import Table
7171

7272

73+
@lru_cache(maxsize=None)
7374
def _get_name_from_heading(heading: Heading) -> Optional[str]:
7475
last_child = heading.children[-1]
7576
if isinstance(last_child, CodeSpan):
7677
return last_child.children
7778
return None
7879

7980

81+
@lru_cache(maxsize=None)
8082
def _get_source_from_code_block(block: FencedCode) -> str:
8183
return block.children[0].children.strip()
8284

8385

86+
@lru_cache(maxsize=None)
8487
def _get_function_name_from_source(source: str) -> str:
8588
fn = ast.parse(source).body[0]
8689
return fn.name
8790

8891

92+
@lru_cache(maxsize=None)
8993
def _get_self_type_from_source(source: str) -> Optional[str]:
9094
fn = ast.parse(source).body[0]
9195
args = fn.args.args
@@ -98,6 +102,7 @@ def _get_self_type_from_source(source: str) -> Optional[str]:
98102
return args[0].annotation.id
99103

100104

105+
@lru_cache(maxsize=None)
101106
def _get_class_info_from_source(source: str) -> Tuple[str, Optional[str]]:
102107
class_def = ast.parse(source).body[0]
103108
base = class_def.bases[0]
@@ -113,12 +118,14 @@ def _get_class_info_from_source(source: str) -> Tuple[str, Optional[str]]:
113118
return class_def.name, parent_class
114119

115120

121+
@lru_cache(maxsize=None)
116122
def _is_constant_id(name: str) -> bool:
117123
if name[0] not in string.ascii_uppercase + '_':
118124
return False
119125
return all(map(lambda c: c in string.ascii_uppercase + '_' + string.digits, name[1:]))
120126

121127

128+
@lru_cache(maxsize=None)
122129
def _load_kzg_trusted_setups(preset_name):
123130
trusted_setups_file_path = str(Path(__file__).parent) + '/presets/' + preset_name + '/trusted_setups/trusted_setup_4096.json'
124131

@@ -130,6 +137,7 @@ def _load_kzg_trusted_setups(preset_name):
130137

131138
return trusted_setup_G1_monomial, trusted_setup_G1_lagrange, trusted_setup_G2_monomial
132139

140+
@lru_cache(maxsize=None)
133141
def _load_curdleproofs_crs(preset_name):
134142
"""
135143
NOTE: File generated from https://github.com/asn-d6/curdleproofs/blob/8e8bf6d4191fb6a844002f75666fb7009716319b/tests/crs.rs#L53-L67
@@ -153,6 +161,7 @@ def _load_curdleproofs_crs(preset_name):
153161
}
154162

155163

164+
@lru_cache(maxsize=None)
156165
def _get_eth2_spec_comment(child: LinkRefDef) -> Optional[str]:
157166
_, _, title = child._parse_info
158167
if not (title[0] == "(" and title[len(title)-1] == ")"):
@@ -163,6 +172,7 @@ def _get_eth2_spec_comment(child: LinkRefDef) -> Optional[str]:
163172
return title[len(ETH2_SPEC_COMMENT_PREFIX):].strip()
164173

165174

175+
@lru_cache(maxsize=None)
166176
def _parse_value(name: str, typed_value: str, type_hint: Optional[str] = None) -> VariableDefinition:
167177
comment = None
168178
if name in ("ROOT_OF_UNITY_EXTENDED", "ROOTS_OF_UNITY_EXTENDED", "ROOTS_OF_UNITY_REDUCED"):
@@ -185,6 +195,11 @@ def _update_constant_vars_with_kzg_setups(constant_vars, preset_name):
185195
constant_vars['KZG_SETUP_G2_MONOMIAL'] = VariableDefinition(constant_vars['KZG_SETUP_G2_MONOMIAL'].value, str(kzg_setups[2]), comment, None)
186196

187197

198+
@lru_cache(maxsize=None)
199+
def parse_markdown(content: str):
200+
return gfm.parse(content)
201+
202+
188203
def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str], preset_name=str) -> SpecObject:
189204
functions: Dict[str, str] = {}
190205
protocols: Dict[str, ProtocolDefinition] = {}
@@ -198,7 +213,7 @@ def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str], pr
198213
custom_types: Dict[str, str] = {}
199214

200215
with open(file_name) as source_file:
201-
document = gfm.parse(source_file.read())
216+
document = parse_markdown(source_file.read())
202217

203218
current_name = None
204219
should_skip = False
@@ -326,6 +341,7 @@ def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str], pr
326341
)
327342

328343

344+
@lru_cache(maxsize=None)
329345
def load_preset(preset_files: Sequence[Path]) -> Dict[str, str]:
330346
"""
331347
Loads the a directory of preset files, merges the result into one preset.
@@ -344,6 +360,7 @@ def load_preset(preset_files: Sequence[Path]) -> Dict[str, str]:
344360
return parse_config_vars(preset)
345361

346362

363+
@lru_cache(maxsize=None)
347364
def load_config(config_path: Path) -> Dict[str, str]:
348365
"""
349366
Loads the given configuration file.
@@ -358,7 +375,7 @@ def build_spec(fork: str,
358375
source_files: Sequence[Path],
359376
preset_files: Sequence[Path],
360377
config_file: Path) -> str:
361-
preset = load_preset(preset_files)
378+
preset = load_preset(tuple(preset_files))
362379
config = load_config(config_file)
363380
all_specs = [get_spec(spec, preset, config, preset_name) for spec in source_files]
364381

specs/_features/custody_game/beacon-chain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ def process_custody_slashing(state: BeaconState, signed_custody_slashing: Signed
619619
for attester_index in attesters:
620620
if attester_index != custody_slashing.malefactor_index:
621621
increase_balance(state, attester_index, whistleblower_reward)
622-
# No special whisteblower reward: it is expected to be an attester. Others are free to slash too however.
622+
# No special whistleblower reward: it is expected to be an attester. Others are free to slash too however.
623623
else:
624624
# The claim was false, the custody bit was correct. Slash the whistleblower that induced this work.
625625
slash_validator(state, custody_slashing.whistleblower_index)

specs/_features/eip7732/p2p-interface.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ The *type* of the payload of this topic changes to the (modified) `SignedBeaconB
130130

131131
There are no new validations for this topic. However, all validations with regards to the `ExecutionPayload` are removed:
132132

133-
- _[REJECT]_ The length of KZG commitments is less than or equal to the limitation defined in Consensus Layer -- i.e. validate that len(body.signed_beacon_block.message.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK
133+
- _[REJECT]_ The length of KZG commitments is less than or equal to the limitation defined in Consensus Layer -- i.e. validate that `len(signed_beacon_block.message.body.blob_kzg_commitments) <= MAX_BLOBS_PER_BLOCK`
134134
- _[REJECT]_ The block's execution payload timestamp is correct with respect to the slot
135135
-- i.e. `execution_payload.timestamp == compute_timestamp_at_slot(state, block.slot)`.
136136
- If `execution_payload` verification of block's parent by an execution node is *not* complete:
@@ -151,7 +151,7 @@ This topic is used to propagate execution payload messages as `SignedExecutionPa
151151

152152
The following validations MUST pass before forwarding the `signed_execution_payload_envelope` on the network, assuming the alias `envelope = signed_execution_payload_envelope.message`, `payload = payload_envelope.payload`:
153153

154-
- _[IGNORE]_ The envelope's block root `envelope.block_root` has been seen (via both gossip and non-gossip sources) (a client MAY queue payload for processing once the block is retrieved).
154+
- _[IGNORE]_ The envelope's block root `envelope.block_root` has been seen (via gossip or non-gossip sources) (a client MAY queue payload for processing once the block is retrieved).
155155
- _[IGNORE]_ The node has not seen another valid `SignedExecutionPayloadEnvelope` for this block root from this builder.
156156

157157
Let `block` be the block with `envelope.beacon_block_root`.
@@ -171,7 +171,7 @@ The following validations MUST pass before forwarding the `payload_attestation_m
171171
- _[IGNORE]_ The message's slot is for the current slot (with a `MAXIMUM_GOSSIP_CLOCK_DISPARITY` allowance), i.e. `data.slot == current_slot`.
172172
- _[REJECT]_ The message's payload status is a valid status, i.e. `data.payload_status < PAYLOAD_INVALID_STATUS`.
173173
- _[IGNORE]_ The `payload_attestation_message` is the first valid message received from the validator with index `payload_attestation_message.validate_index`.
174-
- _[IGNORE]_ The message's block `data.beacon_block_root` has been seen (via both gossip and non-gossip sources) (a client MAY queue attestation for processing once the block is retrieved. Note a client might want to request payload after).
174+
- _[IGNORE]_ The message's block `data.beacon_block_root` has been seen (via gossip or non-gossip sources) (a client MAY queue attestation for processing once the block is retrieved. Note a client might want to request payload after).
175175
- _[REJECT]_ The message's block `data.beacon_block_root` passes validation.
176176
- _[REJECT]_ The message's validator index is within the payload committee in `get_ptc(state, data.slot)`. The `state` is the head state corresponding to processing the block up to the current slot as determined by the fork choice.
177177
- _[REJECT]_ The message's signature of `payload_attestation_message.signature` is valid with respect to the validator index.

specs/_features/whisk/beacon-chain.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ This document details the beacon chain additions and changes of to support the W
5454
| `WHISK_PROPOSER_TRACKERS_COUNT` | `uint64(2**13)` (= 8,192) | number of proposer trackers |
5555
| `WHISK_VALIDATORS_PER_SHUFFLE` | `uint64(2**7 - 4)` (= 124) | number of validators shuffled per shuffle step |
5656
| `WHISK_MAX_SHUFFLE_PROOF_SIZE` | `uint64(2**15)` | max size of a shuffle proof |
57-
| `WHISK_MAX_OPENING_PROOF_SIZE` | `uint64(2**10)` | max size of a opening proof |
57+
| `WHISK_MAX_OPENING_PROOF_SIZE` | `uint64(2**10)` | max size of an opening proof |
5858

5959
## Configuration
6060

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ Full nodes SHOULD provide the best derivable `LightClientUpdate` (according to `
146146

147147
- `LightClientUpdate` are assigned to sync committee periods based on their `attested_header.beacon.slot`
148148
- `LightClientUpdate` are only considered if `compute_sync_committee_period_at_slot(update.attested_header.beacon.slot) == compute_sync_committee_period_at_slot(update.signature_slot)`
149-
- Only `LightClientUpdate` with `next_sync_committee` as selected by fork choice are provided, regardless of ranking by `is_better_update`. To uniquely identify a non-finalized sync committee fork, all of `period`, `current_sync_committee` and `next_sync_committee` need to be incorporated, as sync committees may reappear over time.
149+
- Only `LightClientUpdate` with `sync_aggregate` from blocks on the canonical chain as selected by fork choice are considered, regardless of ranking by `is_better_update`. `LightClientUpdate` referring to orphaned blocks SHOULD NOT be provided.
150150

151151
### `create_light_client_finality_update`
152152

0 commit comments

Comments
 (0)