Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/dev' into confirmation_rule
Browse files Browse the repository at this point in the history
  • Loading branch information
saltiniroberto committed May 4, 2023
2 parents 9ccf48b + 0575175 commit b8ac374
Show file tree
Hide file tree
Showing 46 changed files with 1,340 additions and 89 deletions.
38 changes: 27 additions & 11 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ commands:
jobs:
checkout_specs:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
# Restore git repo at point close to target branch/revision, to speed up checkout
Expand All @@ -80,7 +80,7 @@ jobs:
- ~/specs-repo
install_pyspec_test:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- restore_cache:
Expand All @@ -92,7 +92,7 @@ jobs:
- save_pyspec_cached_venv
test-phase0:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- restore_cache:
Expand All @@ -105,7 +105,7 @@ jobs:
path: tests/core/pyspec/test-reports
test-altair:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- restore_cache:
Expand All @@ -118,7 +118,7 @@ jobs:
path: tests/core/pyspec/test-reports
test-bellatrix:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- restore_cache:
Expand All @@ -131,7 +131,7 @@ jobs:
path: tests/core/pyspec/test-reports
test-capella:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- restore_cache:
Expand All @@ -144,7 +144,7 @@ jobs:
path: tests/core/pyspec/test-reports
test-deneb:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- restore_cache:
Expand All @@ -155,6 +155,19 @@ jobs:
command: make citest fork=deneb
- store_test_results:
path: tests/core/pyspec/test-reports
test-eip6110:
docker:
- image: circleci/python:3.8
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=eip6110
- store_test_results:
path: tests/core/pyspec/test-reports
table_of_contents:
docker:
- image: circleci/node:10.16.3
Expand All @@ -166,7 +179,7 @@ jobs:
command: sudo npm install -g doctoc@2 && make check_toc
codespell:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- checkout
Expand All @@ -175,7 +188,7 @@ jobs:
command: pip install 'codespell<3.0.0,>=2.0.0' --user && make codespell
lint:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- restore_cache:
Expand Down Expand Up @@ -231,7 +244,7 @@ jobs:
- /nix
install_deposit_contract_web3_tester:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- restore_cache:
Expand All @@ -243,7 +256,7 @@ jobs:
- save_deposit_contract_tester_cached_venv
test_deposit_contract_web3_tests:
docker:
- image: circleci/python:3.8
- image: circleci/python:3.9
working_directory: ~/specs-repo
steps:
- restore_cache:
Expand Down Expand Up @@ -275,6 +288,9 @@ workflows:
- test-deneb:
requires:
- install_pyspec_test
- test-eip6110:
requires:
- install_pyspec_test
- table_of_contents
- codespell
- lint:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
needs: [preclear,lint,codespell,table_of_contents]
strategy:
matrix:
version: ["phase0", "altair", "bellatrix", "capella", "deneb"]
version: ["phase0", "altair", "bellatrix", "capella", "deneb", "eip6110"]
steps:
- name: Checkout this repo
uses: actions/checkout@v3.2.0
Expand Down
5 changes: 3 additions & 2 deletions configs/mainnet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,9 @@ CAPELLA_FORK_EPOCH: 194048 # April 12, 2023, 10:27:35pm UTC
# Deneb
DENEB_FORK_VERSION: 0x04000000
DENEB_FORK_EPOCH: 18446744073709551615


# EIP6110
EIP6110_FORK_VERSION: 0x05000000 # temporary stub
EIP6110_FORK_EPOCH: 18446744073709551615


# Time parameters
Expand Down
3 changes: 3 additions & 0 deletions configs/minimal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ CAPELLA_FORK_EPOCH: 18446744073709551615
# DENEB
DENEB_FORK_VERSION: 0x04000001
DENEB_FORK_EPOCH: 18446744073709551615
# EIP6110
EIP6110_FORK_VERSION: 0x05000001
EIP6110_FORK_EPOCH: 18446744073709551615


# Time parameters
Expand Down
6 changes: 6 additions & 0 deletions presets/mainnet/eip6110.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Mainnet preset - EIP6110

# Execution
# ---------------------------------------------------------------
# 2**13 (= 8192) receipts
MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 8192
6 changes: 6 additions & 0 deletions presets/minimal/eip6110.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Minimal preset - EIP6110

# Execution
# ---------------------------------------------------------------
# [customized]
MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD: 4
12 changes: 8 additions & 4 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,13 +671,13 @@ def hardcoded_custom_type_dep_constants(cls, spec_object) -> str:
#
# EIP6110SpecBuilder
#
class EIP6110SpecBuilder(CapellaSpecBuilder):
class EIP6110SpecBuilder(DenebSpecBuilder):
fork: str = EIP6110

@classmethod
def imports(cls, preset_name: str):
return super().imports(preset_name) + f'''
from eth2spec.capella import {preset_name} as capella
from eth2spec.deneb import {preset_name} as deneb
'''


Expand Down Expand Up @@ -1023,7 +1023,7 @@ def finalize_options(self):
specs/capella/validator.md
specs/capella/p2p-interface.md
"""
if self.spec_fork == DENEB:
if self.spec_fork in (DENEB, EIP6110):
self.md_doc_paths += """
specs/deneb/light-client/fork.md
specs/deneb/light-client/full-node.md
Expand All @@ -1038,6 +1038,10 @@ def finalize_options(self):
"""
if self.spec_fork == EIP6110:
self.md_doc_paths += """
specs/_features/eip6110/light-client/fork.md
specs/_features/eip6110/light-client/full-node.md
specs/_features/eip6110/light-client/p2p-interface.md
specs/_features/eip6110/light-client/sync-protocol.md
specs/_features/eip6110/beacon-chain.md
specs/_features/eip6110/fork.md
"""
Expand Down Expand Up @@ -1177,7 +1181,7 @@ def run(self):
packages=find_packages(where='tests/core/pyspec') + ['configs', 'specs'],
py_modules=["eth2spec"],
cmdclass=commands,
python_requires=">=3.8, <4",
python_requires=">=3.9, <4",
extras_require={
"test": ["pytest>=4.4", "pytest-cov", "pytest-xdist"],
"lint": ["flake8==5.0.4", "mypy==0.981", "pylint==2.15.3"],
Expand Down
26 changes: 15 additions & 11 deletions specs/_features/eip6110/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
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 [Capella](../../capella/beacon-chain.md) and is under active development.
*Note:* This specification is built upon [Deneb](../../deneb/beacon-chain.md) and is under active development.

## Constants

Expand Down Expand Up @@ -91,7 +91,8 @@ class ExecutionPayload(Container):
block_hash: Hash32
transactions: List[Transaction, MAX_TRANSACTIONS_PER_PAYLOAD]
withdrawals: List[Withdrawal, MAX_WITHDRAWALS_PER_PAYLOAD]
deposit_receipts: List[DepositReceipt, MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD] # [New in EIP-6110]
excess_data_gas: uint256
deposit_receipts: List[DepositReceipt, MAX_DEPOSIT_RECEIPTS_PER_PAYLOAD] # [New in EIP6110]
```

#### `ExecutionPayloadHeader`
Expand All @@ -115,7 +116,8 @@ class ExecutionPayloadHeader(Container):
block_hash: Hash32
transactions_root: Root
withdrawals_root: Root
deposit_receipts_root: Root # [New in EIP-6110]
excess_data_gas: uint256
deposit_receipts_root: Root # [New in EIP6110]
```

#### `BeaconState`
Expand Down Expand Up @@ -157,13 +159,13 @@ class BeaconState(Container):
current_sync_committee: SyncCommittee
next_sync_committee: SyncCommittee
# Execution
latest_execution_payload_header: ExecutionPayloadHeader
latest_execution_payload_header: ExecutionPayloadHeader # [Modified in 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 EIP-6110]
# [New in EIP6110]
deposit_receipts_start_index: uint64
```

Expand All @@ -176,11 +178,12 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None:
process_block_header(state, block)
if is_execution_enabled(state, block.body):
process_withdrawals(state, block.body.execution_payload)
process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [Modified in EIP-6110]
process_execution_payload(state, block.body.execution_payload, EXECUTION_ENGINE) # [Modified in EIP6110]
process_randao(state, block.body)
process_eth1_data(state, block.body)
process_operations(state, block.body) # [Modified in EIP-6110]
process_operations(state, block.body) # [Modified in EIP6110]
process_sync_aggregate(state, block.body.sync_aggregate)
process_blob_kzg_commitments(state, block.body)
```

#### Modified `process_operations`
Expand All @@ -189,7 +192,7 @@ def process_block(state: BeaconState, block: BeaconBlock) -> None:

```python
def process_operations(state: BeaconState, body: BeaconBlockBody) -> None:
# [Modified in EIP-6110]
# [Modified in 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:
Expand All @@ -204,11 +207,11 @@ 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.deposits, process_deposit) # [Modified in EIP-6110]
for_ops(body.deposits, process_deposit)
for_ops(body.voluntary_exits, process_voluntary_exit)
for_ops(body.bls_to_execution_changes, process_bls_to_execution_change)

# [New in EIP-6110]
# [New in EIP6110]
if is_execution_enabled(state, body):
for_ops(body.execution_payload.deposit_receipts, process_deposit_receipt)
```
Expand Down Expand Up @@ -262,7 +265,8 @@ def process_execution_payload(state: BeaconState, payload: ExecutionPayload, exe
block_hash=payload.block_hash,
transactions_root=hash_tree_root(payload.transactions),
withdrawals_root=hash_tree_root(payload.withdrawals),
deposit_receipts_root=hash_tree_root(payload.deposit_receipts), # [New in EIP-6110]
excess_data_gas=payload.excess_data_gas,
deposit_receipts_root=hash_tree_root(payload.deposit_receipts), # [New in EIP6110]
)
```

Expand Down
9 changes: 6 additions & 3 deletions specs/_features/eip6110/fork.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ def compute_fork_version(epoch: Epoch) -> Version:
Return the fork version at the given ``epoch``.
"""
if epoch >= EIP6110_FORK_EPOCH:
return EIP6110_FORK_EPOCH
return EIP6110_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:
Expand All @@ -68,8 +70,8 @@ If `state.slot % SLOTS_PER_EPOCH == 0` and `compute_epoch_at_slot(state.slot) ==
an irregular state change is made to upgrade to EIP-6110.

```python
def upgrade_to_eip6110(pre: capella.BeaconState) -> BeaconState:
epoch = capella.get_current_epoch(pre)
def upgrade_to_eip6110(pre: deneb.BeaconState) -> BeaconState:
epoch = deneb.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,
Expand All @@ -86,6 +88,7 @@ def upgrade_to_eip6110(pre: capella.BeaconState) -> BeaconState:
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,
excess_data_gas=uint256(0),
deposit_receipts_root=Root(), # [New in EIP-6110]
)
post = BeaconState(
Expand Down
Loading

0 comments on commit b8ac374

Please sign in to comment.