Skip to content

Commit

Permalink
feat: enable AVS update metadata uri (#354)
Browse files Browse the repository at this point in the history
* feat:enable AVS update metadata uri

* test: add unit test
  • Loading branch information
bowenli86 authored Dec 1, 2023
1 parent b91a743 commit b599cfe
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ broadcast

# Deployment tools
/data
.idea/

# Certora Outputs
.certora_internal/
Expand Down
8 changes: 8 additions & 0 deletions src/contracts/core/DelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 14 additions & 0 deletions src/contracts/interfaces/IDelegationManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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.
Expand Down
6 changes: 6 additions & 0 deletions src/test/events/IDelegationManagerEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 2 additions & 0 deletions src/test/mocks/DelegationManagerMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
10 changes: 10 additions & 0 deletions src/test/unit/DelegationUnit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit b599cfe

Please sign in to comment.