mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-03 14:24:24 +00:00
Merge branch 'withdrawals_without_queues' of github-potuz:potuz/consensus-specs into withdrawals_without_queues
This commit is contained in:
commit
6179085b7e
@ -46,7 +46,8 @@ def verify_post_state(state, spec, expected_withdrawals,
|
||||
assert state.balances[index] > spec.MAX_EFFECTIVE_BALANCE
|
||||
|
||||
|
||||
def run_withdrawals_processing(spec, state, execution_payload, num_expected_withdrawals=None, valid=True):
|
||||
def run_withdrawals_processing(spec, state, execution_payload, num_expected_withdrawals=None,
|
||||
fully_withdrawable_indices=None, partial_withdrawals_indices=None, valid=True):
|
||||
"""
|
||||
Run ``process_execution_payload``, yielding:
|
||||
- pre-state ('pre')
|
||||
@ -79,6 +80,9 @@ def run_withdrawals_processing(spec, state, execution_payload, num_expected_with
|
||||
elif len(expected_withdrawals) > spec.MAX_WITHDRAWALS_PER_PAYLOAD:
|
||||
raise ValueError('len(expected_withdrawals) should not be greater than MAX_WITHDRAWALS_PER_PAYLOAD')
|
||||
|
||||
if fully_withdrawable_indices is not None or partial_withdrawals_indices is not None:
|
||||
verify_post_state(state, spec, expected_withdrawals, fully_withdrawable_indices, partial_withdrawals_indices)
|
||||
|
||||
return expected_withdrawals
|
||||
|
||||
|
||||
@ -104,9 +108,10 @@ def test_success_one_full_withdrawal(spec, state):
|
||||
next_slot(spec, state)
|
||||
execution_payload = build_empty_execution_payload(spec, state)
|
||||
|
||||
expected_withdrawals = yield from run_withdrawals_processing(spec, state, execution_payload)
|
||||
|
||||
verify_post_state(state, spec, expected_withdrawals, fully_withdrawable_indices, partial_withdrawals_indices)
|
||||
yield from run_withdrawals_processing(
|
||||
spec, state, execution_payload,
|
||||
fully_withdrawable_indices=fully_withdrawable_indices,
|
||||
partial_withdrawals_indices=partial_withdrawals_indices)
|
||||
|
||||
|
||||
@with_capella_and_later
|
||||
@ -122,9 +127,11 @@ def test_success_one_partial_withdrawal(spec, state):
|
||||
next_slot(spec, state)
|
||||
execution_payload = build_empty_execution_payload(spec, state)
|
||||
|
||||
expected_withdrawals = yield from run_withdrawals_processing(spec, state, execution_payload)
|
||||
|
||||
verify_post_state(state, spec, expected_withdrawals, fully_withdrawable_indices, partial_withdrawals_indices)
|
||||
yield from run_withdrawals_processing(
|
||||
spec, state, execution_payload,
|
||||
fully_withdrawable_indices=fully_withdrawable_indices,
|
||||
partial_withdrawals_indices=partial_withdrawals_indices
|
||||
)
|
||||
|
||||
|
||||
@with_capella_and_later
|
||||
@ -139,9 +146,10 @@ def test_success_max_per_slot(spec, state):
|
||||
next_slot(spec, state)
|
||||
execution_payload = build_empty_execution_payload(spec, state)
|
||||
|
||||
expected_withdrawals = yield from run_withdrawals_processing(spec, state, execution_payload)
|
||||
|
||||
verify_post_state(state, spec, expected_withdrawals, fully_withdrawable_indices, partial_withdrawals_indices)
|
||||
yield from run_withdrawals_processing(
|
||||
spec, state, execution_payload,
|
||||
fully_withdrawable_indices=fully_withdrawable_indices,
|
||||
partial_withdrawals_indices=partial_withdrawals_indices)
|
||||
|
||||
|
||||
@with_capella_and_later
|
||||
@ -153,9 +161,10 @@ def test_success_all_fully_withdrawable(spec, state):
|
||||
next_slot(spec, state)
|
||||
execution_payload = build_empty_execution_payload(spec, state)
|
||||
|
||||
expected_withdrawals = yield from run_withdrawals_processing(spec, state, execution_payload)
|
||||
|
||||
verify_post_state(state, spec, expected_withdrawals, fully_withdrawable_indices, partial_withdrawals_indices)
|
||||
yield from run_withdrawals_processing(
|
||||
spec, state, execution_payload,
|
||||
fully_withdrawable_indices=fully_withdrawable_indices,
|
||||
partial_withdrawals_indices=partial_withdrawals_indices)
|
||||
|
||||
|
||||
@with_capella_and_later
|
||||
@ -167,9 +176,10 @@ def test_success_all_partially_withdrawable(spec, state):
|
||||
next_slot(spec, state)
|
||||
execution_payload = build_empty_execution_payload(spec, state)
|
||||
|
||||
expected_withdrawals = yield from run_withdrawals_processing(spec, state, execution_payload)
|
||||
|
||||
verify_post_state(state, spec, expected_withdrawals, fully_withdrawable_indices, partial_withdrawals_indices)
|
||||
yield from run_withdrawals_processing(
|
||||
spec, state, execution_payload,
|
||||
fully_withdrawable_indices=fully_withdrawable_indices,
|
||||
partial_withdrawals_indices=partial_withdrawals_indices)
|
||||
|
||||
|
||||
#
|
||||
|
@ -141,7 +141,7 @@ def test_exit_and_bls_change(spec, state):
|
||||
assert spec.is_fully_withdrawable_validator(validator, balance, validator.withdrawable_epoch)
|
||||
|
||||
|
||||
def _valid_withdrawal(spec, state):
|
||||
def _perform_valid_withdrawal(spec, state):
|
||||
fully_withdrawable_indices, partial_withdrawals_indices = prepare_expected_withdrawals(
|
||||
spec, state, num_partial_withdrawals=spec.MAX_WITHDRAWALS_PER_PAYLOAD * 4,
|
||||
num_full_withdrawals=spec.MAX_WITHDRAWALS_PER_PAYLOAD * 4)
|
||||
@ -173,7 +173,7 @@ def _valid_withdrawal(spec, state):
|
||||
@with_capella_and_later
|
||||
@spec_state_test
|
||||
def test_withdrawal_success_two_blocks(spec, state):
|
||||
pre_state, signed_block_1, pre_next_withdrawal_index = _valid_withdrawal(spec, state)
|
||||
pre_state, signed_block_1, pre_next_withdrawal_index = _perform_valid_withdrawal(spec, state)
|
||||
|
||||
yield 'pre', pre_state
|
||||
|
||||
@ -190,7 +190,7 @@ def test_withdrawal_success_two_blocks(spec, state):
|
||||
@with_capella_and_later
|
||||
@spec_state_test
|
||||
def test_withdrawal_fail_second_block_payload_isnt_compatible(spec, state):
|
||||
_valid_withdrawal(spec, state)
|
||||
_perform_valid_withdrawal(spec, state)
|
||||
|
||||
# Block 2
|
||||
block = build_empty_block_for_next_slot(spec, state)
|
||||
|
Loading…
x
Reference in New Issue
Block a user