Summary
Investigate whether conversions from versioned actor state types to Forest shim types should consume the source value instead of converting from a reference.
Many implementations use patterns such as TryFrom<&fil_actor_*_state::vN::Type> for ShimType. These implementations clone owned fields. The conversion may often occur after the source value is no longer needed.
Required changes
- Inventory conversion implementations in the actor state shims that use
TryFrom<&VersionedType> for ShimType.
- Determine call sites where the versioned value can be moved safely.
- Prefer consuming conversions, such as
TryFrom<VersionedType> for ShimType, when ownership and API behavior permit it.
- Retain reference conversions where callers must preserve the source value or where a move is not practical.
- Measure or otherwise document the reduction in unnecessary cloning for changed conversions.
Affected areas
Initial example:
src/shim/actors/builtin/market/mod.rs
TryFrom<&fil_actor_market_state::vN::DealProposal> for DealProposal, including the v19 implementation
Other actor shim modules may contain the same conversion pattern.
Rationale
Consuming a versioned value can avoid cloning labels, collateral values, and other owned fields. The compiler can identify call sites where the source value is still required.
Acceptance criteria
- The investigation identifies applicable conversions and their call sites.
- Safe consuming conversions replace reference conversions where appropriate.
- Reference conversions remain only where required, with rationale where non-obvious.
- Relevant tests or compile checks cover modified conversion paths.
Backlinks
Summary
Investigate whether conversions from versioned actor state types to Forest shim types should consume the source value instead of converting from a reference.
Many implementations use patterns such as
TryFrom<&fil_actor_*_state::vN::Type> for ShimType. These implementations clone owned fields. The conversion may often occur after the source value is no longer needed.Required changes
TryFrom<&VersionedType> for ShimType.TryFrom<VersionedType> for ShimType, when ownership and API behavior permit it.Affected areas
Initial example:
src/shim/actors/builtin/market/mod.rsTryFrom<&fil_actor_market_state::vN::DealProposal> for DealProposal, including the v19 implementationOther actor shim modules may contain the same conversion pattern.
Rationale
Consuming a versioned value can avoid cloning labels, collateral values, and other owned fields. The compiler can identify call sites where the source value is still required.
Acceptance criteria
Backlinks