blockchain: discard_pending_subtree recurses once per pending descendant

Offen
#810 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Maintainer antworten meist innerhalb von 6 Tagen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
1-2 Tage
Anfängerfreundlichkeit
68/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
rust

Rechercherichtung

Read crates/blockchain/src/lib.rs, especially BlockChainServer::discard_pending_subtree near line 3196 and invalidate_subtree for the existing worklist pattern. Replace recursive child processing with an explicit worklist while preserving per-root cleanup, then add a deep pending-chain test that discards its root on a thread with a 2 MiB stack. Done means the discard completes without stack overflow and the test passes.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

BlockChainServer::discard_pending_subtree (crates/blockchain/src/lib.rs:3196) calls itself for every child in pending_blocks (lib.rs:3223), on the chain actor's thread. That thread runs with the default 2 MiB stack.

I found no cap on pending_blocks (lib.rs:464). No use of it in crates/blockchain/src checks its length or evicts by size; the inserts are at lib.rs:2810 and 2863. A chain of pending blocks N deep would make the discard recurse N times. A deep enough chain would abort the process with a stack overflow, the failure lambdaclass/ethlambda#758 removed from filter_block_tree.

Not traced or measured:

  • whether such a chain forms in practice (a range catch-up whose first block's parent is missing is one unverified candidate);
  • the function's frame size;
  • the depth at which it would overflow.

The import cascade that releases pending children (lib.rs:3078) already uses a queue, so only the discard path recurses.

This is out of scope for lambdaclass/ethlambda#758, which changes only the fork-choice filter.

A fix would use an explicit worklist, the way invalidate_subtree already does: let mut stack = vec![block_root]; while let Some(root) = stack.pop() { ...; stack.extend(children) }, with the same per-root cleanup. A test like #758's deep-chain test would cover it: build a deep pending chain, then discard its root on a thread with an explicit 2 MiB stack.

Vorherrschende Sprache
Rust
Sterne
86
Forks
34
Ø Merge
9 T. 20 Std.
Gemergte PRs (30 T.)
77

Entwicklungsumgebung

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus lambdaclass/ethlambda

Alle Issues in lambdaclass/ethlambda

Ähnliche Issues

Weitere Issues zu Rust

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.