From d2c69fe3cfd87c3a891154aa73d9464b58fe1359 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Fri, 16 Feb 2024 12:29:00 +0800 Subject: [PATCH 01/11] Rename EIP6110 to Electra --- .circleci/config.yml | 6 ++-- .github/workflows/run-tests.yml | 12 +++---- .gitignore | 3 +- Makefile | 4 +-- README.md | 2 +- configs/mainnet.yaml | 5 +-- configs/minimal.yaml | 3 -- .../mainnet/{eip6110.yaml => electra.yaml} | 2 +- .../minimal/{eip6110.yaml => electra.yaml} | 2 +- pysetup/constants.py | 2 +- pysetup/md_doc_paths.py | 6 ++-- pysetup/spec_builders/__init__.py | 5 ++- .../spec_builders/{eip6110.py => electra.py} | 6 ++-- scripts/build_run_docker_tests.sh | 2 +- .../eip6110 => electra}/beacon-chain.md | 6 ++-- specs/{_features/eip6110 => electra}/fork.md | 18 +++++----- .../eip6110 => electra}/validator.md | 0 tests/core/pyspec/eth2spec/test/context.py | 6 ++-- .../test/{eip6110 => electra}/__init__.py | 0 .../block_processing/__init__.py | 0 .../test_process_deposit_receipt.py | 36 +++++++++---------- .../{eip6110 => electra}/sanity/__init__.py | 0 .../sanity/blocks/__init__.py | 0 .../sanity/blocks/test_deposit_transition.py | 18 +++++----- .../pyspec/eth2spec/test/helpers/constants.py | 10 +++--- .../test/helpers/execution_payload.py | 10 +++--- .../pyspec/eth2spec/test/helpers/forks.py | 6 ++-- .../pyspec/eth2spec/test/helpers/genesis.py | 6 ++-- tests/formats/operations/README.md | 2 +- tests/generators/epoch_processing/main.py | 6 ++-- tests/generators/finality/main.py | 6 ++-- tests/generators/fork_choice/main.py | 6 ++-- tests/generators/genesis/main.py | 6 ++-- tests/generators/operations/main.py | 8 ++--- tests/generators/rewards/main.py | 6 ++-- tests/generators/sanity/main.py | 8 ++--- tests/generators/sync/main.py | 6 ++-- 37 files changed, 112 insertions(+), 118 deletions(-) rename presets/mainnet/{eip6110.yaml => electra.yaml} (84%) rename presets/minimal/{eip6110.yaml => electra.yaml} (82%) rename pysetup/spec_builders/{eip6110.py => electra.py} (62%) rename specs/{_features/eip6110 => electra}/beacon-chain.md (98%) rename specs/{_features/eip6110 => electra}/fork.md (91%) rename specs/{_features/eip6110 => electra}/validator.md (100%) rename tests/core/pyspec/eth2spec/test/{eip6110 => electra}/__init__.py (100%) rename tests/core/pyspec/eth2spec/test/{eip6110 => electra}/block_processing/__init__.py (100%) rename tests/core/pyspec/eth2spec/test/{eip6110 => electra}/block_processing/test_process_deposit_receipt.py (96%) rename tests/core/pyspec/eth2spec/test/{eip6110 => electra}/sanity/__init__.py (100%) rename tests/core/pyspec/eth2spec/test/{eip6110 => electra}/sanity/blocks/__init__.py (100%) rename tests/core/pyspec/eth2spec/test/{eip6110 => electra}/sanity/blocks/test_deposit_transition.py (98%) diff --git a/.circleci/config.yml b/.circleci/config.yml index ef2eff9e26..6a3c46fa9b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -155,7 +155,7 @@ jobs: command: make citest fork=deneb - store_test_results: path: tests/core/pyspec/test-reports - test-eip6110: + test-electra: docker: - image: circleci/python:3.9 working_directory: ~/specs-repo @@ -165,7 +165,7 @@ jobs: - restore_pyspec_cached_venv - run: name: Run py-tests - command: make citest fork=eip6110 + command: make citest fork=electra - store_test_results: path: tests/core/pyspec/test-reports test-eip7002: @@ -340,7 +340,7 @@ workflows: - test-deneb: requires: - install_pyspec_test - - test-eip6110: + - test-electra: requires: - install_pyspec_test - test-eip7002: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 9693217971..ccf4ec1caf 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -10,9 +10,9 @@ env: on: push: branches: - - dev + - dev - master - pull_request: + pull_request: workflow_dispatch: inputs: test_preset_type: @@ -71,22 +71,22 @@ jobs: needs: [preclear,lint,codespell,table_of_contents] strategy: matrix: - version: ["phase0", "altair", "bellatrix", "capella", "deneb", "eip6110", "eip7002", "eip7549", "whisk", "eip7594"] + version: ["phase0", "altair", "bellatrix", "capella", "deneb", "electra", "eip7002", "eip7549", "whisk", "eip7594"] steps: - name: Checkout this repo uses: actions/checkout@v3.2.0 - name: set TEST_PRESET_TYPE - if: github.event.inputs.test_preset_type != '' + if: github.event.inputs.test_preset_type != '' run: | echo "spec_test_preset_type=${{ github.event.inputs.test_preset_type || env.TEST_PRESET_TYPE }}" >> $GITHUB_ENV - name: set TEST_PRESET_TYPE if: ${{ (github.event_name == 'push' && github.ref_name != 'master') || github.event_name == 'pull_request' }} run: | - echo "spec_test_preset_type=${{ env.TEST_PRESET_TYPE}}" >> $GITHUB_ENV + echo "spec_test_preset_type=${{ env.TEST_PRESET_TYPE}}" >> $GITHUB_ENV - name: set TEST_PRESET_TYPE if: ${{ github.event_name == 'push' && github.ref_name == 'master' }} run: | - echo "spec_test_preset_type=mainnet" >> $GITHUB_ENV + echo "spec_test_preset_type=mainnet" >> $GITHUB_ENV - name: set TEST_PRESET_TYPE if: github.event.schedule=='0 0 * * *' run: | diff --git a/.gitignore b/.gitignore index b5f4bddbab..daa006a8e7 100644 --- a/.gitignore +++ b/.gitignore @@ -21,11 +21,12 @@ tests/core/pyspec/eth2spec/altair/ tests/core/pyspec/eth2spec/bellatrix/ tests/core/pyspec/eth2spec/capella/ tests/core/pyspec/eth2spec/deneb/ -tests/core/pyspec/eth2spec/eip6110/ +tests/core/pyspec/eth2spec/electra/ tests/core/pyspec/eth2spec/eip7002/ tests/core/pyspec/eth2spec/eip7549/ tests/core/pyspec/eth2spec/whisk/ tests/core/pyspec/eth2spec/eip7251/ +tests/core/pyspec/eth2spec/eip7549/ tests/core/pyspec/eth2spec/eip7594/ # coverage reports diff --git a/Makefile b/Makefile index c6bc8dd842..fc3593124d 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/*/*.md) \ $(wildcard $(SPEC_DIR)/_features/*/*/*.md) \ $(wildcard $(SSZ_DIR)/*.md) -ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb eip6110 eip7002 eip7549 whisk +ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra eip7002 eip7549 whisk # The parameters for commands. Use `foreach` to avoid listing specs again. COVERAGE_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), --cov=eth2spec.$S.$(TEST_PRESET_TYPE)) PYLINT_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), ./eth2spec/$S) @@ -244,5 +244,5 @@ build_docs: copy_docs mkdocs build serve_docs: - . venv/bin/activate; + . venv/bin/activate; mkdocs serve diff --git a/README.md b/README.md index 1e4ceebf54..e59e096121 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ Features are researched and developed in parallel, and then consolidated into se | Sharding (outdated) | | | Custody Game (outdated) | | Dependent on sharding | | Data Availability Sampling (outdated) | | | -| EIP-6110 | | +| EIP-6110 | | ### Accompanying documents can be found in [specs](specs) and include: diff --git a/configs/mainnet.yaml b/configs/mainnet.yaml index 24788459f2..8bbac14672 100644 --- a/configs/mainnet.yaml +++ b/configs/mainnet.yaml @@ -51,11 +51,8 @@ CAPELLA_FORK_EPOCH: 194048 # April 12, 2023, 10:27:35pm UTC DENEB_FORK_VERSION: 0x04000000 DENEB_FORK_EPOCH: 269568 # March 13, 2024, 01:55:35pm UTC # Electra -ELECTRA_FORK_VERSION: 0x05000000 +ELECTRA_FORK_VERSION: 0x05000000 # temporary stub ELECTRA_FORK_EPOCH: 18446744073709551615 -# EIP6110 -EIP6110_FORK_VERSION: 0x06000000 # temporary stub -EIP6110_FORK_EPOCH: 18446744073709551615 # EIP7002 EIP7002_FORK_VERSION: 0x07000000 # temporary stub EIP7002_FORK_EPOCH: 18446744073709551615 diff --git a/configs/minimal.yaml b/configs/minimal.yaml index 984bb253f5..b67bb39a00 100644 --- a/configs/minimal.yaml +++ b/configs/minimal.yaml @@ -52,9 +52,6 @@ DENEB_FORK_EPOCH: 18446744073709551615 # Electra ELECTRA_FORK_VERSION: 0x05000001 ELECTRA_FORK_EPOCH: 18446744073709551615 -# EIP6110 -EIP6110_FORK_VERSION: 0x06000001 -EIP6110_FORK_EPOCH: 18446744073709551615 # EIP7002 EIP7002_FORK_VERSION: 0x07000001 EIP7002_FORK_EPOCH: 18446744073709551615 diff --git a/presets/mainnet/eip6110.yaml b/presets/mainnet/electra.yaml similarity index 84% rename from presets/mainnet/eip6110.yaml rename to presets/mainnet/electra.yaml index 16bf787d0c..1f64c2332e 100644 --- a/presets/mainnet/eip6110.yaml +++ b/presets/mainnet/electra.yaml @@ -1,4 +1,4 @@ -# Mainnet preset - EIP6110 +# Mainnet preset - ELECTRA # Execution # --------------------------------------------------------------- diff --git a/presets/minimal/eip6110.yaml b/presets/minimal/electra.yaml similarity index 82% rename from presets/minimal/eip6110.yaml rename to presets/minimal/electra.yaml index 7486aa16e7..75664afa5c 100644 --- a/presets/minimal/eip6110.yaml +++ b/presets/minimal/electra.yaml @@ -1,4 +1,4 @@ -# Minimal preset - EIP6110 +# Minimal preset - Electra # Execution # --------------------------------------------------------------- diff --git a/pysetup/constants.py b/pysetup/constants.py index 422bd1a43c..ec7a82a784 100644 --- a/pysetup/constants.py +++ b/pysetup/constants.py @@ -4,7 +4,7 @@ BELLATRIX = 'bellatrix' CAPELLA = 'capella' DENEB = 'deneb' -EIP6110 = 'eip6110' +ELECTRA = 'electra' EIP7002 = 'eip7002' EIP7251 = 'eip7251' EIP7549 = 'eip7549' diff --git a/pysetup/md_doc_paths.py b/pysetup/md_doc_paths.py index f60f2fb90d..0dfd322cae 100644 --- a/pysetup/md_doc_paths.py +++ b/pysetup/md_doc_paths.py @@ -6,7 +6,7 @@ BELLATRIX, CAPELLA, DENEB, - EIP6110, + ELECTRA, EIP7002, EIP7251, EIP7549, @@ -21,11 +21,11 @@ BELLATRIX: ALTAIR, CAPELLA: BELLATRIX, DENEB: CAPELLA, - EIP6110: DENEB, - EIP7549: DENEB, + ELECTRA: DENEB, WHISK: CAPELLA, EIP7002: CAPELLA, EIP7251: DENEB, + EIP7549: DENEB, EIP7594: DENEB, } diff --git a/pysetup/spec_builders/__init__.py b/pysetup/spec_builders/__init__.py index 61c1c807e9..f51c951f84 100644 --- a/pysetup/spec_builders/__init__.py +++ b/pysetup/spec_builders/__init__.py @@ -3,7 +3,7 @@ from .bellatrix import BellatrixSpecBuilder from .capella import CapellaSpecBuilder from .deneb import DenebSpecBuilder -from .eip6110 import EIP6110SpecBuilder +from .electra import ElectraSpecBuilder from .eip7002 import EIP7002SpecBuilder from .eip7549 import EIP7549SpecBuilder from .whisk import WhiskSpecBuilder @@ -15,7 +15,6 @@ builder.fork: builder for builder in ( Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder, CapellaSpecBuilder, DenebSpecBuilder, - EIP6110SpecBuilder, EIP7002SpecBuilder, EIP7549SpecBuilder, WhiskSpecBuilder, EIP7251SpecBuilder, - EIP7594SpecBuilder, + ElectraSpecBuilder, EIP7002SpecBuilder, EIP7549SpecBuilder, WhiskSpecBuilder, EIP7251SpecBuilder, EIP7594SpecBuilder, ) } diff --git a/pysetup/spec_builders/eip6110.py b/pysetup/spec_builders/electra.py similarity index 62% rename from pysetup/spec_builders/eip6110.py rename to pysetup/spec_builders/electra.py index e0fd253f19..bee1e72e9a 100644 --- a/pysetup/spec_builders/eip6110.py +++ b/pysetup/spec_builders/electra.py @@ -1,9 +1,9 @@ from .base import BaseSpecBuilder -from ..constants import EIP6110 +from ..constants import ELECTRA -class EIP6110SpecBuilder(BaseSpecBuilder): - fork: str = EIP6110 +class ElectraSpecBuilder(BaseSpecBuilder): + fork: str = ELECTRA @classmethod def imports(cls, preset_name: str): diff --git a/scripts/build_run_docker_tests.sh b/scripts/build_run_docker_tests.sh index 368fab94c1..a7fdfbc3dc 100755 --- a/scripts/build_run_docker_tests.sh +++ b/scripts/build_run_docker_tests.sh @@ -10,7 +10,7 @@ # Set variables -ALL_EXECUTABLE_SPECS=("phase0" "altair" "bellatrix" "capella" "deneb" "eip6110" "whisk") +ALL_EXECUTABLE_SPECS=("phase0" "altair" "bellatrix" "capella" "deneb" "electra" "whisk") TEST_PRESET_TYPE=minimal FORK_TO_TEST=phase0 NUMBER_OF_CORES=4 diff --git a/specs/_features/eip6110/beacon-chain.md b/specs/electra/beacon-chain.md similarity index 98% rename from specs/_features/eip6110/beacon-chain.md rename to specs/electra/beacon-chain.md index e2964267d9..4351c7482a 100644 --- a/specs/_features/eip6110/beacon-chain.md +++ b/specs/electra/beacon-chain.md @@ -284,7 +284,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi *Note*: The function `initialize_beacon_state_from_eth1` is modified for pure EIP-6110 testing only. Modifications include: -1. Use `EIP6110_FORK_VERSION` as the previous and current fork version. +1. Use `ELECTRA_FORK_VERSION` as the previous and current fork version. 2. Utilize the EIP-6110 `BeaconBlockBody` when constructing the initial `latest_block_header`. 3. Add `deposit_receipts_start_index` variable to the genesis state initialization. @@ -295,8 +295,8 @@ def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32, execution_payload_header: ExecutionPayloadHeader=ExecutionPayloadHeader() ) -> BeaconState: fork = Fork( - previous_version=EIP6110_FORK_VERSION, # [Modified in EIP6110] for testing only - current_version=EIP6110_FORK_VERSION, # [Modified in EIP6110] + previous_version=ELECTRA_FORK_VERSION, # [Modified in EIP6110] for testing only + current_version=ELECTRA_FORK_VERSION, # [Modified in EIP6110] epoch=GENESIS_EPOCH, ) state = BeaconState( diff --git a/specs/_features/eip6110/fork.md b/specs/electra/fork.md similarity index 91% rename from specs/_features/eip6110/fork.md rename to specs/electra/fork.md index 8bb8e2a67e..a592f1c5ee 100644 --- a/specs/_features/eip6110/fork.md +++ b/specs/electra/fork.md @@ -28,8 +28,8 @@ Warning: this configuration is not definitive. | Name | Value | | - | - | -| `EIP6110_FORK_VERSION` | `Version('0x06000000')` | -| `EIP6110_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** | +| `ELECTRA_FORK_VERSION` | `Version('0x05000000')` | +| `ELECTRA_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** | ## Helper functions @@ -42,8 +42,8 @@ def compute_fork_version(epoch: Epoch) -> Version: """ Return the fork version at the given ``epoch``. """ - if epoch >= EIP6110_FORK_EPOCH: - return EIP6110_FORK_VERSION + if epoch >= ELECTRA_FORK_EPOCH: + return ELECTRA_FORK_VERSION if epoch >= DENEB_FORK_EPOCH: return DENEB_FORK_VERSION if epoch >= CAPELLA_FORK_EPOCH: @@ -60,17 +60,17 @@ def compute_fork_version(epoch: Epoch) -> Version: ### Fork trigger TBD. This fork is defined for testing purposes, the EIP may be combined with other consensus-layer upgrade. -For now, we assume the condition will be triggered at epoch `EIP6110_FORK_EPOCH`. +For now, we assume the condition will be triggered at epoch `ELECTRA_FORK_EPOCH`. -Note that for the pure EIP-6110 networks, we don't apply `upgrade_to_eip6110` since it starts with EIP-6110 version logic. +Note that for the pure EIP-6110 networks, we don't apply `upgrade_to_electra` since it starts with EIP-6110 version logic. ### Upgrading the state -If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == EIP6110_FORK_EPOCH`, +If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == ELECTRA_FORK_EPOCH`, an irregular state change is made to upgrade to EIP-6110. ```python -def upgrade_to_eip6110(pre: deneb.BeaconState) -> BeaconState: +def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState: epoch = deneb.get_current_epoch(pre) latest_execution_payload_header = ExecutionPayloadHeader( parent_hash=pre.latest_execution_payload_header.parent_hash, @@ -99,7 +99,7 @@ def upgrade_to_eip6110(pre: deneb.BeaconState) -> BeaconState: slot=pre.slot, fork=Fork( previous_version=pre.fork.current_version, - current_version=EIP6110_FORK_VERSION, # [Modified in EIP-6110] + current_version=ELECTRA_FORK_VERSION, # [Modified in EIP-6110] epoch=epoch, ), # History diff --git a/specs/_features/eip6110/validator.md b/specs/electra/validator.md similarity index 100% rename from specs/_features/eip6110/validator.md rename to specs/electra/validator.md diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index 64d3635789..f80e1dc14a 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -7,8 +7,8 @@ from .exceptions import SkippedTest from .helpers.constants import ( - PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, - EIP6110, EIP7002, EIP7251, EIP7549, EIP7594, + PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, + EIP7002, EIP7251, EIP7549, EIP7594, WHISK, MINIMAL, ALL_PHASES, @@ -519,7 +519,7 @@ def wrapper(*args, spec: Spec, **kw): with_bellatrix_and_later = with_all_phases_from(BELLATRIX) with_capella_and_later = with_all_phases_from(CAPELLA) with_deneb_and_later = with_all_phases_from(DENEB) -with_eip6110_and_later = with_all_phases_from(EIP6110) +with_electra_and_later = with_all_phases_from(ELECTRA) with_eip7002_and_later = with_all_phases_from(EIP7002) with_eip7549_and_later = with_all_phases_from(EIP7549) with_whisk_and_later = with_all_phases_from(WHISK, all_phases=ALLOWED_TEST_RUNNER_FORKS) diff --git a/tests/core/pyspec/eth2spec/test/eip6110/__init__.py b/tests/core/pyspec/eth2spec/test/electra/__init__.py similarity index 100% rename from tests/core/pyspec/eth2spec/test/eip6110/__init__.py rename to tests/core/pyspec/eth2spec/test/electra/__init__.py diff --git a/tests/core/pyspec/eth2spec/test/eip6110/block_processing/__init__.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/__init__.py similarity index 100% rename from tests/core/pyspec/eth2spec/test/eip6110/block_processing/__init__.py rename to tests/core/pyspec/eth2spec/test/electra/block_processing/__init__.py diff --git a/tests/core/pyspec/eth2spec/test/eip6110/block_processing/test_process_deposit_receipt.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_deposit_receipt.py similarity index 96% rename from tests/core/pyspec/eth2spec/test/eip6110/block_processing/test_process_deposit_receipt.py rename to tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_deposit_receipt.py index d78c18ecb7..d1b8fec12a 100644 --- a/tests/core/pyspec/eth2spec/test/eip6110/block_processing/test_process_deposit_receipt.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_deposit_receipt.py @@ -1,4 +1,4 @@ -from eth2spec.test.context import spec_state_test, always_bls, with_eip6110_and_later +from eth2spec.test.context import spec_state_test, always_bls, with_electra_and_later from eth2spec.test.helpers.deposits import ( prepare_deposit_receipt, run_deposit_receipt_processing, @@ -8,7 +8,7 @@ from eth2spec.test.helpers.withdrawals import set_validator_fully_withdrawable -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_new_deposit_under_max(spec, state): # fresh deposit = next validator index = validator appended to registry @@ -20,7 +20,7 @@ def test_new_deposit_under_max(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_new_deposit_max(spec, state): # fresh deposit = next validator index = validator appended to registry @@ -32,7 +32,7 @@ def test_new_deposit_max(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_new_deposit_over_max(spec, state): # fresh deposit = next validator index = validator appended to registry @@ -44,7 +44,7 @@ def test_new_deposit_over_max(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_new_deposit_eth1_withdrawal_credentials(spec, state): # fresh deposit = next validator index = validator appended to registry @@ -66,7 +66,7 @@ def test_new_deposit_eth1_withdrawal_credentials(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_new_deposit_non_versioned_withdrawal_credentials(spec, state): # fresh deposit = next validator index = validator appended to registry @@ -87,7 +87,7 @@ def test_new_deposit_non_versioned_withdrawal_credentials(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test @always_bls def test_correct_sig_but_forked_state(spec, state): @@ -99,7 +99,7 @@ def test_correct_sig_but_forked_state(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test @always_bls def test_incorrect_sig_new_deposit(spec, state): @@ -110,7 +110,7 @@ def test_incorrect_sig_new_deposit(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index, effective=False) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_top_up__max_effective_balance(spec, state): validator_index = 0 @@ -126,7 +126,7 @@ def test_top_up__max_effective_balance(spec, state): assert state.validators[validator_index].effective_balance == spec.MAX_EFFECTIVE_BALANCE -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_top_up__less_effective_balance(spec, state): validator_index = 0 @@ -145,7 +145,7 @@ def test_top_up__less_effective_balance(spec, state): assert state.validators[validator_index].effective_balance == initial_effective_balance -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_top_up__zero_balance(spec, state): validator_index = 0 @@ -164,7 +164,7 @@ def test_top_up__zero_balance(spec, state): assert state.validators[validator_index].effective_balance == initial_effective_balance -@with_eip6110_and_later +@with_electra_and_later @spec_state_test @always_bls def test_incorrect_sig_top_up(spec, state): @@ -176,7 +176,7 @@ def test_incorrect_sig_top_up(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_incorrect_withdrawal_credentials_top_up(spec, state): validator_index = 0 @@ -193,7 +193,7 @@ def test_incorrect_withdrawal_credentials_top_up(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_key_validate_invalid_subgroup(spec, state): validator_index = len(state.validators) @@ -207,7 +207,7 @@ def test_key_validate_invalid_subgroup(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_key_validate_invalid_decompression(spec, state): validator_index = len(state.validators) @@ -223,7 +223,7 @@ def test_key_validate_invalid_decompression(spec, state): yield from run_deposit_receipt_processing(spec, state, deposit_receipt, validator_index) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test @always_bls def test_ineffective_deposit_with_previous_fork_version(spec, state): @@ -240,7 +240,7 @@ def test_ineffective_deposit_with_previous_fork_version(spec, state): ) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test @always_bls def test_effective_deposit_with_genesis_fork_version(spec, state): @@ -253,7 +253,7 @@ def test_effective_deposit_with_genesis_fork_version(spec, state): ) -@with_eip6110_and_later +@with_electra_and_later @spec_state_test def test_success_top_up_to_withdrawn_validator(spec, state): validator_index = 0 diff --git a/tests/core/pyspec/eth2spec/test/eip6110/sanity/__init__.py b/tests/core/pyspec/eth2spec/test/electra/sanity/__init__.py similarity index 100% rename from tests/core/pyspec/eth2spec/test/eip6110/sanity/__init__.py rename to tests/core/pyspec/eth2spec/test/electra/sanity/__init__.py diff --git a/tests/core/pyspec/eth2spec/test/eip6110/sanity/blocks/__init__.py b/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/__init__.py similarity index 100% rename from tests/core/pyspec/eth2spec/test/eip6110/sanity/blocks/__init__.py rename to tests/core/pyspec/eth2spec/test/electra/sanity/blocks/__init__.py diff --git a/tests/core/pyspec/eth2spec/test/eip6110/sanity/blocks/test_deposit_transition.py b/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_deposit_transition.py similarity index 98% rename from tests/core/pyspec/eth2spec/test/eip6110/sanity/blocks/test_deposit_transition.py rename to tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_deposit_transition.py index 51ef109605..419bc55cfe 100644 --- a/tests/core/pyspec/eth2spec/test/eip6110/sanity/blocks/test_deposit_transition.py +++ b/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_deposit_transition.py @@ -4,7 +4,7 @@ from eth2spec.test.context import ( spec_state_test, with_phases, - EIP6110, + ELECTRA, ) from eth2spec.test.helpers.deposits import ( build_deposit_data, @@ -108,7 +108,7 @@ def prepare_state_and_block(spec, return state, block -@with_phases([EIP6110]) +@with_phases([ELECTRA]) @spec_state_test def test_deposit_transition__start_index_is_set(spec, state): # 0 deposits, 2 deposit receipts, unset deposit_receipts_start_index @@ -123,7 +123,7 @@ def test_deposit_transition__start_index_is_set(spec, state): assert state.deposit_receipts_start_index == block.body.execution_payload.deposit_receipts[0].index -@with_phases([EIP6110]) +@with_phases([ELECTRA]) @spec_state_test def test_deposit_transition__process_eth1_deposits(spec, state): # 3 deposits, 1 deposit receipt, state.eth1_data.deposit_count < state.deposit_receipts_start_index @@ -136,7 +136,7 @@ def test_deposit_transition__process_eth1_deposits(spec, state): yield from run_deposit_transition_block(spec, state, block) -@with_phases([EIP6110]) +@with_phases([ELECTRA]) @spec_state_test def test_deposit_transition__process_max_eth1_deposits(spec, state): # spec.MAX_DEPOSITS deposits, 1 deposit receipt, state.eth1_data.deposit_count > state.deposit_receipts_start_index @@ -151,7 +151,7 @@ def test_deposit_transition__process_max_eth1_deposits(spec, state): yield from run_deposit_transition_block(spec, state, block) -@with_phases([EIP6110]) +@with_phases([ELECTRA]) @spec_state_test def test_deposit_transition__process_eth1_deposits_up_to_start_index(spec, state): # 3 deposits, 1 deposit receipt, state.eth1_data.deposit_count == state.deposit_receipts_start_index @@ -164,7 +164,7 @@ def test_deposit_transition__process_eth1_deposits_up_to_start_index(spec, state yield from run_deposit_transition_block(spec, state, block) -@with_phases([EIP6110]) +@with_phases([ELECTRA]) @spec_state_test def test_deposit_transition__invalid_not_enough_eth1_deposits(spec, state): # 3 deposits, 1 deposit receipt, state.eth1_data.deposit_count < state.deposit_receipts_start_index @@ -178,7 +178,7 @@ def test_deposit_transition__invalid_not_enough_eth1_deposits(spec, state): yield from run_deposit_transition_block(spec, state, block, valid=False) -@with_phases([EIP6110]) +@with_phases([ELECTRA]) @spec_state_test def test_deposit_transition__invalid_too_many_eth1_deposits(spec, state): # 3 deposits, 1 deposit receipt, state.eth1_data.deposit_count < state.eth1_data_index @@ -192,7 +192,7 @@ def test_deposit_transition__invalid_too_many_eth1_deposits(spec, state): yield from run_deposit_transition_block(spec, state, block, valid=False) -@with_phases([EIP6110]) +@with_phases([ELECTRA]) @spec_state_test def test_deposit_transition__invalid_eth1_deposits_overlap_in_protocol_deposits(spec, state): # spec.MAX_DEPOSITS deposits, 1 deposit receipt, state.eth1_data.deposit_count > state.deposit_receipts_start_index @@ -207,7 +207,7 @@ def test_deposit_transition__invalid_eth1_deposits_overlap_in_protocol_deposits( yield from run_deposit_transition_block(spec, state, block, valid=False) -@with_phases([EIP6110]) +@with_phases([ELECTRA]) @spec_state_test def test_deposit_transition__deposit_and_top_up_same_block(spec, state): # 1 deposit, 1 deposit receipt that top ups deposited validator diff --git a/tests/core/pyspec/eth2spec/test/helpers/constants.py b/tests/core/pyspec/eth2spec/test/helpers/constants.py index b482b3a027..f6577f93ab 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/constants.py +++ b/tests/core/pyspec/eth2spec/test/helpers/constants.py @@ -16,7 +16,7 @@ SHARDING = SpecForkName('sharding') CUSTODY_GAME = SpecForkName('custody_game') DAS = SpecForkName('das') -EIP6110 = SpecForkName('eip6110') +ELECTRA = SpecForkName('electra') EIP7002 = SpecForkName('eip7002') EIP7549 = SpecForkName('eip7549') WHISK = SpecForkName('whisk') @@ -37,8 +37,8 @@ # Formal forks *MAINNET_FORKS, DENEB, + ELECTRA, # Experimental patches - EIP6110, EIP7002, EIP7251, EIP7549, @@ -47,7 +47,7 @@ # The forks that have light client specs LIGHT_CLIENT_TESTING_FORKS = (*[item for item in MAINNET_FORKS if item != PHASE0], DENEB) # The forks that output to the test vectors. -TESTGEN_FORKS = (*MAINNET_FORKS, DENEB, EIP6110, WHISK) +TESTGEN_FORKS = (*MAINNET_FORKS, DENEB, ELECTRA, WHISK) # Forks allowed in the test runner `--fork` flag, to fail fast in case of typos ALLOWED_TEST_RUNNER_FORKS = (*ALL_PHASES, WHISK) @@ -59,8 +59,8 @@ BELLATRIX: ALTAIR, CAPELLA: BELLATRIX, DENEB: CAPELLA, + ELECTRA: DENEB, # Experimental patches - EIP6110: DENEB, WHISK: CAPELLA, EIP7002: CAPELLA, EIP7549: DENEB, @@ -75,7 +75,7 @@ ALTAIR: BELLATRIX, BELLATRIX: CAPELLA, CAPELLA: DENEB, - DENEB: EIP6110, + DENEB: ELECTRA, } ALL_PRE_POST_FORKS = POST_FORK_OF.items() diff --git a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py index adec1d781c..0d1269dda7 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py @@ -7,7 +7,7 @@ from eth2spec.test.helpers.forks import ( is_post_capella, is_post_deneb, - is_post_eip6110, + is_post_electra, is_post_eip7002, ) @@ -34,7 +34,7 @@ def get_execution_payload_header(spec, execution_payload): if is_post_deneb(spec): payload_header.blob_gas_used = execution_payload.blob_gas_used payload_header.excess_blob_gas = execution_payload.excess_blob_gas - if is_post_eip6110(spec): + if is_post_electra(spec): payload_header.deposit_receipts_root = spec.hash_tree_root(execution_payload.deposit_receipts) if is_post_eip7002(spec): payload_header.exits_root = spec.hash_tree_root(execution_payload.exits) @@ -105,7 +105,7 @@ def compute_el_header_block_hash(spec, # excess_blob_gas execution_payload_header_rlp.append((big_endian_int, payload_header.blob_gas_used)) execution_payload_header_rlp.append((big_endian_int, payload_header.excess_blob_gas)) - if is_post_eip6110(spec): + if is_post_electra(spec): # deposit_receipts_root assert deposit_receipts_trie_root is not None execution_payload_header_rlp.append((Binary(32, 32), deposit_receipts_trie_root)) @@ -181,7 +181,7 @@ def compute_el_block_hash(spec, payload): if is_post_capella(spec): withdrawals_encoded = [get_withdrawal_rlp(withdrawal) for withdrawal in payload.withdrawals] withdrawals_trie_root = compute_trie_root_from_indexed_data(withdrawals_encoded) - if is_post_eip6110(spec): + if is_post_electra(spec): deposit_receipts_encoded = [get_deposit_receipt_rlp(spec, receipt) for receipt in payload.deposit_receipts] deposit_receipts_trie_root = compute_trie_root_from_indexed_data(deposit_receipts_encoded) if is_post_eip7002(spec): @@ -231,7 +231,7 @@ def build_empty_execution_payload(spec, state, randao_mix=None): if is_post_deneb(spec): payload.blob_gas_used = 0 payload.excess_blob_gas = 0 - if is_post_eip6110(spec): + if is_post_electra(spec): # just to be clear payload.deposit_receipts = [] diff --git a/tests/core/pyspec/eth2spec/test/helpers/forks.py b/tests/core/pyspec/eth2spec/test/helpers/forks.py index 8b03c8fb79..b1b6a168f7 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/forks.py +++ b/tests/core/pyspec/eth2spec/test/helpers/forks.py @@ -1,6 +1,6 @@ from .constants import ( PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, - EIP6110, EIP7002, EIP7251, EIP7549, WHISK, + ELECTRA, EIP7002, EIP7251, EIP7549, WHISK, PREVIOUS_FORK_OF, ) @@ -37,8 +37,8 @@ def is_post_deneb(spec): return is_post_fork(spec.fork, DENEB) -def is_post_eip6110(spec): - return is_post_fork(spec.fork, EIP6110) +def is_post_electra(spec): + return is_post_fork(spec.fork, ELECTRA) def is_post_eip7002(spec): diff --git a/tests/core/pyspec/eth2spec/test/helpers/genesis.py b/tests/core/pyspec/eth2spec/test/helpers/genesis.py index acf96a4940..248e47736b 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/genesis.py +++ b/tests/core/pyspec/eth2spec/test/helpers/genesis.py @@ -6,7 +6,7 @@ compute_el_header_block_hash, ) from eth2spec.test.helpers.forks import ( - is_post_altair, is_post_bellatrix, is_post_capella, is_post_eip6110, is_post_eip7002, is_post_whisk, is_post_eip7251 + is_post_altair, is_post_bellatrix, is_post_capella, is_post_eip7002, is_post_whisk, is_post_eip7251 ) from eth2spec.test.helpers.keys import pubkeys from eth2spec.test.helpers.whisk import compute_whisk_initial_tracker_cached, compute_whisk_initial_k_commitment_cached @@ -55,7 +55,7 @@ def get_sample_genesis_execution_payload_header(spec, if is_post_capella(spec): withdrawals_trie_root = bytes.fromhex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") - if is_post_eip6110(spec): + if is_post_electra(spec): deposit_receipts_trie_root = bytes.fromhex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") if is_post_eip7002(spec): exits_trie_root = bytes.fromhex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") @@ -134,7 +134,7 @@ def create_genesis_state(spec, validator_balances, activation_threshold): eth1_block_hash=eth1_block_hash, ) - if is_post_eip6110(spec): + if is_post_electra(spec): state.deposit_receipts_start_index = spec.UNSET_DEPOSIT_RECEIPTS_START_INDEX if is_post_whisk(spec): diff --git a/tests/formats/operations/README.md b/tests/formats/operations/README.md index ba764879bd..8e9841618a 100644 --- a/tests/formats/operations/README.md +++ b/tests/formats/operations/README.md @@ -45,7 +45,7 @@ Operations: | `execution_payload` | `BeaconBlockBody` | **`body`** | `process_execution_payload(state, body)` (new in Bellatrix) | | `withdrawals` | `ExecutionPayload` | `execution_payload` | `process_withdrawals(state, execution_payload)` (new in Capella) | | `bls_to_execution_change` | `SignedBLSToExecutionChange` | `address_change` | `process_bls_to_execution_change(state, address_change)` (new in Capella) | -| `deposit_receipt` | `DepositReceipt` | `deposit_receipt` | `process_deposit_receipt(state, deposit_receipt)` (new in EIP6110) | +| `deposit_receipt` | `DepositReceipt` | `deposit_receipt` | `process_deposit_receipt(state, deposit_receipt)` (new in Electra) | Note that `block_header` is not strictly an operation (and is a full `Block`), but processed in the same manner, and hence included here. diff --git a/tests/generators/epoch_processing/main.py b/tests/generators/epoch_processing/main.py index 63c2a548fd..93e9a366c2 100644 --- a/tests/generators/epoch_processing/main.py +++ b/tests/generators/epoch_processing/main.py @@ -1,5 +1,5 @@ from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods -from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110 +from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA if __name__ == "__main__": @@ -37,7 +37,7 @@ ]} deneb_mods = combine_mods(_new_deneb_mods, capella_mods) - eip6110_mods = deneb_mods + electra_mods = deneb_mods # TODO Custody Game testgen is disabled for now # custody_game_mods = {**{key: 'eth2spec.test.custody_game.epoch_processing.test_process_' + key for key in [ @@ -52,7 +52,7 @@ BELLATRIX: bellatrix_mods, CAPELLA: capella_mods, DENEB: deneb_mods, - EIP6110: eip6110_mods, + ELECTRA: electra_mods, } run_state_test_generators(runner_name="epoch_processing", all_mods=all_mods) diff --git a/tests/generators/finality/main.py b/tests/generators/finality/main.py index 15c6cad8dd..6d33ae6bdc 100644 --- a/tests/generators/finality/main.py +++ b/tests/generators/finality/main.py @@ -1,5 +1,5 @@ from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators -from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110 +from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA if __name__ == "__main__": @@ -8,7 +8,7 @@ bellatrix_mods = altair_mods # No additional Bellatrix specific finality tests capella_mods = bellatrix_mods # No additional Capella specific finality tests deneb_mods = capella_mods # No additional Deneb specific finality tests - eip6110_mods = deneb_mods # No additional EIP6110 specific finality tests + electra_mods = deneb_mods # No additional Electra specific finality tests all_mods = { PHASE0: phase_0_mods, @@ -16,7 +16,7 @@ BELLATRIX: bellatrix_mods, CAPELLA: capella_mods, DENEB: deneb_mods, - EIP6110: eip6110_mods, + ELECTRA: electra_mods, } run_state_test_generators(runner_name="finality", all_mods=all_mods) diff --git a/tests/generators/fork_choice/main.py b/tests/generators/fork_choice/main.py index df117ccd16..92c67e4c0b 100644 --- a/tests/generators/fork_choice/main.py +++ b/tests/generators/fork_choice/main.py @@ -1,5 +1,5 @@ from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods -from eth2spec.test.helpers.constants import ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110 +from eth2spec.test.helpers.constants import ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA if __name__ == "__main__": @@ -28,14 +28,14 @@ ]} deneb_mods = combine_mods(_new_deneb_mods, capella_mods) - eip6110_mods = deneb_mods # No additional EIP6110 specific fork choice tests + electra_mods = deneb_mods # No additional Electra specific fork choice tests all_mods = { ALTAIR: altair_mods, BELLATRIX: bellatrix_mods, CAPELLA: capella_mods, DENEB: deneb_mods, - EIP6110: eip6110_mods, + ELECTRA: electra_mods, } run_state_test_generators(runner_name="fork_choice", all_mods=all_mods) diff --git a/tests/generators/genesis/main.py b/tests/generators/genesis/main.py index feffde8e38..57b680ebac 100644 --- a/tests/generators/genesis/main.py +++ b/tests/generators/genesis/main.py @@ -1,5 +1,5 @@ from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods -from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110 +from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA if __name__ == "__main__": @@ -17,14 +17,14 @@ bellatrix_mods = combine_mods(_new_bellatrix_mods, altair_mods) capella_mods = bellatrix_mods # No additional Capella specific genesis tests deneb_mods = capella_mods # No additional Deneb specific genesis tests - eip6110_mods = deneb_mods # No additional EIP6110 specific genesis tests + electra_mods = deneb_mods # No additional Electra specific genesis tests all_mods = { PHASE0: phase_0_mods, ALTAIR: altair_mods, BELLATRIX: bellatrix_mods, CAPELLA: capella_mods, DENEB: deneb_mods, - EIP6110: eip6110_mods, + ELECTRA: electra_mods, } run_state_test_generators(runner_name="genesis", all_mods=all_mods) diff --git a/tests/generators/operations/main.py b/tests/generators/operations/main.py index 053236c8d7..c31a72285b 100644 --- a/tests/generators/operations/main.py +++ b/tests/generators/operations/main.py @@ -1,5 +1,5 @@ from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods -from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110 +from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA if __name__ == "__main__": @@ -43,10 +43,10 @@ ]} deneb_mods = combine_mods(_new_deneb_mods, capella_mods) - _new_eip6110_mods = {key: 'eth2spec.test.eip6110.block_processing.test_process_' + key for key in [ + _new_electra_mods = {key: 'eth2spec.test.electra.block_processing.test_process_' + key for key in [ 'deposit_receipt', ]} - eip6110_mods = combine_mods(_new_eip6110_mods, deneb_mods) + electra_mods = combine_mods(_new_electra_mods, deneb_mods) # TODO Custody Game testgen is disabled for now # _new_custody_game_mods = {key: 'eth2spec.test.custody_game.block_processing.test_process_' + key for key in [ @@ -64,7 +64,7 @@ BELLATRIX: bellatrix_mods, CAPELLA: capella_mods, DENEB: deneb_mods, - EIP6110: eip6110_mods, + ELECTRA: electra_mods, } run_state_test_generators(runner_name="operations", all_mods=all_mods) diff --git a/tests/generators/rewards/main.py b/tests/generators/rewards/main.py index d01d4a424e..dcf2c6ce23 100644 --- a/tests/generators/rewards/main.py +++ b/tests/generators/rewards/main.py @@ -1,5 +1,5 @@ from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators -from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110 +from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA if __name__ == "__main__": @@ -17,7 +17,7 @@ bellatrix_mods = altair_mods capella_mods = bellatrix_mods deneb_mods = capella_mods - eip6110_mods = deneb_mods + electra_mods = deneb_mods all_mods = { PHASE0: phase_0_mods, @@ -25,7 +25,7 @@ BELLATRIX: bellatrix_mods, CAPELLA: capella_mods, DENEB: deneb_mods, - EIP6110: eip6110_mods, + ELECTRA: electra_mods, } run_state_test_generators(runner_name="rewards", all_mods=all_mods) diff --git a/tests/generators/sanity/main.py b/tests/generators/sanity/main.py index b9f6d7fbb1..f2485eef53 100644 --- a/tests/generators/sanity/main.py +++ b/tests/generators/sanity/main.py @@ -1,4 +1,4 @@ -from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110 +from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators, combine_mods @@ -28,10 +28,10 @@ ]} deneb_mods = combine_mods(_new_deneb_mods, capella_mods) - _new_eip6110_mods = {key: 'eth2spec.test.eip6110.sanity.' + key for key in [ + _new_electra_mods = {key: 'eth2spec.test.electra.sanity.' + key for key in [ 'blocks', ]} - eip6110_mods = combine_mods(_new_eip6110_mods, deneb_mods) + electra_mods = combine_mods(_new_electra_mods, deneb_mods) all_mods = { PHASE0: phase_0_mods, @@ -39,7 +39,7 @@ BELLATRIX: bellatrix_mods, CAPELLA: capella_mods, DENEB: deneb_mods, - EIP6110: eip6110_mods, + ELECTRA: electra_mods, } run_state_test_generators(runner_name="sanity", all_mods=all_mods) diff --git a/tests/generators/sync/main.py b/tests/generators/sync/main.py index 5563e6f8c3..94e392b775 100644 --- a/tests/generators/sync/main.py +++ b/tests/generators/sync/main.py @@ -1,5 +1,5 @@ from eth2spec.gen_helpers.gen_from_tests.gen import run_state_test_generators -from eth2spec.test.helpers.constants import BELLATRIX, CAPELLA, DENEB, EIP6110 +from eth2spec.test.helpers.constants import BELLATRIX, CAPELLA, DENEB, ELECTRA if __name__ == "__main__": @@ -8,13 +8,13 @@ ]} capella_mods = bellatrix_mods deneb_mods = capella_mods - eip6110_mods = deneb_mods + electra_mods = deneb_mods all_mods = { BELLATRIX: bellatrix_mods, CAPELLA: capella_mods, DENEB: deneb_mods, - EIP6110: eip6110_mods, + ELECTRA: electra_mods, } run_state_test_generators(runner_name="sync", all_mods=all_mods) From 9c4e1db821488b2bb631a5229d36c2dfb5b13520 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Wed, 6 Mar 2024 14:00:55 +0800 Subject: [PATCH 02/11] EIP6110 meta update --- README.md | 2 +- specs/electra/beacon-chain.md | 50 +++++++++++++++++++---------------- specs/electra/fork.md | 20 +++++++------- specs/electra/validator.md | 8 +++--- 4 files changed, 42 insertions(+), 38 deletions(-) diff --git a/README.md b/README.md index e59e096121..58bff5b9e4 100644 --- a/README.md +++ b/README.md @@ -26,10 +26,10 @@ Features are researched and developed in parallel, and then consolidated into se ### In-development Specifications | Code Name or Topic | Specs | Notes | | - | - | - | +| Electra | | | Sharding (outdated) | | | Custody Game (outdated) | | Dependent on sharding | | Data Availability Sampling (outdated) | | | -| EIP-6110 | | ### Accompanying documents can be found in [specs](specs) and include: diff --git a/specs/electra/beacon-chain.md b/specs/electra/beacon-chain.md index 4351c7482a..34b8b4b451 100644 --- a/specs/electra/beacon-chain.md +++ b/specs/electra/beacon-chain.md @@ -1,4 +1,6 @@ -# EIP-6110 -- The Beacon Chain +# Electra -- The Beacon Chain + +**Notice**: This document is a work-in-progress for researchers and implementers. ## Table of contents @@ -30,10 +32,8 @@ ## Introduction -This is the beacon chain specification of in-protocol deposits processing mechanism. -This mechanism relies on the changes proposed by [EIP-6110](http://eips.ethereum.org/EIPS/eip-6110). - -*Note:* This specification is built upon [Deneb](../../deneb/beacon-chain.md) and is under active development. +Electra is a consensus-layer upgrade containing a number of features. Including: +* [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110): Supply validator deposits on chain ## Constants @@ -41,9 +41,9 @@ The following values are (non-configurable) constants used throughout the specif ### Misc -| Name | Value | -| - | - | -| `UNSET_DEPOSIT_RECEIPTS_START_INDEX` | `uint64(2**64 - 1)` | +| Name | Value | Description | +| - | - | - | +| `UNSET_DEPOSIT_RECEIPTS_START_INDEX` | `uint64(2**64 - 1)` | *[New in Electra:EIP6110]* | ## Preset @@ -51,7 +51,7 @@ The following values are (non-configurable) constants used throughout the specif | Name | Value | Description | | - | - | - | -| `MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD` | `uint64(2**13)` (= 8,192) | Maximum number of deposit receipts allowed in each payload | +| `MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD` | `uint64(2**13)` (= 8,192) | *[New in Electra:EIP6110]* Maximum number of deposit receipts allowed in each payload | ## Containers @@ -59,6 +59,8 @@ The following values are (non-configurable) constants used throughout the specif #### `DepositReceipt` +*Note*: The container is new in EIP6110. + ```python class DepositReceipt(Container): pubkey: BLSPubkey @@ -93,7 +95,7 @@ class ExecutionPayload(Container): withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD] blob_gas_used: uint64 excess_blob_gas: uint64 - deposit_receipts: List[DepositReceipt, MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD] # [New in EIP6110] + deposit_receipts: List[DepositReceipt, MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD] # [New in Electra:EIP6110] ``` #### `ExecutionPayloadHeader` @@ -119,7 +121,7 @@ class ExecutionPayloadHeader(Container): withdrawals_root: Root blob_gas_used: uint64 excess_blob_gas: uint64 - deposit_receipts_root: Root # [New in EIP6110] + deposit_receipts_root: Root # [New in Electra:EIP6110] ``` #### `BeaconState` @@ -161,13 +163,13 @@ class BeaconState(Container): current_sync_committee: SyncCommittee next_sync_committee: SyncCommittee # Execution - latest_execution_payload_header: ExecutionPayloadHeader # [Modified in EIP6110] + latest_execution_payload_header: ExecutionPayloadHeader # [Modified in Electra:EIP6110] # Withdrawals next_withdrawal_index: WithdrawalIndex next_withdrawal_validator_index: ValidatorIndex # Deep history valid from Capella onwards historical_summaries: List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT] - # [New in EIP6110] + # [New in Electra:EIP6110] deposit_receipts_start_index: uint64 ``` @@ -179,10 +181,10 @@ class BeaconState(Container): def process_block(state: BeaconState, block: BeaconBlock) -> None: process_block_header(state, block) process_withdrawals(state, block.body.execution_payload) - process_execution_payload(state, block.body, EXECUTION_ENGINE) # [Modified in EIP6110] + process_execution_payload(state, block.body, EXECUTION_ENGINE) # [Modified in Electra:EIP6110] process_randao(state, block.body) process_eth1_data(state, block.body) - process_operations(state, block.body) # [Modified in EIP6110] + process_operations(state, block.body) # [Modified in Electra:EIP6110] process_sync_aggregate(state, block.body.sync_aggregate) ``` @@ -192,7 +194,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: ```python def process_operations(state: BeaconState, body: BeaconBlockBody) -> None: - # [Modified in EIP6110] + # [Modified in Electra:EIP6110] # Disable former deposit mechanism once all prior deposits are processed eth1_deposit_index_limit = min(state.eth1_data.deposit_count, state.deposit_receipts_start_index) if state.eth1_deposit_index < eth1_deposit_index_limit: @@ -217,6 +219,8 @@ def process_operations(state: BeaconState, body: BeaconBlockBody) -> None: #### New `process_deposit_receipt` +*Note*: This function is new in Electra:EIP6110. + ```python def process_deposit_receipt(state: BeaconState, deposit_receipt: DepositReceipt) -> None: # Set deposit receipt start index @@ -276,17 +280,17 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi withdrawals_root=hash_tree_root(payload.withdrawals), blob_gas_used=payload.blob_gas_used, excess_blob_gas=payload.excess_blob_gas, - deposit_receipts_root=hash_tree_root(payload.deposit_receipts), # [New in EIP6110] + deposit_receipts_root=hash_tree_root(payload.deposit_receipts), # [New in Electra:EIP6110] ) ``` ## Testing -*Note*: The function `initialize_beacon_state_from_eth1` is modified for pure EIP-6110 testing only. +*Note*: The function `initialize_beacon_state_from_eth1` is modified for pure Electra testing only. Modifications include: 1. Use `ELECTRA_FORK_VERSION` as the previous and current fork version. -2. Utilize the EIP-6110 `BeaconBlockBody` when constructing the initial `latest_block_header`. -3. Add `deposit_receipts_start_index` variable to the genesis state initialization. +2. Utilize the Electra `BeaconBlockBody` when constructing the initial `latest_block_header`. +3. *[New in Electra:EIP6110]* Add `deposit_receipts_start_index` variable to the genesis state initialization. ```python def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32, @@ -295,8 +299,8 @@ def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32, execution_payload_header: ExecutionPayloadHeader=ExecutionPayloadHeader() ) -> BeaconState: fork = Fork( - previous_version=ELECTRA_FORK_VERSION, # [Modified in EIP6110] for testing only - current_version=ELECTRA_FORK_VERSION, # [Modified in EIP6110] + previous_version=ELECTRA_FORK_VERSION, # [Modified in Electra:EIP6110] for testing only + current_version=ELECTRA_FORK_VERSION, # [Modified in Electra:EIP6110] epoch=GENESIS_EPOCH, ) state = BeaconState( @@ -305,7 +309,7 @@ def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32, eth1_data=Eth1Data(block_hash=eth1_block_hash, deposit_count=uint64(len(deposits))), latest_block_header=BeaconBlockHeader(body_root=hash_tree_root(BeaconBlockBody())), randao_mixes=[eth1_block_hash] * EPOCHS_PER_HISTORICAL_VECTOR, # Seed RANDAO with Eth1 entropy - deposit_receipts_start_index=UNSET_DEPOSIT_RECEIPTS_START_INDEX, # [New in EIP6110] + deposit_receipts_start_index=UNSET_DEPOSIT_RECEIPTS_START_INDEX, # [New in Electra:EIP6110] ) # Process deposits diff --git a/specs/electra/fork.md b/specs/electra/fork.md index a592f1c5ee..f93ef03dfe 100644 --- a/specs/electra/fork.md +++ b/specs/electra/fork.md @@ -1,4 +1,4 @@ -# EIP-6110 -- Fork Logic +# Electra -- Fork Logic **Notice**: This document is a work-in-progress for researchers and implementers. @@ -12,7 +12,7 @@ - [Helper functions](#helper-functions) - [Misc](#misc) - [Modified `compute_fork_version`](#modified-compute_fork_version) -- [Fork to EIP-6110](#fork-to-eip-6110) +- [Fork to Electra](#fork-to-electra) - [Fork trigger](#fork-trigger) - [Upgrading the state](#upgrading-the-state) @@ -55,19 +55,19 @@ def compute_fork_version(epoch: Epoch) -> Version: return GENESIS_FORK_VERSION ``` -## Fork to EIP-6110 +## Fork to Electra ### Fork trigger TBD. This fork is defined for testing purposes, the EIP may be combined with other consensus-layer upgrade. For now, we assume the condition will be triggered at epoch `ELECTRA_FORK_EPOCH`. -Note that for the pure EIP-6110 networks, we don't apply `upgrade_to_electra` since it starts with EIP-6110 version logic. +Note that for the pure Electra networks, we don't apply `upgrade_to_electra` since it starts with Electra version logic. ### Upgrading the state If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == ELECTRA_FORK_EPOCH`, -an irregular state change is made to upgrade to EIP-6110. +an irregular state change is made to upgrade to Electra. ```python def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState: @@ -90,7 +90,7 @@ def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState: withdrawals_root=pre.latest_execution_payload_header.withdrawals_root, blob_gas_used=uint64(0), excess_blob_gas=uint64(0), - deposit_receipts_root=Root(), # [New in EIP-6110] + deposit_receipts_root=Root(), # [New in Electra:EIP6110] ) post = BeaconState( # Versioning @@ -99,7 +99,7 @@ def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState: slot=pre.slot, fork=Fork( previous_version=pre.fork.current_version, - current_version=ELECTRA_FORK_VERSION, # [Modified in EIP-6110] + current_version=ELECTRA_FORK_VERSION, # [Modified in Electra:EIP6110] epoch=epoch, ), # History @@ -132,14 +132,14 @@ def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState: current_sync_committee=pre.current_sync_committee, next_sync_committee=pre.next_sync_committee, # Execution-layer - latest_execution_payload_header=latest_execution_payload_header, # [Modified in EIP-6110] + latest_execution_payload_header=latest_execution_payload_header, # [Modified in Electra:EIP6110] # Withdrawals next_withdrawal_index=pre.next_withdrawal_index, next_withdrawal_validator_index=pre.next_withdrawal_validator_index, # Deep history valid from Capella onwards historical_summaries=pre.historical_summaries, - # EIP-6110 - deposit_receipts_start_index=UNSET_DEPOSIT_RECEIPTS_START_INDEX, # [New in EIP-6110] + # EIP6110 + deposit_receipts_start_index=UNSET_DEPOSIT_RECEIPTS_START_INDEX, # [New in Electra:EIP6110] ) return post diff --git a/specs/electra/validator.md b/specs/electra/validator.md index 54c5bb5cbc..c572e93914 100644 --- a/specs/electra/validator.md +++ b/specs/electra/validator.md @@ -1,4 +1,4 @@ -# EIP-6110 -- Honest Validator +# Electra -- Honest Validator ## Table of contents @@ -16,21 +16,21 @@ ## Introduction -This document represents the changes to be made in the code of an "honest validator" to implement EIP-6110. +This document represents the changes to be made in the code of an "honest validator" to implement Electra. ## Prerequisites This document is an extension of the [Deneb -- Honest Validator](../../deneb/validator.md) guide. All behaviors and definitions defined in this document, and documents it extends, carry over unless explicitly noted or overridden. -All terminology, constants, functions, and protocol mechanics defined in the updated Beacon Chain doc of [EIP-6110](./beacon-chain.md) are requisite for this document and used throughout. +All terminology, constants, functions, and protocol mechanics defined in the updated Beacon Chain doc of [Electra](./beacon-chain.md) are requisite for this document and used throughout. Please see related Beacon Chain doc before continuing and use them as a reference throughout. ## Block proposal ### Deposits -The expected number of deposits MUST be changed from `min(MAX_DEPOSITS, eth1_data.deposit_count - state.eth1_deposit_index)` to the result of the following function: +*[New in Electra:EIP6110* The expected number of deposits MUST be changed from `min(MAX_DEPOSITS, eth1_data.deposit_count - state.eth1_deposit_index)` to the result of the following function: ```python def get_eth1_pending_deposit_count(state: BeaconState) -> uint64: From 55c81e7fa1b69467507e9565620d305cf34d8bc4 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Wed, 6 Mar 2024 14:23:23 +0800 Subject: [PATCH 03/11] Merge EIP7002 into Electra --- .circleci/config.yml | 18 +- .github/workflows/run-tests.yml | 2 +- .gitignore | 2 - Makefile | 2 +- configs/mainnet.yaml | 3 - configs/minimal.yaml | 3 - presets/mainnet/electra.yaml | 2 + presets/minimal/electra.yaml | 2 + pysetup/constants.py | 3 +- pysetup/md_doc_paths.py | 6 +- pysetup/spec_builders/__init__.py | 5 +- specs/_features/eip7002/beacon-chain.md | 300 ------------------ specs/electra/beacon-chain.md | 51 ++- specs/electra/fork.md | 3 +- tests/core/pyspec/eth2spec/test/context.py | 7 +- .../test_process_execution_layer_exit.py | 12 +- .../sanity/blocks}/test_blocks.py | 10 +- .../pyspec/eth2spec/test/helpers/constants.py | 5 +- .../test/helpers/execution_payload.py | 4 - .../pyspec/eth2spec/test/helpers/forks.py | 6 +- .../pyspec/eth2spec/test/helpers/genesis.py | 3 +- 21 files changed, 81 insertions(+), 368 deletions(-) delete mode 100644 specs/_features/eip7002/beacon-chain.md rename tests/core/pyspec/eth2spec/test/{eip7002 => electra}/block_processing/test_process_execution_layer_exit.py (95%) rename tests/core/pyspec/eth2spec/test/{eip7002/sanity => electra/sanity/blocks}/test_blocks.py (98%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 6a3c46fa9b..013619172d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -168,19 +168,6 @@ jobs: command: make citest fork=electra - store_test_results: path: tests/core/pyspec/test-reports - test-eip7002: - docker: - - image: circleci/python:3.9 - working_directory: ~/specs-repo - steps: - - restore_cache: - key: v3-specs-repo-{{ .Branch }}-{{ .Revision }} - - restore_pyspec_cached_venv - - run: - name: Run py-tests - command: make citest fork=eip7002 - - store_test_results: - path: tests/core/pyspec/test-reports test-eip7549: docker: - image: circleci/python:3.9 @@ -343,9 +330,6 @@ workflows: - test-electra: requires: - install_pyspec_test - - test-eip7002: - requires: - - install_pyspec_test - test-eip7549: requires: - install_pyspec_test @@ -360,7 +344,7 @@ workflows: - lint: requires: - install_pyspec_test - # NOTE: Since phase 0 has been launched, we disabled the deposit contract tests. + # NOTE: Since phase 0 has been launched, we disabled the deposit contract tests. # - install_deposit_contract_web3_tester: # requires: # - checkout_specs diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index ccf4ec1caf..b92fd60dd3 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -71,7 +71,7 @@ jobs: needs: [preclear,lint,codespell,table_of_contents] strategy: matrix: - version: ["phase0", "altair", "bellatrix", "capella", "deneb", "electra", "eip7002", "eip7549", "whisk", "eip7594"] + version: ["phase0", "altair", "bellatrix", "capella", "deneb", "electra", "whisk", "eip7549", "eip7594"] steps: - name: Checkout this repo uses: actions/checkout@v3.2.0 diff --git a/.gitignore b/.gitignore index daa006a8e7..acfaae8718 100644 --- a/.gitignore +++ b/.gitignore @@ -22,8 +22,6 @@ tests/core/pyspec/eth2spec/bellatrix/ tests/core/pyspec/eth2spec/capella/ tests/core/pyspec/eth2spec/deneb/ tests/core/pyspec/eth2spec/electra/ -tests/core/pyspec/eth2spec/eip7002/ -tests/core/pyspec/eth2spec/eip7549/ tests/core/pyspec/eth2spec/whisk/ tests/core/pyspec/eth2spec/eip7251/ tests/core/pyspec/eth2spec/eip7549/ diff --git a/Makefile b/Makefile index fc3593124d..71d07aed79 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/*/*.md) \ $(wildcard $(SPEC_DIR)/_features/*/*/*.md) \ $(wildcard $(SSZ_DIR)/*.md) -ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra eip7002 eip7549 whisk +ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra eip7549 whisk # The parameters for commands. Use `foreach` to avoid listing specs again. COVERAGE_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), --cov=eth2spec.$S.$(TEST_PRESET_TYPE)) PYLINT_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), ./eth2spec/$S) diff --git a/configs/mainnet.yaml b/configs/mainnet.yaml index 8bbac14672..7d89833d67 100644 --- a/configs/mainnet.yaml +++ b/configs/mainnet.yaml @@ -53,9 +53,6 @@ DENEB_FORK_EPOCH: 269568 # March 13, 2024, 01:55:35pm UTC # Electra ELECTRA_FORK_VERSION: 0x05000000 # temporary stub ELECTRA_FORK_EPOCH: 18446744073709551615 -# EIP7002 -EIP7002_FORK_VERSION: 0x07000000 # temporary stub -EIP7002_FORK_EPOCH: 18446744073709551615 # EIP7251 EIP7251_FORK_VERSION: 0x06000000 # temporary stub EIP7251_FORK_EPOCH: 18446744073709551615 diff --git a/configs/minimal.yaml b/configs/minimal.yaml index b67bb39a00..7e0e444834 100644 --- a/configs/minimal.yaml +++ b/configs/minimal.yaml @@ -52,9 +52,6 @@ DENEB_FORK_EPOCH: 18446744073709551615 # Electra ELECTRA_FORK_VERSION: 0x05000001 ELECTRA_FORK_EPOCH: 18446744073709551615 -# EIP7002 -EIP7002_FORK_VERSION: 0x07000001 -EIP7002_FORK_EPOCH: 18446744073709551615 # EIP7251 EIP7251_FORK_VERSION: 0x06000001 # temporary stub EIP7251_FORK_EPOCH: 18446744073709551615 diff --git a/presets/mainnet/electra.yaml b/presets/mainnet/electra.yaml index 1f64c2332e..badb4e95d6 100644 --- a/presets/mainnet/electra.yaml +++ b/presets/mainnet/electra.yaml @@ -4,3 +4,5 @@ # --------------------------------------------------------------- # 2**13 (= 8192) receipts MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 8192 +# 2**4 (= 16) exits +MAX_EXECUTION_LAYER_EXITS: 16 diff --git a/presets/minimal/electra.yaml b/presets/minimal/electra.yaml index 75664afa5c..5c359728b4 100644 --- a/presets/minimal/electra.yaml +++ b/presets/minimal/electra.yaml @@ -4,3 +4,5 @@ # --------------------------------------------------------------- # [customized] MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 4 +# 2**4 (= 16) exits +MAX_EXECUTION_LAYER_EXITS: 16 diff --git a/pysetup/constants.py b/pysetup/constants.py index ec7a82a784..eb272d60ae 100644 --- a/pysetup/constants.py +++ b/pysetup/constants.py @@ -5,11 +5,10 @@ CAPELLA = 'capella' DENEB = 'deneb' ELECTRA = 'electra' -EIP7002 = 'eip7002' +EIP7594 = 'eip7594' EIP7251 = 'eip7251' EIP7549 = 'eip7549' WHISK = 'whisk' -EIP7594 = 'eip7594' diff --git a/pysetup/md_doc_paths.py b/pysetup/md_doc_paths.py index 0dfd322cae..8c15fc719b 100644 --- a/pysetup/md_doc_paths.py +++ b/pysetup/md_doc_paths.py @@ -7,11 +7,10 @@ CAPELLA, DENEB, ELECTRA, - EIP7002, - EIP7251, - EIP7549, WHISK, EIP7594, + EIP7251, + EIP7549, ) @@ -23,7 +22,6 @@ DENEB: CAPELLA, ELECTRA: DENEB, WHISK: CAPELLA, - EIP7002: CAPELLA, EIP7251: DENEB, EIP7549: DENEB, EIP7594: DENEB, diff --git a/pysetup/spec_builders/__init__.py b/pysetup/spec_builders/__init__.py index f51c951f84..cf8a49972d 100644 --- a/pysetup/spec_builders/__init__.py +++ b/pysetup/spec_builders/__init__.py @@ -4,10 +4,9 @@ from .capella import CapellaSpecBuilder from .deneb import DenebSpecBuilder from .electra import ElectraSpecBuilder -from .eip7002 import EIP7002SpecBuilder -from .eip7549 import EIP7549SpecBuilder from .whisk import WhiskSpecBuilder from .eip7251 import EIP7251SpecBuilder +from .eip7549 import EIP7549SpecBuilder from .eip7594 import EIP7594SpecBuilder @@ -15,6 +14,6 @@ builder.fork: builder for builder in ( Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder, CapellaSpecBuilder, DenebSpecBuilder, - ElectraSpecBuilder, EIP7002SpecBuilder, EIP7549SpecBuilder, WhiskSpecBuilder, EIP7251SpecBuilder, EIP7594SpecBuilder, + ElectraSpecBuilder, WhiskSpecBuilder, EIP7594SpecBuilder, EIP7549SpecBuilder, EIP7251SpecBuilder, ) } diff --git a/specs/_features/eip7002/beacon-chain.md b/specs/_features/eip7002/beacon-chain.md deleted file mode 100644 index 39b03e878a..0000000000 --- a/specs/_features/eip7002/beacon-chain.md +++ /dev/null @@ -1,300 +0,0 @@ -# EIP-7002 -- The Beacon Chain - -## Table of contents - - - - - -- [Introduction](#introduction) -- [Preset](#preset) - - [Max operations per block](#max-operations-per-block) -- [Containers](#containers) - - [New containers](#new-containers) - - [`ExecutionLayerExit`](#executionlayerexit) - - [Extended Containers](#extended-containers) - - [`ExecutionPayload`](#executionpayload) - - [`ExecutionPayloadHeader`](#executionpayloadheader) - - [`BeaconState`](#beaconstate) -- [Beacon chain state transition function](#beacon-chain-state-transition-function) - - [Block processing](#block-processing) - - [Execution payload](#execution-payload) - - [Modified `process_execution_payload`](#modified-process_execution_payload) - - [Operations](#operations) - - [Modified `process_operations`](#modified-process_operations) - - [New `process_execution_layer_exit`](#new-process_execution_layer_exit) -- [Testing](#testing) - - - - -## Introduction - -This is the beacon chain specification of the execution layer triggerable exits feature. - -This mechanism relies on the changes proposed by [EIP-7002](http://eips.ethereum.org/EIPS/eip-7002). - -*Note:* This specification is built upon [Capella](../../capella/beacon-chain.md) and is under active development. - -## Preset - -### Max operations per block - -| Name | Value | -| - | - | -| `MAX_EXECUTION_LAYER_EXITS` | `2**4` (= 16) | - -## Containers - -### New containers - -#### `ExecutionLayerExit` - -```python -class ExecutionLayerExit(Container): - source_address: ExecutionAddress - validator_pubkey: BLSPubkey -``` - -### Extended Containers - -#### `ExecutionPayload` - -```python -class ExecutionPayload(Container): - # Execution block header fields - parent_hash: Hash32 - fee_recipient: ExecutionAddress - state_root: Bytes32 - receipts_root: Bytes32 - logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM] - prev_randao: Bytes32 - block_number: uint64 - gas_limit: uint64 - gas_used: uint64 - timestamp: uint64 - extra_data: ByteList[MAX_EXTRA_DATA_BYTES] - base_fee_per_gas: uint256 - # Extra payload fields - block_hash: Hash32 - transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD] - withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD] - exits: List[ExecutionLayerExit, MAX_EXECUTION_LAYER_EXITS] # [New in EIP7002] -``` - -#### `ExecutionPayloadHeader` - -```python -class ExecutionPayloadHeader(Container): - # Execution block header fields - parent_hash: Hash32 - fee_recipient: ExecutionAddress - state_root: Bytes32 - receipts_root: Bytes32 - logs_bloom: ByteVector[BYTES_PER_LOGS_BLOOM] - prev_randao: Bytes32 - block_number: uint64 - gas_limit: uint64 - gas_used: uint64 - timestamp: uint64 - extra_data: ByteList[MAX_EXTRA_DATA_BYTES] - base_fee_per_gas: uint256 - # Extra payload fields - block_hash: Hash32 - transactions_root: Root - withdrawals_root: Root - exits_root: Root # [New in EIP7002] -``` - -#### `BeaconState` - -```python -class BeaconState(Container): - # Versioning - genesis_time: uint64 - genesis_validators_root: Root - slot: Slot - fork: Fork - # History - latest_block_header: BeaconBlockHeader - block_roots: Vector[Root, SLOTS_PER_HISTORICAL_ROOT] - state_roots: Vector[Root, SLOTS_PER_HISTORICAL_ROOT] - historical_roots: List[Root, HISTORICAL_ROOTS_LIMIT] - # Eth1 - eth1_data: Eth1Data - eth1_data_votes: List[Eth1Data, EPOCHS_PER_ETH1_VOTING_PERIOD * SLOTS_PER_EPOCH] - eth1_deposit_index: uint64 - # Registry - validators: List[Validator, VALIDATOR_REGISTRY_LIMIT] - balances: List[Gwei, VALIDATOR_REGISTRY_LIMIT] - # Randomness - randao_mixes: Vector[Bytes32, EPOCHS_PER_HISTORICAL_VECTOR] - # Slashings - slashings: Vector[Gwei, EPOCHS_PER_SLASHINGS_VECTOR] # Per-epoch sums of slashed effective balances - # Participation - previous_epoch_participation: List[ParticipationFlags, VALIDATOR_REGISTRY_LIMIT] - current_epoch_participation: List[ParticipationFlags, VALIDATOR_REGISTRY_LIMIT] - # Finality - justification_bits: Bitvector[JUSTIFICATION_BITS_LENGTH] # Bit set for every recent justified epoch - previous_justified_checkpoint: Checkpoint - current_justified_checkpoint: Checkpoint - finalized_checkpoint: Checkpoint - # Inactivity - inactivity_scores: List[uint64, VALIDATOR_REGISTRY_LIMIT] - # Sync - current_sync_committee: SyncCommittee - next_sync_committee: SyncCommittee - # Execution - latest_execution_payload_header: ExecutionPayloadHeader # [Modified in EIP7002] - # Withdrawals - next_withdrawal_index: WithdrawalIndex - next_withdrawal_validator_index: ValidatorIndex - # Deep history valid from Capella onwards - historical_summaries: List[HistoricalSummary, HISTORICAL_ROOTS_LIMIT] -``` - -## Beacon chain state transition function - -### Block processing - -#### Execution payload - -##### Modified `process_execution_payload` - -```python -def process_execution_payload(state: BeaconState, body: BeaconBlockBody, execution_engine: ExecutionEngine) -> None: - payload = body.execution_payload - # Verify consistency of the parent hash with respect to the previous execution payload header - assert payload.parent_hash == state.latest_execution_payload_header.block_hash - # Verify prev_randao - assert payload.prev_randao == get_randao_mix(state, get_current_epoch(state)) - # Verify timestamp - assert payload.timestamp == compute_timestamp_at_slot(state, state.slot) - # Verify the execution payload is valid - assert execution_engine.verify_and_notify_new_payload(NewPayloadRequest(execution_payload=payload)) - # Cache execution payload header - state.latest_execution_payload_header = ExecutionPayloadHeader( - parent_hash=payload.parent_hash, - fee_recipient=payload.fee_recipient, - state_root=payload.state_root, - receipts_root=payload.receipts_root, - logs_bloom=payload.logs_bloom, - prev_randao=payload.prev_randao, - block_number=payload.block_number, - gas_limit=payload.gas_limit, - gas_used=payload.gas_used, - timestamp=payload.timestamp, - extra_data=payload.extra_data, - base_fee_per_gas=payload.base_fee_per_gas, - block_hash=payload.block_hash, - transactions_root=hash_tree_root(payload.transactions), - withdrawals_root=hash_tree_root(payload.withdrawals), - exits_root=hash_tree_root(payload.exits), # [New in EIP7002] - ) -``` - -#### Operations - -##### Modified `process_operations` - -*Note*: The function `process_operations` is modified to process `ExecutionLayerExit` operations included in the block. - -```python -def process_operations(state: BeaconState, body: BeaconBlockBody) -> None: - # Verify that outstanding deposits are processed up to the maximum number of deposits - assert len(body.deposits) == min(MAX_DEPOSITS, state.eth1_data.deposit_count - state.eth1_deposit_index) - - def for_ops(operations: Sequence[Any], fn: Callable[[BeaconState, Any], None]) -> None: - for operation in operations: - fn(state, operation) - - for_ops(body.proposer_slashings, process_proposer_slashing) - for_ops(body.attester_slashings, process_attester_slashing) - for_ops(body.attestations, process_attestation) - for_ops(body.deposits, process_deposit) - for_ops(body.voluntary_exits, process_voluntary_exit) - for_ops(body.execution_payload.exits, process_execution_layer_exit) # [New in EIP7002] - for_ops(body.bls_to_execution_changes, process_bls_to_execution_change) -``` - -##### New `process_execution_layer_exit` - -```python -def process_execution_layer_exit(state: BeaconState, execution_layer_exit: ExecutionLayerExit) -> None: - validator_pubkeys = [v.pubkey for v in state.validators] - validator_index = ValidatorIndex(validator_pubkeys.index(execution_layer_exit.validator_pubkey)) - validator = state.validators[validator_index] - - # Verify withdrawal credentials - is_execution_address = validator.withdrawal_credentials[:1] == ETH1_ADDRESS_WITHDRAWAL_PREFIX - is_correct_source_address = validator.withdrawal_credentials[12:] == execution_layer_exit.source_address - if not (is_execution_address and is_correct_source_address): - return - # Verify the validator is active - if not is_active_validator(validator, get_current_epoch(state)): - return - # Verify exit has not been initiated - if validator.exit_epoch != FAR_FUTURE_EPOCH: - return - # Verify the validator has been active long enough - if get_current_epoch(state) < validator.activation_epoch + SHARD_COMMITTEE_PERIOD: - return - - # Initiate exit - initiate_validator_exit(state, validator_index) -``` - -## Testing - -*Note*: The function `initialize_beacon_state_from_eth1` is modified for pure EIP-7002 testing only. -Modifications include: -1. Use `EIP7002_FORK_VERSION` as the previous and current fork version. -2. Utilize the EIP-7002 `BeaconBlockBody` when constructing the initial `latest_block_header`. - -```python -def initialize_beacon_state_from_eth1(eth1_block_hash: Hash32, - eth1_timestamp: uint64, - deposits: Sequence[Deposit], - execution_payload_header: ExecutionPayloadHeader=ExecutionPayloadHeader() - ) -> BeaconState: - fork = Fork( - previous_version=EIP7002_FORK_VERSION, # [Modified in EIP7002] for testing only - current_version=EIP7002_FORK_VERSION, # [Modified in EIP7002] - epoch=GENESIS_EPOCH, - ) - state = BeaconState( - genesis_time=eth1_timestamp + GENESIS_DELAY, - fork=fork, - eth1_data=Eth1Data(block_hash=eth1_block_hash, deposit_count=uint64(len(deposits))), - latest_block_header=BeaconBlockHeader(body_root=hash_tree_root(BeaconBlockBody())), - randao_mixes=[eth1_block_hash] * EPOCHS_PER_HISTORICAL_VECTOR, # Seed RANDAO with Eth1 entropy - ) - - # Process deposits - leaves = list(map(lambda deposit: deposit.data, deposits)) - for index, deposit in enumerate(deposits): - deposit_data_list = List[DepositData, 2**DEPOSIT_CONTRACT_TREE_DEPTH](*leaves[:index + 1]) - state.eth1_data.deposit_root = hash_tree_root(deposit_data_list) - process_deposit(state, deposit) - - # Process activations - for index, validator in enumerate(state.validators): - balance = state.balances[index] - validator.effective_balance = min(balance - balance % EFFECTIVE_BALANCE_INCREMENT, MAX_EFFECTIVE_BALANCE) - if validator.effective_balance == MAX_EFFECTIVE_BALANCE: - validator.activation_eligibility_epoch = GENESIS_EPOCH - validator.activation_epoch = GENESIS_EPOCH - - # Set genesis validators root for domain separation and chain versioning - state.genesis_validators_root = hash_tree_root(state.validators) - - # Fill in sync committees - # Note: A duplicate committee is assigned for the current and next committee at genesis - state.current_sync_committee = get_next_sync_committee(state) - state.next_sync_committee = get_next_sync_committee(state) - - # Initialize the execution payload header - state.latest_execution_payload_header = execution_payload_header - - return state -``` diff --git a/specs/electra/beacon-chain.md b/specs/electra/beacon-chain.md index 34b8b4b451..b41042c877 100644 --- a/specs/electra/beacon-chain.md +++ b/specs/electra/beacon-chain.md @@ -16,6 +16,7 @@ - [Containers](#containers) - [New containers](#new-containers) - [`DepositReceipt`](#depositreceipt) + - [`ExecutionLayerExit`](#executionlayerexit) - [Extended Containers](#extended-containers) - [`ExecutionPayload`](#executionpayload) - [`ExecutionPayloadHeader`](#executionpayloadheader) @@ -24,6 +25,7 @@ - [Block processing](#block-processing) - [Modified `process_operations`](#modified-process_operations) - [New `process_deposit_receipt`](#new-process_deposit_receipt) + - [New `process_execution_layer_exit`](#new-process_execution_layer_exit) - [Modified `process_execution_payload`](#modified-process_execution_payload) - [Testing](#testing) @@ -34,6 +36,7 @@ Electra is a consensus-layer upgrade containing a number of features. Including: * [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110): Supply validator deposits on chain +* [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002): Execution layer triggerable exits ## Constants @@ -52,6 +55,7 @@ The following values are (non-configurable) constants used throughout the specif | Name | Value | Description | | - | - | - | | `MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD` | `uint64(2**13)` (= 8,192) | *[New in Electra:EIP6110]* Maximum number of deposit receipts allowed in each payload | +| `MAX_EXECUTION_LAYER_EXITS` | `2**4` (= 16) | *[New in Electra:EIP7002]* | ## Containers @@ -70,6 +74,16 @@ class DepositReceipt(Container): index: uint64 ``` +#### `ExecutionLayerExit` + +*Note*: The container is new in EIP7002. + +```python +class ExecutionLayerExit(Container): + source_address: ExecutionAddress + validator_pubkey: BLSPubkey +``` + ### Extended Containers #### `ExecutionPayload` @@ -96,6 +110,7 @@ class ExecutionPayload(Container): blob_gas_used: uint64 excess_blob_gas: uint64 deposit_receipts: List[DepositReceipt, MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD] # [New in Electra:EIP6110] + exits: List[ExecutionLayerExit, MAX_EXECUTION_LAYER_EXITS] # [New in Electra:EIP7002] ``` #### `ExecutionPayloadHeader` @@ -122,6 +137,7 @@ class ExecutionPayloadHeader(Container): blob_gas_used: uint64 excess_blob_gas: uint64 deposit_receipts_root: Root # [New in Electra:EIP6110] + exits_root: Root # [New in Electra:EIP7002] ``` #### `BeaconState` @@ -163,7 +179,7 @@ class BeaconState(Container): current_sync_committee: SyncCommittee next_sync_committee: SyncCommittee # Execution - latest_execution_payload_header: ExecutionPayloadHeader # [Modified in Electra:EIP6110] + latest_execution_payload_header: ExecutionPayloadHeader # [Modified in Electra:EIP6110:EIP7002] # Withdrawals next_withdrawal_index: WithdrawalIndex next_withdrawal_validator_index: ValidatorIndex @@ -190,7 +206,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: #### Modified `process_operations` -*Note*: The function `process_operations` is modified to process `DepositReceipt` operations included in the payload. +*Note*: The function `process_operations` is modified to process `DepositReceipt` and `ExecutionLayerExit` operations included in the payload. ```python def process_operations(state: BeaconState, body: BeaconBlockBody) -> None: @@ -211,6 +227,7 @@ def process_operations(state: BeaconState, body: BeaconBlockBody) -> None: for_ops(body.attestations, process_attestation) for_ops(body.deposits, process_deposit) for_ops(body.voluntary_exits, process_voluntary_exit) + for_ops(body.execution_payload.exits, process_execution_layer_exit) # [New in Electra:EIP7002] for_ops(body.bls_to_execution_changes, process_bls_to_execution_change) # [New in EIP6110] @@ -236,6 +253,35 @@ def process_deposit_receipt(state: BeaconState, deposit_receipt: DepositReceipt) ) ``` +#### New `process_execution_layer_exit` + +*Note*: This function is new in Electra:EIP7002. + +```python +def process_execution_layer_exit(state: BeaconState, execution_layer_exit: ExecutionLayerExit) -> None: + validator_pubkeys = [v.pubkey for v in state.validators] + validator_index = ValidatorIndex(validator_pubkeys.index(execution_layer_exit.validator_pubkey)) + validator = state.validators[validator_index] + + # Verify withdrawal credentials + is_execution_address = validator.withdrawal_credentials[:1] == ETH1_ADDRESS_WITHDRAWAL_PREFIX + is_correct_source_address = validator.withdrawal_credentials[12:] == execution_layer_exit.source_address + if not (is_execution_address and is_correct_source_address): + return + # Verify the validator is active + if not is_active_validator(validator, get_current_epoch(state)): + return + # Verify exit has not been initiated + if validator.exit_epoch != FAR_FUTURE_EPOCH: + return + # Verify the validator has been active long enough + if get_current_epoch(state) < validator.activation_epoch + SHARD_COMMITTEE_PERIOD: + return + + # Initiate exit + initiate_validator_exit(state, validator_index) +``` + #### Modified `process_execution_payload` *Note*: The function `process_execution_payload` is modified to use the new `ExecutionPayloadHeader` type. @@ -281,6 +327,7 @@ def process_execution_payload(state: BeaconState, body: BeaconBlockBody, executi blob_gas_used=payload.blob_gas_used, excess_blob_gas=payload.excess_blob_gas, deposit_receipts_root=hash_tree_root(payload.deposit_receipts), # [New in Electra:EIP6110] + exits_root=hash_tree_root(payload.exits), # [New in Electra:EIP7002] ) ``` diff --git a/specs/electra/fork.md b/specs/electra/fork.md index f93ef03dfe..ffc4a8d3c1 100644 --- a/specs/electra/fork.md +++ b/specs/electra/fork.md @@ -91,6 +91,7 @@ def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState: blob_gas_used=uint64(0), excess_blob_gas=uint64(0), deposit_receipts_root=Root(), # [New in Electra:EIP6110] + exits_root=Root(), # [New in Electra:EIP-7002], ) post = BeaconState( # Versioning @@ -132,7 +133,7 @@ def upgrade_to_electra(pre: deneb.BeaconState) -> BeaconState: current_sync_committee=pre.current_sync_committee, next_sync_committee=pre.next_sync_committee, # Execution-layer - latest_execution_payload_header=latest_execution_payload_header, # [Modified in Electra:EIP6110] + latest_execution_payload_header=latest_execution_payload_header, # [Modified in Electra:EIP6110:EIP7002] # Withdrawals next_withdrawal_index=pre.next_withdrawal_index, next_withdrawal_validator_index=pre.next_withdrawal_validator_index, diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index f80e1dc14a..e8568df20e 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -8,7 +8,9 @@ from .exceptions import SkippedTest from .helpers.constants import ( PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, - EIP7002, EIP7251, EIP7549, EIP7594, + EIP7251, + EIP7549, + EIP7594, WHISK, MINIMAL, ALL_PHASES, @@ -520,9 +522,8 @@ def wrapper(*args, spec: Spec, **kw): with_capella_and_later = with_all_phases_from(CAPELLA) with_deneb_and_later = with_all_phases_from(DENEB) with_electra_and_later = with_all_phases_from(ELECTRA) -with_eip7002_and_later = with_all_phases_from(EIP7002) -with_eip7549_and_later = with_all_phases_from(EIP7549) with_whisk_and_later = with_all_phases_from(WHISK, all_phases=ALLOWED_TEST_RUNNER_FORKS) +with_eip7549_and_later = with_all_phases_from(EIP7549) with_eip7594_and_later = with_all_phases_from(EIP7594, all_phases=ALLOWED_TEST_RUNNER_FORKS) with_eip7251_and_later = with_all_phases_from(EIP7251, all_phases=ALLOWED_TEST_RUNNER_FORKS) diff --git a/tests/core/pyspec/eth2spec/test/eip7002/block_processing/test_process_execution_layer_exit.py b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_execution_layer_exit.py similarity index 95% rename from tests/core/pyspec/eth2spec/test/eip7002/block_processing/test_process_execution_layer_exit.py rename to tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_execution_layer_exit.py index bd944a1fa3..841998c172 100644 --- a/tests/core/pyspec/eth2spec/test/eip7002/block_processing/test_process_execution_layer_exit.py +++ b/tests/core/pyspec/eth2spec/test/electra/block_processing/test_process_execution_layer_exit.py @@ -1,9 +1,9 @@ -from eth2spec.test.context import spec_state_test, with_eip7002_and_later +from eth2spec.test.context import spec_state_test, with_electra_and_later from eth2spec.test.helpers.execution_layer_exits import run_execution_layer_exit_processing from eth2spec.test.helpers.withdrawals import set_eth1_withdrawal_credential_with_balance -@with_eip7002_and_later +@with_electra_and_later @spec_state_test def test_basic_exit(spec, state): # move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit @@ -22,7 +22,7 @@ def test_basic_exit(spec, state): yield from run_execution_layer_exit_processing(spec, state, execution_layer_exit) -@with_eip7002_and_later +@with_electra_and_later @spec_state_test def test_incorrect_source_address(spec, state): # move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit @@ -42,7 +42,7 @@ def test_incorrect_source_address(spec, state): yield from run_execution_layer_exit_processing(spec, state, execution_layer_exit, success=False) -@with_eip7002_and_later +@with_electra_and_later @spec_state_test def test_incorrect_withdrawal_credential_prefix(spec, state): # move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit @@ -66,7 +66,7 @@ def test_incorrect_withdrawal_credential_prefix(spec, state): yield from run_execution_layer_exit_processing(spec, state, execution_layer_exit, success=False) -@with_eip7002_and_later +@with_electra_and_later @spec_state_test def test_on_exit_initiated_validator(spec, state): # move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit @@ -87,7 +87,7 @@ def test_on_exit_initiated_validator(spec, state): yield from run_execution_layer_exit_processing(spec, state, execution_layer_exit, success=False) -@with_eip7002_and_later +@with_electra_and_later @spec_state_test def test_activation_epoch_less_than_shard_committee_period(spec, state): current_epoch = spec.get_current_epoch(state) diff --git a/tests/core/pyspec/eth2spec/test/eip7002/sanity/test_blocks.py b/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_blocks.py similarity index 98% rename from tests/core/pyspec/eth2spec/test/eip7002/sanity/test_blocks.py rename to tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_blocks.py index 29a03fee01..fabe196ef7 100644 --- a/tests/core/pyspec/eth2spec/test/eip7002/sanity/test_blocks.py +++ b/tests/core/pyspec/eth2spec/test/electra/sanity/blocks/test_blocks.py @@ -3,7 +3,7 @@ ) from eth2spec.test.context import ( spec_state_test, - with_eip7002_and_later, + with_electra_and_later, ) from eth2spec.test.helpers.bls_to_execution_changes import ( get_signed_address_change, @@ -22,7 +22,7 @@ ) -@with_eip7002_and_later +@with_electra_and_later @spec_state_test def test_basic_el_exit(spec, state): # move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit @@ -51,7 +51,7 @@ def test_basic_el_exit(spec, state): assert state.validators[validator_index].exit_epoch < spec.FAR_FUTURE_EPOCH -@with_eip7002_and_later +@with_electra_and_later @spec_state_test def test_basic_btec_and_el_exit_in_same_block(spec, state): # move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit @@ -94,7 +94,7 @@ def test_basic_btec_and_el_exit_in_same_block(spec, state): assert is_execution_address and is_correct_source_address -@with_eip7002_and_later +@with_electra_and_later @spec_state_test def test_basic_btec_before_el_exit(spec, state): # move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit @@ -141,7 +141,7 @@ def test_basic_btec_before_el_exit(spec, state): assert state.validators[validator_index].exit_epoch < spec.FAR_FUTURE_EPOCH -@with_eip7002_and_later +@with_electra_and_later @spec_state_test def test_cl_exit_and_el_exit_in_same_block(spec, state): # move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit diff --git a/tests/core/pyspec/eth2spec/test/helpers/constants.py b/tests/core/pyspec/eth2spec/test/helpers/constants.py index f6577f93ab..f8e555afbd 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/constants.py +++ b/tests/core/pyspec/eth2spec/test/helpers/constants.py @@ -17,10 +17,9 @@ CUSTODY_GAME = SpecForkName('custody_game') DAS = SpecForkName('das') ELECTRA = SpecForkName('electra') -EIP7002 = SpecForkName('eip7002') -EIP7549 = SpecForkName('eip7549') WHISK = SpecForkName('whisk') EIP7251 = SpecForkName('eip7251') +EIP7549 = SpecForkName('eip7549') EIP7594 = SpecForkName('eip7594') # @@ -39,7 +38,6 @@ DENEB, ELECTRA, # Experimental patches - EIP7002, EIP7251, EIP7549, EIP7594, @@ -62,7 +60,6 @@ ELECTRA: DENEB, # Experimental patches WHISK: CAPELLA, - EIP7002: CAPELLA, EIP7549: DENEB, EIP7251: DENEB, EIP7594: DENEB, diff --git a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py index 0d1269dda7..629f424b39 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py +++ b/tests/core/pyspec/eth2spec/test/helpers/execution_payload.py @@ -8,7 +8,6 @@ is_post_capella, is_post_deneb, is_post_electra, - is_post_eip7002, ) @@ -36,7 +35,6 @@ def get_execution_payload_header(spec, execution_payload): payload_header.excess_blob_gas = execution_payload.excess_blob_gas if is_post_electra(spec): payload_header.deposit_receipts_root = spec.hash_tree_root(execution_payload.deposit_receipts) - if is_post_eip7002(spec): payload_header.exits_root = spec.hash_tree_root(execution_payload.exits) return payload_header @@ -109,7 +107,6 @@ def compute_el_header_block_hash(spec, # deposit_receipts_root assert deposit_receipts_trie_root is not None execution_payload_header_rlp.append((Binary(32, 32), deposit_receipts_trie_root)) - if is_post_eip7002(spec): # exits_trie_root execution_payload_header_rlp.append((Binary(32, 32), exits_trie_root)) @@ -184,7 +181,6 @@ def compute_el_block_hash(spec, payload): if is_post_electra(spec): deposit_receipts_encoded = [get_deposit_receipt_rlp(spec, receipt) for receipt in payload.deposit_receipts] deposit_receipts_trie_root = compute_trie_root_from_indexed_data(deposit_receipts_encoded) - if is_post_eip7002(spec): exits_encoded = [get_exit_rlp(exit) for exit in payload.exits] exits_trie_root = compute_trie_root_from_indexed_data(exits_encoded) diff --git a/tests/core/pyspec/eth2spec/test/helpers/forks.py b/tests/core/pyspec/eth2spec/test/helpers/forks.py index b1b6a168f7..238a39b8ca 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/forks.py +++ b/tests/core/pyspec/eth2spec/test/helpers/forks.py @@ -1,6 +1,6 @@ from .constants import ( PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, - ELECTRA, EIP7002, EIP7251, EIP7549, WHISK, + ELECTRA, WHISK, EIP7251, EIP7549, PREVIOUS_FORK_OF, ) @@ -41,10 +41,6 @@ def is_post_electra(spec): return is_post_fork(spec.fork, ELECTRA) -def is_post_eip7002(spec): - return is_post_fork(spec.fork, EIP7002) - - def is_post_eip7251(spec): return is_post_fork(spec.fork, EIP7251) diff --git a/tests/core/pyspec/eth2spec/test/helpers/genesis.py b/tests/core/pyspec/eth2spec/test/helpers/genesis.py index 248e47736b..cd43ca9f32 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/genesis.py +++ b/tests/core/pyspec/eth2spec/test/helpers/genesis.py @@ -6,7 +6,7 @@ compute_el_header_block_hash, ) from eth2spec.test.helpers.forks import ( - is_post_altair, is_post_bellatrix, is_post_capella, is_post_eip7002, is_post_whisk, is_post_eip7251 + is_post_altair, is_post_bellatrix, is_post_capella, is_post_electra, is_post_whisk, is_post_eip7251, ) from eth2spec.test.helpers.keys import pubkeys from eth2spec.test.helpers.whisk import compute_whisk_initial_tracker_cached, compute_whisk_initial_k_commitment_cached @@ -57,7 +57,6 @@ def get_sample_genesis_execution_payload_header(spec, withdrawals_trie_root = bytes.fromhex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") if is_post_electra(spec): deposit_receipts_trie_root = bytes.fromhex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") - if is_post_eip7002(spec): exits_trie_root = bytes.fromhex("56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421") payload_header.block_hash = compute_el_header_block_hash( From 07ed5176aedb1d1a286c6b4bf9bc1c01071cfdca Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Wed, 6 Mar 2024 14:26:59 +0800 Subject: [PATCH 04/11] update eip7002 operation tests to testgen --- tests/formats/operations/README.md | 1 + tests/generators/operations/main.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/formats/operations/README.md b/tests/formats/operations/README.md index 8e9841618a..b020b5fd03 100644 --- a/tests/formats/operations/README.md +++ b/tests/formats/operations/README.md @@ -46,6 +46,7 @@ Operations: | `withdrawals` | `ExecutionPayload` | `execution_payload` | `process_withdrawals(state, execution_payload)` (new in Capella) | | `bls_to_execution_change` | `SignedBLSToExecutionChange` | `address_change` | `process_bls_to_execution_change(state, address_change)` (new in Capella) | | `deposit_receipt` | `DepositReceipt` | `deposit_receipt` | `process_deposit_receipt(state, deposit_receipt)` (new in Electra) | +| `exits` | `ExecutionLayerExit` | `execution_layer_exit` | `process_execution_layer_exit(state, execution_layer_exit)` (new in Electra) | Note that `block_header` is not strictly an operation (and is a full `Block`), but processed in the same manner, and hence included here. diff --git a/tests/generators/operations/main.py b/tests/generators/operations/main.py index c31a72285b..0413eb2b23 100644 --- a/tests/generators/operations/main.py +++ b/tests/generators/operations/main.py @@ -45,6 +45,7 @@ _new_electra_mods = {key: 'eth2spec.test.electra.block_processing.test_process_' + key for key in [ 'deposit_receipt', + 'execution_layer_exit', ]} electra_mods = combine_mods(_new_electra_mods, deneb_mods) From 257b2ebe7a19b1371c174d28f9179af8d2493345 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Fri, 5 Apr 2024 06:13:45 +0800 Subject: [PATCH 05/11] Apply suggestions from code review Co-authored-by: Mikhail Kalinin --- presets/mainnet/electra.yaml | 2 +- specs/electra/beacon-chain.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/presets/mainnet/electra.yaml b/presets/mainnet/electra.yaml index badb4e95d6..d38c3e2e3b 100644 --- a/presets/mainnet/electra.yaml +++ b/presets/mainnet/electra.yaml @@ -1,4 +1,4 @@ -# Mainnet preset - ELECTRA +# Mainnet preset - Electra # Execution # --------------------------------------------------------------- diff --git a/specs/electra/beacon-chain.md b/specs/electra/beacon-chain.md index b41042c877..9c9066c3e2 100644 --- a/specs/electra/beacon-chain.md +++ b/specs/electra/beacon-chain.md @@ -200,7 +200,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: process_execution_payload(state, block.body, EXECUTION_ENGINE) # [Modified in Electra:EIP6110] process_randao(state, block.body) process_eth1_data(state, block.body) - process_operations(state, block.body) # [Modified in Electra:EIP6110] + process_operations(state, block.body) # [Modified in Electra:EIP6110:EIP7002] process_sync_aggregate(state, block.body.sync_aggregate) ``` From bba0e63ec4c3b50f011e777afeb271666accc481 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Fri, 5 Apr 2024 11:16:34 -0600 Subject: [PATCH 06/11] typo: electra fork summary --- specs/electra/fork.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/electra/fork.md b/specs/electra/fork.md index ffc4a8d3c1..17792e8d6c 100644 --- a/specs/electra/fork.md +++ b/specs/electra/fork.md @@ -20,7 +20,7 @@ ## Introduction -This document describes the process of EIP-6110 upgrade. +This document describes the process of the Electra upgrade. ## Configuration From 4287340401ad9f83c01cdae9150766f9433fcc5a Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Fri, 5 Apr 2024 11:17:53 -0600 Subject: [PATCH 07/11] typo: text of electra validator guide --- specs/electra/validator.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/specs/electra/validator.md b/specs/electra/validator.md index c572e93914..623041f524 100644 --- a/specs/electra/validator.md +++ b/specs/electra/validator.md @@ -30,7 +30,7 @@ Please see related Beacon Chain doc before continuing and use them as a referenc ### Deposits -*[New in Electra:EIP6110* The expected number of deposits MUST be changed from `min(MAX_DEPOSITS, eth1_data.deposit_count - state.eth1_deposit_index)` to the result of the following function: +*[New in Electra:EIP6110]* The expected number of deposits MUST be changed from `min(MAX_DEPOSITS, eth1_data.deposit_count - state.eth1_deposit_index)` to the result of the following function: ```python def get_eth1_pending_deposit_count(state: BeaconState) -> uint64: From e4068b53916105c1916f93aad8c7f3e8d939191a Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Fri, 5 Apr 2024 11:02:03 -0600 Subject: [PATCH 08/11] Merge EIP-7549 into Electra --- .circleci/config.yml | 16 -- .github/workflows/run-tests.yml | 2 +- .gitignore | 1 - Makefile | 2 +- configs/mainnet.yaml | 5 +- configs/minimal.yaml | 3 - presets/mainnet/eip7549.yaml | 8 - presets/mainnet/electra.yaml | 7 + presets/minimal/eip7549.yaml | 8 - presets/minimal/electra.yaml | 7 + pysetup/constants.py | 1 - pysetup/md_doc_paths.py | 2 - pysetup/spec_builders/__init__.py | 3 +- pysetup/spec_builders/eip7549.py | 11 -- specs/_features/eip7549/beacon-chain.md | 163 ------------------ specs/_features/eip7549/fork.md | 141 --------------- specs/_features/eip7549/validator.md | 74 -------- specs/electra/beacon-chain.md | 139 ++++++++++++++- .../eip7549 => electra}/p2p-interface.md | 33 ++-- specs/electra/validator.md | 60 ++++++- tests/core/pyspec/eth2spec/test/context.py | 2 - .../eth2spec/test/helpers/attestations.py | 18 +- .../test/helpers/attester_slashings.py | 6 +- .../pyspec/eth2spec/test/helpers/constants.py | 3 - .../pyspec/eth2spec/test/helpers/forks.py | 6 +- .../fork_choice/test_on_attestation.py | 4 +- 26 files changed, 247 insertions(+), 478 deletions(-) delete mode 100644 presets/mainnet/eip7549.yaml delete mode 100644 presets/minimal/eip7549.yaml delete mode 100644 pysetup/spec_builders/eip7549.py delete mode 100644 specs/_features/eip7549/beacon-chain.md delete mode 100644 specs/_features/eip7549/fork.md delete mode 100644 specs/_features/eip7549/validator.md rename specs/{_features/eip7549 => electra}/p2p-interface.md (60%) diff --git a/.circleci/config.yml b/.circleci/config.yml index 013619172d..bf8b7ada8a 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -168,19 +168,6 @@ jobs: command: make citest fork=electra - store_test_results: path: tests/core/pyspec/test-reports - test-eip7549: - docker: - - image: circleci/python:3.9 - working_directory: ~/specs-repo - steps: - - restore_cache: - key: v3-specs-repo-{{ .Branch }}-{{ .Revision }} - - restore_pyspec_cached_venv - - run: - name: Run py-tests - command: make citest fork=eip7549 - - store_test_results: - path: tests/core/pyspec/test-reports test-whisk: docker: - image: circleci/python:3.9 @@ -330,9 +317,6 @@ workflows: - test-electra: requires: - install_pyspec_test - - test-eip7549: - requires: - - install_pyspec_test - test-whisk: requires: - install_pyspec_test diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index b92fd60dd3..0e9126e392 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -71,7 +71,7 @@ jobs: needs: [preclear,lint,codespell,table_of_contents] strategy: matrix: - version: ["phase0", "altair", "bellatrix", "capella", "deneb", "electra", "whisk", "eip7549", "eip7594"] + version: ["phase0", "altair", "bellatrix", "capella", "deneb", "electra", "whisk", "eip7594"] steps: - name: Checkout this repo uses: actions/checkout@v3.2.0 diff --git a/.gitignore b/.gitignore index acfaae8718..91270239a0 100644 --- a/.gitignore +++ b/.gitignore @@ -24,7 +24,6 @@ tests/core/pyspec/eth2spec/deneb/ tests/core/pyspec/eth2spec/electra/ tests/core/pyspec/eth2spec/whisk/ tests/core/pyspec/eth2spec/eip7251/ -tests/core/pyspec/eth2spec/eip7549/ tests/core/pyspec/eth2spec/eip7594/ # coverage reports diff --git a/Makefile b/Makefile index 71d07aed79..1025a2a1ea 100644 --- a/Makefile +++ b/Makefile @@ -35,7 +35,7 @@ MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/*/*.md) \ $(wildcard $(SPEC_DIR)/_features/*/*/*.md) \ $(wildcard $(SSZ_DIR)/*.md) -ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra eip7549 whisk +ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb electra whisk # The parameters for commands. Use `foreach` to avoid listing specs again. COVERAGE_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), --cov=eth2spec.$S.$(TEST_PRESET_TYPE)) PYLINT_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), ./eth2spec/$S) diff --git a/configs/mainnet.yaml b/configs/mainnet.yaml index 7d89833d67..dd63b1ac82 100644 --- a/configs/mainnet.yaml +++ b/configs/mainnet.yaml @@ -51,14 +51,11 @@ CAPELLA_FORK_EPOCH: 194048 # April 12, 2023, 10:27:35pm UTC DENEB_FORK_VERSION: 0x04000000 DENEB_FORK_EPOCH: 269568 # March 13, 2024, 01:55:35pm UTC # Electra -ELECTRA_FORK_VERSION: 0x05000000 # temporary stub +ELECTRA_FORK_VERSION: 0x05000000 ELECTRA_FORK_EPOCH: 18446744073709551615 # EIP7251 EIP7251_FORK_VERSION: 0x06000000 # temporary stub EIP7251_FORK_EPOCH: 18446744073709551615 -# EIP7549 -EIP7549_FORK_VERSION: 0x06000000 # temporary stub -EIP7549_FORK_EPOCH: 18446744073709551615 # WHISK WHISK_FORK_VERSION: 0x08000000 # temporary stub WHISK_FORK_EPOCH: 18446744073709551615 diff --git a/configs/minimal.yaml b/configs/minimal.yaml index 7e0e444834..b819bd9559 100644 --- a/configs/minimal.yaml +++ b/configs/minimal.yaml @@ -55,9 +55,6 @@ ELECTRA_FORK_EPOCH: 18446744073709551615 # EIP7251 EIP7251_FORK_VERSION: 0x06000001 # temporary stub EIP7251_FORK_EPOCH: 18446744073709551615 -# EIP7549 -EIP7549_FORK_VERSION: 0x06000001 # temporary stub -EIP7549_FORK_EPOCH: 18446744073709551615 # WHISK WHISK_FORK_VERSION: 0x08000001 WHISK_FORK_EPOCH: 18446744073709551615 diff --git a/presets/mainnet/eip7549.yaml b/presets/mainnet/eip7549.yaml deleted file mode 100644 index 6d10f82e15..0000000000 --- a/presets/mainnet/eip7549.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# Mainnet preset - EIP7594 - -# # Max operations per block -# --------------------------------------------------------------- -# `uint64(2**0)` (= 1) -MAX_ATTESTER_SLASHINGS_EIP7549: 1 -# `uint64(2 * 3)` (= 8) -MAX_ATTESTATIONS_EIP7549: 8 diff --git a/presets/mainnet/electra.yaml b/presets/mainnet/electra.yaml index d38c3e2e3b..e206a65052 100644 --- a/presets/mainnet/electra.yaml +++ b/presets/mainnet/electra.yaml @@ -1,5 +1,12 @@ # Mainnet preset - Electra +# # Max operations per block +# --------------------------------------------------------------- +# `uint64(2**0)` (= 1) +MAX_ATTESTER_SLASHINGS_ELECTRA: 1 +# `uint64(2 * 3)` (= 8) +MAX_ATTESTATIONS_ELECTRA: 8 + # Execution # --------------------------------------------------------------- # 2**13 (= 8192) receipts diff --git a/presets/minimal/eip7549.yaml b/presets/minimal/eip7549.yaml deleted file mode 100644 index 17e21652a3..0000000000 --- a/presets/minimal/eip7549.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# Minimal preset - EIP7594 - -# # Max operations per block -# --------------------------------------------------------------- -# `uint64(2**0)` (= 1) -MAX_ATTESTER_SLASHINGS_EIP7549: 1 -# `uint64(2 * 3)` (= 8) -MAX_ATTESTATIONS_EIP7549: 8 diff --git a/presets/minimal/electra.yaml b/presets/minimal/electra.yaml index 5c359728b4..c7750a3cb9 100644 --- a/presets/minimal/electra.yaml +++ b/presets/minimal/electra.yaml @@ -1,5 +1,12 @@ # Minimal preset - Electra +# # Max operations per block +# --------------------------------------------------------------- +# `uint64(2**0)` (= 1) +MAX_ATTESTER_SLASHINGS_ELECTRA: 1 +# `uint64(2 * 3)` (= 8) +MAX_ATTESTATIONS_ELECTRA: 8 + # Execution # --------------------------------------------------------------- # [customized] diff --git a/pysetup/constants.py b/pysetup/constants.py index eb272d60ae..299f96132a 100644 --- a/pysetup/constants.py +++ b/pysetup/constants.py @@ -7,7 +7,6 @@ ELECTRA = 'electra' EIP7594 = 'eip7594' EIP7251 = 'eip7251' -EIP7549 = 'eip7549' WHISK = 'whisk' diff --git a/pysetup/md_doc_paths.py b/pysetup/md_doc_paths.py index 8c15fc719b..c7c9ebf047 100644 --- a/pysetup/md_doc_paths.py +++ b/pysetup/md_doc_paths.py @@ -10,7 +10,6 @@ WHISK, EIP7594, EIP7251, - EIP7549, ) @@ -23,7 +22,6 @@ ELECTRA: DENEB, WHISK: CAPELLA, EIP7251: DENEB, - EIP7549: DENEB, EIP7594: DENEB, } diff --git a/pysetup/spec_builders/__init__.py b/pysetup/spec_builders/__init__.py index cf8a49972d..63519f57f3 100644 --- a/pysetup/spec_builders/__init__.py +++ b/pysetup/spec_builders/__init__.py @@ -6,7 +6,6 @@ from .electra import ElectraSpecBuilder from .whisk import WhiskSpecBuilder from .eip7251 import EIP7251SpecBuilder -from .eip7549 import EIP7549SpecBuilder from .eip7594 import EIP7594SpecBuilder @@ -14,6 +13,6 @@ builder.fork: builder for builder in ( Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder, CapellaSpecBuilder, DenebSpecBuilder, - ElectraSpecBuilder, WhiskSpecBuilder, EIP7594SpecBuilder, EIP7549SpecBuilder, EIP7251SpecBuilder, + ElectraSpecBuilder, WhiskSpecBuilder, EIP7594SpecBuilder, EIP7251SpecBuilder, ) } diff --git a/pysetup/spec_builders/eip7549.py b/pysetup/spec_builders/eip7549.py deleted file mode 100644 index bd5dbbeaec..0000000000 --- a/pysetup/spec_builders/eip7549.py +++ /dev/null @@ -1,11 +0,0 @@ -from .base import BaseSpecBuilder -from ..constants import EIP7549 - - -class EIP7549SpecBuilder(BaseSpecBuilder): - fork: str = EIP7549 - - @classmethod - def imports(cls, preset_name: str): - return super().imports(preset_name) + f''' -''' diff --git a/specs/_features/eip7549/beacon-chain.md b/specs/_features/eip7549/beacon-chain.md deleted file mode 100644 index 9ee88e7def..0000000000 --- a/specs/_features/eip7549/beacon-chain.md +++ /dev/null @@ -1,163 +0,0 @@ -# EIP-7549 -- The Beacon Chain - -## Table of contents - - - - - -- [Introduction](#introduction) -- [Preset](#preset) -- [Containers](#containers) - - [Modified containers](#modified-containers) - - [`Attestation`](#attestation) - - [`IndexedAttestation`](#indexedattestation) - - [`BeaconBlockBody`](#beaconblockbody) -- [Helper functions](#helper-functions) - - [Misc](#misc) - - [`get_committee_indices`](#get_committee_indices) - - [Beacon state accessors](#beacon-state-accessors) - - [Modified `get_attesting_indices`](#modified-get_attesting_indices) - - [Block processing](#block-processing) - - [Modified `process_attestation`](#modified-process_attestation) - - - - -## Introduction - -This is the beacon chain specification to move the attestation committee index outside of the signed message. For motivation, refer to [EIP-7549](https://eips.ethereum.org/EIPS/eip-7549). - -*Note:* This specification is built upon [Deneb](../../deneb/beacon_chain.md) and is under active development. - -## Preset - -| Name | Value | Description | -| - | - | - | -| `MAX_ATTESTER_SLASHINGS_EIP7549` | `2**0` (= 1) | -| `MAX_ATTESTATIONS_EIP7549` | `2**3` (= 8) | - -## Containers - -### Modified containers - -#### `Attestation` - -```python -class Attestation(Container): - aggregation_bits: Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT] # [Modified in EIP7549] - data: AttestationData - committee_bits: Bitvector[MAX_COMMITTEES_PER_SLOT] # [New in EIP7549] - signature: BLSSignature -``` - -#### `IndexedAttestation` - -```python -class IndexedAttestation(Container): - # [Modified in EIP7549] - attesting_indices: List[ValidatorIndex, MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT] - data: AttestationData - signature: BLSSignature -``` - -#### `BeaconBlockBody` - -```python -class BeaconBlockBody(Container): - randao_reveal: BLSSignature - eth1_data: Eth1Data # Eth1 data vote - graffiti: Bytes32 # Arbitrary data - # Operations - proposer_slashings: List[ProposerSlashing, MAX_PROPOSER_SLASHINGS] - attester_slashings: List[AttesterSlashing, MAX_ATTESTER_SLASHINGS_EIP7549] # [Modified in EIP7549] - attestations: List[Attestation, MAX_ATTESTATIONS_EIP7549] # [Modified in EIP7549] - deposits: List[Deposit, MAX_DEPOSITS] - voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS] - sync_aggregate: SyncAggregate - # Execution - execution_payload: ExecutionPayload - bls_to_execution_changes: List[SignedBLSToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES] - blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK] -``` - -## Helper functions - -### Misc - -#### `get_committee_indices` - -```python -def get_committee_indices(commitee_bits: Bitvector) -> Sequence[CommitteeIndex]: - return [CommitteeIndex(index) for index, bit in enumerate(commitee_bits) if bit] -``` - -### Beacon state accessors - -#### Modified `get_attesting_indices` - -```python -def get_attesting_indices(state: BeaconState, attestation: Attestation) -> Set[ValidatorIndex]: - """ - Return the set of attesting indices corresponding to ``aggregation_bits`` and ``committee_bits``. - """ - output: Set[ValidatorIndex] = set() - committee_indices = get_committee_indices(attestation.committee_bits) - committee_offset = 0 - for index in committee_indices: - committee = get_beacon_committee(state, attestation.data.slot, index) - committee_attesters = set( - index for i, index in enumerate(committee) if attestation.aggregation_bits[committee_offset + i]) - output = output.union(committee_attesters) - - committee_offset += len(committee) - - return output -``` - -### Block processing - -#### Modified `process_attestation` - -```python -def process_attestation(state: BeaconState, attestation: Attestation) -> None: - data = attestation.data - assert data.target.epoch in (get_previous_epoch(state), get_current_epoch(state)) - assert data.target.epoch == compute_epoch_at_slot(data.slot) - assert data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot - - # [Modified in EIP7549] - assert data.index == 0 - committee_indices = get_committee_indices(attestation.committee_bits) - participants_count = 0 - for index in committee_indices: - assert index < get_committee_count_per_slot(state, data.target.epoch) - committee = get_beacon_committee(state, data.slot, index) - participants_count += len(committee) - - assert len(attestation.aggregation_bits) == participants_count - - # Participation flag indices - participation_flag_indices = get_attestation_participation_flag_indices(state, data, state.slot - data.slot) - - # Verify signature - assert is_valid_indexed_attestation(state, get_indexed_attestation(state, attestation)) - - # Update epoch participation flags - if data.target.epoch == get_current_epoch(state): - epoch_participation = state.current_epoch_participation - else: - epoch_participation = state.previous_epoch_participation - - proposer_reward_numerator = 0 - for index in get_attesting_indices(state, attestation): - for flag_index, weight in enumerate(PARTICIPATION_FLAG_WEIGHTS): - if flag_index in participation_flag_indices and not has_flag(epoch_participation[index], flag_index): - epoch_participation[index] = add_flag(epoch_participation[index], flag_index) - proposer_reward_numerator += get_base_reward(state, index) * weight - - # Reward proposer - proposer_reward_denominator = (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT) * WEIGHT_DENOMINATOR // PROPOSER_WEIGHT - proposer_reward = Gwei(proposer_reward_numerator // proposer_reward_denominator) - increase_balance(state, get_beacon_proposer_index(state), proposer_reward) -``` diff --git a/specs/_features/eip7549/fork.md b/specs/_features/eip7549/fork.md deleted file mode 100644 index 9294670db8..0000000000 --- a/specs/_features/eip7549/fork.md +++ /dev/null @@ -1,141 +0,0 @@ -# EIP-7549 -- Fork Logic - -**Notice**: This document is a work-in-progress for researchers and implementers. - -## Table of contents - - - - -- [Introduction](#introduction) -- [Configuration](#configuration) -- [Helper functions](#helper-functions) - - [Misc](#misc) - - [Modified `compute_fork_version`](#modified-compute_fork_version) -- [Fork to EIP-7549](#fork-to-eip-7549) - - [Fork trigger](#fork-trigger) - - [Upgrading the state](#upgrading-the-state) - - - -## Introduction - -This document describes the process of EIP-7549 upgrade. - -## Configuration - -Warning: this configuration is not definitive. - -| Name | Value | -| - | - | -| `EIP7549_FORK_VERSION` | `Version('0x06000000')` | -| `EIP7549_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** | - -## Helper functions - -### Misc - -#### Modified `compute_fork_version` - -```python -def compute_fork_version(epoch: Epoch) -> Version: - """ - Return the fork version at the given ``epoch``. - """ - if epoch >= EIP7549_FORK_EPOCH: - return EIP7549_FORK_VERSION - if epoch >= DENEB_FORK_EPOCH: - return DENEB_FORK_VERSION - if epoch >= CAPELLA_FORK_EPOCH: - return CAPELLA_FORK_VERSION - if epoch >= BELLATRIX_FORK_EPOCH: - return BELLATRIX_FORK_VERSION - if epoch >= ALTAIR_FORK_EPOCH: - return ALTAIR_FORK_VERSION - return GENESIS_FORK_VERSION -``` - -## Fork to EIP-7549 - -### Fork trigger - -TBD. This fork is defined for testing purposes, the EIP may be combined with other consensus-layer upgrade. -For now, we assume the condition will be triggered at epoch `EIP7549_FORK_EPOCH`. - -Note that for the pure EIP-7549 networks, we don't apply `upgrade_to_eip7549` since it starts with EIP-7549 version logic. - -### Upgrading the state - -If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == EIP7549_FORK_EPOCH`, -an irregular state change is made to upgrade to EIP-7549. - -```python -def upgrade_to_eip7549(pre: capella.BeaconState) -> BeaconState: - epoch = capella.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=pre.latest_execution_payload_header.withdrawals_root, - ) - post = BeaconState( - # Versioning - genesis_time=pre.genesis_time, - genesis_validators_root=pre.genesis_validators_root, - slot=pre.slot, - fork=Fork( - previous_version=pre.fork.current_version, - current_version=EIP7549_FORK_VERSION, # [Modified in EIP-7549] - epoch=epoch, - ), - # History - latest_block_header=pre.latest_block_header, - block_roots=pre.block_roots, - state_roots=pre.state_roots, - historical_roots=pre.historical_roots, - # Eth1 - eth1_data=pre.eth1_data, - eth1_data_votes=pre.eth1_data_votes, - eth1_deposit_index=pre.eth1_deposit_index, - # Registry - validators=pre.validators, - balances=pre.balances, - # Randomness - randao_mixes=pre.randao_mixes, - # Slashings - slashings=pre.slashings, - # Participation - previous_epoch_participation=pre.previous_epoch_participation, - current_epoch_participation=pre.current_epoch_participation, - # Finality - justification_bits=pre.justification_bits, - previous_justified_checkpoint=pre.previous_justified_checkpoint, - current_justified_checkpoint=pre.current_justified_checkpoint, - finalized_checkpoint=pre.finalized_checkpoint, - # Inactivity - inactivity_scores=pre.inactivity_scores, - # Sync - current_sync_committee=pre.current_sync_committee, - next_sync_committee=pre.next_sync_committee, - # Execution-layer - latest_execution_payload_header=latest_execution_payload_header, - # Withdrawals - next_withdrawal_index=pre.next_withdrawal_index, - next_withdrawal_validator_index=pre.next_withdrawal_validator_index, - # Deep history valid from Capella onwards - historical_summaries=pre.historical_summaries, - ) - - return post -``` diff --git a/specs/_features/eip7549/validator.md b/specs/_features/eip7549/validator.md deleted file mode 100644 index d904e23f92..0000000000 --- a/specs/_features/eip7549/validator.md +++ /dev/null @@ -1,74 +0,0 @@ -# Deneb -- Honest Validator - -## Table of contents - - - - - -- [Modifications in EIP-7549](#modifications-in-eip-7549) - - [Block proposal](#block-proposal) - - [Constructing the `BeaconBlockBody`](#constructing-the-beaconblockbody) - - [Attester slashings](#attester-slashings) - - [Attestations](#attestations) - - [Attesting](#attesting) - - [Construct attestation](#construct-attestation) - - [Attestation aggregation](#attestation-aggregation) - - [Construct aggregate](#construct-aggregate) - - - - -## Modifications in EIP-7549 - -### Block proposal - -#### Constructing the `BeaconBlockBody` - -##### Attester slashings - -Changed the max attestations size to `MAX_ATTESTER_SLASHINGS_EIP7549`. - -##### Attestations - -The network attestation aggregates contain only the assigned committee attestations. -Attestation aggregates received by the block proposer from the committee aggregators with disjoint `committee_bits` sets and equal `AttestationData` SHOULD be consolidated into a single `Attestation` object. -The proposer should run the following function to construct an on chain final aggregate form a list of network aggregates with equal `AttestationData`: - -```python -def compute_on_chain_aggregate(network_aggregates: Sequence[Attestation]) -> Attestation: - aggregates = sorted(network_aggregates, key=lambda a: get_committee_indices(a.committee_bits)[0]) - - data = aggregates[0].data - aggregation_bits = Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]() - for a in aggregates: - for b in a.aggregation_bits: - aggregation_bits.append(b) - - signature = bls.Aggregate([a.signature for a in aggregates]) - - committee_indices = [get_committee_indices(a.committee_bits)[0] for a in aggregates] - committee_flags = [(index in committee_indices) for index in range(0, MAX_COMMITTEES_PER_SLOT)] - committee_bits = Bitvector[MAX_COMMITTEES_PER_SLOT](committee_flags) - - return Attestation(aggregation_bits, data, committee_bits, signature) -``` - -### Attesting - -#### Construct attestation - -- Set `attestation_data.index = 0`. -- Let `attestation.aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]` of length `len(committee)`, where the bit of the index of the validator in the `committee` is set to `0b1`. -- Let `attestation.committee_bits` be a `Bitvector[MAX_COMMITTEES_PER_SLOT]`, where the bit at the index associated with the validator's committee is set to `0b1`. - -*Note*: Calling `get_attesting_indices(state, attestation)` should return a list of length equal to 1, containing `validator_index`. - -### Attestation aggregation - -#### Construct aggregate - -- Set `attestation_data.index = 0`. -- Let `aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]` of length `len(committee)`, where each bit set from each individual attestation is set to `0b1`. -- Set `attestation.committee_bits = committee_bits`, where `committee_bits` has the same value as in each individual attestation. - diff --git a/specs/electra/beacon-chain.md b/specs/electra/beacon-chain.md index 9c9066c3e2..ea33ff5341 100644 --- a/specs/electra/beacon-chain.md +++ b/specs/electra/beacon-chain.md @@ -18,12 +18,21 @@ - [`DepositReceipt`](#depositreceipt) - [`ExecutionLayerExit`](#executionlayerexit) - [Extended Containers](#extended-containers) + - [`Attestation`](#attestation) + - [`IndexedAttestation`](#indexedattestation) + - [`BeaconBlockBody`](#beaconblockbody) - [`ExecutionPayload`](#executionpayload) - [`ExecutionPayloadHeader`](#executionpayloadheader) - [`BeaconState`](#beaconstate) +- [Helper functions](#helper-functions) + - [Misc](#misc-1) + - [`get_committee_indices`](#get_committee_indices) + - [Beacon state accessors](#beacon-state-accessors) + - [Modified `get_attesting_indices`](#modified-get_attesting_indices) - [Beacon chain state transition function](#beacon-chain-state-transition-function) - [Block processing](#block-processing) - [Modified `process_operations`](#modified-process_operations) + - [Modified `process_attestation`](#modified-process_attestation) - [New `process_deposit_receipt`](#new-process_deposit_receipt) - [New `process_execution_layer_exit`](#new-process_execution_layer_exit) - [Modified `process_execution_payload`](#modified-process_execution_payload) @@ -37,6 +46,9 @@ Electra is a consensus-layer upgrade containing a number of features. Including: * [EIP-6110](https://eips.ethereum.org/EIPS/eip-6110): Supply validator deposits on chain * [EIP-7002](https://eips.ethereum.org/EIPS/eip-7002): Execution layer triggerable exits +* [EIP-7549](https://eips.ethereum.org/EIPS/eip-7549): Move committee index outside Attestation + +*Note:* This specification is built upon [Deneb](../../deneb/beacon_chain.md) and is under active development. ## Constants @@ -56,6 +68,8 @@ The following values are (non-configurable) constants used throughout the specif | - | - | - | | `MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD` | `uint64(2**13)` (= 8,192) | *[New in Electra:EIP6110]* Maximum number of deposit receipts allowed in each payload | | `MAX_EXECUTION_LAYER_EXITS` | `2**4` (= 16) | *[New in Electra:EIP7002]* | +| `MAX_ATTESTER_SLASHINGS_ELECTRA` | `2**0` (= 1) | *[New in Electra:EIP7549]* | +| `MAX_ATTESTATIONS_ELECTRA` | `2**3` (= 8) | *[New in Electra:EIP7549]* | ## Containers @@ -86,6 +100,46 @@ class ExecutionLayerExit(Container): ### Extended Containers +#### `Attestation` + +```python +class Attestation(Container): + aggregation_bits: Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT] # [Modified in Electra:EIP7549] + data: AttestationData + committee_bits: Bitvector[MAX_COMMITTEES_PER_SLOT] # [New in Electra:EIP7549] + signature: BLSSignature +``` + +#### `IndexedAttestation` + +```python +class IndexedAttestation(Container): + # [Modified in Electra:EIP7549] + attesting_indices: List[ValidatorIndex, MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT] + data: AttestationData + signature: BLSSignature +``` + +#### `BeaconBlockBody` + +```python +class BeaconBlockBody(Container): + randao_reveal: BLSSignature + eth1_data: Eth1Data # Eth1 data vote + graffiti: Bytes32 # Arbitrary data + # Operations + proposer_slashings: List[ProposerSlashing, MAX_PROPOSER_SLASHINGS] + attester_slashings: List[AttesterSlashing, MAX_ATTESTER_SLASHINGS_ELECTRA] # [Modified in Electra:EIP7549] + attestations: List[Attestation, MAX_ATTESTATIONS_ELECTRA] # [Modified in Electra:EIP7549] + deposits: List[Deposit, MAX_DEPOSITS] + voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS] + sync_aggregate: SyncAggregate + # Execution + execution_payload: ExecutionPayload # [Modified in Electra:EIP6110:EIP7002] + bls_to_execution_changes: List[SignedBLSToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES] + blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK] +``` + #### `ExecutionPayload` ```python @@ -189,6 +243,40 @@ class BeaconState(Container): deposit_receipts_start_index: uint64 ``` +## Helper functions + +### Misc + +#### `get_committee_indices` + +```python +def get_committee_indices(commitee_bits: Bitvector) -> Sequence[CommitteeIndex]: + return [CommitteeIndex(index) for index, bit in enumerate(commitee_bits) if bit] +``` + +### Beacon state accessors + +#### Modified `get_attesting_indices` + +```python +def get_attesting_indices(state: BeaconState, attestation: Attestation) -> Set[ValidatorIndex]: + """ + Return the set of attesting indices corresponding to ``aggregation_bits`` and ``committee_bits``. + """ + output: Set[ValidatorIndex] = set() + committee_indices = get_committee_indices(attestation.committee_bits) + committee_offset = 0 + for index in committee_indices: + committee = get_beacon_committee(state, attestation.data.slot, index) + committee_attesters = set( + index for i, index in enumerate(committee) if attestation.aggregation_bits[committee_offset + i]) + output = output.union(committee_attesters) + + committee_offset += len(committee) + + return output +``` + ## Beacon chain state transition function ### Block processing @@ -200,13 +288,13 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None: process_execution_payload(state, block.body, EXECUTION_ENGINE) # [Modified in Electra:EIP6110] process_randao(state, block.body) process_eth1_data(state, block.body) - process_operations(state, block.body) # [Modified in Electra:EIP6110:EIP7002] + process_operations(state, block.body) # [Modified in Electra:EIP6110:EIP7002:EIP7549] process_sync_aggregate(state, block.body.sync_aggregate) ``` #### Modified `process_operations` -*Note*: The function `process_operations` is modified to process `DepositReceipt` and `ExecutionLayerExit` operations included in the payload. +*Note*: The function `process_operations` is modified to process `DepositReceipt` and `ExecutionLayerExit` operations included in the payload, along with the new attestation format. ```python def process_operations(state: BeaconState, body: BeaconBlockBody) -> None: @@ -224,7 +312,7 @@ def process_operations(state: BeaconState, body: BeaconBlockBody) -> None: for_ops(body.proposer_slashings, process_proposer_slashing) for_ops(body.attester_slashings, process_attester_slashing) - for_ops(body.attestations, process_attestation) + for_ops(body.attestations, process_attestation) # [Modified in Electra:EIP7549] for_ops(body.deposits, process_deposit) for_ops(body.voluntary_exits, process_voluntary_exit) for_ops(body.execution_payload.exits, process_execution_layer_exit) # [New in Electra:EIP7002] @@ -234,6 +322,51 @@ def process_operations(state: BeaconState, body: BeaconBlockBody) -> None: for_ops(body.execution_payload.deposit_receipts, process_deposit_receipt) ``` +#### Modified `process_attestation` + +```python +def process_attestation(state: BeaconState, attestation: Attestation) -> None: + data = attestation.data + assert data.target.epoch in (get_previous_epoch(state), get_current_epoch(state)) + assert data.target.epoch == compute_epoch_at_slot(data.slot) + assert data.slot + MIN_ATTESTATION_INCLUSION_DELAY <= state.slot + + # [Modified in Electra:EIP7549] + assert data.index == 0 + committee_indices = get_committee_indices(attestation.committee_bits) + participants_count = 0 + for index in committee_indices: + assert index < get_committee_count_per_slot(state, data.target.epoch) + committee = get_beacon_committee(state, data.slot, index) + participants_count += len(committee) + + assert len(attestation.aggregation_bits) == participants_count + + # Participation flag indices + participation_flag_indices = get_attestation_participation_flag_indices(state, data, state.slot - data.slot) + + # Verify signature + assert is_valid_indexed_attestation(state, get_indexed_attestation(state, attestation)) + + # Update epoch participation flags + if data.target.epoch == get_current_epoch(state): + epoch_participation = state.current_epoch_participation + else: + epoch_participation = state.previous_epoch_participation + + proposer_reward_numerator = 0 + for index in get_attesting_indices(state, attestation): + for flag_index, weight in enumerate(PARTICIPATION_FLAG_WEIGHTS): + if flag_index in participation_flag_indices and not has_flag(epoch_participation[index], flag_index): + epoch_participation[index] = add_flag(epoch_participation[index], flag_index) + proposer_reward_numerator += get_base_reward(state, index) * weight + + # Reward proposer + proposer_reward_denominator = (WEIGHT_DENOMINATOR - PROPOSER_WEIGHT) * WEIGHT_DENOMINATOR // PROPOSER_WEIGHT + proposer_reward = Gwei(proposer_reward_numerator // proposer_reward_denominator) + increase_balance(state, get_beacon_proposer_index(state), proposer_reward) +``` + #### New `process_deposit_receipt` *Note*: This function is new in Electra:EIP6110. diff --git a/specs/_features/eip7549/p2p-interface.md b/specs/electra/p2p-interface.md similarity index 60% rename from specs/_features/eip7549/p2p-interface.md rename to specs/electra/p2p-interface.md index 20aa291b3f..ebdcaaa831 100644 --- a/specs/_features/eip7549/p2p-interface.md +++ b/specs/electra/p2p-interface.md @@ -1,6 +1,6 @@ -# EIP-7549 -- Networking +# Electra -- Networking -This document contains the consensus-layer networking specification for EIP-7549. +This document contains the consensus-layer networking specification for Electra. The specification of these changes continues in the same format as the network specifications of previous upgrades, and assumes them as pre-requisite. @@ -10,29 +10,37 @@ The specification of these changes continues in the same format as the network s -- [Modifications in EIP-7549](#modifications-in-eip-7549) +- [Modifications in Electra](#modifications-in-electra) - [The gossip domain: gossipsub](#the-gossip-domain-gossipsub) - [Topics and messages](#topics-and-messages) - - [Global topics](#global-topics) - - [`beacon_aggregate_and_proof`](#beacon_aggregate_and_proof) - - [`beacon_attestation_{subnet_id}`](#beacon_attestation_subnet_id) + - [Global topics](#global-topics) + - [`beacon_aggregate_and_proof`](#beacon_aggregate_and_proof) + - [`beacon_attestation_{subnet_id}`](#beacon_attestation_subnet_id) -## Modifications in EIP-7549 +## Modifications in Electra ### The gossip domain: gossipsub +Some gossip meshes are upgraded in the fork of Electra to support upgraded types. + #### Topics and messages -The `beacon_aggregate_and_proof` and `beacon_attestation_{subnet_id}` topics are modified to support the gossip of a new attestation type. +Topics follow the same specification as in prior upgrades. + +The `beacon_block` topic is modified to also support Electra blocks. + +The `beacon_aggregate_and_proof` and `beacon_attestation_{subnet_id}` topics are modified to support the gossip of the new attestation type. -##### Global topics +The specification around the creation, validation, and dissemination of messages has not changed from the Capella document unless explicitly noted here. -###### `beacon_aggregate_and_proof` +The derivation of the `message-id` remains stable. -*[Modified in EIP7549]* +#### Global topics + +##### `beacon_aggregate_and_proof` The following convenience variables are re-defined - `index = get_committee_indices(aggregate.committee_bits)[0]` @@ -41,7 +49,7 @@ The following validations are added: * [REJECT] `len(committee_indices) == 1`, where `committee_indices = get_committee_indices(aggregate)`. * [REJECT] `aggregate.data.index == 0` -###### `beacon_attestation_{subnet_id}` +##### `beacon_attestation_{subnet_id}` The following convenience variables are re-defined - `index = get_committee_indices(attestation.committee_bits)[0]` @@ -49,4 +57,3 @@ The following convenience variables are re-defined The following validations are added: * [REJECT] `len(committee_indices) == 1`, where `committee_indices = get_committee_indices(attestation)`. * [REJECT] `attestation.data.index == 0` - diff --git a/specs/electra/validator.md b/specs/electra/validator.md index 623041f524..cc118bfb66 100644 --- a/specs/electra/validator.md +++ b/specs/electra/validator.md @@ -9,7 +9,14 @@ - [Introduction](#introduction) - [Prerequisites](#prerequisites) - [Block proposal](#block-proposal) - - [Deposits](#deposits) + - [Constructing the `BeaconBlockBody`](#constructing-the-beaconblockbody) + - [Attester slashings](#attester-slashings) + - [Attestations](#attestations) + - [Deposits](#deposits) +- [Attesting](#attesting) + - [Construct attestation](#construct-attestation) +- [Attestation aggregation](#attestation-aggregation) + - [Construct aggregate](#construct-aggregate) @@ -28,7 +35,38 @@ Please see related Beacon Chain doc before continuing and use them as a referenc ## Block proposal -### Deposits +### Constructing the `BeaconBlockBody` + +#### Attester slashings + +Changed the max attestations size to `MAX_ATTESTER_SLASHINGS_ELECTRA`. + +#### Attestations + +The network attestation aggregates contain only the assigned committee attestations. +Attestation aggregates received by the block proposer from the committee aggregators with disjoint `committee_bits` sets and equal `AttestationData` SHOULD be consolidated into a single `Attestation` object. +The proposer should run the following function to construct an on chain final aggregate form a list of network aggregates with equal `AttestationData`: + +```python +def compute_on_chain_aggregate(network_aggregates: Sequence[Attestation]) -> Attestation: + aggregates = sorted(network_aggregates, key=lambda a: get_committee_indices(a.committee_bits)[0]) + + data = aggregates[0].data + aggregation_bits = Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]() + for a in aggregates: + for b in a.aggregation_bits: + aggregation_bits.append(b) + + signature = bls.Aggregate([a.signature for a in aggregates]) + + committee_indices = [get_committee_indices(a.committee_bits)[0] for a in aggregates] + committee_flags = [(index in committee_indices) for index in range(0, MAX_COMMITTEES_PER_SLOT)] + committee_bits = Bitvector[MAX_COMMITTEES_PER_SLOT](committee_flags) + + return Attestation(aggregation_bits, data, committee_bits, signature) +``` + +#### Deposits *[New in Electra:EIP6110]* The expected number of deposits MUST be changed from `min(MAX_DEPOSITS, eth1_data.deposit_count - state.eth1_deposit_index)` to the result of the following function: @@ -40,3 +78,21 @@ def get_eth1_pending_deposit_count(state: BeaconState) -> uint64: else: return uint64(0) ``` + +## Attesting + +### Construct attestation + +- Set `attestation_data.index = 0`. +- Let `attestation.aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]` of length `len(committee)`, where the bit of the index of the validator in the `committee` is set to `0b1`. +- Let `attestation.committee_bits` be a `Bitvector[MAX_COMMITTEES_PER_SLOT]`, where the bit at the index associated with the validator's committee is set to `0b1`. + +*Note*: Calling `get_attesting_indices(state, attestation)` should return a list of length equal to 1, containing `validator_index`. + +## Attestation aggregation + +### Construct aggregate + +- Set `attestation_data.index = 0`. +- Let `aggregation_bits` be a `Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]` of length `len(committee)`, where each bit set from each individual attestation is set to `0b1`. +- Set `attestation.committee_bits = committee_bits`, where `committee_bits` has the same value as in each individual attestation. diff --git a/tests/core/pyspec/eth2spec/test/context.py b/tests/core/pyspec/eth2spec/test/context.py index e8568df20e..064bdea5c8 100644 --- a/tests/core/pyspec/eth2spec/test/context.py +++ b/tests/core/pyspec/eth2spec/test/context.py @@ -9,7 +9,6 @@ from .helpers.constants import ( PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, EIP7251, - EIP7549, EIP7594, WHISK, MINIMAL, @@ -523,7 +522,6 @@ def wrapper(*args, spec: Spec, **kw): with_deneb_and_later = with_all_phases_from(DENEB) with_electra_and_later = with_all_phases_from(ELECTRA) with_whisk_and_later = with_all_phases_from(WHISK, all_phases=ALLOWED_TEST_RUNNER_FORKS) -with_eip7549_and_later = with_all_phases_from(EIP7549) with_eip7594_and_later = with_all_phases_from(EIP7594, all_phases=ALLOWED_TEST_RUNNER_FORKS) with_eip7251_and_later = with_all_phases_from(EIP7251, all_phases=ALLOWED_TEST_RUNNER_FORKS) diff --git a/tests/core/pyspec/eth2spec/test/helpers/attestations.py b/tests/core/pyspec/eth2spec/test/helpers/attestations.py index 916a7ca00d..68dd884709 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/attestations.py +++ b/tests/core/pyspec/eth2spec/test/helpers/attestations.py @@ -5,7 +5,7 @@ from eth2spec.test.context import expect_assertion_error from eth2spec.test.helpers.state import state_transition_and_sign_block, next_epoch, next_slot from eth2spec.test.helpers.block import build_empty_block_for_next_slot -from eth2spec.test.helpers.forks import is_post_altair, is_post_deneb, is_post_eip7549 +from eth2spec.test.helpers.forks import is_post_altair, is_post_deneb, is_post_electra from eth2spec.test.helpers.keys import privkeys from eth2spec.utils import bls from eth2spec.utils.ssz.ssz_typing import Bitlist @@ -78,7 +78,7 @@ def build_attestation_data(spec, state, slot, index, beacon_block_root=None, sha data = spec.AttestationData( slot=slot, - index=0 if is_post_eip7549(spec) else index, + index=0 if is_post_electra(spec) else index, beacon_block_root=beacon_block_root, source=spec.Checkpoint(epoch=source_epoch, root=source_root), target=spec.Checkpoint(epoch=spec.compute_epoch_at_slot(slot), root=epoch_boundary_root), @@ -174,7 +174,7 @@ def fill_aggregate_attestation(spec, state, attestation, committee_index, signed participants = filter_participant_set(participants) # initialize `aggregation_bits` - if is_post_eip7549(spec): + if is_post_electra(spec): attestation.committee_bits[committee_index] = True attestation.aggregation_bits = get_empty_eip7549_aggregation_bits( spec, state, attestation.committee_bits, attestation.data.slot) @@ -184,7 +184,7 @@ def fill_aggregate_attestation(spec, state, attestation, committee_index, signed # fill in the `aggregation_bits` for i in range(len(beacon_committee)): - if is_post_eip7549(spec): + if is_post_electra(spec): offset = get_eip7549_aggregation_bits_offset( spec, state, attestation.data.slot, attestation.committee_bits, committee_index) aggregation_bits_index = offset + i @@ -272,10 +272,10 @@ def _aggregate_aggregation_bits_and_signatures(spec, state, slot, aggregate, att def get_valid_attestation_at_slot(state, spec, slot_to_attest, participation_fn=None, beacon_block_root=None): """ - Return the aggregate attestation post EIP-7549. + Return the aggregate attestation post Electra. Note: this EIP supports dense packing of on-chain aggregates so we can just return a single `Attestation`. """ - assert is_post_eip7549(spec) + assert is_post_electra(spec) attestations = list(get_valid_attestations_at_slot( state, spec, slot_to_attest, participation_fn=participation_fn, @@ -322,7 +322,7 @@ def next_slots_with_attestations(spec, def _add_valid_attestations(spec, state, block, slot_to_attest, participation_fn=None): - if is_post_eip7549(spec): + if is_post_electra(spec): attestation = get_valid_attestation_at_slot( state, spec, @@ -482,8 +482,8 @@ def cached_prepare_state_with_attestations(spec, state): def get_max_attestations(spec): - if is_post_eip7549(spec): - return spec.MAX_ATTESTATIONS_EIP7549 + if is_post_electra(spec): + return spec.MAX_ATTESTATIONS_ELECTRA else: return spec.MAX_ATTESTATIONS diff --git a/tests/core/pyspec/eth2spec/test/helpers/attester_slashings.py b/tests/core/pyspec/eth2spec/test/helpers/attester_slashings.py index bdda3bf766..c16096565e 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/attester_slashings.py +++ b/tests/core/pyspec/eth2spec/test/helpers/attester_slashings.py @@ -1,5 +1,5 @@ from eth2spec.test.helpers.attestations import get_valid_attestation, sign_attestation, sign_indexed_attestation -from eth2spec.test.helpers.forks import is_post_eip7549 +from eth2spec.test.helpers.forks import is_post_electra def get_valid_attester_slashing(spec, state, slot=None, signed_1=False, signed_2=False, filter_participant_set=None): @@ -66,7 +66,7 @@ def get_attestation_2_data(spec, att_slashing): def get_max_attester_slashings(spec): - if is_post_eip7549(spec): - return spec.MAX_ATTESTER_SLASHINGS_EIP7549 + if is_post_electra(spec): + return spec.MAX_ATTESTER_SLASHINGS_ELECTRA else: return spec.MAX_ATTESTER_SLASHINGS diff --git a/tests/core/pyspec/eth2spec/test/helpers/constants.py b/tests/core/pyspec/eth2spec/test/helpers/constants.py index f8e555afbd..d5ba2f5c1b 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/constants.py +++ b/tests/core/pyspec/eth2spec/test/helpers/constants.py @@ -19,7 +19,6 @@ ELECTRA = SpecForkName('electra') WHISK = SpecForkName('whisk') EIP7251 = SpecForkName('eip7251') -EIP7549 = SpecForkName('eip7549') EIP7594 = SpecForkName('eip7594') # @@ -39,7 +38,6 @@ ELECTRA, # Experimental patches EIP7251, - EIP7549, EIP7594, ) # The forks that have light client specs @@ -60,7 +58,6 @@ ELECTRA: DENEB, # Experimental patches WHISK: CAPELLA, - EIP7549: DENEB, EIP7251: DENEB, EIP7594: DENEB, } diff --git a/tests/core/pyspec/eth2spec/test/helpers/forks.py b/tests/core/pyspec/eth2spec/test/helpers/forks.py index 238a39b8ca..c288b3e6ed 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/forks.py +++ b/tests/core/pyspec/eth2spec/test/helpers/forks.py @@ -1,6 +1,6 @@ from .constants import ( PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB, - ELECTRA, WHISK, EIP7251, EIP7549, + ELECTRA, WHISK, EIP7251, PREVIOUS_FORK_OF, ) @@ -45,10 +45,6 @@ def is_post_eip7251(spec): return is_post_fork(spec.fork, EIP7251) -def is_post_eip7549(spec): - return is_post_fork(spec.fork, EIP7549) - - def is_post_whisk(spec): return is_post_fork(spec.fork, WHISK) diff --git a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py index 128c6bd704..e3ec931b32 100644 --- a/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py +++ b/tests/core/pyspec/eth2spec/test/phase0/unittests/fork_choice/test_on_attestation.py @@ -2,7 +2,7 @@ from eth2spec.test.helpers.block import build_empty_block_for_next_slot from eth2spec.test.helpers.attestations import get_valid_attestation, sign_attestation from eth2spec.test.helpers.constants import ALL_PHASES -from eth2spec.test.helpers.forks import is_post_eip7549 +from eth2spec.test.helpers.forks import is_post_electra from eth2spec.test.helpers.state import transition_to, state_transition_and_sign_block, next_epoch, next_slot from eth2spec.test.helpers.fork_choice import get_genesis_forkchoice_store @@ -326,7 +326,7 @@ def test_on_attestation_invalid_attestation(spec, state): attestation = get_valid_attestation(spec, state, slot=block.slot, signed=True) # make invalid by using an invalid committee index - if is_post_eip7549(spec): + if is_post_electra(spec): attestation.committee_bits = spec.Bitvector[spec.MAX_COMMITTEES_PER_SLOT]() else: attestation.data.index = spec.MAX_COMMITTEES_PER_SLOT * spec.SLOTS_PER_EPOCH From a626a798501f732068fb5e841cca51d4635f6cd4 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Fri, 5 Apr 2024 14:08:39 -0600 Subject: [PATCH 09/11] bugfix: use right test tool to construct Electra `AttesterSlashing` from Deneb attestations --- .../pyspec/eth2spec/test/helpers/fork_transition.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py b/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py index 078b9779f8..14c593d321 100644 --- a/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py +++ b/tests/core/pyspec/eth2spec/test/helpers/fork_transition.py @@ -17,6 +17,7 @@ PHASE0, POST_FORK_OF, PREVIOUS_FORK_OF, + DENEB, ) from eth2spec.test.helpers.deposits import ( prepare_state_and_deposit, @@ -296,8 +297,15 @@ def run_transition_with_operation(state, operation_dict = {'proposer_slashings': [proposer_slashing]} else: # operation_type == OperationType.ATTESTER_SLASHING: + if is_at_fork and spec.fork == DENEB: + # NOTE: attestation format changes between Deneb and Electra + # so attester slashing must be made with the `post_spec` + target_spec = post_spec + else: + target_spec = spec + attester_slashing = get_valid_attester_slashing_by_indices( - spec, state, + target_spec, state, [selected_validator_index], signed_1=True, signed_2=True, ) From d35b4091fb34339517ae5c7bce9a786298954b79 Mon Sep 17 00:00:00 2001 From: Alex Stokes Date: Fri, 5 Apr 2024 14:30:32 -0600 Subject: [PATCH 10/11] bugfix: make correct attestation type across fork boundary --- .../eth2spec/test/deneb/transition/test_operations.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/core/pyspec/eth2spec/test/deneb/transition/test_operations.py b/tests/core/pyspec/eth2spec/test/deneb/transition/test_operations.py index 27c27c8c6d..67ae50129b 100644 --- a/tests/core/pyspec/eth2spec/test/deneb/transition/test_operations.py +++ b/tests/core/pyspec/eth2spec/test/deneb/transition/test_operations.py @@ -11,6 +11,7 @@ ) from eth2spec.test.helpers.constants import ( AFTER_DENEB_PRE_POST_FORKS, + DENEB, ) from eth2spec.test.helpers.state import ( next_epoch_via_block, @@ -78,7 +79,13 @@ def test_transition_attestation_from_previous_fork_with_new_range( next_epoch_via_block(spec, state) # Generate an attestation for slot 0 of this epoch - attestation = get_valid_attestation(spec, state, signed=True) + if spec.fork == DENEB: + # NOTE: attestation format changes from Deneb to Electra + # so the attestation must be made with the `post_spec` + target_spec = post_spec + else: + target_spec = spec + attestation = get_valid_attestation(target_spec, state, signed=True) yield 'pre', state From 9edfb29e2ca2e9cf891265d7c1e825aa0a137a40 Mon Sep 17 00:00:00 2001 From: Hsiao-Wei Wang Date: Tue, 9 Apr 2024 14:13:44 +0800 Subject: [PATCH 11/11] fix conflict --- .gitignore | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.gitignore b/.gitignore index 23109dd28d..91270239a0 100644 --- a/.gitignore +++ b/.gitignore @@ -22,10 +22,6 @@ tests/core/pyspec/eth2spec/bellatrix/ tests/core/pyspec/eth2spec/capella/ tests/core/pyspec/eth2spec/deneb/ tests/core/pyspec/eth2spec/electra/ -<<<<<<< HEAD -======= -tests/core/pyspec/eth2spec/eip7549/ ->>>>>>> dev tests/core/pyspec/eth2spec/whisk/ tests/core/pyspec/eth2spec/eip7251/ tests/core/pyspec/eth2spec/eip7594/