Skip to content

on_initialize in pallet-commitments performs heavy work but returns Weight::zero() #1989

@PraetorP

Description

@PraetorP

Hi @JohnReedV,

While reviewing the pallet-commitments code I noticed a potentially critical issue with the on_initialize implementation:

🔗 pallets/commitments/src/lib.rs#L365


Problem

  • The function performs non-trivial iteration over storage and executes complex logic.
  • However, it returns Weight::zero().
  • This causes a mismatch between the actual CPU/memory work and the weight system.

Potential Risks

  • Unaccounted workload: since on_initialize returns Weight::zero(), heavy storage iteration is not deducted from the block weight budget. Extrinsics can fill their 75% quota while this logic still executes “for free”.
  • Slot timing issues: block production (Proposer::propose) has a strict max_duration tied to the consensus slot. If on_initialize takes significant time but is reported as zero weight, authors might not complete block construction within the deadline, leading to missed slots.
  • Reduced throughput / liveness: in a solochain, consistent missed slots do not directly break finalization, but they reduce effective throughput and can impact network liveness if too many blocks are skipped.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions