fork_choice: the filtered block tree costs leaves × depth through get_checkpoint_block
Maintainers usually reply within 6 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 58/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- rust
- Domain
- backend, performance
Research direction
Start in crates/blockchain/state_transition/src/beacon/fork_choice.rs at is_viable_leaf and read the get_checkpoint_block calls alongside the path stack added by #758. Compare the proposed ancestor and partition_point lookup with filter_block_tree_by_scan; the issue identifies a randomized differential test as coverage. Done means checkpoint lookup no longer walks each leaf's ancestry and the differential test passes.
Written by the indexing model from the issue text.
Description
is_viable_leaf (crates/blockchain/state_transition/src/beacon/fork_choice.rs:1989) calls get_checkpoint_block(index, block_root, finalized_checkpoint.epoch) once per leaf of the justified subtree. Each call walks that leaf back to the finalized epoch's start slot. Every head computation therefore costs leaves × depth.
The #746 measurements (https://github.com/lambdaclass/ethlambda/pull/746#issuecomment-6533272351) put that at 74 ms with 14,851 blocks and 451 leaves. During a finality stall the depth grows by a block every slot. Until lambdaclass/ethlambda#758, a stack overflow capped that depth; now nothing does.
This is out of scope for lambdaclass/ethlambda#758, which only replaces the recursion with an explicit stack and keeps the per-leaf check unchanged.
A fix (Pablo's sketch in the #758 review), using the path stack that #758 adds:
- If the justified block's slot is at or above the finalized epoch's start slot, every leaf has the same checkpoint block. One
get_ancestorfrom the justified root answers all of them. - Otherwise the checkpoint block lies on
path, between the justified root and the leaf. Apartition_pointby slot over the frames finds it without walking the index.
The randomized differential test against filter_block_tree_by_scan would cover the change.
- 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