@@ -968,42 +968,43 @@ def produce_block_with_signatures(
968968 )
969969 post_state = head_state .process_slots (slot ).process_block (temp_block )
970970
971- # Find new valid attestations
971+ # Find new valid attestations matching post-state justification
972972 new_attestations : list [Attestation ] = []
973973 new_signatures : list [Signature ] = []
974974
975975 for signed_attestation in store .latest_known_attestations .values ():
976976 data = signed_attestation .message .data
977977
978- # Skip unknown target blocks
978+ # Skip if target block is unknown in our store
979979 if data .head .root not in store .blocks :
980980 continue
981981
982982 # Skip if source doesn't match post-state's justified
983983 if data .source != post_state .latest_justified :
984984 continue
985985
986- # Add if not already included
986+ # Add attestation if not already included
987987 if signed_attestation .message not in attestations :
988988 new_attestations .append (signed_attestation .message )
989989 new_signatures .append (signed_attestation .signature )
990990
991- # Fixed point reached
991+ # Fixed point reached: no new attestations found
992992 if not new_attestations :
993993 break
994994
995+ # Add new attestations and continue iteration
995996 attestations .extend (new_attestations )
996997 signatures .extend (new_signatures )
997998
998- # Build final block using State.build_block
999+ # Build final block and post-state
9991000 final_block , final_post_state = head_state .build_block (
10001001 slot = slot ,
10011002 proposer_index = validator_index ,
10021003 parent_root = head_root ,
10031004 attestations = attestations ,
10041005 )
10051006
1006- # Store block and state
1007+ # Store block and state immutably
10071008 block_hash = hash_tree_root (final_block )
10081009 store = store .model_copy (
10091010 update = {
0 commit comments