Skip to content

[A01-9] [LOW] BadMinStackLength declared in Flow.sol instead of ErrFlow.sol #414

@thedavidmeister

Description

@thedavidmeister

Description

Flow.sol:45 declares the error BadMinStackLength inline at file scope:

/// Thrown when the min outputs for a flow is fewer than the sentinels.
/// This is always an implementation bug as the min outputs and sentinel count
/// should both be compile time constants.
/// @param flowMinOutputs The min outputs for the flow.
error BadMinStackLength(uint256 flowMinOutputs);

Every other error reverted from Flow.sol (UnsupportedFlowInputs, InsufficientFlowOutputs, UnregisteredFlow, InitializeSignatureFn) is declared in a dedicated error file: src/error/ErrFlow.sol for the first three, and rain.factory/.../ICloneableV2.sol for the fourth. BadMinStackLength is the only outlier — it lives in the implementation file even though the convention in this repo is to centralise error declarations.

This forces consumers (interfaces, ABI bindings, integrators) to import Flow.sol (a concrete contract pulling in OZ Multicall, ReentrancyGuard, the interpreter caller, etc.) just to get the error selector.

Location

src/concrete/Flow.sol:41-45

Proposed fix

Move BadMinStackLength (and its NatSpec) to src/error/ErrFlow.sol, then import it from Flow.sol alongside UnsupportedFlowInputs / InsufficientFlowOutputs:

-import {UnsupportedFlowInputs, InsufficientFlowOutputs} from "../error/ErrFlow.sol";
+import {UnsupportedFlowInputs, InsufficientFlowOutputs, BadMinStackLength} from "../error/ErrFlow.sol";
...
-/// Thrown when the min outputs for a flow is fewer than the sentinels.
-/// ...
-error BadMinStackLength(uint256 flowMinOutputs);

And in ErrFlow.sol, add the declaration with its NatSpec.

Metadata

Metadata

Assignees

No one assigned

    Labels

    auditAudit findinglowSeverity: lowpass4Audit Pass 4: Code Quality

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions