6262from ..protocol import ForkProtocol , SpecBlockType , SpecStateType
6363from .store import AttestationSignatureEntry , Store
6464
65+ LstarStore = Store [State , Block ]
66+ """Concrete Store specialization owned by the lstar fork."""
67+
6568
6669class LstarSpec (ForkProtocol ):
6770 """Lstar fork."""
@@ -80,7 +83,7 @@ class LstarSpec(ForkProtocol):
8083 block_signatures_class : type [BlockSignatures ] = BlockSignatures
8184 aggregated_attestations_class : type [AggregatedAttestations ] = AggregatedAttestations
8285 attestation_signatures_class : type [AttestationSignatures ] = AttestationSignatures
83- store_class : type [Store ] = Store
86+ store_class : type [Store [ State , Block ]] = LstarStore
8487
8588 attestation_data_class : type [AttestationData ] = AttestationData
8689 attestation_class : type [Attestation ] = Attestation
@@ -878,7 +881,7 @@ def create_store( # type: ignore[override] # ty: ignore[invalid-method-overrid
878881 state : SpecStateType ,
879882 anchor_block : SpecBlockType ,
880883 validator_id : ValidatorIndex | None ,
881- ) -> Store :
884+ ) -> LstarStore :
882885 """Initialize a forkchoice store from an anchor state and block.
883886
884887 The anchor block and state form the starting point for fork choice.
@@ -935,7 +938,7 @@ def create_store( # type: ignore[override] # ty: ignore[invalid-method-overrid
935938 validator_id = validator_id ,
936939 )
937940
938- def prune_stale_attestation_data (self , store : Store ) -> Store :
941+ def prune_stale_attestation_data (self , store : LstarStore ) -> LstarStore :
939942 """Remove attestation data that can no longer influence fork choice.
940943
941944 An attestation becomes stale when its target checkpoint falls at or before
@@ -972,7 +975,7 @@ def prune_stale_attestation_data(self, store: Store) -> Store:
972975 }
973976 )
974977
975- def validate_attestation (self , store : Store , attestation_data : AttestationData ) -> None :
978+ def validate_attestation (self , store : LstarStore , attestation_data : AttestationData ) -> None :
976979 """Validate incoming attestation before processing.
977980
978981 Ensures the vote respects the basic laws of time and topology:
@@ -1026,11 +1029,11 @@ def validate_attestation(self, store: Store, attestation_data: AttestationData)
10261029
10271030 def on_gossip_attestation (
10281031 self ,
1029- store : Store ,
1032+ store : LstarStore ,
10301033 signed_attestation : SignedAttestation ,
10311034 scheme : GeneralizedXmssScheme = TARGET_SIGNATURE_SCHEME ,
10321035 is_aggregator : bool = False ,
1033- ) -> Store :
1036+ ) -> LstarStore :
10341037 """Process a signed attestation received via gossip network.
10351038
10361039 This method:
@@ -1090,9 +1093,9 @@ def on_gossip_attestation(
10901093
10911094 def on_gossip_aggregated_attestation (
10921095 self ,
1093- store : Store ,
1096+ store : LstarStore ,
10941097 signed_attestation : SignedAggregatedAttestation ,
1095- ) -> Store :
1098+ ) -> LstarStore :
10961099 """Process a signed aggregated attestation received via aggregation topic.
10971100
10981101 This method:
@@ -1155,10 +1158,10 @@ def on_gossip_aggregated_attestation(
11551158
11561159 def on_block (
11571160 self ,
1158- store : Store ,
1161+ store : LstarStore ,
11591162 signed_block : SignedBlock ,
11601163 scheme : GeneralizedXmssScheme = TARGET_SIGNATURE_SCHEME ,
1161- ) -> Store :
1164+ ) -> LstarStore :
11621165 """Process a new block and update the forkchoice state.
11631166
11641167 This method integrates a block into the forkchoice store by:
@@ -1263,7 +1266,7 @@ def on_block(
12631266
12641267 def extract_attestations_from_aggregated_payloads (
12651268 self ,
1266- store : Store ,
1269+ store : LstarStore ,
12671270 aggregated_payloads : dict [AttestationData , set [AggregatedSignatureProof ]],
12681271 ) -> dict [ValidatorIndex , AttestationData ]:
12691272 """Extract attestations from aggregated payloads.
@@ -1281,7 +1284,7 @@ def extract_attestations_from_aggregated_payloads(
12811284 attestations [validator_id ] = attestation_data
12821285 return attestations
12831286
1284- def compute_block_weights (self , store : Store ) -> dict [Bytes32 , int ]:
1287+ def compute_block_weights (self , store : LstarStore ) -> dict [Bytes32 , int ]:
12851288 """Compute attestation-based weight for each block above the finalized slot.
12861289
12871290 Walks backward from each validator's latest head vote, incrementing weight
@@ -1306,7 +1309,7 @@ def compute_block_weights(self, store: Store) -> dict[Bytes32, int]:
13061309
13071310 def _compute_lmd_ghost_head (
13081311 self ,
1309- store : Store ,
1312+ store : LstarStore ,
13101313 start_root : Bytes32 ,
13111314 attestations : dict [ValidatorIndex , AttestationData ],
13121315 min_score : int = 0 ,
@@ -1388,7 +1391,7 @@ def _compute_lmd_ghost_head(
13881391
13891392 return head
13901393
1391- def update_head (self , store : Store ) -> Store :
1394+ def update_head (self , store : LstarStore ) -> LstarStore :
13921395 """Compute updated store with new canonical head.
13931396
13941397 Selects the canonical chain head using:
@@ -1418,7 +1421,7 @@ def update_head(self, store: Store) -> Store:
14181421 }
14191422 )
14201423
1421- def accept_new_attestations (self , store : Store ) -> Store :
1424+ def accept_new_attestations (self , store : LstarStore ) -> LstarStore :
14221425 """Process pending aggregated payloads and update forkchoice head.
14231426
14241427 Moves aggregated payloads from latest_new_aggregated_payloads to
@@ -1456,7 +1459,7 @@ def accept_new_attestations(self, store: Store) -> Store:
14561459 # Update head with newly accepted aggregated payloads
14571460 return self .update_head (store )
14581461
1459- def update_safe_target (self , store : Store ) -> Store :
1462+ def update_safe_target (self , store : LstarStore ) -> LstarStore :
14601463 """Compute the deepest block that has 2/3+ supermajority attestation weight.
14611464
14621465 The safe target is the furthest-from-genesis block where enough validators
@@ -1523,7 +1526,7 @@ def update_safe_target(self, store: Store) -> Store:
15231526 # The head and attestation pools remain unchanged.
15241527 return store .model_copy (update = {"safe_target" : safe_target })
15251528
1526- def aggregate (self , store : Store ) -> tuple [Store , list [SignedAggregatedAttestation ]]:
1529+ def aggregate (self , store : LstarStore ) -> tuple [LstarStore , list [SignedAggregatedAttestation ]]:
15271530 """Turn raw validator votes into compact aggregated attestations.
15281531
15291532 Validators cast individual signatures over gossip. Before those
@@ -1660,10 +1663,10 @@ def aggregate(self, store: Store) -> tuple[Store, list[SignedAggregatedAttestati
16601663
16611664 def tick_interval (
16621665 self ,
1663- store : Store ,
1666+ store : LstarStore ,
16641667 has_proposal : bool ,
16651668 is_aggregator : bool = False ,
1666- ) -> tuple [Store , list [SignedAggregatedAttestation ]]:
1669+ ) -> tuple [LstarStore , list [SignedAggregatedAttestation ]]:
16671670 """Advance store time by one interval and perform interval-specific actions.
16681671
16691672 Different actions are performed based on interval within slot:
@@ -1691,11 +1694,11 @@ def tick_interval(
16911694
16921695 def on_tick (
16931696 self ,
1694- store : Store ,
1697+ store : LstarStore ,
16951698 target_interval : Interval ,
16961699 has_proposal : bool ,
16971700 is_aggregator : bool = False ,
1698- ) -> tuple [Store , list [SignedAggregatedAttestation ]]:
1701+ ) -> tuple [LstarStore , list [SignedAggregatedAttestation ]]:
16991702 """Advance forkchoice store time to given interval count.
17001703
17011704 Ticks store forward interval by interval, performing appropriate
@@ -1716,7 +1719,7 @@ def on_tick(
17161719
17171720 return store , all_new_aggregates
17181721
1719- def get_proposal_head (self , store : Store , slot : Slot ) -> tuple [Store , Bytes32 ]:
1722+ def get_proposal_head (self , store : LstarStore , slot : Slot ) -> tuple [LstarStore , Bytes32 ]:
17201723 """Get the head for block proposal at given slot.
17211724
17221725 Ensures store is up-to-date and processes any pending attestations
@@ -1732,7 +1735,7 @@ def get_proposal_head(self, store: Store, slot: Slot) -> tuple[Store, Bytes32]:
17321735
17331736 return store , store .head
17341737
1735- def get_attestation_target (self , store : Store ) -> Checkpoint :
1738+ def get_attestation_target (self , store : LstarStore ) -> Checkpoint :
17361739 """Calculate target checkpoint for validator attestations.
17371740
17381741 Determines appropriate attestation target based on head, safe target,
@@ -1770,7 +1773,7 @@ def get_attestation_target(self, store: Store) -> Checkpoint:
17701773
17711774 return Checkpoint (root = target_block_root , slot = target_block .slot )
17721775
1773- def produce_attestation_data (self , store : Store , slot : Slot ) -> AttestationData :
1776+ def produce_attestation_data (self , store : LstarStore , slot : Slot ) -> AttestationData :
17741777 """Produce attestation data for the given slot.
17751778
17761779 This method constructs an AttestationData object according to the lean protocol
@@ -1796,10 +1799,10 @@ def produce_attestation_data(self, store: Store, slot: Slot) -> AttestationData:
17961799
17971800 def produce_block_with_signatures (
17981801 self ,
1799- store : Store ,
1802+ store : LstarStore ,
18001803 slot : Slot ,
18011804 validator_index : ValidatorIndex ,
1802- ) -> tuple [Store , Block , list [AggregatedSignatureProof ]]:
1805+ ) -> tuple [LstarStore , Block , list [AggregatedSignatureProof ]]:
18031806 """Produce a block and its aggregated signature proofs for the target slot.
18041807
18051808 Block production proceeds in four stages:
0 commit comments