@@ -887,6 +887,42 @@ def test_incorrect_target_with_bls_credential(spec, state):
887
887
)
888
888
889
889
890
+ @with_electra_and_later
891
+ @with_presets ([MINIMAL ], "need sufficient consolidation churn limit" )
892
+ @with_custom_state (
893
+ balances_fn = scaled_churn_balances_exceed_activation_exit_churn_limit ,
894
+ threshold_fn = default_activation_threshold ,
895
+ )
896
+ @spec_test
897
+ @single_phase
898
+ def test_incorrect_source_with_bls_credential (spec , state ):
899
+ # Move state forward SHARD_COMMITTEE_PERIOD epochs to allow for consolidation
900
+ state .slot += spec .config .SHARD_COMMITTEE_PERIOD * spec .SLOTS_PER_EPOCH
901
+
902
+ current_epoch = spec .get_current_epoch (state )
903
+ source_index = spec .get_active_validator_indices (state , current_epoch )[0 ]
904
+ target_index = spec .get_active_validator_indices (state , current_epoch )[1 ]
905
+ set_compounding_withdrawal_credential_with_balance (spec , state , target_index )
906
+
907
+ # Ensure that the source validator has BLS-type withdrawal credentials
908
+ assert state .validators [source_index ].withdrawal_credentials [:1 ] == spec .BLS_WITHDRAWAL_PREFIX
909
+
910
+ # An attacker could create a new validator with BLS withdrawal credentials where the last twenty
911
+ # bytes of the BLS pubkey are hardcoded to an address that they control. To be clear, the source
912
+ # address field in consolidation requests cannot be set to an arbitrary value.
913
+ source_address = state .validators [source_index ].withdrawal_credentials [- 20 :]
914
+
915
+ consolidation = spec .ConsolidationRequest (
916
+ source_address = source_address ,
917
+ source_pubkey = state .validators [source_index ].pubkey ,
918
+ target_pubkey = state .validators [target_index ].pubkey ,
919
+ )
920
+
921
+ yield from run_consolidation_processing (
922
+ spec , state , consolidation , success = False
923
+ )
924
+
925
+
890
926
@with_electra_and_later
891
927
@with_presets ([MINIMAL ], "need sufficient consolidation churn limit" )
892
928
@with_custom_state (
@@ -928,7 +964,7 @@ def test_incorrect_target_with_eth1_credential(spec, state):
928
964
)
929
965
@spec_test
930
966
@single_phase
931
- def test_incorrect_incorrect_source_address (spec , state ):
967
+ def test_incorrect_source_address (spec , state ):
932
968
# move state forward SHARD_COMMITTEE_PERIOD epochs to allow for consolidation
933
969
state .slot += spec .config .SHARD_COMMITTEE_PERIOD * spec .SLOTS_PER_EPOCH
934
970
# Set up an otherwise correct consolidation
@@ -1017,7 +1053,7 @@ def test_incorrect_unknown_target_pubkey(spec, state):
1017
1053
)
1018
1054
set_compounding_withdrawal_credential_with_balance (spec , state , target_index )
1019
1055
1020
- # Check the the return condition
1056
+ # Check the return condition
1021
1057
assert not state .validators [target_index ].pubkey == consolidation .target_pubkey
1022
1058
1023
1059
yield from run_consolidation_processing (
0 commit comments