Skip to content

Commit d828cd7

Browse files
committed
feat: require avs register metadata in allocation manager
1 parent 38f5faa commit d828cd7

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

src/contracts/core/AllocationManager.sol

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,8 @@ contract AllocationManager is
256256
) external onlyWhenNotPaused(PAUSED_OPERATOR_SET_REGISTRATION_AND_DEREGISTRATION) checkCanCall(operator) {
257257
// Check that the operator exists
258258
require(delegation.isOperator(operator), InvalidOperator());
259+
// Check that the AVS exists and has registered metadata
260+
require(_avsRegisteredMetadata[params.avs], InvalidAVSWithNoMetadataRegistered());
259261

260262
for (uint256 i = 0; i < params.operatorSetIds.length; i++) {
261263
// Check the operator set exists and the operator is not currently registered to it
@@ -282,6 +284,8 @@ contract AllocationManager is
282284
) external onlyWhenNotPaused(PAUSED_OPERATOR_SET_REGISTRATION_AND_DEREGISTRATION) {
283285
// Check that the caller is either authorized on behalf of the operator or AVS
284286
require(_checkCanCall(params.operator) || _checkCanCall(params.avs), InvalidCaller());
287+
// Check that the AVS exists and has registered metadata
288+
require(_avsRegisteredMetadata[params.avs], InvalidAVSWithNoMetadataRegistered());
285289

286290
for (uint256 i = 0; i < params.operatorSetIds.length; i++) {
287291
// Check the operator set exists and the operator is registered to it
@@ -324,6 +328,10 @@ contract AllocationManager is
324328

325329
/// @inheritdoc IAllocationManager
326330
function updateAVSMetadataURI(address avs, string calldata metadataURI) external checkCanCall(avs) {
331+
if (!_avsRegisteredMetadata[avs]) {
332+
_avsRegisteredMetadata[avs] = true;
333+
}
334+
327335
emit AVSMetadataURIUpdated(avs, metadataURI);
328336
}
329337

src/contracts/core/AllocationManagerStorage.sol

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ abstract contract AllocationManagerStorage is IAllocationManager {
4343
/// Note: if set to 0, defaults to the AVS's address
4444
mapping(address avs => IAVSRegistrar) internal _avsRegistrar;
4545

46+
/// @dev Lists the AVSs who has registered metadata and claimed itself as an AVS
47+
/// @notice bool is not used and if always true if the avs has registered metadata
48+
mapping(address avs => bool) internal _avsRegisteredMetadata;
49+
4650
/// @dev Lists the operator set ids an AVS has created
4751
mapping(address avs => EnumerableSet.UintSet) internal _operatorSets;
4852

@@ -102,5 +106,5 @@ abstract contract AllocationManagerStorage is IAllocationManager {
102106
* variables without shifting down storage in the inheritance chain.
103107
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
104108
*/
105-
uint256[37] private __gap;
109+
uint256[36] private __gap;
106110
}

src/contracts/interfaces/IAllocationManager.sol

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ interface IAllocationManagerErrors {
2323

2424
/// @dev Thrown when an invalid operator is provided.
2525
error InvalidOperator();
26+
/// @dev Thrown when an invalid avs whose metadata is not registered is provided.
27+
error InvalidAVSWithNoMetadataRegistered();
2628
/// @dev Thrown when an operator's allocation delay has yet to be set.
2729
error UninitializedAllocationDelay();
2830
/// @dev Thrown when attempting to slash an operator when they are not slashable.

0 commit comments

Comments
 (0)