blockchain: discard_pending_subtree recurses once per pending descendant
Maintainers usually reply within 6 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 68/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- backend, distributed-systems
Research direction
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.
Written by the indexing model from the issue text.
Description
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.
- Dominant language
- Rust
- Stars
- 86
- Forks
- 34
- Avg merge
- 9d 20h
- Merged PRs (30d)
- 77
Getting set up
- Ships a Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from lambdaclass/ethlambda
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
lambdaclass/ethlambda#850 ·
Maintainers usually reply within 6 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
lambdaclass/ethlambda#777 · 1 reaction ·
Maintainers usually reply within 6 days
-
Run all gossip validation testsMay be free again @dicethedev claimed this 9 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
lambdaclass/ethlambda#725 · 2 comments ·
Maintainers usually reply within 6 days
-
Handle malformed DB dataMay be free again @dicethedev claimed this 115 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
lambdaclass/ethlambda#529 · 4 comments ·
Maintainers usually reply within 6 days
-
Document architectural choicesMay be free again @dicethedev claimed this 115 days ago, and no pull request is open. Open
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
lambdaclass/ethlambda#521 · 2 comments ·
Maintainers usually reply within 6 days
All issues in lambdaclass/ethlambda
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
antithesishq/bombadil#473 ·
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
libracoder/kiri#669 ·
Maintainers usually reply within 1 day
-
Difficulty 1/5 Under an hour Newbie friendliness 88/100
Maintainers usually reply within 5 days
-
autofixer: follow-up
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
tursodatabase/turso#12217 ·
Maintainers usually reply within 1 day
-
Declare the CMS schema library in the optional recipients extraPossibly taken A pull request linked to this issue is open or already merged. Openarea:python in-progress
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
yhay81/pyropdf#1005 · 2 comments ·
Maintainers usually reply within 1 day