Skip to content
Merged
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
40 changes: 0 additions & 40 deletions tests/core/pyspec/eth2spec/test/deneb/sanity/test_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,18 @@

from eth2spec.test.helpers.state import (
state_transition_and_sign_block,
next_epoch_via_block,
transition_to,
)
from eth2spec.test.helpers.block import (
build_empty_block_for_next_slot,
)
from eth2spec.test.context import (
DENEB,
spec_state_test,
spec_configured_state_test,
with_deneb_and_later,
with_phases,
)
from eth2spec.test.helpers.execution_payload import (
compute_el_block_hash,
get_random_tx,
)
from eth2spec.test.helpers.attestations import (
get_valid_attestation,
)
from eth2spec.test.helpers.sharding import (
get_sample_opaque_tx,
)
Expand Down Expand Up @@ -111,35 +103,3 @@ def test_invalid_exceed_max_blobs_per_block(spec, state):
@spec_state_test
def test_mix_blob_tx_and_non_blob_tx(spec, state):
yield from run_block_with_blobs(spec, state, blob_count=1, tx_count=1, non_blob_tx_count=1)


@with_phases([DENEB])
@spec_configured_state_test({
'DENEB_FORK_EPOCH': 2,
})
def test_include_attestation_from_previous_fork_with_new_range(spec, state):
# Transition to the epoch prior to the fork epoch
next_epoch_via_block(spec, state)

# Generate an attestation for slot 0 of this epoch
attestation = get_valid_attestation(spec, state, signed=True)

# Transition to second to last slot in `DENEB_FORK_EPOCH`
next_epoch_via_block(spec, state)
current_epoch = spec.get_current_epoch(state)
assert current_epoch == spec.config.DENEB_FORK_EPOCH
penultimate_slot = spec.compute_start_slot_at_epoch(current_epoch + 1) - 2
transition_to(spec, state, penultimate_slot)

# Ensure the new state is in the increased EIP-7045 slot inclusion range
assert penultimate_slot - attestation.data.slot > spec.SLOTS_PER_EPOCH

block = build_empty_block_for_next_slot(spec, state)
block.body.attestations.append(attestation)

yield 'pre', state

signed_block = state_transition_and_sign_block(spec, state, block)

yield 'blocks', [signed_block]
yield 'post', state
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,25 @@
always_bls,
with_fork_metas,
)
from eth2spec.test.helpers.attestations import (
get_valid_attestation,
)
from eth2spec.test.helpers.block import (
build_empty_block_for_next_slot,
)
from eth2spec.test.helpers.constants import (
AFTER_DENEB_PRE_POST_FORKS,
)
from eth2spec.test.helpers.state import (
next_epoch_via_block,
state_transition_and_sign_block,
transition_to,
)
from eth2spec.test.helpers.fork_transition import (
OperationType,
do_fork,
run_transition_with_operation,
transition_until_fork,
)


Expand Down Expand Up @@ -52,3 +65,38 @@ def test_transition_with_btec_right_before_fork(state, fork_epoch, spec, post_sp
operation_type=OperationType.BLS_TO_EXECUTION_CHANGE,
operation_at_slot=fork_epoch * spec.SLOTS_PER_EPOCH - 1,
)


@with_fork_metas([ForkMeta(pre_fork_name=pre, post_fork_name=post, fork_epoch=2)
for pre, post in AFTER_DENEB_PRE_POST_FORKS])
def test_transition_attestation_from_previous_fork_with_new_range(
state, fork_epoch, spec, post_spec, pre_tag, post_tag):
"""
[EIP-7045] test
"""
# Transition to the epoch prior to the fork epoch
next_epoch_via_block(spec, state)

# Generate an attestation for slot 0 of this epoch
attestation = get_valid_attestation(spec, state, signed=True)

yield 'pre', state

# Transition to the fork epoch with a block
transition_until_fork(spec, state, fork_epoch)
state, fork_block = do_fork(state, spec, post_spec, fork_epoch)
current_epoch = spec.get_current_epoch(state)
assert current_epoch == fork_epoch
# Transition to second to last slot in `fork_epoch`
penultimate_slot = post_spec.compute_start_slot_at_epoch(current_epoch + 1) - 2
transition_to(post_spec, state, penultimate_slot)

# Ensure the new state is in the increased EIP-7045 slot inclusion range
assert penultimate_slot - attestation.data.slot > post_spec.SLOTS_PER_EPOCH

block = build_empty_block_for_next_slot(post_spec, state)
block.body.attestations.append(attestation)
signed_block = state_transition_and_sign_block(post_spec, state, block)

yield 'blocks', [post_tag(fork_block), post_tag(signed_block)]
yield 'post', state