Omniscia rain protocol Audit

TierReport Code Style Findings

TierReport Code Style Findings

TRT-01C: Redundant Maximum Tier Enforcement

Description:

The updateBlocksForTierRange function redundantly enforces the maxTier modifier on both the startTier_ and the endTier_.

Example:

contracts/tier/libraries/TierReport.sol
121/// Updates a report with a block number for every tier in a range.
122///
123/// Does nothing if the end status is equal or less than the start tier.
124/// @param report_ The report to update.
125/// @param startTier_ The tier at the start of the range (exclusive).
126/// @param endTier_ The tier at the end of the range (inclusive).
127/// @param blockNumber_ The block number to set for every tier in the
128/// range.
129/// @return The updated report.
130function updateBlocksForTierRange(
131 uint256 report_,
132 uint256 startTier_,
133 uint256 endTier_,
134 uint256 blockNumber_
135) internal pure maxTier(startTier_) maxTier(endTier_) returns (uint256) {
136 unchecked {
137 uint256 offset_;
138 for (uint256 i_ = startTier_; i_ < endTier_; i_++) {
139 offset_ = i_ * 32;
140 report_ =
141 (report_ &
142 ~uint256(
143 uint256(TierConstants.NEVER_TIER) << offset_
144 )) |
145 uint256(blockNumber_ << offset_);
146 }
147 return report_;
148 }
149}

Recommendation:

Given that both are used in the for construct within the function, we advise only endTier_ to be evaluated as in the case whereby endTier_ <= startTier_ the function results in a no-op.

Alleviation:

The redundant maximum tier enforcement for startTier_ was safely omitted from the codebase.