filecoin-project / ref-fvm

Reference implementation of the Filecoin Virtual Machine
https://fvm.filecoin.io/
Other
384 stars 139 forks source link

HAMT/AMT flush always writes node to store, even when unchanged #1443

Closed anorth closed 1 year ago

anorth commented 1 year ago

The HAMT and AMT flush methods write the root block content to store even if it's the same data that was read from store. While this could in theory be detected and prevented by callers, it's easily overlooked. For example, a common pattern is:

To implement, I suggest Node::flush() return a boolean indicating whether it wrote anything, and then skip writing the root node if it didn't.

Stebalien commented 1 year ago

https://github.com/filecoin-project/ref-fvm/pull/901 https://github.com/filecoin-project/ref-fvm/pull/1272

(or is this something different)

anorth commented 1 year ago

That looks like it. Sigh, why aren't the actors using this? I guess it went on the v3 branch even though we were deploying actors v10 on fvm v2.