You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
it("should not recompute hashTreeRoot() when no fields is changed",()=>{constroot=state.hashTreeRoot();// this causes viewsChanged inside BeaconState containerstate.validators.length;state.balances.length;// but we should not recompute root, should get from cache insteadconstroot2=state.hashTreeRoot();expect(root2).to.equal(root,"should not recompute hashTreeRoot() when no fields are changed");});
the BeaconState container tracked validators and length as "viewsChanged" and it rebinds the underlying tree to compute new root with same nodes, which results in the same value but different tree/nodes, and we need to rehash the different nodes
note that #378 implemented a cache that returns the same root for multiple ViewDU.hashTreeRoot() calls
Expected behavior
according to the design of ssz v2, BeaconState container should still track validators and balances as "viewsChanged" so that when we modify them they will escalate the change to BeaconState. However when we commit those viewDUs, if we see no change we should not rebind the nodes, and it should return the same cached root
Describe the bug
Consider this unit test here in #378
the BeaconState container tracked
validators
andlength
as"viewsChanged"
and it rebinds the underlying tree to compute new root with same nodes, which results in the same value but different tree/nodes, and we need to rehash the different nodesnote that #378 implemented a cache that returns the same root for multiple
ViewDU.hashTreeRoot()
callsExpected behavior
validators
andbalances
as "viewsChanged" so that when we modify them they will escalate the change to BeaconState. However when we commit those viewDUs, if we see no change we should not rebind the nodes, and it should return the same cached rootSteps to Reproduce
The text was updated successfully, but these errors were encountered: