1+ from eth2spec .test .helpers .constants import MINIMAL
12from eth2spec .test .context import (
23 always_bls ,
34 spec_state_test ,
45 with_electra_and_later ,
6+ with_presets ,
57)
68from eth2spec .test .helpers .attestations import (
79 run_attestation_processing ,
810 get_valid_attestation ,
911 sign_attestation ,
12+ build_attestation_data ,
13+ get_valid_attestation_at_slot ,
14+ get_empty_eip7549_aggregation_bits ,
1015)
1116from eth2spec .test .helpers .state import (
1217 next_slots ,
@@ -35,7 +40,7 @@ def test_invalid_attestation_data_index_not_zero(spec, state):
3540@with_electra_and_later
3641@spec_state_test
3742@always_bls
38- def test_invalid_committe_index (spec , state ):
43+ def test_invalid_committee_index (spec , state ):
3944 """
4045 EIP-7549 test
4146 """
@@ -53,7 +58,7 @@ def test_invalid_committe_index(spec, state):
5358
5459@with_electra_and_later
5560@spec_state_test
56- def test_invalid_too_many_committe_bits (spec , state ):
61+ def test_invalid_too_many_committee_bits (spec , state ):
5762 """
5863 EIP-7549 test
5964 """
@@ -68,7 +73,7 @@ def test_invalid_too_many_committe_bits(spec, state):
6873
6974@with_electra_and_later
7075@spec_state_test
71- def test_invalid_nonset_committe_bits (spec , state ):
76+ def test_invalid_nonset_committee_bits (spec , state ):
7277 """
7378 EIP-7549 test
7479 """
@@ -79,3 +84,67 @@ def test_invalid_nonset_committe_bits(spec, state):
7984 attestation .committee_bits [committee_index ] = 0
8085
8186 yield from run_attestation_processing (spec , state , attestation , valid = False )
87+
88+
89+ @with_electra_and_later
90+ @spec_state_test
91+ def test_invalid_nonset_multiple_committee_bits (spec , state ):
92+ """
93+ EIP-7549 test
94+ """
95+ attestation_data = build_attestation_data (spec , state , slot = state .slot , index = 0 )
96+ attestation = spec .Attestation (data = attestation_data )
97+
98+ # a single attestation with all committees of a slot, but with unset aggregation_bits
99+ committees_per_slot = spec .get_committee_count_per_slot (state , spec .get_current_epoch (state ))
100+ for index in range (committees_per_slot ):
101+ attestation .committee_bits [index ] = True
102+
103+ attestation .aggregation_bits = get_empty_eip7549_aggregation_bits (
104+ spec , state , attestation .committee_bits , attestation .data .slot
105+ )
106+
107+ next_slots (spec , state , spec .MIN_ATTESTATION_INCLUSION_DELAY )
108+
109+ yield from run_attestation_processing (spec , state , attestation , valid = False )
110+
111+
112+ @with_electra_and_later
113+ @spec_state_test
114+ @with_presets ([MINIMAL ], "need multiple committees per slot" )
115+ @always_bls
116+ def test_multiple_committees (spec , state ):
117+ """
118+ EIP-7549 test
119+ """
120+ attestation_data = build_attestation_data (spec , state , slot = state .slot , index = 0 )
121+ attestation = spec .Attestation (data = attestation_data )
122+
123+ # a single attestation with all committees of a slot
124+ attestation = get_valid_attestation_at_slot (state , spec , state .slot )
125+
126+ # check that all committees are presented in a single attestation
127+ attesting_indices = set ()
128+ committees_per_slot = spec .get_committee_count_per_slot (state , spec .get_current_epoch (state ))
129+ for index in range (committees_per_slot ):
130+ attesting_indices .update (spec .get_beacon_committee (state , state .slot , index ))
131+ assert spec .get_attesting_indices (state , attestation ) == attesting_indices
132+
133+ # advance a slot
134+ next_slots (spec , state , spec .MIN_ATTESTATION_INCLUSION_DELAY )
135+
136+ yield from run_attestation_processing (spec , state , attestation )
137+
138+
139+ @with_electra_and_later
140+ @spec_state_test
141+ @with_presets ([MINIMAL ], "need multiple committees per slot" )
142+ @always_bls
143+ def test_one_committee_with_gap (spec , state ):
144+ """
145+ EIP-7549 test
146+ """
147+ attestation = get_valid_attestation (spec , state , index = 1 , signed = True )
148+ next_slots (spec , state , spec .MIN_ATTESTATION_INCLUSION_DELAY )
149+
150+ yield from run_attestation_processing (spec , state , attestation )
0 commit comments