Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce Group Max Size Limit of 1000 #395

Merged
merged 2 commits into from
Feb 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions contracts/lib/Errors.sol
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ library Errors {
/// @notice Group Pool is not registered.
error GroupIPAssetRegistry__GroupRewardPoolNotRegistered(address groupPool);

/// @notice The group size exceeds the limit.
error GroupIPAssetRegistry__GroupSizeExceedsLimit(uint256 groupSize, uint256 limit);

/// @notice The group ip has derivative IPs.
error GroupingModule__GroupFrozenDueToHasDerivativeIps(address groupId);

Expand Down Expand Up @@ -1049,4 +1052,7 @@ library Errors {

/// @notice Deposit token into pool but the token address is zero.
error EvenSplitGroupPool__DepositWithZeroTokenAddress(address groupId);

/// @notice The maximum group size has been reached.
error EvenSplitGroupPool__MaxGroupSizeReached(address groupId, uint32 groupSize, uint256 maxGroupSize);
}
5 changes: 4 additions & 1 deletion contracts/modules/grouping/EvenSplitGroupPool.sol
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ contract EvenSplitGroupPool is IGroupRewardPool, ProtocolPausableUpgradeable, UU
/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IGroupIPAssetRegistry public immutable GROUP_IP_ASSET_REGISTRY;

uint32 public constant MAX_GROUP_SIZE = 1_000_000_000;
uint32 public constant MAX_GROUP_SIZE = 1_000;

/// @dev Storage structure for the GroupInfo
/// As a group can only attach one non-default license to it, the reward token is defined by the license terms
Expand Down Expand Up @@ -101,6 +101,9 @@ contract EvenSplitGroupPool is IGroupRewardPool, ProtocolPausableUpgradeable, UU
if (_isIpAdded(groupId, ipId)) return groupInfo.averageRewardShare * $.groupInfo[groupId].totalMembers;
$.ipAddedTime[groupId][ipId] = block.timestamp;
groupInfo.totalMembers += 1;
if (groupInfo.totalMembers > MAX_GROUP_SIZE) {
revert Errors.EvenSplitGroupPool__MaxGroupSizeReached(groupId, groupInfo.totalMembers, MAX_GROUP_SIZE);
}
if (minimumGroupRewardShare > 0) {
$.minimumRewardShare[groupId][ipId] = minimumGroupRewardShare;
groupInfo.averageRewardShare = Math.max(groupInfo.averageRewardShare, minimumGroupRewardShare);
Expand Down
5 changes: 5 additions & 0 deletions contracts/registries/GroupIPAssetRegistry.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ abstract contract GroupIPAssetRegistry is IGroupIPAssetRegistry, ProtocolPausabl
using IPAccountStorageOps for IIPAccount;
using EnumerableSet for EnumerableSet.AddressSet;

uint256 public constant MAX_GROUP_SIZE = 1000;

/// @custom:oz-upgrades-unsafe-allow state-variable-immutable
IGroupingModule public immutable GROUPING_MODULE;

Expand Down Expand Up @@ -95,6 +97,9 @@ abstract contract GroupIPAssetRegistry is IGroupIPAssetRegistry, ProtocolPausabl
if (!_isRegistered(ipIds[i])) revert Errors.GroupIPAssetRegistry__NotRegisteredIP(ipIds[i]);
allMemberIpIds.add(ipIds[i]);
}
if (allMemberIpIds.length() > MAX_GROUP_SIZE) {
revert Errors.GroupIPAssetRegistry__GroupSizeExceedsLimit(allMemberIpIds.length(), MAX_GROUP_SIZE);
}
}

/// @notice Removes a member from a Group IPA
Expand Down