ChainSafe / ChainSafe/forest

Backport `for_each_cacheless` to fvm2 and fvm3 state trees

Open
#7,238 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
697
Forks
200
Avg merge
1d 5h
Merged PRs (30d)
65

Description

## Summary

Currently, `StateTree::for_each_cacheless` in `src/shim/state_tree.rs` falls back to the caching `for_each` for `FvmV2` and `FvmV3` variants, because those upstream crates do not yet expose a cacheless iteration API. Only `FvmV4` has a native `for_each_cacheless`.

## Required Changes

1. Contribute `for_each_cacheless` upstream to the `fvm2` and `fvm3` crates (or, if upstream is not feasible, implement a workaround in the shim layer that avoids caching HAMT nodes during iteration).
2. Once available, update `StateTree::for_each_cacheless` in `src/shim/state_tree.rs` to call the native cacheless method for `FvmV2` and `FvmV3` variants instead of falling back to `for_each`.

## Affected Files

- `src/shim/state_tree.rs` — `StateTree::for_each_cacheless` implementation for `FvmV2` and `FvmV3` arms.

## Context

- Introduced in PR: https://github.com/ChainSafe/forest/pull/7237
- Review comment: https://github.com/ChainSafe/forest/pull/7237#discussion_r3468497399

## Acceptance Criteria

- `StateTree::for_each_cacheless` for `FvmV2` and `FvmV3` no longer caches HAMT nodes during iteration.
- Memory usage during state-tree iteration on older network versions is comparable to `FvmV4`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.