Skip to content

Commit

Permalink
Merge pull request #2778 from ethereum/dev
Browse files Browse the repository at this point in the history
release v1.1.8
  • Loading branch information
hwwhww authored Dec 24, 2021
2 parents 93c933c + db642e0 commit 180855b
Show file tree
Hide file tree
Showing 66 changed files with 385 additions and 377 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ jobs:
command: make citest fork=altair
- store_test_results:
path: tests/core/pyspec/test-reports
test-merge:
test-bellatrix:
docker:
- image: circleci/python:3.8
working_directory: ~/specs-repo
Expand All @@ -126,7 +126,7 @@ jobs:
- restore_pyspec_cached_venv
- run:
name: Run py-tests
command: make citest fork=merge
command: make citest fork=bellatrix
- store_test_results:
path: tests/core/pyspec/test-reports
table_of_contents:
Expand Down Expand Up @@ -240,7 +240,7 @@ workflows:
- test-altair:
requires:
- install_pyspec_test
- test-merge:
- test-bellatrix:
requires:
- install_pyspec_test
- table_of_contents
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ consensus-spec-tests/
# Dynamically built from Markdown spec
tests/core/pyspec/eth2spec/phase0/
tests/core/pyspec/eth2spec/altair/
tests/core/pyspec/eth2spec/merge/
tests/core/pyspec/eth2spec/bellatrix/

# coverage reports
.htmlcov
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ GENERATOR_VENVS = $(patsubst $(GENERATOR_DIR)/%, $(GENERATOR_DIR)/%venv, $(GENER
#$(info $$GENERATOR_TARGETS is [${GENERATOR_TARGETS}])

MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/phase0/*.md) $(wildcard $(SPEC_DIR)/altair/*.md) $(wildcard $(SSZ_DIR)/*.md) \
$(wildcard $(SPEC_DIR)/merge/*.md) \
$(wildcard $(SPEC_DIR)/bellatrix/*.md) \
$(wildcard $(SPEC_DIR)/custody/*.md) \
$(wildcard $(SPEC_DIR)/das/*.md) \
$(wildcard $(SPEC_DIR)/sharding/*.md)
Expand Down Expand Up @@ -59,7 +59,7 @@ partial_clean:
rm -rf $(DEPOSIT_CONTRACT_TESTER_DIR)/.pytest_cache
rm -rf $(ETH2SPEC_MODULE_DIR)/phase0
rm -rf $(ETH2SPEC_MODULE_DIR)/altair
rm -rf $(ETH2SPEC_MODULE_DIR)/merge
rm -rf $(ETH2SPEC_MODULE_DIR)/bellatrix
rm -rf $(COV_HTML_OUT_DIR)
rm -rf $(TEST_REPORT_DIR)
rm -rf eth2spec.egg-info dist build
Expand Down Expand Up @@ -97,12 +97,12 @@ install_test:
# Testing against `minimal` config by default
test: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
python3 -m pytest -n 4 --disable-bls --cov=eth2spec.phase0.minimal --cov=eth2spec.altair.minimal --cov=eth2spec.merge.minimal --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
python3 -m pytest -n 4 --disable-bls --cov=eth2spec.phase0.minimal --cov=eth2spec.altair.minimal --cov=eth2spec.bellatrix.minimal --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec

# Testing against `minimal` config by default
find_test: pyspec
. venv/bin/activate; cd $(PY_SPEC_DIR); \
python3 -m pytest -k=$(K) --disable-bls --cov=eth2spec.phase0.minimal --cov=eth2spec.altair.minimal --cov=eth2spec.merge.minimal --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec
python3 -m pytest -k=$(K) --disable-bls --cov=eth2spec.phase0.minimal --cov=eth2spec.altair.minimal --cov=eth2spec.bellatrix.minimal --cov-report="html:$(COV_HTML_OUT)" --cov-branch eth2spec

citest: pyspec
mkdir -p tests/core/pyspec/test-reports/eth2spec;
Expand All @@ -129,11 +129,11 @@ check_toc: $(MARKDOWN_FILES:=.toc)
codespell:
codespell . --skip ./.git -I .codespell-whitelist

# TODO: add future merge, sharding, etc. packages to linting.
# TODO: add future protocol upgrade patch packages to linting.
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.altair -p eth2spec.merge
&& mypy --config-file $(LINTER_CONFIG_FILE) -p eth2spec.phase0 -p eth2spec.altair -p eth2spec.bellatrix

lint_generators: pyspec
. venv/bin/activate; cd $(TEST_GENERATORS_DIR); \
Expand Down
22 changes: 11 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,24 @@ The current features are:
* [Honest Validator guide changes](specs/altair/validator.md)
* [P2P Networking](specs/altair/p2p-interface.md)

### Merge
### Bellatrix (as known as The Merge)

The merge is still actively in development. The exact specification has not been formally accepted as final and details are still subject to change.
The Bellatrix protocol upgrade is still actively in development. The exact specification has not been formally accepted as final and details are still subject to change.

* Background material:
* An [ethresear.ch](https://ethresear.ch) post [describing the basic mechanism](https://ethresear.ch/t/the-eth1-eth2-transition/6265)
* [ethereum.org](https://ethereum.org) high-level description of the merge [here](https://ethereum.org/en/eth2/docking/)
* An [ethresear.ch](https://ethresear.ch) post [describing the basic mechanism of the CL+EL merge](https://ethresear.ch/t/the-eth1-eth2-transition/6265)
* [ethereum.org](https://ethereum.org) high-level description of the CL+EL merge [here](https://ethereum.org/en/eth2/docking/)
* Specifications:
* [Beacon Chain changes](specs/merge/beacon-chain.md)
* [Merge fork](specs/merge/fork.md)
* [Fork Choice changes](specs/merge/fork-choice.md)
* [Validator additions](specs/merge/validator.md)
* [Client settings](specs/merge/client-settings.md)
* [P2P Networking](specs/merge/p2p-interface.md)
* [Beacon Chain changes](specs/bellatrix/beacon-chain.md)
* [Bellatrix fork](specs/bellatrix/fork.md)
* [Fork Choice changes](specs/bellatrix/fork-choice.md)
* [Validator additions](specs/bellatrix/validator.md)
* [Client settings](specs/bellatrix/client-settings.md)
* [P2P Networking](specs/bellatrix/p2p-interface.md)

### Sharding

Sharding follows the merge, and is divided into three parts:
Sharding follows Bellatrix, and is divided into three parts:

* Sharding base functionality - In early engineering phase
* [Beacon Chain changes](specs/sharding/beacon-chain.md)
Expand Down
6 changes: 3 additions & 3 deletions configs/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ GENESIS_DELAY: 604800
# Altair
ALTAIR_FORK_VERSION: 0x01000000
ALTAIR_FORK_EPOCH: 74240 # Oct 27, 2021, 10:56:23am UTC
# Merge
MERGE_FORK_VERSION: 0x02000000
MERGE_FORK_EPOCH: 18446744073709551615
# Bellatrix
BELLATRIX_FORK_VERSION: 0x02000000
BELLATRIX_FORK_EPOCH: 18446744073709551615
# Sharding
SHARDING_FORK_VERSION: 0x03000000
SHARDING_FORK_EPOCH: 18446744073709551615
Expand Down
6 changes: 3 additions & 3 deletions configs/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ GENESIS_DELAY: 300
# Altair
ALTAIR_FORK_VERSION: 0x01000001
ALTAIR_FORK_EPOCH: 18446744073709551615
# Merge
MERGE_FORK_VERSION: 0x02000001
MERGE_FORK_EPOCH: 18446744073709551615
# Bellatrix
BELLATRIX_FORK_VERSION: 0x02000001
BELLATRIX_FORK_EPOCH: 18446744073709551615
# Sharding
SHARDING_FORK_VERSION: 0x03000001
SHARDING_FORK_EPOCH: 18446744073709551615
Expand Down
8 changes: 4 additions & 4 deletions presets/mainnet/merge.yaml → presets/mainnet/bellatrix.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Mainnet preset - The Merge
# Mainnet preset - Bellatrix

# Updated penalty values
# ---------------------------------------------------------------
# 2**24 (= 16,777,216)
INACTIVITY_PENALTY_QUOTIENT_MERGE: 16777216
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX: 16777216
# 2**5 (= 32)
MIN_SLASHING_PENALTY_QUOTIENT_MERGE: 32
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX: 32
# 3
PROPORTIONAL_SLASHING_MULTIPLIER_MERGE: 3
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX: 3

# Execution
# ---------------------------------------------------------------
Expand Down
8 changes: 4 additions & 4 deletions presets/minimal/merge.yaml → presets/minimal/bellatrix.yaml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# Minimal preset - The Merge
# Minimal preset - Bellatrix

# Updated penalty values
# ---------------------------------------------------------------
# 2**24 (= 16,777,216)
INACTIVITY_PENALTY_QUOTIENT_MERGE: 16777216
INACTIVITY_PENALTY_QUOTIENT_BELLATRIX: 16777216
# 2**5 (= 32)
MIN_SLASHING_PENALTY_QUOTIENT_MERGE: 32
MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX: 32
# 3
PROPORTIONAL_SLASHING_MULTIPLIER_MERGE: 3
PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX: 3

# Execution
# ---------------------------------------------------------------
Expand Down
24 changes: 12 additions & 12 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def installPackage(package: str):
# Definitions in context.py
PHASE0 = 'phase0'
ALTAIR = 'altair'
MERGE = 'merge'
BELLATRIX = 'bellatrix'

# The helper functions that are used when defining constants
CONSTANT_DEP_SUNDRY_CONSTANTS_FUNCTIONS = '''
Expand Down Expand Up @@ -487,10 +487,10 @@ def implement_optimizations(cls, functions: Dict[str, str]) -> Dict[str, str]:
return super().implement_optimizations(functions)

#
# MergeSpecBuilder
# BellatrixSpecBuilder
#
class MergeSpecBuilder(AltairSpecBuilder):
fork: str = MERGE
class BellatrixSpecBuilder(AltairSpecBuilder):
fork: str = BELLATRIX

@classmethod
def imports(cls, preset_name: str):
Expand Down Expand Up @@ -550,7 +550,7 @@ def hardcoded_custom_type_dep_constants(cls) -> str:

spec_builders = {
builder.fork: builder
for builder in (Phase0SpecBuilder, AltairSpecBuilder, MergeSpecBuilder)
for builder in (Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder)
}


Expand Down Expand Up @@ -846,14 +846,14 @@ def finalize_options(self):
if len(self.md_doc_paths) == 0:
print("no paths were specified, using default markdown file paths for pyspec"
" build (spec fork: %s)" % self.spec_fork)
if self.spec_fork in (PHASE0, ALTAIR, MERGE):
if self.spec_fork in (PHASE0, ALTAIR, BELLATRIX):
self.md_doc_paths = """
specs/phase0/beacon-chain.md
specs/phase0/fork-choice.md
specs/phase0/validator.md
specs/phase0/weak-subjectivity.md
"""
if self.spec_fork in (ALTAIR, MERGE):
if self.spec_fork in (ALTAIR, BELLATRIX):
self.md_doc_paths += """
specs/altair/beacon-chain.md
specs/altair/bls.md
Expand All @@ -862,12 +862,12 @@ def finalize_options(self):
specs/altair/p2p-interface.md
specs/altair/sync-protocol.md
"""
if self.spec_fork == MERGE:
if self.spec_fork == BELLATRIX:
self.md_doc_paths += """
specs/merge/beacon-chain.md
specs/merge/fork.md
specs/merge/fork-choice.md
specs/merge/validator.md
specs/bellatrix/beacon-chain.md
specs/bellatrix/fork.md
specs/bellatrix/fork-choice.md
specs/bellatrix/validator.md
"""
if len(self.md_doc_paths) == 0:
raise Exception('no markdown files specified, and spec fork "%s" is unknown', self.spec_fork)
Expand Down
44 changes: 22 additions & 22 deletions specs/merge/beacon-chain.md → specs/bellatrix/beacon-chain.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# The Merge -- The Beacon Chain
# Bellatrix -- The Beacon Chain

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

Expand Down Expand Up @@ -48,7 +48,7 @@

## Introduction

This upgrade adds transaction execution to the beacon chain as part of the Merge fork.
This upgrade adds transaction execution to the beacon chain as part of Bellatrix upgrade.

Additionally, this upgrade introduces the following minor changes:
* Penalty parameter updates to their planned maximally punitive values
Expand All @@ -75,15 +75,15 @@ Additionally, this upgrade introduces the following minor changes:

### Updated penalty values

The Merge updates a few configuration values to move penalty parameters to their final, maximum security values.
Bellatrix updates a few configuration values to move penalty parameters to their final, maximum security values.

*Note*: The spec does *not* override previous configuration values but instead creates new values and replaces usage throughout.

| Name | Value |
| - | - |
| `INACTIVITY_PENALTY_QUOTIENT_MERGE` | `uint64(2**24)` (= 16,777,216) |
| `MIN_SLASHING_PENALTY_QUOTIENT_MERGE` | `uint64(2**5)` (= 32) |
| `PROPORTIONAL_SLASHING_MULTIPLIER_MERGE` | `uint64(3)` |
| `INACTIVITY_PENALTY_QUOTIENT_BELLATRIX` | `uint64(2**24)` (= 16,777,216) |
| `MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX` | `uint64(2**5)` (= 32) |
| `PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX` | `uint64(3)` |

## Configuration

Expand Down Expand Up @@ -114,7 +114,7 @@ class BeaconBlockBody(Container):
voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS]
sync_aggregate: SyncAggregate
# Execution
execution_payload: ExecutionPayload # [New in Merge]
execution_payload: ExecutionPayload # [New in Bellatrix]
```

#### `BeaconState`
Expand Down Expand Up @@ -156,7 +156,7 @@ class BeaconState(Container):
current_sync_committee: SyncCommittee
next_sync_committee: SyncCommittee
# Execution
latest_execution_payload_header: ExecutionPayloadHeader # [New in Merge]
latest_execution_payload_header: ExecutionPayloadHeader # [New in Bellatrix]
```

### New containers
Expand Down Expand Up @@ -246,7 +246,7 @@ def compute_timestamp_at_slot(state: BeaconState, slot: Slot) -> uint64:

#### Modified `get_inactivity_penalty_deltas`

*Note*: The function `get_inactivity_penalty_deltas` is modified to use `INACTIVITY_PENALTY_QUOTIENT_MERGE`.
*Note*: The function `get_inactivity_penalty_deltas` is modified to use `INACTIVITY_PENALTY_QUOTIENT_BELLATRIX`.

```python
def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], Sequence[Gwei]]:
Expand All @@ -260,8 +260,8 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S
for index in get_eligible_validator_indices(state):
if index not in matching_target_indices:
penalty_numerator = state.validators[index].effective_balance * state.inactivity_scores[index]
# [Modified in Merge]
penalty_denominator = INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_MERGE
# [Modified in Bellatrix]
penalty_denominator = INACTIVITY_SCORE_BIAS * INACTIVITY_PENALTY_QUOTIENT_BELLATRIX
penalties[index] += Gwei(penalty_numerator // penalty_denominator)
return rewards, penalties
```
Expand All @@ -270,7 +270,7 @@ def get_inactivity_penalty_deltas(state: BeaconState) -> Tuple[Sequence[Gwei], S

#### Modified `slash_validator`

*Note*: The function `slash_validator` is modified to use `MIN_SLASHING_PENALTY_QUOTIENT_MERGE`.
*Note*: The function `slash_validator` is modified to use `MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX`.

```python
def slash_validator(state: BeaconState,
Expand All @@ -285,7 +285,7 @@ def slash_validator(state: BeaconState,
validator.slashed = True
validator.withdrawable_epoch = max(validator.withdrawable_epoch, Epoch(epoch + EPOCHS_PER_SLASHINGS_VECTOR))
state.slashings[epoch % EPOCHS_PER_SLASHINGS_VECTOR] += validator.effective_balance
slashing_penalty = validator.effective_balance // MIN_SLASHING_PENALTY_QUOTIENT_MERGE # [Modified in Merge]
slashing_penalty = validator.effective_balance // MIN_SLASHING_PENALTY_QUOTIENT_BELLATRIX # [Modified in Bellatrix]
decrease_balance(state, slashed_index, slashing_penalty)

# Apply proposer and whistleblower rewards
Expand Down Expand Up @@ -332,7 +332,7 @@ def execute_payload(self: ExecutionEngine, execution_payload: ExecutionPayload)
def process_block(state: BeaconState, block: BeaconBlock) -> None:
process_block_header(state, block)
if is_execution_enabled(state, block.body):
process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [New in Merge]
process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [New in Bellatrix]
process_randao(state, block.body)
process_eth1_data(state, block.body)
process_operations(state, block.body)
Expand Down Expand Up @@ -377,14 +377,14 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe

#### Slashings

*Note*: The function `process_slashings` is modified to use `PROPORTIONAL_SLASHING_MULTIPLIER_MERGE`.
*Note*: The function `process_slashings` is modified to use `PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX`.

```python
def process_slashings(state: BeaconState) -> None:
epoch = get_current_epoch(state)
total_balance = get_total_active_balance(state)
adjusted_total_slashing_balance = min(
sum(state.slashings) * PROPORTIONAL_SLASHING_MULTIPLIER_MERGE, # [Modified in Merge]
sum(state.slashings) * PROPORTIONAL_SLASHING_MULTIPLIER_BELLATRIX, # [Modified in Bellatrix]
total_balance
)
for index, validator in enumerate(state.validators):
Expand All @@ -397,10 +397,10 @@ def process_slashings(state: BeaconState) -> None:

## Testing

*Note*: The function `initialize_beacon_state_from_eth1` is modified for pure Merge testing only.
*Note*: The function `initialize_beacon_state_from_eth1` is modified for pure Bellatrix testing only.
Modifications include:
1. Use `MERGE_FORK_VERSION` as the current fork version.
2. Utilize the Merge `BeaconBlockBody` when constructing the initial `latest_block_header`.
1. Use `BELLATRIX_FORK_VERSION` as the current fork version.
2. Utilize the Bellatrix `BeaconBlockBody` when constructing the initial `latest_block_header`.
3. Initialize `latest_execution_payload_header`.
If `execution_payload_header == ExecutionPayloadHeader()`, then the Merge has not yet occurred.
Else, the Merge starts from genesis and the transition is incomplete.
Expand All @@ -412,8 +412,8 @@ def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32,
execution_payload_header: ExecutionPayloadHeader=ExecutionPayloadHeader()
) -> BeaconState:
fork = Fork(
previous_version=MERGE_FORK_VERSION, # [Modified in Merge] for testing only
current_version=MERGE_FORK_VERSION, # [Modified in Merge]
previous_version=BELLATRIX_FORK_VERSION, # [Modified in Bellatrix] for testing only
current_version=BELLATRIX_FORK_VERSION, # [Modified in Bellatrix]
epoch=GENESIS_EPOCH,
)
state = BeaconState(
Expand Down Expand Up @@ -447,7 +447,7 @@ def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32,
state.current_sync_committee = get_next_sync_committee(state)
state.next_sync_committee = get_next_sync_committee(state)

# [New in Merge] Initialize the execution payload header
# [New in Bellatrix] Initialize the execution payload header
# If empty, will initialize a chain that has not yet gone through the Merge transition
state.latest_execution_payload_header = execution_payload_header

Expand Down
Loading

0 comments on commit 180855b

Please sign in to comment.