From 2a7a4d905db7178f32d2e08ae3ea75504444ea09 Mon Sep 17 00:00:00 2001 From: 8sunyuan Date: Tue, 7 May 2024 15:52:39 -0400 Subject: [PATCH] feat: update core contracts submodule --- lib/eigenlayer-contracts | 2 +- test/events/IServiceManagerBaseEvents.sol | 5 +++-- test/mocks/PaymentCoordinatorMock.sol | 24 ++++++++++++++++++--- test/unit/ServiceManagerBase.t.sol | 26 ++++++++++++----------- 4 files changed, 39 insertions(+), 18 deletions(-) diff --git a/lib/eigenlayer-contracts b/lib/eigenlayer-contracts index f13e1c21..3eec97dd 160000 --- a/lib/eigenlayer-contracts +++ b/lib/eigenlayer-contracts @@ -1 +1 @@ -Subproject commit f13e1c21c5c4a90f1550fb80c132428bbacd731c +Subproject commit 3eec97dd1c0e3b153c89fa3cd6334612679439c3 diff --git a/test/events/IServiceManagerBaseEvents.sol b/test/events/IServiceManagerBaseEvents.sol index 8227e65c..81ac6dc6 100644 --- a/test/events/IServiceManagerBaseEvents.sol +++ b/test/events/IServiceManagerBaseEvents.sol @@ -35,7 +35,7 @@ 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 @@ -43,7 +43,8 @@ interface IServiceManagerBaseEvents { bytes32 root, address indexed earner, address indexed claimer, - IERC20 indexed token, + address indexed recipient, + IERC20 token, uint256 claimedAmount ); diff --git a/test/mocks/PaymentCoordinatorMock.sol b/test/mocks/PaymentCoordinatorMock.sol index 679eb73f..68d8a990 100644 --- a/test/mocks/PaymentCoordinatorMock.sol +++ b/test/mocks/PaymentCoordinatorMock.sol @@ -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) {} @@ -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) {} @@ -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 /// /** @@ -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 @@ -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 {} } \ No newline at end of file diff --git a/test/unit/ServiceManagerBase.t.sol b/test/unit/ServiceManagerBase.t.sol index da715940..c4277b5e 100644 --- a/test/unit/ServiceManagerBase.t.sol +++ b/test/unit/ServiceManagerBase.t.sol @@ -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; @@ -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, @@ -68,7 +70,6 @@ contract ServiceManagerBase_UnitTests is 0 /*initialPausedStatus*/, paymentUpdater, activationDelay, - calculationIntervalSeconds, globalCommissionBips ) ) @@ -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); @@ -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( @@ -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[] @@ -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( @@ -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