Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unimplement TreeHash for BeaconState #6083

Merged
merged 1 commit into from
Jul 12, 2024

Conversation

michaelsproul
Copy link
Member

Issue Addressed

Since we moved to tree-states the tree_hash_root method on BeaconState became potentially dangerous. It would panic if any pending updates were waiting to be applied to the tree. We've done a good job of vetting that this doesn't happen on production code paths, but it's easy to do accidentally in tests, and I'm worried about regressions.

More background here:

Proposed Changes

  • Remove the trait implementation of TreeHash for BeaconState as a safeguard against accidental misuse.
  • Change the canonical_root method to call the safe mutable method update_tree_hash_cache.
  • Update all usages (mostly tests). I've used unwrap liberally in tests as hashing a valid state should never fail.

@michaelsproul michaelsproul added ready-for-review The code is ready for review code-quality consensus An issue/PR that touches consensus code, such as state_processing or block verification. tree-states Upcoming state and database overhaul labels Jul 12, 2024
Copy link
Collaborator

@dapplion dapplion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quite painless change to remove this nasty footgun. Future mantainers will appreciate :)

@michaelsproul michaelsproul added ready-for-merge This PR is ready to merge. and removed ready-for-review The code is ready for review labels Jul 12, 2024
@michaelsproul
Copy link
Member Author

@mergify queue

Copy link

mergify bot commented Jul 12, 2024

queue

✅ The pull request has been merged automatically

The pull request has been merged automatically at 2f0af2b

mergify bot added a commit that referenced this pull request Jul 12, 2024
@mergify mergify bot merged commit 2f0af2b into sigp:unstable Jul 12, 2024
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code-quality consensus An issue/PR that touches consensus code, such as state_processing or block verification. ready-for-merge This PR is ready to merge. tree-states Upcoming state and database overhaul
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants