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

Prevent hash_tree_root caching of mutable objects #206

Open
ericsson49 opened this issue Sep 25, 2019 · 0 comments
Open

Prevent hash_tree_root caching of mutable objects #206

ericsson49 opened this issue Sep 25, 2019 · 0 comments
Labels
bug Something isn't working

Comments

@ericsson49
Copy link
Contributor

CachingBeaconChainSpec::hash_tree_root can be passed with a mutable object, e.g. MutableBeaconState or WriteList/WriteVector. Thus it can return wrong value, if the mutable object is modified, since the caching code uses Object identity (BeaconStateImple::hashCode is not overridden).
There are several possible ways to solve the problem:

  1. implement proper BeaconStateImple::hashCode to match the BeaconStateImple::equals implementation
  2. Invalidate cache based on updates
  3. Do not cache mutable objects. This will require implementing an appropriate flag/interface to manifest (im)mutability.
@ericsson49 ericsson49 added the bug Something isn't working label Sep 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant