Skip to content

Commit 8a0f032

Browse files
tcoratgerclaude
andauthored
refactor(node): remove dead code in event source and head sync (leanEthereum#836)
Three unused items, all verified to have zero live call sites: - set_block_by_slot_lookup setter on the live event source: never called anywhere. Its only sibling lookup field on the request handler is set directly. Removing it leaves the AsyncBlockBySlotLookup import unused, so drop that too. - connection parameter on the status-exchange helper: status goes through the reqresp client, the connection is never read. - peer_id parameter on the descendant-processing helper: threaded in and documented but never read in the body. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0ca2e89 commit 8a0f032

2 files changed

Lines changed: 2 additions & 25 deletions

File tree

src/lean_spec/node/networking/client/event_source/live.py

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,6 @@
8181
from lean_spec.node.networking.gossipsub.types import TopicId
8282
from lean_spec.node.networking.reqresp.handler import (
8383
REQRESP_PROTOCOL_IDS,
84-
AsyncBlockBySlotLookup,
8584
AsyncBlockLookup,
8685
CurrentSlotLookup,
8786
ReqRespServer,
@@ -329,20 +328,6 @@ def set_block_lookup(self, lookup: AsyncBlockLookup) -> None:
329328
"""
330329
self._reqresp_handler.block_lookup = lookup
331330

332-
def set_block_by_slot_lookup(self, lookup: AsyncBlockBySlotLookup) -> None:
333-
"""
334-
Set the callback for looking up canonical blocks by slot.
335-
336-
Used by the inbound ReqResp handler to serve BlocksByRange requests.
337-
338-
The callback MUST consult fork choice.
339-
It returns the canonical block at that slot, or None for empty slots.
340-
341-
Args:
342-
lookup: Async function from Slot to SignedBlock or None.
343-
"""
344-
self._reqresp_handler.block_by_slot_lookup = lookup
345-
346331
def set_current_slot_lookup(self, lookup: CurrentSlotLookup) -> None:
347332
"""
348333
Set the callback returning the node's current slot.
@@ -582,7 +567,7 @@ async def dial(self, multiaddr: str) -> PeerId | None:
582567
task.add_done_callback(self._gossip_tasks.discard)
583568

584569
# Exchange status.
585-
await self._exchange_status(peer_id, connection)
570+
await self._exchange_status(peer_id)
586571

587572
# Set up gossipsub stream for full protocol support.
588573
await self._setup_gossipsub_stream(peer_id, connection)
@@ -698,17 +683,12 @@ async def _handle_inbound_connection(self, connection: QuicConnection) -> None:
698683

699684
logger.info("Accepted connection from peer %s", peer_id)
700685

701-
async def _exchange_status(
702-
self,
703-
peer_id: PeerId,
704-
connection: QuicConnection,
705-
) -> None:
686+
async def _exchange_status(self, peer_id: PeerId) -> None:
706687
"""
707688
Exchange Status messages with a peer.
708689
709690
Args:
710691
peer_id: Peer identifier.
711-
connection: QuicConnection to use.
712692
"""
713693
if self._our_status is None:
714694
logger.debug("No status set, skipping status exchange")

src/lean_spec/node/sync/head_sync.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,6 @@ async def on_gossip_block(
182182
logger.debug("on_gossip_block: parent found, processing")
183183
return await self._process_block_with_descendants(
184184
block=block,
185-
peer_id=peer_id,
186185
store=store,
187186
)
188187

@@ -200,7 +199,6 @@ async def on_gossip_block(
200199
async def _process_block_with_descendants(
201200
self,
202201
block: SignedBlock,
203-
peer_id: PeerId | None,
204202
store: Store,
205203
) -> tuple[HeadSyncResult, Store]:
206204
"""
@@ -211,7 +209,6 @@ async def _process_block_with_descendants(
211209
212210
Args:
213211
block: Block to process.
214-
peer_id: Peer that sent the block.
215212
store: Current store.
216213
217214
Returns:

0 commit comments

Comments
 (0)