Skip to content

Investigate consuming conversions for versioned actor state shim types #7633

Description

@coderabbitai

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions