Function: settleRail(uint256 railId, uint256 untilEpoch)
Settles payments for a rail up to the specified epoch. Settlement may fail to reach the target epoch if either the client lacks the funds to pay up to the current epoch or the validator refuses to settle the entire requested range.
Can only be one of the three participants in the rail, either the payer, payee or operator.
Inputs
railIdControl: Fully controlled by the caller.
Constraints: Must reference an active rail (
from != address(0)) — caller must be a rail participant (client, operator, or payee).Impact: Selects the rail to settle and determines token/payer/payee/validator context used by downstream logic.
untilEpochControl: Fully controlled by the caller.
Constraints: Must be ≤ current
block.number. Effective target is bounded by rail state — for active rails,min(untilEpoch, payer.lockupLastSettledAt), and for terminated rails,min(untilEpoch, rail.endEpoch).Impact: Upper bound for requested settlement window — influences how much is attempted to be settled.
Branches and code coverage
Intended branches
Called by client/payer.
Called by payee.
Called by operator.
Called on a terminated rail that is settled, but not finalized.
Called on a non-terminated rail.
Negative behavior
Caller is not a participant (payer, payee, operator).
untilEpochis in the future.Rate change queue is empty, but settlement has not progressed (i.e.
startEpoch <= rail.settledUpTo).
Function call analysis
this.burnAndRefundRest(Payments.NETWORK_FEE) -> Payments.burnAndRefundRest
What is controllable? N/A.
If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? The function consumes and native tokens and send these to the burn address. The remainder is refunded.
this.settleRailInternal(railId, untilEpoch, skipValidation) -> Payments.settleRailInternal
What is controllable?
railIdanduntilEpochare fully controllable.skipValidationis alwaysfalsehere.If the return value is controllable, how is it used and how can it go wrong? Returns only calculated values that are relayed to the initial caller directly.
railIdis already assumed valid, but an erroneous one would fail the firstisRailTerminatedcheck as addresses would be zero.What happens if it reverts, reenters or does other unusual control flow? Function is internal and only called from non-reentrant functions, where the second caller is an emergency function locked behind operator capabilities.