blockchain: discard_pending_subtree recurses once per pending descendant

未關閉
#810 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 6 天內回覆

還沒有人認領這個 Issue。

評估

難度
3/5
預估耗時
1-2 天
新手友好度
68/100
Issue 類型
缺陷
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
rust

研究方向

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.

由索引模型根據 Issue 內容生成。

描述

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.

主要語言
Rust
星號
86
分支
34
平均合併
9 天 20 小時
30 天內合併 PR
77

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

lambdaclass/ethlambda 的其他 Issue

查看 lambdaclass/ethlambda 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。