Skip to content

Make List::tree_hash_root infallible by computing hashes with pending updates#92

Open
Copilot wants to merge 9 commits intomainfrom
copilot/update-tree-hash-root-method
Open

Make List::tree_hash_root infallible by computing hashes with pending updates#92
Copilot wants to merge 9 commits intomainfrom
copilot/update-tree-hash-root-method

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 13, 2026

Implementation Summary

Successfully implemented infallible tree_hash_root for List and Vector that handles pending updates without requiring apply_updates() to be called first.

Changes Made

  • Added methods to ImmList trait to enable tree traversal (tree(), depth(), packing_depth())
  • Implemented new tree_hash_root method in Interface that:
    • Computes tree hashes with pending updates
    • Uses cached hashes for subtrees without updates for efficiency
    • Handles both packed and regular leaves
    • Handles Zero trees with pending updates (empty lists with pushes)
    • Recursively traverses the tree
  • Updated List::tree_hash_root and Vector::tree_hash_root:
    • Removed assertions about pending updates
    • Delegated to new interface method
  • Implemented trait methods for ListInner and VectorInner
  • Added comprehensive tests (11 tests total):
    • Empty list with pending push
    • Large lists with updates at different depths
    • Multiple pending pushes
    • Vector with pending updates
    • Packed types with multiple updates in same leaf
    • Single element list
    • All elements updated
  • Addressed all code review feedback
  • Ran cargo fmt to format code

Testing

All 282 tests pass (7 new tests added):

  • Tree hash and SSZ tests
  • Operations tests
  • Rebase tests
  • Comprehensive pending updates tests covering edge cases

Coverage Improvements

Added tests for:

  • Empty lists transitioning to non-empty via pending updates
  • Large lists exercising deeper tree structures
  • Multiple simultaneous pending pushes
  • Vector-specific pending update paths
  • Packed leaf edge cases with multiple updates
  • Complete list update scenarios
Original prompt

I want you to update the tree_hash_root method on List so that it is infallible, i.e. remove the assert about pending updates. To do this safely, I think the best approach is to make use of the pending updates while hashing. Add a new tree_hash_root method to interface.rs which can handle getting hashes from the pending updates or from cached within the tree as appropriate. You may need to add some methods to the ImmList trait in order to enable tree traversal from this generic code.

After your changes all of the tests run by cargo test --release should pass. While you are making changes you can quickly check that your code compiles with cargo check.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 4 commits January 13, 2026 01:12
Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
…ControlFlow

Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
Copilot AI changed the title [WIP] Update tree_hash_root method for infallibility Make List::tree_hash_root infallible by computing hashes with pending updates Jan 13, 2026
Copilot AI requested a review from michaelsproul January 13, 2026 01:30
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 66.90647% with 46 lines in your changes missing coverage. Please review.
✅ Project coverage is 69.94%. Comparing base (4d88c72) to head (a0c1d0b).

Files with missing lines Patch % Lines
src/interface.rs 64.80% 44 Missing ⚠️
src/list.rs 85.71% 1 Missing ⚠️
src/vector.rs 85.71% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #92      +/-   ##
==========================================
- Coverage   70.15%   69.94%   -0.22%     
==========================================
  Files          22       22              
  Lines        1280     1414     +134     
==========================================
+ Hits          898      989      +91     
- Misses        382      425      +43     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@michaelsproul
Copy link
Copy Markdown
Member

@copilot Please run cargo fmt and try to increase coverage by looking at the coverage report from coverrals (or run cargo-tarpaulin locally)

Copilot AI and others added 2 commits January 13, 2026 01:54
Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
…pending updates

Co-authored-by: michaelsproul <4452260+michaelsproul@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 13, 2026

@copilot Please run cargo fmt and try to increase coverage by looking at the coverage report from coverrals (or run cargo-tarpaulin locally)

Done! I've:

  1. Run cargo fmt - committed formatting changes in 506cbfe
  2. Added 7 comprehensive tests to increase coverage in b38cdef:
    • Empty list with pending push (tests Zero tree with updates)
    • Large lists (exercises deeper tree structures)
    • Multiple pending pushes
    • Vector with pending updates
    • Packed types with multiple updates in same leaf
    • Single element list
    • All elements updated

All 282 tests now pass. The new tests cover edge cases like empty lists transitioning to non-empty via pending updates, and Zero tree handling which wasn't previously tested.

@michaelsproul michaelsproul marked this pull request as ready for review February 17, 2026 22:48
@michaelsproul michaelsproul mentioned this pull request Feb 17, 2026
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