Skip to content

Commit 025ebed

Browse files
authored
Merge pull request #3640 from ethereum/eip7549-tests
EIP-7549: Enable EIP-7549 on CI
2 parents e5020c7 + 4408837 commit 025ebed

File tree

18 files changed

+309
-32
lines changed

18 files changed

+309
-32
lines changed

.circleci/config.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,19 @@ jobs:
181181
command: make citest fork=eip7002
182182
- store_test_results:
183183
path: tests/core/pyspec/test-reports
184+
test-eip7549:
185+
docker:
186+
- image: circleci/python:3.9
187+
working_directory: ~/specs-repo
188+
steps:
189+
- restore_cache:
190+
key: v3-specs-repo-{{ .Branch }}-{{ .Revision }}
191+
- restore_pyspec_cached_venv
192+
- run:
193+
name: Run py-tests
194+
command: make citest fork=eip7549
195+
- store_test_results:
196+
path: tests/core/pyspec/test-reports
184197
test-whisk:
185198
docker:
186199
- image: circleci/python:3.9
@@ -333,6 +346,9 @@ workflows:
333346
- test-eip7002:
334347
requires:
335348
- install_pyspec_test
349+
- test-eip7549:
350+
requires:
351+
- install_pyspec_test
336352
- test-whisk:
337353
requires:
338354
- install_pyspec_test

.github/workflows/run-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ jobs:
7171
needs: [preclear,lint,codespell,table_of_contents]
7272
strategy:
7373
matrix:
74-
version: ["phase0", "altair", "bellatrix", "capella", "deneb", "eip6110", "eip7002", "whisk", "eip7594"]
74+
version: ["phase0", "altair", "bellatrix", "capella", "deneb", "eip6110", "eip7002", "eip7549", "whisk", "eip7594"]
7575
steps:
7676
- name: Checkout this repo
7777
uses: actions/[email protected]

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ MARKDOWN_FILES = $(wildcard $(SPEC_DIR)/*/*.md) \
3535
$(wildcard $(SPEC_DIR)/_features/*/*/*.md) \
3636
$(wildcard $(SSZ_DIR)/*.md)
3737

38-
ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb eip6110 eip7002 whisk
38+
ALL_EXECUTABLE_SPEC_NAMES = phase0 altair bellatrix capella deneb eip6110 eip7002 eip7549 whisk
3939
# The parameters for commands. Use `foreach` to avoid listing specs again.
4040
COVERAGE_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), --cov=eth2spec.$S.$(TEST_PRESET_TYPE))
4141
PYLINT_SCOPE := $(foreach S,$(ALL_EXECUTABLE_SPEC_NAMES), ./eth2spec/$S)

configs/mainnet.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ EIP7002_FORK_EPOCH: 18446744073709551615
6262
# EIP7251
6363
EIP7251_FORK_VERSION: 0x06000000 # temporary stub
6464
EIP7251_FORK_EPOCH: 18446744073709551615
65+
# EIP7549
66+
EIP7549_FORK_VERSION: 0x06000000 # temporary stub
67+
EIP7549_FORK_EPOCH: 18446744073709551615
6568
# WHISK
6669
WHISK_FORK_VERSION: 0x08000000 # temporary stub
6770
WHISK_FORK_EPOCH: 18446744073709551615

configs/minimal.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ EIP6110_FORK_EPOCH: 18446744073709551615
5959
EIP7002_FORK_VERSION: 0x07000001
6060
EIP7002_FORK_EPOCH: 18446744073709551615
6161
# EIP7251
62-
EIP7251_FORK_VERSION: 0x06000000 # temporary stub
62+
EIP7251_FORK_VERSION: 0x06000001 # temporary stub
6363
EIP7251_FORK_EPOCH: 18446744073709551615
64+
# EIP7549
65+
EIP7549_FORK_VERSION: 0x06000001 # temporary stub
66+
EIP7549_FORK_EPOCH: 18446744073709551615
6467
# WHISK
6568
WHISK_FORK_VERSION: 0x08000001
6669
WHISK_FORK_EPOCH: 18446744073709551615

presets/mainnet/eip7549.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Mainnet preset - EIP7594
2+
3+
# # Max operations per block
4+
# ---------------------------------------------------------------
5+
# `uint64(2**0)` (= 1)
6+
MAX_ATTESTER_SLASHINGS_EIP7549: 1
7+
# `uint64(2 * 3)` (= 8)
8+
MAX_ATTESTATIONS_EIP7549: 8

presets/minimal/eip7549.yaml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Minimal preset - EIP7594
2+
3+
# # Max operations per block
4+
# ---------------------------------------------------------------
5+
# `uint64(2**0)` (= 1)
6+
MAX_ATTESTER_SLASHINGS_EIP7549: 1
7+
# `uint64(2 * 3)` (= 8)
8+
MAX_ATTESTATIONS_EIP7549: 8

specs/_features/eip7549/beacon-chain.md

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- [Modified containers](#modified-containers)
1313
- [`Attestation`](#attestation)
1414
- [`IndexedAttestation`](#indexedattestation)
15+
- [`BeaconBlockBody`](#beaconblockbody)
1516
- [Helper functions](#helper-functions)
1617
- [Misc](#misc)
1718
- [`get_committee_indices`](#get_committee_indices)
@@ -33,8 +34,8 @@ This is the beacon chain specification to move the attestation committee index o
3334

3435
| Name | Value | Description |
3536
| - | - | - |
36-
| `MAX_ATTESTER_SLASHINGS` | `2**0` (= 1) |
37-
| `MAX_ATTESTATIONS` | `2**3` (= 8) |
37+
| `MAX_ATTESTER_SLASHINGS_EIP7549` | `2**0` (= 1) |
38+
| `MAX_ATTESTATIONS_EIP7549` | `2**3` (= 8) |
3839

3940
## Containers
4041

@@ -60,15 +61,35 @@ class IndexedAttestation(Container):
6061
signature: BLSSignature
6162
```
6263

64+
#### `BeaconBlockBody`
65+
66+
```python
67+
class BeaconBlockBody(Container):
68+
randao_reveal: BLSSignature
69+
eth1_data: Eth1Data # Eth1 data vote
70+
graffiti: Bytes32 # Arbitrary data
71+
# Operations
72+
proposer_slashings: List[ProposerSlashing, MAX_PROPOSER_SLASHINGS]
73+
attester_slashings: List[AttesterSlashing, MAX_ATTESTER_SLASHINGS_EIP7549] # [Modified in EIP7549]
74+
attestations: List[Attestation, MAX_ATTESTATIONS_EIP7549] # [Modified in EIP7549]
75+
deposits: List[Deposit, MAX_DEPOSITS]
76+
voluntary_exits: List[SignedVoluntaryExit, MAX_VOLUNTARY_EXITS]
77+
sync_aggregate: SyncAggregate
78+
# Execution
79+
execution_payload: ExecutionPayload
80+
bls_to_execution_changes: List[SignedBLSToExecutionChange, MAX_BLS_TO_EXECUTION_CHANGES]
81+
blob_kzg_commitments: List[KZGCommitment, MAX_BLOB_COMMITMENTS_PER_BLOCK]
82+
```
83+
6384
## Helper functions
6485

6586
### Misc
6687

6788
#### `get_committee_indices`
6889

6990
```python
70-
def get_committee_indices(commitee_bits: Bitvector) -> List[CommitteeIndex]:
71-
return [CommitteeIndex(index) for bit, index in enumerate(commitee_bits) if bit]
91+
def get_committee_indices(commitee_bits: Bitvector) -> Sequence[CommitteeIndex]:
92+
return [CommitteeIndex(index) for index, bit in enumerate(commitee_bits) if bit]
7293
```
7394

7495
### Beacon state accessors
@@ -80,8 +101,7 @@ def get_attesting_indices(state: BeaconState, attestation: Attestation) -> Set[V
80101
"""
81102
Return the set of attesting indices corresponding to ``aggregation_bits`` and ``committee_bits``.
82103
"""
83-
84-
output = set()
104+
output: Set[ValidatorIndex] = set()
85105
committee_indices = get_committee_indices(attestation.committee_bits)
86106
committee_offset = 0
87107
for index in committee_indices:

specs/_features/eip7549/fork.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# EIP-7549 -- Fork Logic
2+
3+
**Notice**: This document is a work-in-progress for researchers and implementers.
4+
5+
## Table of contents
6+
7+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
8+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
9+
10+
- [Introduction](#introduction)
11+
- [Configuration](#configuration)
12+
- [Helper functions](#helper-functions)
13+
- [Misc](#misc)
14+
- [Modified `compute_fork_version`](#modified-compute_fork_version)
15+
- [Fork to EIP-7549](#fork-to-eip-7549)
16+
- [Fork trigger](#fork-trigger)
17+
- [Upgrading the state](#upgrading-the-state)
18+
19+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
20+
21+
## Introduction
22+
23+
This document describes the process of EIP-7549 upgrade.
24+
25+
## Configuration
26+
27+
Warning: this configuration is not definitive.
28+
29+
| Name | Value |
30+
| - | - |
31+
| `EIP7549_FORK_VERSION` | `Version('0x06000000')` |
32+
| `EIP7549_FORK_EPOCH` | `Epoch(18446744073709551615)` **TBD** |
33+
34+
## Helper functions
35+
36+
### Misc
37+
38+
#### Modified `compute_fork_version`
39+
40+
```python
41+
def compute_fork_version(epoch: Epoch) -> Version:
42+
"""
43+
Return the fork version at the given ``epoch``.
44+
"""
45+
if epoch >= EIP7549_FORK_EPOCH:
46+
return EIP7549_FORK_VERSION
47+
if epoch >= DENEB_FORK_EPOCH:
48+
return DENEB_FORK_VERSION
49+
if epoch >= CAPELLA_FORK_EPOCH:
50+
return CAPELLA_FORK_VERSION
51+
if epoch >= BELLATRIX_FORK_EPOCH:
52+
return BELLATRIX_FORK_VERSION
53+
if epoch >= ALTAIR_FORK_EPOCH:
54+
return ALTAIR_FORK_VERSION
55+
return GENESIS_FORK_VERSION
56+
```
57+
58+
## Fork to EIP-7549
59+
60+
### Fork trigger
61+
62+
TBD. This fork is defined for testing purposes, the EIP may be combined with other consensus-layer upgrade.
63+
For now, we assume the condition will be triggered at epoch `EIP7549_FORK_EPOCH`.
64+
65+
Note that for the pure EIP-7549 networks, we don't apply `upgrade_to_eip7549` since it starts with EIP-7549 version logic.
66+
67+
### Upgrading the state
68+
69+
If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) == EIP7549_FORK_EPOCH`,
70+
an irregular state change is made to upgrade to EIP-7549.
71+
72+
```python
73+
def upgrade_to_eip7549(pre: capella.BeaconState) -> BeaconState:
74+
epoch = capella.get_current_epoch(pre)
75+
latest_execution_payload_header = ExecutionPayloadHeader(
76+
parent_hash=pre.latest_execution_payload_header.parent_hash,
77+
fee_recipient=pre.latest_execution_payload_header.fee_recipient,
78+
state_root=pre.latest_execution_payload_header.state_root,
79+
receipts_root=pre.latest_execution_payload_header.receipts_root,
80+
logs_bloom=pre.latest_execution_payload_header.logs_bloom,
81+
prev_randao=pre.latest_execution_payload_header.prev_randao,
82+
block_number=pre.latest_execution_payload_header.block_number,
83+
gas_limit=pre.latest_execution_payload_header.gas_limit,
84+
gas_used=pre.latest_execution_payload_header.gas_used,
85+
timestamp=pre.latest_execution_payload_header.timestamp,
86+
extra_data=pre.latest_execution_payload_header.extra_data,
87+
base_fee_per_gas=pre.latest_execution_payload_header.base_fee_per_gas,
88+
block_hash=pre.latest_execution_payload_header.block_hash,
89+
transactions_root=pre.latest_execution_payload_header.transactions_root,
90+
withdrawals_root=pre.latest_execution_payload_header.withdrawals_root,
91+
)
92+
post = BeaconState(
93+
# Versioning
94+
genesis_time=pre.genesis_time,
95+
genesis_validators_root=pre.genesis_validators_root,
96+
slot=pre.slot,
97+
fork=Fork(
98+
previous_version=pre.fork.current_version,
99+
current_version=EIP7549_FORK_VERSION, # [Modified in EIP-7549]
100+
epoch=epoch,
101+
),
102+
# History
103+
latest_block_header=pre.latest_block_header,
104+
block_roots=pre.block_roots,
105+
state_roots=pre.state_roots,
106+
historical_roots=pre.historical_roots,
107+
# Eth1
108+
eth1_data=pre.eth1_data,
109+
eth1_data_votes=pre.eth1_data_votes,
110+
eth1_deposit_index=pre.eth1_deposit_index,
111+
# Registry
112+
validators=pre.validators,
113+
balances=pre.balances,
114+
# Randomness
115+
randao_mixes=pre.randao_mixes,
116+
# Slashings
117+
slashings=pre.slashings,
118+
# Participation
119+
previous_epoch_participation=pre.previous_epoch_participation,
120+
current_epoch_participation=pre.current_epoch_participation,
121+
# Finality
122+
justification_bits=pre.justification_bits,
123+
previous_justified_checkpoint=pre.previous_justified_checkpoint,
124+
current_justified_checkpoint=pre.current_justified_checkpoint,
125+
finalized_checkpoint=pre.finalized_checkpoint,
126+
# Inactivity
127+
inactivity_scores=pre.inactivity_scores,
128+
# Sync
129+
current_sync_committee=pre.current_sync_committee,
130+
next_sync_committee=pre.next_sync_committee,
131+
# Execution-layer
132+
latest_execution_payload_header=latest_execution_payload_header,
133+
# Withdrawals
134+
next_withdrawal_index=pre.next_withdrawal_index,
135+
next_withdrawal_validator_index=pre.next_withdrawal_validator_index,
136+
# Deep history valid from Capella onwards
137+
historical_summaries=pre.historical_summaries,
138+
)
139+
140+
return post
141+
```

specs/_features/eip7549/validator.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- [Modifications in EIP-7549](#modifications-in-eip-7549)
1010
- [Block proposal](#block-proposal)
1111
- [Constructing the `BeaconBlockBody`](#constructing-the-beaconblockbody)
12+
- [Attester slashings](#attester-slashings)
1213
- [Attestations](#attestations)
1314
- [Attesting](#attesting)
1415
- [Construct attestation](#construct-attestation)
@@ -24,14 +25,18 @@
2425

2526
#### Constructing the `BeaconBlockBody`
2627

28+
##### Attester slashings
29+
30+
Changed the max attestations size to `MAX_ATTESTER_SLASHINGS_EIP7549`.
31+
2732
##### Attestations
2833

2934
The network attestation aggregates contain only the assigned committee attestations.
3035
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.
3136
The proposer should run the following function to construct an on chain final aggregate form a list of network aggregates with equal `AttestationData`:
3237

3338
```python
34-
def compute_on_chain_aggregate(network_aggregates: List[Attestation]) -> Attestation:
39+
def compute_on_chain_aggregate(network_aggregates: Sequence[Attestation]) -> Attestation:
3540
aggregates = sorted(network_aggregates, key=lambda a: get_committee_indices(a.committee_bits)[0])
3641

3742
data = aggregates[0].data

0 commit comments

Comments
 (0)