Skip to content

Fix: potential OOM in TreeFromNodes for large limits#65

Merged
pk910 merged 3 commits intopk910:masterfrom
Sahil-4555:optimize-tree-proof
Dec 19, 2025
Merged

Fix: potential OOM in TreeFromNodes for large limits#65
pk910 merged 3 commits intopk910:masterfrom
Sahil-4555:optimize-tree-proof

Conversation

@Sahil-4555
Copy link
Copy Markdown
Contributor

While running the TestBeaconState_BlockRootAtIndexProof test in fastssz, TreeFromNodes was invoked with a very large limit derived from a generalized index. Allocating memory based on this limit caused excessive allocations and resulted in an out-of-memory (OOM) error.

This change avoids allocating storage proportional to limit and instead constructs the tree bottom-up using only the actual number of leaves, filling missing nodes with zero-hashes. This keeps memory usage bounded and prevents OOM when limit is much larger than the real tree size.

@codecov
Copy link
Copy Markdown

codecov Bot commented Dec 19, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.65%. Comparing base (482fc6b) to head (dce6b4a).
⚠️ Report is 14 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #65      +/-   ##
==========================================
+ Coverage   83.65%   87.65%   +3.99%     
==========================================
  Files          34       34              
  Lines        5856     5831      -25     
==========================================
+ Hits         4899     5111     +212     
+ Misses        572      424     -148     
+ Partials      385      296      -89     
Components Coverage Δ
dynssz 89.10% <ø> (+8.47%) ⬆️
dynsszgen 84.56% <ø> (+1.86%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@pk910
Copy link
Copy Markdown
Owner

pk910 commented Dec 19, 2025

Thanks for the fix, this looks very good (again :D).

@pk910 pk910 merged commit 1c1e61b into pk910:master Dec 19, 2025
17 checks passed
@nongbivl01-source
Copy link
Copy Markdown

...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants