You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
blockchain: discard_pending_subtree recurses once per pending descendant #810
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 #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 #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.
Activity