linera-io / linera-protocol

Main repository for the Linera protocol
Apache License 2.0
112 stars 94 forks source link

Fix rollback making cached hash value incorrect #2197

Closed jvff closed 1 week ago

jvff commented 1 week ago

Motivation

When a view wrapped in a WrappedHashableContainverView is cleared and flushed, its state in the persistent storage was cleared. However, the value of the persisted hash value that was cached in memory was not cleared, making it different than the value that was actually persisted (which was an empty value, because it was also cleared). When rollback is called, it uses the cached stored value to update the cached staged value, which set it to an invalid value.

Proposal

Clear the cached value of the stored hash value when it is cleared from disk.

Test Plan

A unit test was added that reproduces a minimal scenario, and that fails without the fix and passes with the fix.

Release Plan

This is a bug fix, so nothing is needed except releasing a new patch version.

Links