mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-09 09:14:32 +00:00
Add EIP-7514 into Deneb
This commit is contained in:
parent
0efd778594
commit
e5e50e3e40
1
.gitignore
vendored
1
.gitignore
vendored
@ -23,7 +23,6 @@ tests/core/pyspec/eth2spec/capella/
|
||||
tests/core/pyspec/eth2spec/deneb/
|
||||
tests/core/pyspec/eth2spec/eip6110/
|
||||
tests/core/pyspec/eth2spec/eip7002/
|
||||
tests/core/pyspec/eth2spec/eip7668/
|
||||
tests/core/pyspec/eth2spec/whisk/
|
||||
|
||||
# coverage reports
|
||||
|
@ -56,9 +56,6 @@ EIP6110_FORK_EPOCH: 18446744073709551615
|
||||
# EIP7002
|
||||
EIP7002_FORK_VERSION: 0x05000000 # temporary stub
|
||||
EIP7002_FORK_EPOCH: 18446744073709551615
|
||||
# EIP7514
|
||||
EIP7514_FORK_VERSION: 0x05000000 # temporary stub
|
||||
EIP7514_FORK_EPOCH: 18446744073709551615
|
||||
# WHISK
|
||||
WHISK_FORK_VERSION: 0x06000000 # temporary stub
|
||||
WHISK_FORK_EPOCH: 18446744073709551615
|
||||
@ -90,7 +87,8 @@ EJECTION_BALANCE: 16000000000
|
||||
MIN_PER_EPOCH_CHURN_LIMIT: 4
|
||||
# 2**16 (= 65,536)
|
||||
CHURN_LIMIT_QUOTIENT: 65536
|
||||
|
||||
# [New in Deneb:EIP7514] 2**3 (=8)
|
||||
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8
|
||||
|
||||
# Fork choice
|
||||
# ---------------------------------------------------------------
|
||||
@ -149,6 +147,3 @@ BLOB_SIDECAR_SUBNET_COUNT: 6
|
||||
WHISK_EPOCHS_PER_SHUFFLING_PHASE: 256
|
||||
# `Epoch(2)`
|
||||
WHISK_PROPOSER_SELECTION_GAP: 2
|
||||
|
||||
# EIP7514
|
||||
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 8
|
||||
|
@ -55,9 +55,6 @@ EIP6110_FORK_EPOCH: 18446744073709551615
|
||||
# EIP7002
|
||||
EIP7002_FORK_VERSION: 0x05000001
|
||||
EIP7002_FORK_EPOCH: 18446744073709551615
|
||||
# EIP7514
|
||||
EIP7514_FORK_VERSION: 0x05000001 # temporary stub
|
||||
EIP7514_FORK_EPOCH: 18446744073709551615
|
||||
# WHISK
|
||||
WHISK_FORK_VERSION: 0x06000001
|
||||
WHISK_FORK_EPOCH: 18446744073709551615
|
||||
@ -89,6 +86,8 @@ EJECTION_BALANCE: 16000000000
|
||||
MIN_PER_EPOCH_CHURN_LIMIT: 2
|
||||
# [customized] scale queue churn at much lower validator counts for testing
|
||||
CHURN_LIMIT_QUOTIENT: 32
|
||||
# [New in Deneb:EIP7514] [customized]
|
||||
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 4
|
||||
|
||||
|
||||
# Fork choice
|
||||
@ -148,7 +147,3 @@ BLOB_SIDECAR_SUBNET_COUNT: 6
|
||||
# Whisk
|
||||
WHISK_EPOCHS_PER_SHUFFLING_PHASE: 4
|
||||
WHISK_PROPOSER_SELECTION_GAP: 1
|
||||
|
||||
# EIP7514
|
||||
# [customized]
|
||||
MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT: 4
|
||||
|
@ -6,7 +6,6 @@ CAPELLA = 'capella'
|
||||
DENEB = 'deneb'
|
||||
EIP6110 = 'eip6110'
|
||||
EIP7002 = 'eip7002'
|
||||
EIP7514 = 'eip7514'
|
||||
WHISK = 'whisk'
|
||||
|
||||
|
||||
|
@ -9,7 +9,6 @@ from .constants import (
|
||||
EIP6110,
|
||||
WHISK,
|
||||
EIP7002,
|
||||
EIP7514,
|
||||
)
|
||||
|
||||
|
||||
@ -22,7 +21,6 @@ PREVIOUS_FORK_OF = {
|
||||
EIP6110: DENEB,
|
||||
WHISK: CAPELLA,
|
||||
EIP7002: CAPELLA,
|
||||
EIP7514: CAPELLA,
|
||||
}
|
||||
|
||||
ALL_FORKS = list(PREVIOUS_FORK_OF.keys())
|
||||
|
@ -5,7 +5,6 @@ from .capella import CapellaSpecBuilder
|
||||
from .deneb import DenebSpecBuilder
|
||||
from .eip6110 import EIP6110SpecBuilder
|
||||
from .eip7002 import EIP7002SpecBuilder
|
||||
from .eip7514 import EIP7514SpecBuilder
|
||||
from .whisk import WhiskSpecBuilder
|
||||
|
||||
|
||||
@ -13,6 +12,6 @@ spec_builders = {
|
||||
builder.fork: builder
|
||||
for builder in (
|
||||
Phase0SpecBuilder, AltairSpecBuilder, BellatrixSpecBuilder, CapellaSpecBuilder, DenebSpecBuilder,
|
||||
EIP6110SpecBuilder, EIP7002SpecBuilder, EIP7514SpecBuilder, WhiskSpecBuilder,
|
||||
EIP6110SpecBuilder, EIP7002SpecBuilder, WhiskSpecBuilder,
|
||||
)
|
||||
}
|
||||
|
@ -1,12 +0,0 @@
|
||||
from .base import BaseSpecBuilder
|
||||
from ..constants import EIP7514
|
||||
|
||||
|
||||
class EIP7514SpecBuilder(BaseSpecBuilder):
|
||||
fork: str = EIP7514
|
||||
|
||||
@classmethod
|
||||
def imports(cls, preset_name: str):
|
||||
return super().imports(preset_name) + f'''
|
||||
from eth2spec.capella import {preset_name} as capella
|
||||
'''
|
@ -1,83 +0,0 @@
|
||||
EIP-7514 -- The Beacon Chain
|
||||
|
||||
## Table of contents
|
||||
|
||||
<!-- TOC -->
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Configuration](#configuration)
|
||||
- [Validator cycle](#validator-cycle)
|
||||
- [Helper functions](#helper-functions)
|
||||
- [Beacon state accessors](#beacon-state-accessors)
|
||||
- [New `get_validator_activation_churn_limit`](#new-get_validator_activation_churn_limit)
|
||||
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
|
||||
- [Epoch processing](#epoch-processing)
|
||||
- [Registry updates](#registry-updates)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- /TOC -->
|
||||
|
||||
## Introduction
|
||||
|
||||
This is the beacon chain specification to limit the max inbound churn value, motivated to limit the validator active set growth rate.
|
||||
|
||||
*Note:* This specification is built upon [Capella](../../capella/beacon_chain.md) and is under active development.
|
||||
|
||||
## Configuration
|
||||
|
||||
### Validator cycle
|
||||
|
||||
| Name | Value |
|
||||
| - | - |
|
||||
| `MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT` | `uint64(8)` (= 8) |
|
||||
|
||||
## Helper functions
|
||||
|
||||
### Beacon state accessors
|
||||
|
||||
#### New `get_validator_activation_churn_limit`
|
||||
|
||||
```python
|
||||
def get_validator_activation_churn_limit(state: BeaconState) -> uint64:
|
||||
"""
|
||||
Return the validator activation churn limit for the current epoch.
|
||||
"""
|
||||
return min(MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT, get_validator_churn_limit(state))
|
||||
```
|
||||
|
||||
## Beacon chain state transition function
|
||||
|
||||
### Epoch processing
|
||||
|
||||
#### Registry updates
|
||||
|
||||
Note: The function `process_registry_updates` is modified to utilize `get_validator_inbound_churn_limit()` the rate limit the activation queue for EIP-7514.
|
||||
|
||||
```python
|
||||
def process_registry_updates(state: BeaconState) -> None:
|
||||
# Process activation eligibility and ejections
|
||||
for index, validator in enumerate(state.validators):
|
||||
if is_eligible_for_activation_queue(validator):
|
||||
validator.activation_eligibility_epoch = get_current_epoch(state) + 1
|
||||
|
||||
if (
|
||||
is_active_validator(validator, get_current_epoch(state))
|
||||
and validator.effective_balance <= EJECTION_BALANCE
|
||||
):
|
||||
initiate_validator_exit(state, ValidatorIndex(index))
|
||||
|
||||
# Queue validators eligible for activation and not yet dequeued for activation
|
||||
activation_queue = sorted([
|
||||
index for index, validator in enumerate(state.validators)
|
||||
if is_eligible_for_activation(state, validator)
|
||||
# Order by the sequence of activation_eligibility_epoch setting and then index
|
||||
], key=lambda index: (state.validators[index].activation_eligibility_epoch, index))
|
||||
# Dequeued validators for activation up to churn limit
|
||||
# [Modified in EIP7514]
|
||||
for index in activation_queue[:get_validator_activation_churn_limit(state)]:
|
||||
validator = state.validators[index]
|
||||
validator.activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
|
||||
```
|
||||
|
@ -1,139 +0,0 @@
|
||||
# EIP-7514 -- Fork Logic
|
||||
|
||||
**Notice**: This document is a work-in-progress for researchers and implementers.
|
||||
|
||||
## Table of contents
|
||||
|
||||
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
|
||||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
|
||||
|
||||
- [Introduction](#introduction)
|
||||
- [Configuration](#configuration)
|
||||
- [Helper functions](#helper-functions)
|
||||
- [Misc](#misc)
|
||||
- [Modified `compute_fork_version`](#modified-compute_fork_version)
|
||||
- [Fork to EIP-7514](#fork-to-eip-7514)
|
||||
- [Fork trigger](#fork-trigger)
|
||||
- [Upgrading the state](#upgrading-the-state)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
|
||||
## Introduction
|
||||
|
||||
This document describes the process of EIP-7514 upgrade.
|
||||
|
||||
## Configuration
|
||||
|
||||
Warning: this configuration is not definitive.
|
||||
|
||||
| Name | Value |
|
||||
| - | - |
|
||||
| `EIP7514_FORK_VERSION` | `Version('0x05000000')` |
|
||||
| `EIP7514_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 >= EIP7514_FORK_EPOCH:
|
||||
return EIP7514_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-7514
|
||||
|
||||
### 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 `EIP7514_FORK_EPOCH`.
|
||||
|
||||
Note that for the pure EIP-7514 networks, we don't apply `upgrade_to_eip7514` since it starts with EIP-7514 version logic.
|
||||
|
||||
### Upgrading the state
|
||||
|
||||
If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == EIP7514_FORK_EPOCH`,
|
||||
an irregular state change is made to upgrade to EIP-7514.
|
||||
|
||||
```python
|
||||
def upgrade_to_eip7514(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=EIP7514_FORK_VERSION, # [Modified in EIP-7514]
|
||||
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
|
||||
```
|
@ -16,6 +16,7 @@
|
||||
- [Preset](#preset)
|
||||
- [Execution](#execution)
|
||||
- [Configuration](#configuration)
|
||||
- [Validator cycle](#validator-cycle)
|
||||
- [Containers](#containers)
|
||||
- [Extended containers](#extended-containers)
|
||||
- [`BeaconBlockBody`](#beaconblockbody)
|
||||
@ -26,6 +27,7 @@
|
||||
- [`kzg_commitment_to_versioned_hash`](#kzg_commitment_to_versioned_hash)
|
||||
- [Beacon state accessors](#beacon-state-accessors)
|
||||
- [Modified `get_attestation_participation_flag_indices`](#modified-get_attestation_participation_flag_indices)
|
||||
- [New `get_validator_activation_churn_limit`](#new-get_validator_activation_churn_limit)
|
||||
- [Beacon chain state transition function](#beacon-chain-state-transition-function)
|
||||
- [Execution engine](#execution-engine)
|
||||
- [Request data](#request-data)
|
||||
@ -40,6 +42,8 @@
|
||||
- [Execution payload](#execution-payload)
|
||||
- [Modified `process_execution_payload`](#modified-process_execution_payload)
|
||||
- [Modified `process_voluntary_exit`](#modified-process_voluntary_exit)
|
||||
- [Epoch processing](#epoch-processing)
|
||||
- [Registry updates](#registry-updates)
|
||||
- [Testing](#testing)
|
||||
|
||||
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
|
||||
@ -52,6 +56,7 @@ Deneb is a consensus-layer upgrade containing a number of features. Including:
|
||||
* [EIP-4844](https://eips.ethereum.org/EIPS/eip-4844): Shard Blob Transactions scale data-availability of Ethereum in a simple, forwards-compatible manner
|
||||
* [EIP-7044](https://github.com/ethereum/EIPs/pull/7044): Perpetually Valid Signed Voluntary Exits
|
||||
* [EIP-7045](https://eips.ethereum.org/EIPS/eip-7045): Increase Max Attestation Inclusion Slot
|
||||
* [EIP-7514](https://eips.ethereum.org/EIPS/eip-7514): Add Max Epoch Churn Limit
|
||||
|
||||
## Custom types
|
||||
|
||||
@ -89,6 +94,12 @@ and are limited by `MAX_BLOB_GAS_PER_BLOCK // GAS_PER_BLOB`. However the CL limi
|
||||
|
||||
## Configuration
|
||||
|
||||
### Validator cycle
|
||||
|
||||
| Name | Value |
|
||||
| - | - |
|
||||
| `MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT` | `uint64(2**3)` (= 8) |
|
||||
|
||||
## Containers
|
||||
|
||||
### Extended containers
|
||||
@ -211,6 +222,16 @@ def get_attestation_participation_flag_indices(state: BeaconState,
|
||||
return participation_flag_indices
|
||||
```
|
||||
|
||||
#### New `get_validator_activation_churn_limit`
|
||||
|
||||
```python
|
||||
def get_validator_activation_churn_limit(state: BeaconState) -> uint64:
|
||||
"""
|
||||
Return the validator activation churn limit for the current epoch.
|
||||
"""
|
||||
return min(MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT, get_validator_churn_limit(state))
|
||||
```
|
||||
|
||||
## Beacon chain state transition function
|
||||
|
||||
### Execution engine
|
||||
@ -415,6 +436,38 @@ def process_voluntary_exit(state: BeaconState, signed_voluntary_exit: SignedVolu
|
||||
initiate_validator_exit(state, voluntary_exit.validator_index)
|
||||
```
|
||||
|
||||
### Epoch processing
|
||||
|
||||
#### Registry updates
|
||||
|
||||
*Note*: The function `process_registry_updates` is modified to utilize `get_validator_activation_churn_limit()` the rate limit the activation queue for EIP-7514.
|
||||
|
||||
```python
|
||||
def process_registry_updates(state: BeaconState) -> None:
|
||||
# Process activation eligibility and ejections
|
||||
for index, validator in enumerate(state.validators):
|
||||
if is_eligible_for_activation_queue(validator):
|
||||
validator.activation_eligibility_epoch = get_current_epoch(state) + 1
|
||||
|
||||
if (
|
||||
is_active_validator(validator, get_current_epoch(state))
|
||||
and validator.effective_balance <= EJECTION_BALANCE
|
||||
):
|
||||
initiate_validator_exit(state, ValidatorIndex(index))
|
||||
|
||||
# Queue validators eligible for activation and not yet dequeued for activation
|
||||
activation_queue = sorted([
|
||||
index for index, validator in enumerate(state.validators)
|
||||
if is_eligible_for_activation(state, validator)
|
||||
# Order by the sequence of activation_eligibility_epoch setting and then index
|
||||
], key=lambda index: (state.validators[index].activation_eligibility_epoch, index))
|
||||
# Dequeued validators for activation up to churn limit
|
||||
# [Modified in Deneb:EIP7514]
|
||||
for index in activation_queue[:get_validator_activation_churn_limit(state)]:
|
||||
validator = state.validators[index]
|
||||
validator.activation_epoch = compute_activation_exit_epoch(get_current_epoch(state))
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
*Note*: The function `initialize_beacon_state_from_eth1` is modified for pure Deneb testing only.
|
||||
|
@ -10,13 +10,12 @@ from eth2spec.capella import mainnet as spec_capella_mainnet, minimal as spec_ca
|
||||
from eth2spec.deneb import mainnet as spec_deneb_mainnet, minimal as spec_deneb_minimal
|
||||
from eth2spec.eip6110 import mainnet as spec_eip6110_mainnet, minimal as spec_eip6110_minimal
|
||||
from eth2spec.eip7002 import mainnet as spec_eip7002_mainnet, minimal as spec_eip7002_minimal
|
||||
from eth2spec.eip7514 import mainnet as spec_eip7514_mainnet, minimal as spec_eip7514_minimal
|
||||
from eth2spec.utils import bls
|
||||
|
||||
from .exceptions import SkippedTest
|
||||
from .helpers.constants import (
|
||||
PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB,
|
||||
EIP6110, EIP7002, EIP7514,
|
||||
EIP6110, EIP7002,
|
||||
MINIMAL, MAINNET,
|
||||
ALL_PHASES,
|
||||
ALL_FORK_UPGRADES,
|
||||
@ -86,7 +85,6 @@ spec_targets: Dict[PresetBaseName, Dict[SpecForkName, Spec]] = {
|
||||
DENEB: spec_deneb_minimal,
|
||||
EIP6110: spec_eip6110_minimal,
|
||||
EIP7002: spec_eip7002_minimal,
|
||||
EIP7514: spec_eip7514_minimal,
|
||||
},
|
||||
MAINNET: {
|
||||
PHASE0: spec_phase0_mainnet,
|
||||
@ -96,7 +94,6 @@ spec_targets: Dict[PresetBaseName, Dict[SpecForkName, Spec]] = {
|
||||
DENEB: spec_deneb_mainnet,
|
||||
EIP6110: spec_eip6110_mainnet,
|
||||
EIP7002: spec_eip7002_mainnet,
|
||||
EIP7514: spec_eip7514_mainnet,
|
||||
},
|
||||
}
|
||||
|
||||
@ -176,21 +173,21 @@ def scaled_churn_balances_min_churn_limit(spec: Spec):
|
||||
return [spec.MAX_EFFECTIVE_BALANCE] * num_validators
|
||||
|
||||
|
||||
def scaled_churn_balances_equal_inbound_churn_limit(spec: Spec):
|
||||
def scaled_churn_balances_equal_activation_churn_limit(spec: Spec):
|
||||
"""
|
||||
Helper method to create enough validators to scale the churn limit.
|
||||
(This is *firmly* over the churn limit -- thus the +2 instead of just +1)
|
||||
Usage: `@with_custom_state(balances_fn=scaled_churn_balances_exceed_inbound_churn_limit, ...)`
|
||||
Usage: `@with_custom_state(balances_fn=scaled_churn_balances_exceed_activation_churn_limit, ...)`
|
||||
"""
|
||||
num_validators = spec.config.CHURN_LIMIT_QUOTIENT * (spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT)
|
||||
return [spec.MAX_EFFECTIVE_BALANCE] * num_validators
|
||||
|
||||
|
||||
def scaled_churn_balances_exceed_inbound_churn_limit(spec: Spec):
|
||||
def scaled_churn_balances_exceed_activation_churn_limit(spec: Spec):
|
||||
"""
|
||||
Helper method to create enough validators to scale the churn limit.
|
||||
(This is *firmly* over the churn limit -- thus the +2 instead of just +1)
|
||||
Usage: `@with_custom_state(balances_fn=scaled_churn_balances_exceed_inbound_churn_limit, ...)`
|
||||
Usage: `@with_custom_state(balances_fn=scaled_churn_balances_exceed_activation_churn_limit, ...)`
|
||||
"""
|
||||
num_validators = spec.config.CHURN_LIMIT_QUOTIENT * (spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT + 2)
|
||||
return [spec.MAX_EFFECTIVE_BALANCE] * num_validators
|
||||
@ -568,7 +565,6 @@ 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_eip7002_and_later = with_all_phases_from(EIP7002)
|
||||
with_eip7514_and_later = with_all_phases_from(EIP7514)
|
||||
|
||||
|
||||
class quoted_str(str):
|
||||
|
@ -1,14 +1,14 @@
|
||||
from eth2spec.test.helpers.keys import pubkeys
|
||||
from eth2spec.test.helpers.constants import MINIMAL
|
||||
from eth2spec.test.context import (
|
||||
with_eip7514_and_later,
|
||||
with_deneb_and_later,
|
||||
spec_test,
|
||||
spec_state_test,
|
||||
single_phase,
|
||||
with_custom_state,
|
||||
with_presets,
|
||||
scaled_churn_balances_exceed_inbound_churn_limit,
|
||||
scaled_churn_balances_equal_inbound_churn_limit,
|
||||
scaled_churn_balances_exceed_activation_churn_limit,
|
||||
scaled_churn_balances_equal_activation_churn_limit,
|
||||
)
|
||||
from eth2spec.test.helpers.epoch_processing import run_epoch_processing_with
|
||||
|
||||
@ -17,7 +17,7 @@ def run_process_registry_updates(spec, state):
|
||||
yield from run_epoch_processing_with(spec, state, 'process_registry_updates')
|
||||
|
||||
|
||||
def run_test_inbound_churn_limit(spec, state):
|
||||
def run_test_activation_churn_limit(spec, state):
|
||||
mock_activations = spec.get_validator_activation_churn_limit(state) * 2
|
||||
|
||||
validator_count_0 = len(state.validators)
|
||||
@ -54,37 +54,37 @@ def run_test_inbound_churn_limit(spec, state):
|
||||
assert state.validators[index].activation_epoch == spec.FAR_FUTURE_EPOCH
|
||||
|
||||
|
||||
@with_eip7514_and_later
|
||||
@with_deneb_and_later
|
||||
@with_presets([MINIMAL],
|
||||
reason="mainnet config leads to larger validator set than limit of public/private keys pre-generated")
|
||||
@spec_test
|
||||
@with_custom_state(balances_fn=scaled_churn_balances_exceed_inbound_churn_limit,
|
||||
@with_custom_state(balances_fn=scaled_churn_balances_exceed_activation_churn_limit,
|
||||
threshold_fn=lambda spec: spec.config.EJECTION_BALANCE)
|
||||
@single_phase
|
||||
def test_inbound_churn_limit__greater_than_inbound_limit(spec, state):
|
||||
def test_activation_churn_limit__greater_than_inbound_limit(spec, state):
|
||||
assert spec.get_validator_activation_churn_limit(state) == spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT
|
||||
assert spec.get_validator_churn_limit(state) > spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT
|
||||
yield from run_test_inbound_churn_limit(spec, state)
|
||||
yield from run_test_activation_churn_limit(spec, state)
|
||||
|
||||
|
||||
@with_eip7514_and_later
|
||||
@with_deneb_and_later
|
||||
@with_presets([MINIMAL],
|
||||
reason="mainnet config leads to larger validator set than limit of public/private keys pre-generated")
|
||||
@spec_test
|
||||
@with_custom_state(balances_fn=scaled_churn_balances_equal_inbound_churn_limit,
|
||||
@with_custom_state(balances_fn=scaled_churn_balances_equal_activation_churn_limit,
|
||||
threshold_fn=lambda spec: spec.config.EJECTION_BALANCE)
|
||||
@single_phase
|
||||
def test_inbound_churn_limit__equal_to_inbound_limit(spec, state):
|
||||
def test_activation_churn_limit__equal_to_inbound_limit(spec, state):
|
||||
assert spec.get_validator_activation_churn_limit(state) == spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT
|
||||
assert spec.get_validator_churn_limit(state) == spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT
|
||||
yield from run_test_inbound_churn_limit(spec, state)
|
||||
yield from run_test_activation_churn_limit(spec, state)
|
||||
|
||||
|
||||
@with_eip7514_and_later
|
||||
@with_deneb_and_later
|
||||
@with_presets([MINIMAL],
|
||||
reason="mainnet config leads to larger validator set than limit of public/private keys pre-generated")
|
||||
@spec_state_test
|
||||
def test_inbound_churn_limit__less_than_inbound_limit(spec, state):
|
||||
def test_activation_churn_limit__less_than_inbound_limit(spec, state):
|
||||
assert spec.get_validator_activation_churn_limit(state) < spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT
|
||||
assert spec.get_validator_churn_limit(state) < spec.config.MAX_PER_EPOCH_ACTIVATION_CHURN_LIMIT
|
||||
yield from run_test_inbound_churn_limit(spec, state)
|
||||
yield from run_test_activation_churn_limit(spec, state)
|
@ -18,7 +18,6 @@ CUSTODY_GAME = SpecForkName('custody_game')
|
||||
DAS = SpecForkName('das')
|
||||
EIP6110 = SpecForkName('eip6110')
|
||||
EIP7002 = SpecForkName('eip7002')
|
||||
EIP7514 = SpecForkName('eip7514')
|
||||
|
||||
#
|
||||
# SpecFork settings
|
||||
@ -35,7 +34,6 @@ ALL_PHASES = (
|
||||
# Experimental patches
|
||||
EIP6110,
|
||||
EIP7002,
|
||||
EIP7514,
|
||||
)
|
||||
# The forks that have light client specs
|
||||
LIGHT_CLIENT_TESTING_FORKS = (*[item for item in MAINNET_FORKS if item != PHASE0], DENEB)
|
||||
|
@ -1,12 +1,10 @@
|
||||
from .constants import (
|
||||
PHASE0, ALTAIR, BELLATRIX, CAPELLA, DENEB,
|
||||
EIP6110, EIP7002, EIP7514,
|
||||
EIP6110, EIP7002,
|
||||
)
|
||||
|
||||
|
||||
def is_post_fork(a, b):
|
||||
if a == EIP7514:
|
||||
return b in [PHASE0, ALTAIR, BELLATRIX, CAPELLA, EIP7514]
|
||||
if a == EIP7002:
|
||||
return b in [PHASE0, ALTAIR, BELLATRIX, CAPELLA, EIP7002]
|
||||
if a == EIP6110:
|
||||
@ -46,7 +44,3 @@ def is_post_eip6110(spec):
|
||||
|
||||
def is_post_eip7002(spec):
|
||||
return is_post_fork(spec.fork, EIP7002)
|
||||
|
||||
|
||||
def is_post_eip7514(spec):
|
||||
return is_post_fork(spec.fork, EIP7514)
|
||||
|
@ -1,5 +1,5 @@
|
||||
from eth2spec.test.helpers.constants import (
|
||||
ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110, EIP7002, EIP7514,
|
||||
ALTAIR, BELLATRIX, CAPELLA, DENEB, EIP6110, EIP7002,
|
||||
)
|
||||
from eth2spec.test.helpers.execution_payload import (
|
||||
compute_el_header_block_hash,
|
||||
@ -93,9 +93,6 @@ def create_genesis_state(spec, validator_balances, activation_threshold):
|
||||
elif spec.fork == EIP7002:
|
||||
previous_version = spec.config.CAPELLA_FORK_VERSION
|
||||
current_version = spec.config.EIP7002_FORK_VERSION
|
||||
elif spec.fork == EIP7514:
|
||||
previous_version = spec.config.CAPELLA_FORK_VERSION
|
||||
current_version = spec.config.EIP7514_FORK_VERSION
|
||||
|
||||
state = spec.BeaconState(
|
||||
genesis_time=0,
|
||||
|
@ -32,7 +32,10 @@ if __name__ == "__main__":
|
||||
]}
|
||||
capella_mods = combine_mods(_new_capella_mods, bellatrix_mods)
|
||||
|
||||
deneb_mods = capella_mods
|
||||
_new_deneb_mods = {key: 'eth2spec.test.deneb.epoch_processing.test_process_' + key for key in [
|
||||
'registry_updates',
|
||||
]}
|
||||
deneb_mods = combine_mods(_new_deneb_mods, capella_mods)
|
||||
|
||||
eip6110_mods = deneb_mods
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user