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

Release v1.3.0-alpha.0 #3055

Merged
merged 53 commits into from
Oct 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
70f90c5
rmove withdrawn_epoch
djrtwo Sep 19, 2022
91ea9e6
review suggestion from @hwwhww
djrtwo Sep 20, 2022
ceee7bf
EIP-4844: Fee market updates to execution
Inphi Sep 21, 2022
bfca7f9
Apply suggestions from code review
djrtwo Sep 21, 2022
fdb5c7d
Add partial withdrawal balance tests
jtraglia Sep 22, 2022
f4ba8b5
EIP4844: Implement reverse bit ordering in KZG commitments
asn-d6 Sep 26, 2022
d197ed1
EIP4844: Introduce bytes_to_bls_field() helper
asn-d6 Sep 26, 2022
eeebd42
Merge pull request #2998 from ethereum/remove-withdrawn-epoch
djrtwo Sep 26, 2022
0fdab61
Merge pull request #3010 from jtraglia/partial-withdrawal-balance-tests
djrtwo Sep 26, 2022
6c2b46a
Merge pull request #3015 from asn-d6/bytes_to_bls_field
asn-d6 Sep 26, 2022
9ac605c
Fix incorrect comment
xrchz Sep 27, 2022
44424c4
Bump dep packages version and fix lint issues
hwwhww Sep 28, 2022
93cb17d
Eip4844: various fixes
terencechain Sep 29, 2022
06c91e4
Try a different format for epoch
terencechain Sep 29, 2022
779e6e7
Update specs/eip4844/p2p-interface.md
terencechain Sep 29, 2022
55c195d
Merge pull request #3017 from xrchz/dev
hwwhww Sep 30, 2022
9dfb189
Merge pull request #3004 from Inphi/inphi/eip4844-fee-mkt
djrtwo Sep 30, 2022
6b9e65f
Merge pull request #3019 from terencechain/fix-eip4844
djrtwo Sep 30, 2022
807650e
Fix some type annotations for blobs
xrchz Oct 1, 2022
fda2a69
Typo in sync committee duties description
dapplion Oct 2, 2022
7b1b937
Merge pull request #3021 from xrchz/dev
asn-d6 Oct 5, 2022
491f14c
some capella sanity tests
djrtwo Sep 19, 2022
4e26813
Merge pull request #3023 from dapplion/patch-1
ralexstokes Oct 6, 2022
3552e2f
Merge pull request #3018 from ethereum/bump-dep
hwwhww Oct 6, 2022
092617e
Remove duplicated definition of `Validator`
ralexstokes Oct 9, 2022
ae89e4e
Merge pull request #3029 from ethereum/ralexstokes-patch-1
hwwhww Oct 10, 2022
9717daa
Merge branch 'dev' into more-withdrawals-tests
hwwhww Oct 10, 2022
8dcd501
Merge pull request #3024 from ethereum/more-withdrawals-tests
hwwhww Oct 13, 2022
24f8ec1
Remove work-in-progress notes in Bellatrix specs (#3033)
ethosdev Oct 14, 2022
6181035
Fix typo (#3039)
hwwhww Oct 15, 2022
03ced9c
Add Capella tests
hwwhww Oct 13, 2022
b90436c
Fix capella random & fork
hwwhww Oct 14, 2022
940fc20
Apply suggestions from code review
hwwhww Oct 17, 2022
eb5a2c2
Couple beacon block and blob sidecar for p2p
terencechain Oct 17, 2022
96b9020
Fix ToC
terencechain Oct 17, 2022
b128148
Modify `MIN_EPOCHS_FOR_BLOBS_SIDECARS_REQUESTS` to 18 days
terencechain Oct 17, 2022
0345b22
Add validator_index to Withdrawal.
mcdee Oct 18, 2022
779d9be
Compare sidecar slot with block slot
terencechain Oct 18, 2022
cab2e3e
Describe sidecar and block are recieved together
terencechain Oct 18, 2022
dfa5ac8
@protolambda's feedback, `SignedBlobsSidecar` -> `BlobsSidecar`
terencechain Oct 18, 2022
53b63ce
Merge branch 'dev' into pr3050
hwwhww Oct 19, 2022
d013379
Ensure `validator_index` is in validator set
hwwhww Oct 19, 2022
46e4473
Merge pull request #3050 from mcdee/withdrawal-add-validator
hwwhww Oct 20, 2022
0e2c3d8
Fill `bls_to_execution_changes` field in Capella random tests
hwwhww Oct 21, 2022
f48d6b3
Update test formats
hwwhww Oct 21, 2022
9f4ae4c
Update validator spec with `SignedBeaconBlockAndBlobsSidecar`
terencechain Oct 22, 2022
e2d0a4f
Fix ToC and test
terencechain Oct 22, 2022
9844ea1
Merge pull request #3040 from ethereum/capella-test-vectors
hwwhww Oct 22, 2022
3c7c3a9
bump VERSION.txt to 1.3.0-alpha.0 (#3056)
hwwhww Oct 25, 2022
b7c72c3
Merge pull request #3047 from terencechain/reduce-min-epochs-blobs-reqs
hwwhww Oct 26, 2022
af8c5bf
Merge pull request #3046 from terencechain/couple-block-sidecar
hwwhww Oct 26, 2022
6c7922d
Fix bls test case file name
hwwhww Oct 26, 2022
aac851f
Merge pull request #3060 from ethereum/fix-bls-test-file-format
hwwhww Oct 26, 2022
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
4 changes: 3 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ partial_clean:
rm -rf $(ETH2SPEC_MODULE_DIR)/phase0
rm -rf $(ETH2SPEC_MODULE_DIR)/altair
rm -rf $(ETH2SPEC_MODULE_DIR)/bellatrix
rm -rf $(ETH2SPEC_MODULE_DIR)/capella
rm -rf $(ETH2SPEC_MODULE_DIR)/eip4844
rm -rf $(COV_HTML_OUT_DIR)
rm -rf $(TEST_REPORT_DIR)
rm -rf eth2spec.egg-info dist build
Expand Down Expand Up @@ -143,7 +145,7 @@ lint: pyspec

lint_generators: pyspec
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
flake8 --config $(LINTER_CONFIG_FILE)
flake8 --config $(LINTER_CONFIG_FILE)

compile_deposit_contract:
@cd $(SOLIDITY_DEPOSIT_CONTRACT_DIR)
Expand Down
2 changes: 1 addition & 1 deletion presets/minimal/capella.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@ MAX_BLS_TO_EXECUTION_CHANGES: 16
# Execution
# ---------------------------------------------------------------
# [customized] Lower than MAX_PARTIAL_WITHDRAWALS_PER_EPOCH so not all processed in one block
MAX_WITHDRAWALS_PER_PAYLOAD: 16
MAX_WITHDRAWALS_PER_PAYLOAD: 8
47 changes: 30 additions & 17 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
def installPackage(package: str):
subprocess.check_call([sys.executable, '-m', 'pip', 'install', package])

RUAMEL_YAML_VERSION = "ruamel.yaml==0.16.5"
RUAMEL_YAML_VERSION = "ruamel.yaml==0.17.21"
try:
import ruamel.yaml
except ImportError:
Expand Down Expand Up @@ -78,6 +78,7 @@ class VariableDefinition(NamedTuple):
type_name: Optional[str]
value: str
comment: Optional[str] # e.g. "noqa: E501"
type_hint: Optional[str] # e.g., "Final"


class SpecObject(NamedTuple):
Expand Down Expand Up @@ -152,18 +153,18 @@ def _get_eth2_spec_comment(child: LinkRefDef) -> Optional[str]:
return title[len(ETH2_SPEC_COMMENT_PREFIX):].strip()


def _parse_value(name: str, typed_value: str) -> VariableDefinition:
def _parse_value(name: str, typed_value: str, type_hint: Optional[str]=None) -> VariableDefinition:
comment = None
if name == "BLS12_381_Q":
comment = "noqa: E501"

typed_value = typed_value.strip()
if '(' not in typed_value:
return VariableDefinition(type_name=None, value=typed_value, comment=comment)
return VariableDefinition(type_name=None, value=typed_value, comment=comment, type_hint=type_hint)
i = typed_value.index('(')
type_name = typed_value[:i]

return VariableDefinition(type_name=type_name, value=typed_value[i+1:-1], comment=comment)
return VariableDefinition(type_name=type_name, value=typed_value[i+1:-1], comment=comment, type_hint=type_hint)


def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str]) -> SpecObject:
Expand Down Expand Up @@ -241,10 +242,13 @@ def get_spec(file_name: Path, preset: Dict[str, str], config: Dict[str, str]) ->

value_def = _parse_value(name, value)
if name in preset:
preset_vars[name] = VariableDefinition(value_def.type_name, preset[name], value_def.comment)
preset_vars[name] = VariableDefinition(value_def.type_name, preset[name], value_def.comment, None)
elif name in config:
config_vars[name] = VariableDefinition(value_def.type_name, config[name], value_def.comment)
config_vars[name] = VariableDefinition(value_def.type_name, config[name], value_def.comment, None)
else:
if name == 'ENDIANNESS':
# Deal with mypy Literal typing check
value_def = _parse_value(name, value, type_hint='Final')
constant_vars[name] = value_def

elif isinstance(child, LinkRefDef):
Expand Down Expand Up @@ -337,7 +341,7 @@ def imports(cls, preset_name: str) -> str:
field,
)
from typing import (
Any, Callable, Dict, Set, Sequence, Tuple, Optional, TypeVar, NamedTuple
Any, Callable, Dict, Set, Sequence, Tuple, Optional, TypeVar, NamedTuple, Final
)

from eth2spec.utils.ssz.ssz_impl import hash_tree_root, copy, uint_to_bytes
Expand Down Expand Up @@ -589,9 +593,16 @@ def imports(cls, preset_name: str):
from eth2spec.utils.ssz.ssz_impl import serialize as ssz_serialize
'''


@classmethod
def preparations(cls):
return super().preparations() + '\n' + '''
T = TypeVar('T') # For generic function
'''

@classmethod
def sundry_functions(cls) -> str:
return super().sundry_functions() + '''
return super().sundry_functions() + '\n\n' + '''
# TODO: for mainnet, load pre-generated trusted setup file to reduce building time.
# TESTING_FIELD_ELEMENTS_PER_BLOB is hardcoded copy from minimal presets
TESTING_FIELD_ELEMENTS_PER_BLOB = 4
Expand Down Expand Up @@ -696,7 +707,10 @@ def format_config_var(name: str, vardef: VariableDefinition) -> str:

def format_constant(name: str, vardef: VariableDefinition) -> str:
if vardef.type_name is None:
out = f'{name} = {vardef.value}'
if vardef.type_hint is None:
out = f'{name} = {vardef.value}'
else:
out = f'{name}: {vardef.type_hint} = {vardef.value}'
else:
out = f'{name} = {vardef.type_name}({vardef.value})'
if vardef.comment is not None:
Expand Down Expand Up @@ -1108,19 +1122,18 @@ def run(self):
python_requires=">=3.8, <4",
extras_require={
"test": ["pytest>=4.4", "pytest-cov", "pytest-xdist"],
"lint": ["flake8==3.7.7", "mypy==0.812", "pylint==2.12.2"],
"generator": ["python-snappy==0.5.4", "filelock"],
"lint": ["flake8==5.0.4", "mypy==0.981", "pylint==2.15.3"],
"generator": ["python-snappy==0.6.1", "filelock"],
},
install_requires=[
"eth-utils>=1.3.0,<2",
"eth-typing>=2.1.0,<3.0.0",
"pycryptodome==3.9.4",
"py_ecc==5.2.0",
"eth-utils>=2.0.0,<3",
"eth-typing>=3.2.0,<4.0.0",
"pycryptodome==3.15.0",
"py_ecc==6.0.0",
"milagro_bls_binding==1.9.0",
"dataclasses==0.6",
"remerkleable==0.1.24",
RUAMEL_YAML_VERSION,
"lru-dict==1.1.6",
"lru-dict==1.1.8",
MARKO_VERSION,
]
)
2 changes: 1 addition & 1 deletion specs/altair/validator.md
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ This function is a predicate indicating the presence or absence of the validator
*Note*: Being assigned to a sync committee for a given `slot` means that the validator produces and broadcasts signatures for `slot - 1` for inclusion in `slot`.
This means that when assigned to an `epoch` sync committee signatures must be produced and broadcast for slots on range `[compute_start_slot_at_epoch(epoch) - 1, compute_start_slot_at_epoch(epoch) + SLOTS_PER_EPOCH - 1)`
rather than for the range `[compute_start_slot_at_epoch(epoch), compute_start_slot_at_epoch(epoch) + SLOTS_PER_EPOCH)`.
To reduce complexity during the Altair fork, sync committees are not expected to produce signatures for `compute_epoch_at_slot(ALTAIR_FORK_EPOCH) - 1`.
To reduce complexity during the Altair fork, sync committees are not expected to produce signatures for `compute_start_slot_at_epoch(ALTAIR_FORK_EPOCH) - 1`.

```python
def compute_sync_committee_period(epoch: Epoch) -> uint64:
Expand Down
2 changes: 0 additions & 2 deletions specs/bellatrix/beacon-chain.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Bellatrix -- The Beacon Chain

**Notice**: This document is a work-in-progress for researchers and implementers.

## Table of contents

<!-- TOC -->
Expand Down
2 changes: 0 additions & 2 deletions specs/bellatrix/fork-choice.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Bellatrix -- Fork Choice

**Notice**: This document is a work-in-progress for researchers and implementers.

## Table of contents
<!-- TOC -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
Expand Down
2 changes: 0 additions & 2 deletions specs/bellatrix/fork.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Bellatrix -- Fork Logic

**Notice**: This document is a work-in-progress for researchers and implementers.

## Table of contents

<!-- START doctoc generated TOC please keep comment here to allow auto update -->
Expand Down
2 changes: 0 additions & 2 deletions specs/bellatrix/validator.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
# Bellatrix -- Honest Validator

**Notice**: This document is a work-in-progress for researchers and implementers.

## Table of contents

<!-- TOC -->
Expand Down
34 changes: 10 additions & 24 deletions specs/capella/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
- [Extended Containers](#extended-containers)
- [`ExecutionPayload`](#executionpayload)
- [`ExecutionPayloadHeader`](#executionpayloadheader)
- [`Validator`](#validator)
- [`BeaconBlockBody`](#beaconblockbody)
- [`BeaconState`](#beaconstate)
- [Helpers](#helpers)
Expand Down Expand Up @@ -111,6 +110,7 @@ We define the following Python custom types for type hinting and readability:
```python
class Withdrawal(Container):
index: WithdrawalIndex
validator_index: ValidatorIndex
address: ExecutionAddress
amount: Gwei
```
Expand Down Expand Up @@ -180,22 +180,6 @@ class ExecutionPayloadHeader(Container):
withdrawals_root: Root # [New in Capella]
```

#### `Validator`

```python
class Validator(Container):
pubkey: BLSPubkey
withdrawal_credentials: Bytes32 # Commitment to pubkey for withdrawals
effective_balance: Gwei # Balance at stake
slashed: boolean
# Status epochs
activation_eligibility_epoch: Epoch # When criteria for activation were met
activation_epoch: Epoch
exit_epoch: Epoch
withdrawable_epoch: Epoch # When validator can withdraw funds
fully_withdrawn_epoch: Epoch # [New in Capella]
```

#### `BeaconBlockBody`

```python
Expand Down Expand Up @@ -275,6 +259,7 @@ def withdraw_balance(state: BeaconState, validator_index: ValidatorIndex, amount
# Create a corresponding withdrawal receipt
withdrawal = Withdrawal(
index=state.next_withdrawal_index,
validator_index=validator_index,
address=ExecutionAddress(state.validators[validator_index].withdrawal_credentials[12:]),
amount=amount,
)
Expand All @@ -297,13 +282,14 @@ def has_eth1_withdrawal_credential(validator: Validator) -> bool:
#### `is_fully_withdrawable_validator`

```python
def is_fully_withdrawable_validator(validator: Validator, epoch: Epoch) -> bool:
def is_fully_withdrawable_validator(validator: Validator, balance: Gwei, epoch: Epoch) -> bool:
"""
Check if ``validator`` is fully withdrawable.
"""
return (
has_eth1_withdrawal_credential(validator)
and validator.withdrawable_epoch <= epoch < validator.fully_withdrawn_epoch
and validator.withdrawable_epoch <= epoch
and balance > 0
)
```

Expand Down Expand Up @@ -349,11 +335,11 @@ def process_epoch(state: BeaconState) -> None:
```python
def process_full_withdrawals(state: BeaconState) -> None:
current_epoch = get_current_epoch(state)
for index, validator in enumerate(state.validators):
if is_fully_withdrawable_validator(validator, current_epoch):
# TODO, consider the zero-balance case
withdraw_balance(state, ValidatorIndex(index), state.balances[index])
validator.fully_withdrawn_epoch = current_epoch
for index in range(len(state.validators)):
balance = state.balances[index]
validator = state.validators[index]
if is_fully_withdrawable_validator(validator, balance, current_epoch):
withdraw_balance(state, ValidatorIndex(index), balance)
```

#### Partial withdrawals
Expand Down
35 changes: 19 additions & 16 deletions specs/capella/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,23 @@ In particular, the outer `state_transition` function defined in the Phase 0 docu
```python
def upgrade_to_capella(pre: bellatrix.BeaconState) -> BeaconState:
epoch = bellatrix.get_current_epoch(pre)
latest_execution_payload_header = ExecutionPayloadHeader(
parent_hash=pre.latest_execution_payload_header.parent_hash,
fee_recipient=pre.latest_execution_payload_header.fee_recipient,
state_root=pre.latest_execution_payload_header.state_root,
receipts_root=pre.latest_execution_payload_header.receipts_root,
logs_bloom=pre.latest_execution_payload_header.logs_bloom,
prev_randao=pre.latest_execution_payload_header.prev_randao,
block_number=pre.latest_execution_payload_header.block_number,
gas_limit=pre.latest_execution_payload_header.gas_limit,
gas_used=pre.latest_execution_payload_header.gas_used,
timestamp=pre.latest_execution_payload_header.timestamp,
extra_data=pre.latest_execution_payload_header.extra_data,
base_fee_per_gas=pre.latest_execution_payload_header.base_fee_per_gas,
block_hash=pre.latest_execution_payload_header.block_hash,
transactions_root=pre.latest_execution_payload_header.transactions_root,
withdrawals_root=Root(), # [New in Capella]
)
post = BeaconState(
# Versioning
genesis_time=pre.genesis_time,
Expand All @@ -90,7 +107,7 @@ def upgrade_to_capella(pre: bellatrix.BeaconState) -> BeaconState:
eth1_data_votes=pre.eth1_data_votes,
eth1_deposit_index=pre.eth1_deposit_index,
# Registry
validators=[],
validators=pre.validators,
balances=pre.balances,
# Randomness
randao_mixes=pre.randao_mixes,
Expand All @@ -110,26 +127,12 @@ def upgrade_to_capella(pre: bellatrix.BeaconState) -> BeaconState:
current_sync_committee=pre.current_sync_committee,
next_sync_committee=pre.next_sync_committee,
# Execution-layer
latest_execution_payload_header=pre.latest_execution_payload_header,
latest_execution_payload_header=latest_execution_payload_header,
# Withdrawals
withdrawal_queue=[],
next_withdrawal_index=WithdrawalIndex(0),
next_partial_withdrawal_validator_index=ValidatorIndex(0),
)

for pre_validator in pre.validators:
post_validator = Validator(
pubkey=pre_validator.pubkey,
withdrawal_credentials=pre_validator.withdrawal_credentials,
effective_balance=pre_validator.effective_balance,
slashed=pre_validator.slashed,
activation_eligibility_epoch=pre_validator.activation_eligibility_epoch,
activation_epoch=pre_validator.activation_epoch,
exit_epoch=pre_validator.exit_epoch,
withdrawable_epoch=pre_validator.withdrawable_epoch,
fully_withdrawn_epoch=FAR_FUTURE_EPOCH,
)
post.validators.append(post_validator)

return post
```
Loading