Skip to content

Commit edb9fe5

Browse files
tcoratgerclaude
andauthored
refactor(forks): inline single-use get_proposal_head (leanEthereum#1030)
The proposal-head helper had a single caller, was not part of any contract, and returned (store, store.head) — a redundant tuple whose second element was derivable from the first. Inline its three steps (advance time, accept pending attestations, read the head) directly into block production, keeping the rationale comments. Drops the now-unused Bytes32 import. Behavior-preserving: all lstar vectors fill green, byte-identical across hash seeds. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent f5607ef commit edb9fe5

1 file changed

Lines changed: 9 additions & 22 deletions

File tree

src/lean_spec/spec/forks/lstar/validator_duties.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -15,29 +15,12 @@
1515
ValidatorIndex,
1616
)
1717
from lean_spec.spec.forks.lstar.errors import RejectionReason, SpecRejectionError
18-
from lean_spec.spec.ssz import Bytes32, Uint64
18+
from lean_spec.spec.ssz import Uint64
1919

2020

2121
class ValidatorDutiesMixin(LstarSpecBase):
2222
"""Validator duties for the lstar fork."""
2323

24-
def get_proposal_head(self, store: LstarStore, slot: Slot) -> tuple[LstarStore, Bytes32]:
25-
"""
26-
Get the head for block proposal at given slot.
27-
28-
Ensures store is up-to-date and processes any pending attestations
29-
before returning the canonical head. This guarantees the proposer
30-
builds on the most recent view of the chain.
31-
"""
32-
# Advance time to this slot's first interval
33-
target_interval = Interval.from_slot(slot)
34-
store, _ = self.on_tick(store, target_interval, True)
35-
36-
# Process any pending attestations before proposal
37-
store = self.accept_new_attestations(store)
38-
39-
return store, store.head
40-
4124
def get_attestation_target(self, store: LstarStore) -> Checkpoint:
4225
"""
4326
Calculate target checkpoint for validator attestations.
@@ -147,11 +130,15 @@ def produce_block_with_signatures(
147130
or if the produced block fails to close a justified divergence
148131
between the store and the head chain.
149132
"""
150-
# Retrieve parent block.
133+
# Build on the freshest canonical head.
151134
#
152-
# The proposal head reflects the latest chain view after processing
153-
# all pending attestations. Building on stale state would orphan the block.
154-
store, head_root = self.get_proposal_head(store, slot)
135+
# Advance time to this slot's first interval, then fold in pending attestations.
136+
# The proposal head then reflects the latest chain view.
137+
# Building on stale state would orphan the block.
138+
target_interval = Interval.from_slot(slot)
139+
store, _ = self.on_tick(store, target_interval, True)
140+
store = self.accept_new_attestations(store)
141+
head_root = store.head
155142
head_state = store.states[head_root]
156143

157144
# Verify proposer authorization.

0 commit comments

Comments
 (0)