Fix capella random & fork
This commit is contained in:
parent
03ced9c263
commit
b90436c988
2
Makefile
2
Makefile
|
@ -64,6 +64,8 @@ partial_clean:
|
||||||
rm -rf $(ETH2SPEC_MODULE_DIR)/phase0
|
rm -rf $(ETH2SPEC_MODULE_DIR)/phase0
|
||||||
rm -rf $(ETH2SPEC_MODULE_DIR)/altair
|
rm -rf $(ETH2SPEC_MODULE_DIR)/altair
|
||||||
rm -rf $(ETH2SPEC_MODULE_DIR)/bellatrix
|
rm -rf $(ETH2SPEC_MODULE_DIR)/bellatrix
|
||||||
|
rm -rf $(ETH2SPEC_MODULE_DIR)/capella
|
||||||
|
rm -rf $(ETH2SPEC_MODULE_DIR)/eip4844
|
||||||
rm -rf $(COV_HTML_OUT_DIR)
|
rm -rf $(COV_HTML_OUT_DIR)
|
||||||
rm -rf $(TEST_REPORT_DIR)
|
rm -rf $(TEST_REPORT_DIR)
|
||||||
rm -rf eth2spec.egg-info dist build
|
rm -rf eth2spec.egg-info dist build
|
||||||
|
|
|
@ -70,6 +70,23 @@ In particular, the outer `state_transition` function defined in the Phase 0 docu
|
||||||
```python
|
```python
|
||||||
def upgrade_to_capella(pre: bellatrix.BeaconState) -> BeaconState:
|
def upgrade_to_capella(pre: bellatrix.BeaconState) -> BeaconState:
|
||||||
epoch = bellatrix.get_current_epoch(pre)
|
epoch = bellatrix.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=Root(), # [New in Capella]
|
||||||
|
)
|
||||||
post = BeaconState(
|
post = BeaconState(
|
||||||
# Versioning
|
# Versioning
|
||||||
genesis_time=pre.genesis_time,
|
genesis_time=pre.genesis_time,
|
||||||
|
@ -110,7 +127,7 @@ def upgrade_to_capella(pre: bellatrix.BeaconState) -> BeaconState:
|
||||||
current_sync_committee=pre.current_sync_committee,
|
current_sync_committee=pre.current_sync_committee,
|
||||||
next_sync_committee=pre.next_sync_committee,
|
next_sync_committee=pre.next_sync_committee,
|
||||||
# Execution-layer
|
# Execution-layer
|
||||||
latest_execution_payload_header=pre.latest_execution_payload_header,
|
latest_execution_payload_header=latest_execution_payload_header,
|
||||||
# Withdrawals
|
# Withdrawals
|
||||||
withdrawal_queue=[],
|
withdrawal_queue=[],
|
||||||
next_withdrawal_index=WithdrawalIndex(0),
|
next_withdrawal_index=WithdrawalIndex(0),
|
||||||
|
|
|
@ -0,0 +1,438 @@
|
||||||
|
"""
|
||||||
|
This module is generated from the ``random`` test generator.
|
||||||
|
Please do not edit this file manually.
|
||||||
|
See the README for that generator for more information.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from eth2spec.test.helpers.constants import CAPELLA
|
||||||
|
from eth2spec.test.context import (
|
||||||
|
misc_balances_in_default_range_with_many_validators,
|
||||||
|
with_phases,
|
||||||
|
zero_activation_threshold,
|
||||||
|
only_generator,
|
||||||
|
)
|
||||||
|
from eth2spec.test.context import (
|
||||||
|
always_bls,
|
||||||
|
spec_test,
|
||||||
|
with_custom_state,
|
||||||
|
single_phase,
|
||||||
|
)
|
||||||
|
from eth2spec.test.utils.randomized_block_tests import (
|
||||||
|
run_generated_randomized_test,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_0(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:random_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'validation': 'validate_is_not_leaking', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 0, 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'random_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_1(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:random_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'validation': 'validate_is_not_leaking', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'random_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 0, 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_2(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:penultimate_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:last_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'validation': 'validate_is_not_leaking', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'penultimate_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'last_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_3(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:last_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:last_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'validation': 'validate_is_not_leaking', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'last_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'last_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_4(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:last_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:penultimate_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'validation': 'validate_is_not_leaking', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'last_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'penultimate_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_5(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:random_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:random_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'validation': 'validate_is_not_leaking', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'random_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'random_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_6(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:penultimate_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:penultimate_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'validation': 'validate_is_not_leaking', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'penultimate_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'penultimate_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_7(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'validation': 'validate_is_not_leaking', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 0, 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 0, 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_8(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:epochs_until_leak,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:random_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'epochs_to_skip': 'epochs_until_leak', 'validation': 'validate_is_leaking', 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 0, 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'random_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_9(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:epochs_until_leak,slots:0,with-block:no_block
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:random_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'epochs_to_skip': 'epochs_until_leak', 'validation': 'validate_is_leaking', 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'random_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 0, 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_10(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:epochs_until_leak,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:penultimate_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:last_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'epochs_to_skip': 'epochs_until_leak', 'validation': 'validate_is_leaking', 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'penultimate_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'last_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_11(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:epochs_until_leak,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:last_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:last_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'epochs_to_skip': 'epochs_until_leak', 'validation': 'validate_is_leaking', 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'last_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'last_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_12(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:epochs_until_leak,slots:0,with-block:no_block
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:last_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:penultimate_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'epochs_to_skip': 'epochs_until_leak', 'validation': 'validate_is_leaking', 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'last_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'penultimate_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_13(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:epochs_until_leak,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:random_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:random_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'epochs_to_skip': 'epochs_until_leak', 'validation': 'validate_is_leaking', 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'random_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'random_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_14(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:epochs_until_leak,slots:0,with-block:no_block
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:penultimate_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:penultimate_slot_in_epoch,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'epochs_to_skip': 'epochs_until_leak', 'validation': 'validate_is_leaking', 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'penultimate_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 0, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 'penultimate_slot_in_epoch', 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@only_generator("randomized test for broad coverage, not point-to-point CI")
|
||||||
|
@with_phases([CAPELLA])
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=misc_balances_in_default_range_with_many_validators,
|
||||||
|
threshold_fn=zero_activation_threshold
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
|
@always_bls
|
||||||
|
def test_randomized_15(spec, state):
|
||||||
|
# scenario as high-level, informal text:
|
||||||
|
# epochs:epochs_until_leak,slots:0,with-block:no_block
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
# epochs:1,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:no_block
|
||||||
|
# epochs:0,slots:0,with-block:random_block_capella
|
||||||
|
scenario = {'transitions': [{'epochs_to_skip': 'epochs_until_leak', 'validation': 'validate_is_leaking', 'slots_to_skip': 0, 'block_producer': 'no_block'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 0, 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}, {'epochs_to_skip': 1, 'slots_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'slots_to_skip': 0, 'epochs_to_skip': 0, 'block_producer': 'no_block', 'validation': 'no_op_validation'}, {'block_producer': 'random_block_capella', 'epochs_to_skip': 0, 'slots_to_skip': 0, 'validation': 'no_op_validation'}], 'state_randomizer': 'randomize_state_capella'} # noqa: E501
|
||||||
|
yield from run_generated_randomized_test(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
scenario,
|
||||||
|
)
|
|
@ -71,6 +71,15 @@ def randomize_state_bellatrix(spec, state, stats, exit_fraction=0.1, slash_fract
|
||||||
return scenario_state
|
return scenario_state
|
||||||
|
|
||||||
|
|
||||||
|
def randomize_state_capella(spec, state, stats, exit_fraction=0.1, slash_fraction=0.1):
|
||||||
|
scenario_state = randomize_state_bellatrix(spec,
|
||||||
|
state,
|
||||||
|
stats,
|
||||||
|
exit_fraction=exit_fraction,
|
||||||
|
slash_fraction=slash_fraction)
|
||||||
|
return scenario_state
|
||||||
|
|
||||||
|
|
||||||
# epochs
|
# epochs
|
||||||
|
|
||||||
def epochs_until_leak(spec):
|
def epochs_until_leak(spec):
|
||||||
|
@ -195,6 +204,11 @@ def random_block_bellatrix(spec, state, signed_blocks, scenario_state):
|
||||||
return block
|
return block
|
||||||
|
|
||||||
|
|
||||||
|
def random_block_capella(spec, state, signed_blocks, scenario_state):
|
||||||
|
block = random_block_bellatrix(spec, state, signed_blocks, scenario_state)
|
||||||
|
return block
|
||||||
|
|
||||||
|
|
||||||
# validations
|
# validations
|
||||||
|
|
||||||
def no_op_validation(_spec, _state):
|
def no_op_validation(_spec, _state):
|
||||||
|
|
|
@ -5,6 +5,8 @@ all:
|
||||||
rm -f ../../core/pyspec/eth2spec/test/phase0/random/test_random.py
|
rm -f ../../core/pyspec/eth2spec/test/phase0/random/test_random.py
|
||||||
rm -f ../../core/pyspec/eth2spec/test/altair/random/test_random.py
|
rm -f ../../core/pyspec/eth2spec/test/altair/random/test_random.py
|
||||||
rm -f ../../core/pyspec/eth2spec/test/bellatrix/random/test_random.py
|
rm -f ../../core/pyspec/eth2spec/test/bellatrix/random/test_random.py
|
||||||
|
rm -f ../../core/pyspec/eth2spec/test/capella/random/test_random.py
|
||||||
python3 generate.py phase0 > ../../core/pyspec/eth2spec/test/phase0/random/test_random.py
|
python3 generate.py phase0 > ../../core/pyspec/eth2spec/test/phase0/random/test_random.py
|
||||||
python3 generate.py altair > ../../core/pyspec/eth2spec/test/altair/random/test_random.py
|
python3 generate.py altair > ../../core/pyspec/eth2spec/test/altair/random/test_random.py
|
||||||
python3 generate.py bellatrix > ../../core/pyspec/eth2spec/test/bellatrix/random/test_random.py
|
python3 generate.py bellatrix > ../../core/pyspec/eth2spec/test/bellatrix/random/test_random.py
|
||||||
|
python3 generate.py capella > ../../core/pyspec/eth2spec/test/capella/random/test_random.py
|
||||||
|
|
|
@ -20,9 +20,11 @@ from eth2spec.test.utils.randomized_block_tests import (
|
||||||
randomize_state,
|
randomize_state,
|
||||||
randomize_state_altair,
|
randomize_state_altair,
|
||||||
randomize_state_bellatrix,
|
randomize_state_bellatrix,
|
||||||
|
randomize_state_capella,
|
||||||
random_block,
|
random_block,
|
||||||
random_block_altair_with_cycling_sync_committee_participation,
|
random_block_altair_with_cycling_sync_committee_participation,
|
||||||
random_block_bellatrix,
|
random_block_bellatrix,
|
||||||
|
random_block_capella,
|
||||||
last_slot_in_epoch,
|
last_slot_in_epoch,
|
||||||
random_slot_in_epoch,
|
random_slot_in_epoch,
|
||||||
penultimate_slot_in_epoch,
|
penultimate_slot_in_epoch,
|
||||||
|
@ -32,7 +34,7 @@ from eth2spec.test.utils.randomized_block_tests import (
|
||||||
transition_to_leaking,
|
transition_to_leaking,
|
||||||
transition_without_leak,
|
transition_without_leak,
|
||||||
)
|
)
|
||||||
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX
|
from eth2spec.test.helpers.constants import PHASE0, ALTAIR, BELLATRIX, CAPELLA
|
||||||
|
|
||||||
|
|
||||||
# Ensure this many blocks are present in *each* randomized scenario
|
# Ensure this many blocks are present in *each* randomized scenario
|
||||||
|
@ -263,5 +265,12 @@ if __name__ == "__main__":
|
||||||
state_randomizer=randomize_state_bellatrix,
|
state_randomizer=randomize_state_bellatrix,
|
||||||
block_randomizer=random_block_bellatrix,
|
block_randomizer=random_block_bellatrix,
|
||||||
)
|
)
|
||||||
|
if CAPELLA in sys.argv:
|
||||||
|
did_generate = True
|
||||||
|
run_generate_tests_to_std_out(
|
||||||
|
CAPELLA,
|
||||||
|
state_randomizer=randomize_state_capella,
|
||||||
|
block_randomizer=random_block_capella,
|
||||||
|
)
|
||||||
if not did_generate:
|
if not did_generate:
|
||||||
warnings.warn("no phase given for test generation")
|
warnings.warn("no phase given for test generation")
|
||||||
|
|
Loading…
Reference in New Issue