mirror of
https://github.com/status-im/eth2.0-specs.git
synced 2025-02-15 12:07:09 +00:00
Fix consolidation test_invalid_*_signature
tests
This commit is contained in:
parent
b5f22cdd6c
commit
ef9af0d85e
@ -611,9 +611,43 @@ def test_invalid_different_credentials(spec, state):
|
|||||||
|
|
||||||
|
|
||||||
@with_electra_and_later
|
@with_electra_and_later
|
||||||
@spec_state_test
|
@with_presets([MINIMAL], "need sufficient consolidation churn limit")
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=scaled_churn_balances_exceed_activation_exit_churn_limit,
|
||||||
|
threshold_fn=default_activation_threshold,
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
@always_bls
|
@always_bls
|
||||||
def test_invalid_source_signature(spec, state):
|
def test_invalid_source_signature(spec, state):
|
||||||
|
# This state has 256 validators each with 32 ETH in MINIMAL preset, 128 ETH consolidation churn
|
||||||
|
current_epoch = spec.get_current_epoch(state)
|
||||||
|
source_index = spec.get_active_validator_indices(state, current_epoch)[0]
|
||||||
|
target_index = spec.get_active_validator_indices(state, current_epoch)[1]
|
||||||
|
source_privkey = pubkey_to_privkey[state.validators[source_index].pubkey]
|
||||||
|
target_privkey = pubkey_to_privkey[state.validators[target_index].pubkey]
|
||||||
|
|
||||||
|
# Set source and target withdrawal credentials to the same eth1 credential
|
||||||
|
set_eth1_withdrawal_credential_with_balance(spec, state, source_index)
|
||||||
|
set_eth1_withdrawal_credential_with_balance(spec, state, target_index)
|
||||||
|
|
||||||
|
signed_consolidation = sign_consolidation(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
spec.Consolidation(
|
||||||
|
epoch=current_epoch, source_index=source_index, target_index=target_index
|
||||||
|
),
|
||||||
|
source_privkey,
|
||||||
|
target_privkey,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set earliest consolidation epoch to the expected exit epoch
|
||||||
|
expected_exit_epoch = spec.compute_activation_exit_epoch(current_epoch)
|
||||||
|
state.earliest_consolidation_epoch = expected_exit_epoch
|
||||||
|
consolidation_churn_limit = spec.get_consolidation_churn_limit(state)
|
||||||
|
# Set the consolidation balance to consume equal to churn limit
|
||||||
|
state.consolidation_balance_to_consume = consolidation_churn_limit
|
||||||
|
|
||||||
current_epoch = spec.get_current_epoch(state)
|
current_epoch = spec.get_current_epoch(state)
|
||||||
source_privkey = pubkey_to_privkey[state.validators[0].pubkey]
|
source_privkey = pubkey_to_privkey[state.validators[0].pubkey]
|
||||||
target_privkey = pubkey_to_privkey[state.validators[1].pubkey]
|
target_privkey = pubkey_to_privkey[state.validators[1].pubkey]
|
||||||
@ -627,17 +661,53 @@ def test_invalid_source_signature(spec, state):
|
|||||||
source_privkey,
|
source_privkey,
|
||||||
target_privkey,
|
target_privkey,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Change the pubkey of the source validator, invalidating its signature
|
# Change the pubkey of the source validator, invalidating its signature
|
||||||
state.validators[0].pubkey = state.validators[1].pubkey
|
state.validators[0].pubkey = state.validators[1].pubkey
|
||||||
|
|
||||||
yield from run_consolidation_processing(
|
yield from run_consolidation_processing(
|
||||||
spec, state, signed_consolidation, valid=False
|
spec, state, signed_consolidation, valid=False
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
@with_electra_and_later
|
@with_electra_and_later
|
||||||
@spec_state_test
|
@with_presets([MINIMAL], "need sufficient consolidation churn limit")
|
||||||
|
@with_custom_state(
|
||||||
|
balances_fn=scaled_churn_balances_exceed_activation_exit_churn_limit,
|
||||||
|
threshold_fn=default_activation_threshold,
|
||||||
|
)
|
||||||
|
@spec_test
|
||||||
|
@single_phase
|
||||||
@always_bls
|
@always_bls
|
||||||
def test_invalid_target_signature(spec, state):
|
def test_invalid_target_signature(spec, state):
|
||||||
|
# This state has 256 validators each with 32 ETH in MINIMAL preset, 128 ETH consolidation churn
|
||||||
|
current_epoch = spec.get_current_epoch(state)
|
||||||
|
source_index = spec.get_active_validator_indices(state, current_epoch)[0]
|
||||||
|
target_index = spec.get_active_validator_indices(state, current_epoch)[1]
|
||||||
|
source_privkey = pubkey_to_privkey[state.validators[source_index].pubkey]
|
||||||
|
target_privkey = pubkey_to_privkey[state.validators[target_index].pubkey]
|
||||||
|
|
||||||
|
# Set source and target withdrawal credentials to the same eth1 credential
|
||||||
|
set_eth1_withdrawal_credential_with_balance(spec, state, source_index)
|
||||||
|
set_eth1_withdrawal_credential_with_balance(spec, state, target_index)
|
||||||
|
|
||||||
|
signed_consolidation = sign_consolidation(
|
||||||
|
spec,
|
||||||
|
state,
|
||||||
|
spec.Consolidation(
|
||||||
|
epoch=current_epoch, source_index=source_index, target_index=target_index
|
||||||
|
),
|
||||||
|
source_privkey,
|
||||||
|
target_privkey,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Set earliest consolidation epoch to the expected exit epoch
|
||||||
|
expected_exit_epoch = spec.compute_activation_exit_epoch(current_epoch)
|
||||||
|
state.earliest_consolidation_epoch = expected_exit_epoch
|
||||||
|
consolidation_churn_limit = spec.get_consolidation_churn_limit(state)
|
||||||
|
# Set the consolidation balance to consume equal to churn limit
|
||||||
|
state.consolidation_balance_to_consume = consolidation_churn_limit
|
||||||
|
|
||||||
current_epoch = spec.get_current_epoch(state)
|
current_epoch = spec.get_current_epoch(state)
|
||||||
source_privkey = pubkey_to_privkey[state.validators[0].pubkey]
|
source_privkey = pubkey_to_privkey[state.validators[0].pubkey]
|
||||||
target_privkey = pubkey_to_privkey[state.validators[1].pubkey]
|
target_privkey = pubkey_to_privkey[state.validators[1].pubkey]
|
||||||
@ -651,8 +721,10 @@ def test_invalid_target_signature(spec, state):
|
|||||||
source_privkey,
|
source_privkey,
|
||||||
target_privkey,
|
target_privkey,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Change the pubkey of the target validator, invalidating its signature
|
# Change the pubkey of the target validator, invalidating its signature
|
||||||
state.validators[1].pubkey = state.validators[2].pubkey
|
state.validators[1].pubkey = state.validators[2].pubkey
|
||||||
|
|
||||||
yield from run_consolidation_processing(
|
yield from run_consolidation_processing(
|
||||||
spec, state, signed_consolidation, valid=False
|
spec, state, signed_consolidation, valid=False
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user