Skip to content

Commit dabacbc

Browse files
authored
fix: Release Manager internal review fixes (#1571)
<!-- 🚨 ATTENTION! 🚨 This PR template is REQUIRED. PRs not following this format will be closed without review. Requirements: - PR title must follow commit conventions: https://www.conventionalcommits.org/en/v1.0.0/ - Label your PR with the correct type (e.g., πŸ› Bug, ✨ Enhancement, πŸ§ͺ Test, etc.) - Provide clear and specific details in each section --> **Motivation:** After an internal security review, a few helpful fixes were determined for code clarity and reduced complexity. **Modifications:** * Reduced complexity for publishing release * More appropriate function visibility **Result:** Cleaner, safer code
1 parent b00e79f commit dabacbc

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

β€Žsrc/contracts/core/ReleaseManager.solβ€Ž

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,7 @@ contract ReleaseManager is Initializable, ReleaseManagerStorage, PermissionContr
4040
// New release id is the length of the array before this call.
4141
releaseId = releases.length;
4242
// Increment total releases for this operator set.
43-
releases.push();
44-
// Copy the release to storage.
45-
for (uint256 i = 0; i < release.artifacts.length; ++i) {
46-
releases[releaseId].artifacts.push(release.artifacts[i]);
47-
}
48-
releases[releaseId].upgradeByTime = release.upgradeByTime;
43+
releases.push(release);
4944

5045
emit ReleasePublished(operatorSet, releaseId, release);
5146
}
@@ -81,8 +76,10 @@ contract ReleaseManager is Initializable, ReleaseManagerStorage, PermissionContr
8176
/// @inheritdoc IReleaseManager
8277
function getLatestRelease(
8378
OperatorSet memory operatorSet
84-
) public view returns (uint256, Release memory) {
79+
) external view returns (uint256, Release memory) {
8580
Release[] storage releases = _operatorSetReleases[operatorSet.key()];
81+
require(releases.length > 0, NoReleases());
82+
8683
uint256 latestReleaseId = releases.length - 1;
8784
return (latestReleaseId, releases[latestReleaseId]);
8885
}

β€Žsrc/contracts/core/ReleaseManagerStorage.solβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ abstract contract ReleaseManagerStorage is IReleaseManager {
1818
* variables without shifting down storage in the inheritance chain.
1919
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
2020
*/
21-
uint256[49] private __gap;
21+
uint256[48] private __gap;
2222
}

β€Žsrc/contracts/interfaces/IReleaseManager.solβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ interface IReleaseManagerErrors {
1212

1313
/// @notice Thrown when the metadata URI is empty.
1414
error InvalidMetadataURI();
15+
16+
/// @notice Thrown when there are no releases for an operator set.
17+
error NoReleases();
1518
}
1619

1720
interface IReleaseManagerTypes {

0 commit comments

Comments
Β (0)