Skip to content

Commit

Permalink
ELIP-001:middleware test
Browse files Browse the repository at this point in the history
  • Loading branch information
daring5920 committed Jan 6, 2025
1 parent e28d90f commit fa830e3
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 93 deletions.
2 changes: 1 addition & 1 deletion lib/eigenlayer-contracts
20 changes: 0 additions & 20 deletions test/integration/mocks/BeaconChainOracleMock.t.sol

This file was deleted.

42 changes: 12 additions & 30 deletions test/mocks/AVSDirectoryMock.sol
Original file line number Diff line number Diff line change
@@ -1,52 +1,34 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.8.12;
pragma solidity ^0.8.12;

import {IAVSDirectory, ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol";

contract AVSDirectoryMock is IAVSDirectory {
/**
* @notice Called by an avs to register an operator with the avs.
* @param operator The address of the operator to register.
* @param operatorSignature The signature, salt, and expiry of the operator's signature.
*/
mapping(address => mapping(bytes32 => bool)) public operatorSaltIsSpentMapping;

function registerOperatorToAVS(
address operator,
ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature
) external {}

/**
* @notice Called by an avs to deregister an operator with the avs.
* @param operator The address of the operator to deregister.
*/
function deregisterOperatorFromAVS(address operator) 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 Returns whether or not the salt has already been used by the operator.
* @dev Salts is used in the `registerOperatorToAVS` function.
*/
function operatorSaltIsSpent(address operator, bytes32 salt) external view returns (bool) {}

/**
* @notice Calculates the digest hash to be signed by an operator to register with an AVS
* @param operator The account registering as an operator
* @param avs The AVS the operator is registering to
* @param salt A unique and single use value associated with the approver signature.
* @param expiry Time after which the approver's signature becomes invalid
*/
function operatorSaltIsSpent(address operator, bytes32 salt) external view returns (bool) {
return operatorSaltIsSpentMapping[operator][salt];
}

function calculateOperatorAVSRegistrationDigestHash(
address operator,
address avs,
bytes32 salt,
uint256 expiry
) external view returns (bytes32) {}

/// @notice The EIP-712 typehash for the Registration struct used by the contract
function OPERATOR_AVS_REGISTRATION_TYPEHASH() external view returns (bytes32) {}
}

function cancelSalt(bytes32 salt) external {}

function domainSeparator() external view returns (bytes32) {}
}
44 changes: 26 additions & 18 deletions test/mocks/DelegationMock.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity =0.8.12;
pragma solidity ^0.8.12;

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
import "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol";

import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol";
import {IStrategyManager} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol";
Expand All @@ -12,6 +13,12 @@ contract DelegationMock is IDelegationManager {
mapping(address => bool) public isOperator;
mapping(address => mapping(IStrategy => uint256)) public operatorShares;

function getDelegatableShares(address staker) external view returns (IStrategy[] memory, uint256[] memory) {}

function setMinWithdrawalDelayBlocks(uint256 newMinWithdrawalDelayBlocks) external {}

function setStrategyWithdrawalDelayBlocks(IStrategy[] calldata strategies, uint256[] calldata withdrawalDelayBlocks) external {}

function setIsOperator(address operator, bool _isOperatorReturnValue) external {
isOperator[operator] = _isOperatorReturnValue;
}
Expand Down Expand Up @@ -58,21 +65,13 @@ contract DelegationMock is IDelegationManager {

function operatorDetails(address operator) external pure returns (OperatorDetails memory) {
OperatorDetails memory returnValue = OperatorDetails({
__deprecated_earningsReceiver: operator,
__deprecated_earningsReceiver: operator,
delegationApprover: operator,
stakerOptOutWindowBlocks: 0
});
return returnValue;
}

function beaconChainETHStrategy() external pure returns (IStrategy) {
return IStrategy(address(0));
}

function earningsReceiver(address operator) external pure returns (address) {
return operator;
}

function delegationApprover(address operator) external pure returns (address) {
return operator;
}
Expand All @@ -81,15 +80,18 @@ contract DelegationMock is IDelegationManager {
return 0;
}

function minWithdrawalDelayBlocks() external view returns (uint256) {
return 50400;
function minWithdrawalDelayBlocks() external pure returns (uint256) {
return 0;
}

/// @notice return address of the beaconChainETHStrategy
function beaconChainETHStrategy() external view returns (IStrategy) {}

/**
* @notice Minimum delay enforced by this contract per Strategy for completing queued withdrawals. Measured in blocks, and adjustable by this contract's owner,
* up to a maximum of `MAX_WITHDRAWAL_DELAY_BLOCKS`. Minimum value is 0 (i.e. no delay enforced).
*/
function strategyWithdrawalDelayBlocks(IStrategy /*strategy*/) external view returns (uint256) {
function strategyWithdrawalDelayBlocks(IStrategy /*strategy*/) external pure returns (uint256) {
return 0;
}

Expand All @@ -98,14 +100,14 @@ contract DelegationMock is IDelegationManager {
IStrategy[] memory strategies
) external view returns (uint256[] memory) {
uint256[] memory shares = new uint256[](strategies.length);
for (uint256 i = 0; i < strategies.length; ++i) {
for (uint256 i = 0; i < strategies.length; i++) {
shares[i] = operatorShares[operator][strategies[i]];
}
return shares;
}

function getWithdrawalDelay(IStrategy[] calldata /*strategies*/) public view returns (uint256) {
return 0;
function getWithdrawalDelay(IStrategy[] calldata /*strategies*/) public pure returns (uint256) {
return type(uint256).max;
}

function isDelegated(address staker) external view returns (bool) {
Expand Down Expand Up @@ -147,14 +149,20 @@ contract DelegationMock is IDelegationManager {

function DELEGATION_APPROVAL_TYPEHASH() external view returns (bytes32) {}

function domainSeparator() external view returns (bytes32) {}
function OPERATOR_AVS_REGISTRATION_TYPEHASH() external view returns (bytes32) {}

function cumulativeWithdrawalsQueued(address staker) external view returns (uint256) {}

function calculateWithdrawalRoot(Withdrawal memory withdrawal) external pure returns (bytes32) {}

function registerOperatorToAVS(address operator, ISignatureUtils.SignatureWithSaltAndExpiry memory operatorSignature) external {}

function deregisterOperatorFromAVS(address operator) external {}

function operatorSaltIsSpent(address avs, bytes32 salt) external view returns (bool) {}

function domainSeparator() external view returns (bytes32) {}

function queueWithdrawals(
QueuedWithdrawalParams[] calldata queuedWithdrawalParams
) external returns (bytes32[] memory) {}
Expand Down
22 changes: 22 additions & 0 deletions test/mocks/ECDSAServiceManagerMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "../../src/unaudited/ECDSAServiceManagerBase.sol";

contract ECDSAServiceManagerMock is ECDSAServiceManagerBase {
constructor(
address _avsDirectory,
address _stakeRegistry,
address _rewardsCoordinator,
address _delegationManager
)
ECDSAServiceManagerBase(_avsDirectory, _stakeRegistry, _rewardsCoordinator, _delegationManager)
{}

function initialize(
address initialOwner,
address rewardsInitiator
) public virtual initializer {
__ServiceManagerBase_init(initialOwner, rewardsInitiator);
}
}
14 changes: 14 additions & 0 deletions test/mocks/ECDSAStakeRegistryMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.12;

import "../../src/unaudited/ECDSAStakeRegistry.sol";

/**
* @title Mock for ECDSAStakeRegistry
* @dev This contract is a mock implementation of the ECDSAStakeRegistry for testing purposes.
*/
contract ECDSAStakeRegistryMock is ECDSAStakeRegistry {

constructor(IDelegationManager _delegationManager) ECDSAStakeRegistry(_delegationManager) {
}
}
2 changes: 2 additions & 0 deletions test/mocks/RegistryCoordinatorMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,6 @@ contract RegistryCoordinatorMock is IRegistryCoordinator {
function quorumUpdateBlockNumber(uint8 quorumNumber) external view returns (uint256) {}

function owner() external view returns (address) {}

function updateSocket(string memory socket) external {}
}
115 changes: 91 additions & 24 deletions test/mocks/RewardsCoordinatorMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,50 +23,117 @@ contract RewardsCoordinatorMock is IRewardsCoordinator {

function claimerFor(address earner) external view returns (address) {}

function cumulativeClaimed(address claimer, IERC20 token) external view returns (uint256) {}
function cumulativeClaimed(
address claimer,
IERC20 token
) external view returns (uint256) {}

function globalOperatorCommissionBips() external view returns (uint16) {}
function defaultOperatorSplitBips() external view returns (uint16) {}

function operatorCommissionBips(address operator, address avs) external view returns (uint16) {}
function calculateEarnerLeafHash(
EarnerTreeMerkleLeaf calldata leaf
) external pure returns (bytes32) {}

function calculateEarnerLeafHash(EarnerTreeMerkleLeaf calldata leaf) external pure returns (bytes32) {}
function calculateTokenLeafHash(
TokenTreeMerkleLeaf calldata leaf
) external pure returns (bytes32) {}

function calculateTokenLeafHash(TokenTreeMerkleLeaf calldata leaf) external pure returns (bytes32) {}
function checkClaim(
RewardsMerkleClaim calldata claim
) external view returns (bool) {}

function checkClaim(RewardsMerkleClaim calldata claim) external view returns (bool) {}
function currRewardsCalculationEndTimestamp()
external
view
returns (uint32)
{}

function currRewardsCalculationEndTimestamp() external view returns (uint32) {}
function getDistributionRootsLength() external view returns (uint256) {}

function getRootIndexFromHash(bytes32 rootHash) external view returns (uint32) {}
function getDistributionRootAtIndex(
uint256 index
) external view returns (DistributionRoot memory) {}

function getDistributionRootsLength() external view returns (uint256) {}
function getCurrentDistributionRoot()
external
view
returns (DistributionRoot memory)
{}

function getCurrentClaimableDistributionRoot()
external
view
returns (DistributionRoot memory)
{}

function getRootIndexFromHash(
bytes32 rootHash
) external view returns (uint32) {}

function domainSeparator() external view returns (bytes32) {}

function getOperatorAVSSplit(
address operator,
address avs
) external view returns (uint16) {}

/// EXTERNAL FUNCTIONS ///
function getOperatorPISplit(
address operator
) external view returns (uint16) {}

function createAVSRewardsSubmission(
RewardsSubmission[] calldata rewardsSubmissions
) external {}

function createRewardsForAllSubmission(
RewardsSubmission[] calldata rewardsSubmission
) external {}

function createRewardsForAllEarners(
RewardsSubmission[] calldata rewardsSubmissions
) external {}

function createAVSRewardsSubmission(RewardsSubmission[] calldata rewardsSubmissions) external {}
function createOperatorDirectedAVSRewardsSubmission(
address avs,
OperatorDirectedRewardsSubmission[]
calldata operatorDirectedRewardsSubmissions
) external {}

function createRewardsForAllSubmission(RewardsSubmission[] calldata rewardsSubmission) external {}
function processClaim(
RewardsMerkleClaim calldata claim,
address recipient
) external {}

function processClaim(RewardsMerkleClaim calldata claim, address recipient) external {}
function processClaims(
RewardsMerkleClaim[] calldata claims,
address recipient
) external {}

function submitRoot(
bytes32 root,
uint32 rewardsCalculationEndTimestamp
) external {}

function setRewardsUpdater(address _rewardsUpdater) external {}
function disableRoot(uint32 rootIndex) external {}

function setClaimerFor(address claimer) external {}

function setActivationDelay(uint32 _activationDelay) external {}

function setGlobalOperatorCommission(uint16 _globalCommissionBips) external {}
function setDefaultOperatorSplit(uint16 split) external {}

function setClaimerFor(address claimer) external {}
function setRewardsUpdater(address _rewardsUpdater) external {}

function setRewardsForAllSubmitter(
address _submitter,
bool _newValue
) external {}

function setOperatorAVSSplit(
address operator,
address avs,
uint16 split
) external {}

/**
* @notice Sets the permissioned `payAllForRangeSubmitter` address which can submit payAllForRange
* @dev Only callable by the contract owner
* @param _submitter The address of the payAllForRangeSubmitter
* @param _newValue The new value for isPayAllForRangeSubmitter
*/
function setRewardsForAllSubmitter(address _submitter, bool _newValue) external {}
}
function setOperatorPISplit(address operator, uint16 split) external {}
}

0 comments on commit fa830e3

Please sign in to comment.