Skip to content

Prevent hash_tree_root caching of mutable objects #206

@ericsson49

Description

@ericsson49

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions