Skip to content

Commit

Permalink
Merge branch 'm2-mainnet' into feat/remove-set-withdrawal-delay
Browse files Browse the repository at this point in the history
  • Loading branch information
8sunyuan authored Dec 4, 2023
2 parents 810b2a1 + 87f980e commit a152b05
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/certora-prover.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
- master
- release-v*
- formal-verification
- fix-ci-errors
- m2-mainnet
pull_request: {}
workflow_dispatch: {}

Expand Down
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 @@ -142,6 +142,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
2 changes: 1 addition & 1 deletion src/test/WithdrawalMigration.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ contract WithdrawalMigrationTests is EigenLayerTestHelper, Utils {
IERC20 cbETH = IERC20(_CBETH_ADDRESS);

function setUp() public override {
vm.createSelectFork("https://eth.llamarpc.com", _M1_BLOCK_FORK);
vm.createSelectFork(cheats.envString("RPC_MAINNET"), _M1_BLOCK_FORK);
beaconChainETHStrategy = m1StrategyManager.beaconChainETHStrategy();
// Unpause strategyManager
cheats.prank(_M1_UNPAUSER);
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
18 changes: 15 additions & 3 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);

uint256 initializedWithdrawalDelayBlocks = 50400;

Expand Down Expand Up @@ -241,7 +242,7 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag
_registerOperator(operator, operatorDetails, emptyStringForMetadataURI);
}

function _registerOperatorWith1271DelegationApprover(address operator) internal {
function _registerOperatorWith1271DelegationApprover(address operator) internal returns (ERC1271WalletMock) {
address delegationSigner = cheats.addr(delegationSignerPrivateKey);
/**
* deploy a ERC1271WalletMock contract with the `delegationSigner` address as the owner,
Expand All @@ -255,6 +256,8 @@ contract DelegationManagerUnitTests is EigenLayerUnitTestSetup, IDelegationManag
stakerOptOutWindowBlocks: 0
});
_registerOperator(operator, operatorDetails, emptyStringForMetadataURI);

return wallet;
}

function _registerOperator(
Expand Down Expand Up @@ -580,6 +583,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 Expand Up @@ -1399,8 +1411,8 @@ contract DelegationManagerUnitTests_delegateTo is DelegationManagerUnitTests {

// register *this contract* as an operator
// filter inputs, since this will fail when the staker is already registered as an operator
cheats.assume(staker != defaultOperator);
_registerOperatorWith1271DelegationApprover(defaultOperator);
ERC1271WalletMock wallet = _registerOperatorWith1271DelegationApprover(defaultOperator);
cheats.assume(staker != address(wallet) && staker != defaultOperator);

// calculate the delegationSigner's signature
ISignatureUtils.SignatureWithExpiry memory approverSignatureAndExpiry = _getApproverSignature(
Expand Down

0 comments on commit a152b05

Please sign in to comment.