cl/sentinel, cl/phase1/forkchoice: serve req/resp chain data from fork_graph, not forkchoice - #23179
Draft
domiwei wants to merge 2 commits into
Draft
cl/sentinel, cl/phase1/forkchoice: serve req/resp chain data from fork_graph, not forkchoice#23179domiwei wants to merge 2 commits into
domiwei wants to merge 2 commits into
Conversation
…k_graph, not forkchoice Sentinel used only 7 of ForkChoiceStorageReader's 53 methods; 6 of them were one-line fork_graph re-exports and the 7th (GetPeerDas) fetched a PeerDasStateReader that sentinel already holds. Sentinel now depends on a 6-method ChainDataReader interface satisfied by fork_graph.ForkGraph, so its tests use a small map-backed fake instead of the 571-line ForkChoiceStorageMock, and adding methods to the fork-choice interface no longer touches sentinel. Also removes interface/mock surface with zero external callers (JustifiedSlot, ValidateOnAttestation, ShouldExtendPayload, GetPublicKeyForValidator) and adds a compile-time conformance assertion to ForkChoiceStorageMock. The fork_graph re-exports themselves stay on ForkChoiceStorageReader: beacon/handler and stages still call them; their migration is tracked separately.
…ming Review follow-ups: add a test pinning Identity()'s CustodyGroupCount to the injected PeerDasStateReader value (the one behavioral edge of the seam change), rename leftover fork-choice-flavored test identifiers, and use the comma-ok idiom in ChainDataReaderMock getters.
domiwei
force-pushed
the
kewei/sentinel-fork-graph-seam
branch
from
August 11, 2026 13:55
220be16 to
84a7c5d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Sentinel used only 7 of
ForkChoiceStorageReader's 53 methods: 6 were one-linefork_graphre-exports, and the 7th (GetPeerDas) fetched aPeerDasStateReaderthat sentinel already receives at construction. This PR makes the dependency honest:handlers.ChainDataReaderinterface (GetBlock,GetLightClientBootstrap,GetLightClientUpdate,NewestLightClientUpdate,HasEnvelope,ReadEnvelopeFromDisk), satisfied byfork_graph.ForkGraph.Sentinel,ConsensusHandlersandStartSentinelServicetake it instead offorkchoice.ForkChoiceStorageReader.Sentinel.Identity()reads the custody group count from the injectedpeerDasStateReaderfield instead offorkChoiceReader.GetPeerDas().StateReader()— same underlying object (run.gowires the samepeerDasStateinto both), and it removes a nil-panic window between sentinel start andInitPeerDas.cl/sentinelno longer importscl/phase1/forkchoiceat all.ChainDataReaderMockinstead of the 571-lineForkChoiceStorageMock.Drive-by cleanup on surfaces this change already touches:
JustifiedSlot(concrete method was also unused),ValidateOnAttestationandShouldExtendPayload(concrete methods stay — used inside the forkchoice package), and the mock-onlyGetPublicKeyForValidator.var _ forkchoice.ForkChoiceStorage = (*ForkChoiceStorageMock)(nil)so mock drift fails the build instead of a random test.Why
The fork-choice interface is 64 methods wide and every consumer takes all of it; the hand-written mock has to model every method's semantics and has churned repeatedly as consumers hit unmodelled behavior. Narrowing sentinel to the 6 methods it actually uses shrinks its test surface accordingly and stops fork-choice interface growth from rippling into sentinel tests. This is the first slice of a larger consumer-role split of the fork-choice seam.
Explicitly not in this PR
ForkChoiceStorageReader:cl/beacon/handler(and for some,cl/phase1/stages/cl/phase1/network) still call them through the fork-choice interface. Removing them requires migrating those consumers; note some sibling re-exports (AnchorRoot,AnchorSlot,LowestAvailableSlot) takef.mu.RLock()and are not pure pass-throughs, and the participation-indices pair converts blockRoot→epoch, so that migration needs care. Tracked separately.Testing
Pure refactor — no new production behavior, so no new TDD cycle (per the repo's TDD pragmatism rules); the existing sentinel handler/request tests are the safety net and were migrated to the new mock.
make lintclean (multiple runs),make erigon integrationbuilds,go test -short ./cl/... ./cmd/caplin/...all green.