Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions specs/fulu/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
- [Block processing](#block-processing)
- [Execution payload](#execution-payload)
- [Modified `process_execution_payload`](#modified-process_execution_payload)
- [Operations](#operations)
- [Modified `process_operations`](#modified-process_operations)
- [Containers](#containers)
- [Extended Containers](#extended-containers)
- [`BeaconState`](#beaconstate)
Expand Down Expand Up @@ -57,6 +59,18 @@ SHOULD be sorted by epoch in ascending order. The blob schedule MAY be empty.

### Block processing

```python
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)
process_randao(state, block.body)
process_eth1_data(state, block.body)
# [Modified in Fulu]
process_operations(state, block.body)
process_sync_aggregate(state, block.body.sync_aggregate)
```

#### Execution payload

##### Modified `process_execution_payload`
Expand Down Expand Up @@ -117,6 +131,36 @@ def process_execution_payload(
)
```

#### Operations

##### Modified `process_operations`

*Note*: The function `process_operations` is modified to remove support for the
former deposit mechanism.

```python
def process_operations(state: BeaconState, body: BeaconBlockBody) -> None:
# [Modified in Fulu]
assert len(body.deposits) == 0
if state.deposit_requests_start_index != UNSET_DEPOSIT_REQUESTS_START_INDEX:
assert state.eth1_data.deposit_count >= state.deposit_requests_start_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)
# [Modified in Fulu]
# Removed `process_deposit`
for_ops(body.voluntary_exits, process_voluntary_exit)
for_ops(body.bls_to_execution_changes, process_bls_to_execution_change)
for_ops(body.execution_requests.deposits, process_deposit_request)
for_ops(body.execution_requests.withdrawals, process_withdrawal_request)
for_ops(body.execution_requests.consolidations, process_consolidation_request)
```

## Containers

### Extended Containers
Expand Down
14 changes: 3 additions & 11 deletions specs/gloas/beacon-chain.md
Original file line number Diff line number Diff line change
Expand Up @@ -1022,16 +1022,9 @@ calls to `process_deposit_request`, `process_withdrawal_request`, and

```python
def process_operations(state: BeaconState, body: BeaconBlockBody) -> None:
# Disable former deposit mechanism once all prior deposits are processed
eth1_deposit_index_limit = min(
state.eth1_data.deposit_count, state.deposit_requests_start_index
)
if state.eth1_deposit_index < eth1_deposit_index_limit:
assert len(body.deposits) == min(
MAX_DEPOSITS, eth1_deposit_index_limit - state.eth1_deposit_index
)
else:
assert len(body.deposits) == 0
assert len(body.deposits) == 0
if state.deposit_requests_start_index != UNSET_DEPOSIT_REQUESTS_START_INDEX:
assert state.eth1_data.deposit_count >= state.deposit_requests_start_index

def for_ops(operations: Sequence[Any], fn: Callable[[BeaconState, Any], None]) -> None:
for operation in operations:
Expand All @@ -1042,7 +1035,6 @@ def process_operations(state: BeaconState, body: BeaconBlockBody) -> None:
for_ops(body.attester_slashings, process_attester_slashing)
# [Modified in Gloas:EIP7732]
for_ops(body.attestations, process_attestation)
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)
# [Modified in Gloas:EIP7732]
Expand Down
12 changes: 4 additions & 8 deletions tests/core/pyspec/eth2spec/test/capella/sanity/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,7 @@
build_empty_block_for_next_slot,
)
from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change
from eth2spec.test.helpers.constants import (
CAPELLA,
GLOAS,
MINIMAL,
)
from eth2spec.test.helpers.constants import CAPELLA, FULU, GLOAS, MINIMAL
from eth2spec.test.helpers.deposits import (
prepare_state_and_deposit,
)
Expand Down Expand Up @@ -92,7 +88,7 @@ def test_bls_change(spec, state):
assert post_credentials[12:] == signed_address_change.message.to_execution_address


@with_capella_and_later
@with_all_phases_from_to(CAPELLA, FULU)
@spec_state_test
def test_deposit_and_bls_change(spec, state):
initial_registry_len = len(state.validators)
Expand Down Expand Up @@ -435,7 +431,7 @@ def test_invalid_withdrawal_fail_second_block_payload_isnt_compatible(spec, stat
#


@with_capella_and_later
@with_all_phases_from_to(CAPELLA, FULU)
@spec_state_test
def test_top_up_and_partial_withdrawable_validator(spec, state):
next_withdrawal_validator_index = 0
Expand Down Expand Up @@ -477,7 +473,7 @@ def test_top_up_and_partial_withdrawable_validator(spec, state):
assert spec.is_partially_withdrawable_validator(validator, balance)


@with_capella_and_later
@with_all_phases_from_to(CAPELLA, FULU)
@spec_state_test
def test_top_up_to_fully_withdrawn_validator(spec, state):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
from eth2spec.test.context import spec_state_test, with_fulu_and_later
from eth2spec.test.helpers.deposits import prepare_state_and_deposit, run_deposit_processing


@with_fulu_and_later
@spec_state_test
def test_invalid_old_style_deposit_rejected(spec, state):
validator_index = len(state.validators)
amount = spec.MAX_EFFECTIVE_BALANCE
deposit = prepare_state_and_deposit(spec, state, validator_index, amount, signed=True)

yield from run_deposit_processing(spec, state, deposit, validator_index, valid=False)
9 changes: 9 additions & 0 deletions tests/core/pyspec/eth2spec/test/helpers/fork_transition.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
get_next_fork_transition,
is_post_bellatrix,
is_post_electra,
is_post_fulu,
is_post_gloas,
)
from eth2spec.test.helpers.proposer_slashings import (
Expand Down Expand Up @@ -384,6 +385,14 @@ def run_transition_with_operation(
)
operation_dict = {"attester_slashings": [attester_slashing]}
elif operation_type == OperationType.DEPOSIT:
# [Modified for Fulu]
# Old deposits mechanism is not supported in Fulu and later
if is_post_fulu(post_spec):
yield "pre", state
yield "blocks", []
yield "post", state
return

# create a new deposit
selected_validator_index = len(state.validators)
amount = spec.MAX_EFFECTIVE_BALANCE
Expand Down
14 changes: 10 additions & 4 deletions tests/core/pyspec/eth2spec/test/helpers/multi_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
)
from eth2spec.test.helpers.bls_to_execution_changes import get_signed_address_change
from eth2spec.test.helpers.deposits import build_deposit, deposit_from_context
from eth2spec.test.helpers.forks import is_post_electra
from eth2spec.test.helpers.forks import is_post_electra, is_post_fulu
from eth2spec.test.helpers.keys import privkeys, pubkeys
from eth2spec.test.helpers.proposer_slashings import get_valid_proposer_slashing
from eth2spec.test.helpers.state import (
Expand Down Expand Up @@ -244,8 +244,12 @@ def build_random_block_from_state_for_next_slot(spec, state, rng=None, deposits=
]
block.body.attester_slashings = get_random_attester_slashings(spec, state, rng, slashed_indices)
block.body.attestations = get_random_attestations(spec, state, rng)
if deposits:
# [Modified for Fulu]
# Old deposits mechanism is not supported in Fulu and later
if deposits and not is_post_fulu(spec):
block.body.deposits = deposits
else:
block.body.deposits = []

# cannot include to be slashed indices as exits
slashed_indices = set(
Expand All @@ -268,8 +272,10 @@ def run_test_full_random_operations(spec, state, rng=None):
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for exit
state.slot += spec.config.SHARD_COMMITTEE_PERIOD * spec.SLOTS_PER_EPOCH

# prepare state for deposits before building block
deposits = prepare_state_and_get_random_deposits(spec, state, rng)
# prepare state for deposits before building block (not supported in Fulu and later)
deposits = None
if not is_post_fulu(spec):
deposits = prepare_state_and_get_random_deposits(spec, state, rng)
block = build_random_block_from_state_for_next_slot(spec, state, rng, deposits=deposits)

yield "pre", state
Expand Down
11 changes: 6 additions & 5 deletions tests/core/pyspec/eth2spec/test/phase0/sanity/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
spec_state_test,
spec_test,
with_all_phases,
with_all_phases_from_to,
with_custom_state,
with_phases,
with_presets,
Expand All @@ -26,7 +27,7 @@
sign_block,
transition_unsigned_block,
)
from eth2spec.test.helpers.constants import MINIMAL, PHASE0
from eth2spec.test.helpers.constants import FULU, MINIMAL, PHASE0
from eth2spec.test.helpers.deposits import prepare_state_and_deposit
from eth2spec.test.helpers.execution_payload import (
build_empty_execution_payload,
Expand Down Expand Up @@ -793,7 +794,7 @@ def test_high_proposer_index(spec, state):
next_slot(spec, state)


@with_all_phases
@with_all_phases_from_to(PHASE0, FULU)
@spec_state_test
def test_invalid_only_increase_deposit_count(spec, state):
# Make the state expect a deposit, then don't provide it.
Expand All @@ -807,7 +808,7 @@ def test_invalid_only_increase_deposit_count(spec, state):
yield "post", None


@with_all_phases
@with_all_phases_from_to(PHASE0, FULU)
@spec_state_test
def test_deposit_in_block(spec, state):
initial_registry_len = len(state.validators)
Expand Down Expand Up @@ -837,7 +838,7 @@ def test_deposit_in_block(spec, state):
assert state.validators[validator_index].pubkey == pubkeys[validator_index]


@with_all_phases
@with_all_phases_from_to(PHASE0, FULU)
@spec_state_test
def test_invalid_duplicate_deposit_same_block(spec, state):
validator_index = len(state.validators)
Expand All @@ -858,7 +859,7 @@ def test_invalid_duplicate_deposit_same_block(spec, state):
yield "post", None


@with_all_phases
@with_all_phases_from_to(PHASE0, FULU)
@spec_state_test
def test_deposit_top_up(spec, state):
validator_index = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
build_randomized_execution_payload,
compute_el_block_hash_for_block,
)
from eth2spec.test.helpers.forks import is_post_fulu
from eth2spec.test.helpers.inactivity_scores import (
randomize_inactivity_scores,
)
Expand Down Expand Up @@ -47,6 +48,10 @@ def _randomize_deposit_state(spec, state, stats):
This function randomizes the ``state`` in a way that can signal downstream to
the block constructors how they should (or should not) make some randomized deposits.
"""
# Old deposits mechanism is not supported in Fulu and later
if is_post_fulu(spec):
return {"deposits": []}

rng = Random(999)
block_count = stats.get("block_count", 0)
deposits = []
Expand Down
Loading