From 29bcc9adc578a0c3a22d41349e124d982fd51b12 Mon Sep 17 00:00:00 2001 From: Bowen Li Date: Thu, 30 Nov 2023 22:13:38 -0800 Subject: [PATCH 1/2] feat:enable AVS update metadata uri --- .gitignore | 1 + src/contracts/core/DelegationManager.sol | 8 ++++++++ src/contracts/interfaces/IDelegationManager.sol | 14 ++++++++++++++ src/test/events/IDelegationManagerEvents.sol | 6 ++++++ src/test/mocks/DelegationManagerMock.sol | 2 ++ 5 files changed, 31 insertions(+) diff --git a/.gitignore b/.gitignore index 53efdc4ed..84f7c801c 100644 --- a/.gitignore +++ b/.gitignore @@ -22,6 +22,7 @@ broadcast # Deployment tools /data +.idea/ # Certora Outputs .certora_internal/ diff --git a/src/contracts/core/DelegationManager.sol b/src/contracts/core/DelegationManager.sol index d4d9824ff..3fc1befc9 100644 --- a/src/contracts/core/DelegationManager.sol +++ b/src/contracts/core/DelegationManager.sol @@ -139,6 +139,14 @@ contract DelegationManager is Initializable, OwnableUpgradeable, Pausable, Deleg emit OperatorMetadataURIUpdated(msg.sender, metadataURI); } + /** + * @notice Called by an avs to emit an `AVSMetadataURIUpdated` event indicating the information has updated. + * @param metadataURI The URI for metadata associated with an avs + */ + function updateAVSMetadataURI(string calldata metadataURI) external { + emit AVSMetadataURIUpdated(msg.sender, metadataURI); + } + /** * @notice Caller delegates their stake to an operator. * @param operator The account (`msg.sender`) is delegating its assets to for use in serving applications built on EigenLayer. diff --git a/src/contracts/interfaces/IDelegationManager.sol b/src/contracts/interfaces/IDelegationManager.sol index 528b62e50..08a52172f 100644 --- a/src/contracts/interfaces/IDelegationManager.sol +++ b/src/contracts/interfaces/IDelegationManager.sol @@ -116,6 +116,12 @@ interface IDelegationManager is ISignatureUtils { */ event OperatorMetadataURIUpdated(address indexed operator, string metadataURI); + /** + * @notice Emitted when @param avs indicates that they are updating their MetadataURI string + * @dev Note that these strings are *never stored in storage* and are instead purely emitted in events for off-chain indexing + */ + event AVSMetadataURIUpdated(address indexed avs, string metadataURI); + /// @notice Emitted whenever an operator's shares are increased for a given strategy. Note that shares is the delta in the operator's shares. event OperatorSharesIncreased(address indexed operator, address staker, IStrategy strategy, uint256 shares); @@ -173,9 +179,17 @@ interface IDelegationManager is ISignatureUtils { /** * @notice Called by an operator to emit an `OperatorMetadataURIUpdated` event indicating the information has updated. * @param metadataURI The URI for metadata associated with an operator + * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `OperatorMetadataURIUpdated` event */ function updateOperatorMetadataURI(string calldata metadataURI) external; + /** + * @notice Called by an AVS to emit an `AVSMetadataURIUpdated` event indicating the information has updated. + * @param metadataURI The URI for metadata associated with an AVS + * @dev Note that the `metadataURI` is *never stored * and is only emitted in the `AVSMetadataURIUpdated` event + */ + function updateAVSMetadataURI(string calldata metadataURI) external; + /** * @notice Caller delegates their stake to an operator. * @param operator The account (`msg.sender`) is delegating its assets to for use in serving applications built on EigenLayer. diff --git a/src/test/events/IDelegationManagerEvents.sol b/src/test/events/IDelegationManagerEvents.sol index 9219523e9..e82d9c458 100644 --- a/src/test/events/IDelegationManagerEvents.sol +++ b/src/test/events/IDelegationManagerEvents.sol @@ -20,6 +20,12 @@ interface IDelegationManagerEvents { */ event OperatorMetadataURIUpdated(address indexed operator, string metadataURI); + /** + * @notice Emitted when @param avs indicates that they are updating their MetadataURI string + * @dev Note that these strings are *never stored in storage* and are instead purely emitted in events for off-chain indexing + */ + event AVSMetadataURIUpdated(address indexed avs, string metadataURI); + /// @notice Emitted whenever an operator's shares are increased for a given strategy event OperatorSharesIncreased(address indexed operator, address staker, IStrategy strategy, uint256 shares); diff --git a/src/test/mocks/DelegationManagerMock.sol b/src/test/mocks/DelegationManagerMock.sol index 75427229e..3937aa45d 100644 --- a/src/test/mocks/DelegationManagerMock.sol +++ b/src/test/mocks/DelegationManagerMock.sol @@ -28,6 +28,8 @@ contract DelegationManagerMock is IDelegationManager, Test { function updateOperatorMetadataURI(string calldata /*metadataURI*/) external pure {} + function updateAVSMetadataURI(string calldata /*metadataURI*/) external pure {} + function delegateTo(address operator, SignatureWithExpiry memory /*approverSignatureAndExpiry*/, bytes32 /*approverSalt*/) external { delegatedTo[msg.sender] = operator; } From cbccaaf862c7d7ea30537a6c94c7483cf85fe0e5 Mon Sep 17 00:00:00 2001 From: Bowen Li Date: Fri, 1 Dec 2023 11:02:26 -0800 Subject: [PATCH 2/2] test: add unit test --- src/test/unit/DelegationUnit.t.sol | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/test/unit/DelegationUnit.t.sol b/src/test/unit/DelegationUnit.t.sol index ca98d5834..596b048e2 100644 --- a/src/test/unit/DelegationUnit.t.sol +++ b/src/test/unit/DelegationUnit.t.sol @@ -42,6 +42,7 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag // reused in various tests. in storage to help handle stack-too-deep errors address defaultStaker = cheats.addr(uint256(123_456_789)); address defaultOperator = address(this); + address defaultAVS = address(this); IStrategy public constant beaconChainETHStrategy = IStrategy(0xbeaC0eeEeeeeEEeEeEEEEeeEEeEeeeEeeEEBEaC0); @@ -580,6 +581,15 @@ contract DelegationManagerUnitTests_RegisterModifyOperator is DelegationManagerU emit OperatorMetadataURIUpdated(defaultOperator, metadataURI); delegationManager.updateOperatorMetadataURI(metadataURI); } + + // @notice Tests that an avs who calls `updateAVSMetadataURI` will correctly see an `AVSMetadataURIUpdated` event emitted with their input + function testFuzz_UpdateAVSMetadataURI(string memory metadataURI) public { + // call `updateAVSMetadataURI` and check for event + cheats.prank(defaultAVS); + cheats.expectEmit(true, true, true, true, address(delegationManager)); + emit AVSMetadataURIUpdated(defaultAVS, metadataURI); + delegationManager.updateAVSMetadataURI(metadataURI); + } } contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests {