Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: update payments release to core-contracts release #254

Merged
merged 1 commit into from
May 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/eigenlayer-contracts
5 changes: 3 additions & 2 deletions test/events/IServiceManagerBaseEvents.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,16 @@ interface IServiceManagerBaseEvents {
event DistributionRootSubmitted(
uint32 indexed rootIndex,
bytes32 indexed root,
uint32 paymentCalculationEndTimestamp,
uint32 indexed paymentCalculationEndTimestamp,
uint32 activatedAt
);
/// @notice root is one of the submitted distribution roots that was claimed against
event PaymentClaimed(
bytes32 root,
address indexed earner,
address indexed claimer,
IERC20 indexed token,
address indexed recipient,
IERC20 token,
uint256 claimedAmount
);

Expand Down
24 changes: 21 additions & 3 deletions test/mocks/PaymentCoordinatorMock.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ contract PaymentCoordinatorMock is IPaymentCoordinator {
* @notice The interval in seconds at which the calculation for range payment distribution is done.
* @dev Payment durations must be multiples of this interval.
*/
function calculationIntervalSeconds() external view returns (uint32) {}
function CALCULATION_INTERVAL_SECONDS() external view returns (uint32) {}

/// @notice The maximum amount of time that a range payment can end in the future
function MAX_PAYMENT_DURATION() external view returns (uint32) {}
Expand All @@ -39,6 +39,10 @@ contract PaymentCoordinatorMock is IPaymentCoordinator {
/// @notice the commission for all operators across all avss
function globalOperatorCommissionBips() external view returns (uint16) {}

/// @notice the commission for a specific operator for a specific avs
/// NOTE: Currently unused and simply returns the globalOperatorCommissionBips value but will be used in future release
function operatorCommissionBips(address operator, address avs) external view returns (uint16) {}

/// @notice return the hash of the earner's leaf
function calculateEarnerLeafHash(EarnerTreeMerkleLeaf calldata leaf) external pure returns (bytes32) {}

Expand All @@ -49,6 +53,12 @@ contract PaymentCoordinatorMock is IPaymentCoordinator {
/// but will revert if not valid
function checkClaim(PaymentMerkleClaim calldata claim) external view returns (bool) {}

/// @notice The timestamp until which payments have been calculated
function currPaymentCalculationEndTimestamp() external view returns (uint32) {}

/// @notice loop through distribution roots from reverse and return hash
function getRootIndexFromHash(bytes32 rootHash) external view returns (uint32) {}

/// EXTERNAL FUNCTIONS ///

/**
Expand All @@ -75,14 +85,15 @@ contract PaymentCoordinatorMock is IPaymentCoordinator {
* @notice Claim payments against a given root (read from distributionRoots[claim.rootIndex]).
* Earnings are cumulative so earners don't have to claim against all distribution roots they have earnings for,
* they can simply claim against the latest root and the contract will calculate the difference between
* their cumulativeEarnings and cumulativeClaimed. This difference is then transferred to claimerFor[claim.earner]
* their cumulativeEarnings and cumulativeClaimed. This difference is then transferred to recipient address.
* @param claim The PaymentMerkleClaim to be processed.
* Contains the root index, earner, payment leaves, and required proofs
* @param recipient The address recipient that receives the ERC20 payments
* @dev only callable by the valid claimer, that is
* if claimerFor[claim.earner] is address(0) then only the earner can claim, otherwise only
* claimerFor[claim.earner] can claim the payments.
*/
function processClaim(PaymentMerkleClaim calldata claim) external {}
function processClaim(PaymentMerkleClaim calldata claim, address recipient) external {}

/**
* @notice Creates a new distribution root. activatedAt is set to block.timestamp + activationDelay
Expand Down Expand Up @@ -122,4 +133,11 @@ contract PaymentCoordinatorMock is IPaymentCoordinator {
*/
function setClaimerFor(address claimer) 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 setPayAllForRangeSubmitter(address _submitter, bool _newValue) external {}
}
26 changes: 14 additions & 12 deletions test/unit/ServiceManagerBase.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,17 @@ contract ServiceManagerBase_UnitTests is
// PaymentCoordinator config
address paymentUpdater =
address(uint160(uint256(keccak256("paymentUpdater"))));
uint32 CALCULATION_INTERVAL_SECONDS = 7 days;
uint32 MAX_PAYMENT_DURATION = 70 days;
uint32 MAX_RETROACTIVE_LENGTH = 84 days;
uint32 MAX_FUTURE_LENGTH = 28 days;
uint32 GENESIS_PAYMENT_TIMESTAMP = 1712092632;
uint32 GENESIS_PAYMENT_TIMESTAMP = 1712188800;
uint256 MAX_PAYMENT_AMOUNT = 1e38 - 1;
/// @notice Delay in timestamp before a posted root can be claimed against
uint32 activationDelay = 7 days;
/// @notice intervals(epochs) are 2 weeks
uint32 calculationIntervalSeconds = 14 days;
/// @notice the commission for all operators across all avss
uint16 globalCommissionBips = 1000;


// Testing Config and Mocks
address serviceManagerOwner;
Expand All @@ -50,6 +51,7 @@ contract ServiceManagerBase_UnitTests is
paymentCoordinatorImplementation = new PaymentCoordinator(
delegationMock,
strategyManagerMock,
CALCULATION_INTERVAL_SECONDS,
MAX_PAYMENT_DURATION,
MAX_RETROACTIVE_LENGTH,
MAX_FUTURE_LENGTH,
Expand All @@ -68,7 +70,6 @@ contract ServiceManagerBase_UnitTests is
0 /*initialPausedStatus*/,
paymentUpdater,
activationDelay,
calculationIntervalSeconds,
globalCommissionBips
)
)
Expand Down Expand Up @@ -250,6 +251,7 @@ contract ServiceManagerBase_UnitTests is
function testFuzz_submitPayments_Revert_WhenNotOwner(
address caller
) public filterFuzzedAddressInputs(caller) {
cheats.assume(caller != serviceManagerOwner);
IPaymentCoordinator.RangePayment[] memory rangePayments;

cheats.prank(caller);
Expand Down Expand Up @@ -292,9 +294,9 @@ contract ServiceManagerBase_UnitTests is
mockTokenInitialSupply,
serviceManagerOwner
);
amount = bound(amount, 1, mockTokenInitialSupply);
amount = bound(amount, 1, MAX_PAYMENT_AMOUNT);
duration = bound(duration, 0, MAX_PAYMENT_DURATION);
duration = duration - (duration % calculationIntervalSeconds);
duration = duration - (duration % CALCULATION_INTERVAL_SECONDS);
startTimestamp = bound(
startTimestamp,
uint256(
Expand All @@ -303,13 +305,13 @@ contract ServiceManagerBase_UnitTests is
uint32(block.timestamp) - MAX_RETROACTIVE_LENGTH
)
) +
calculationIntervalSeconds -
CALCULATION_INTERVAL_SECONDS -
1,
block.timestamp + uint256(MAX_FUTURE_LENGTH)
);
startTimestamp =
startTimestamp -
(startTimestamp % calculationIntervalSeconds);
(startTimestamp % CALCULATION_INTERVAL_SECONDS);

// 2. Create range payment input param
IPaymentCoordinator.RangePayment[]
Expand Down Expand Up @@ -413,10 +415,10 @@ contract ServiceManagerBase_UnitTests is
// Create multiple range payments and their expected event
for (uint256 i = 0; i < numPayments; ++i) {
// 1. Bound fuzz inputs to valid ranges and amounts using randSeed for each
amount = bound(amount + i, 1, mockTokenInitialSupply);
amount = bound(amount + i, 1, MAX_PAYMENT_AMOUNT);
amounts[i] = amount;
duration = bound(duration + i, 0, MAX_PAYMENT_DURATION);
duration = duration - (duration % calculationIntervalSeconds);
duration = duration - (duration % CALCULATION_INTERVAL_SECONDS);
startTimestamp = bound(
startTimestamp + i,
uint256(
Expand All @@ -425,13 +427,13 @@ contract ServiceManagerBase_UnitTests is
uint32(block.timestamp) - MAX_RETROACTIVE_LENGTH
)
) +
calculationIntervalSeconds -
CALCULATION_INTERVAL_SECONDS -
1,
block.timestamp + uint256(MAX_FUTURE_LENGTH)
);
startTimestamp =
startTimestamp -
(startTimestamp % calculationIntervalSeconds);
(startTimestamp % CALCULATION_INTERVAL_SECONDS);

// 2. Create range payment input param
IPaymentCoordinator.RangePayment
Expand Down
Loading