@@ -203,15 +203,20 @@ func (s *DHT) eligibleForRouting(n *Node) bool {
203203 if s == nil {
204204 return false
205205 }
206+ if n == nil || len (n .ID ) == 0 {
207+ return false
208+ }
206209 // In integration tests allow everything; chain state gating is not stable/available there.
207210 if integrationTestEnabled () {
208211 return true
209212 }
210- // Strict gating: only explicitly allowlisted peers can participate in read/routing.
211- if ! s .routingAllowReady .Load () || s .routingAllowCount .Load () == 0 {
212- return false
213+ // Bootstrap-safe behavior: until first non-empty chain allowlist arrives,
214+ // keep routing/read gating disabled to avoid accidental lockout.
215+ if ! s .routingAllowReady .Load () {
216+ return true
213217 }
214- if n == nil || len (n .ID ) == 0 {
218+ // Once initialized, an empty active set means no routing-eligible peers.
219+ if s .routingAllowCount .Load () == 0 {
215220 return false
216221 }
217222
@@ -269,8 +274,20 @@ func (s *DHT) filterEligibleNodes(nodes []*Node) []*Node {
269274 if integrationTestEnabled () {
270275 return nodes
271276 }
272- // Strict gating: without a routing allowlist there are no eligible routing peers.
273- if ! s .routingAllowReady .Load () || s .routingAllowCount .Load () == 0 {
277+ // If the routing allowlist has not been initialized yet, keep gating disabled
278+ // but still sanitize malformed node entries.
279+ if ! s .routingAllowReady .Load () {
280+ out := nodes [:0 ]
281+ for _ , n := range nodes {
282+ if n == nil || len (n .ID ) == 0 {
283+ continue
284+ }
285+ out = append (out , n )
286+ }
287+ return out
288+ }
289+ // Once initialized, empty means no routing-eligible peers.
290+ if s .routingAllowCount .Load () == 0 {
274291 return nil
275292 }
276293
@@ -2081,8 +2098,8 @@ func (s *DHT) addNode(ctx context.Context, node *Node) *Node {
20812098 }
20822099 node .SetHashedID ()
20832100
2084- // Chain-state gating: only allow Active supernodes into the routing table.
2085- // This prevents postponed/disabled/stopped nodes from being admitted via inbound traffic .
2101+ // Chain-state routing gate (enabled after allowlist initialization):
2102+ // only chain-allowlisted peers may enter the routing table .
20862103 if ! s .eligibleForRouting (node ) {
20872104 logtrace .Debug (ctx , "Rejecting node: not eligible for routing" , logtrace.Fields {
20882105 logtrace .FieldModule : "p2p" ,
0 commit comments