From 51e36f1ea5c5a180dff928e664267cabdf92ade3 Mon Sep 17 00:00:00 2001 From: Michael Sun <35479365+8sunyuan@users.noreply.github.com> Date: Thu, 30 May 2024 12:00:51 -0400 Subject: [PATCH] chore: refactor with RewardsCoordinator (#262) --- docs/README.md | 4 +- docs/ServiceManagerBase.md | 2 +- docs/experimental/AVS-Guide.md | 2 +- lib/eigenlayer-contracts | 2 +- src/ServiceManagerBase.sol | 68 ++-- src/ServiceManagerBaseStorage.sol | 15 +- src/interfaces/IServiceManager.sol | 23 +- src/unaudited/ECDSAServiceManagerBase.sol | 42 +-- test/events/IServiceManagerBaseEvents.sol | 40 +-- test/integration/CoreRegistration.t.sol | 10 +- test/integration/IntegrationDeployer.t.sol | 34 +- test/mocks/PaymentCoordinatorMock.sol | 143 -------- test/mocks/RewardsCoordinatorMock.sol | 72 ++++ test/mocks/ServiceManagerMock.sol | 8 +- test/unit/ServiceManagerBase.t.sol | 365 +++++++++++---------- test/unit/ServiceManagerRouter.t.sol | 2 +- test/utils/MockAVSDeployer.sol | 21 +- 17 files changed, 391 insertions(+), 462 deletions(-) delete mode 100644 test/mocks/PaymentCoordinatorMock.sol create mode 100644 test/mocks/RewardsCoordinatorMock.sol diff --git a/docs/README.md b/docs/README.md index 62e9dd91..676bf182 100644 --- a/docs/README.md +++ b/docs/README.md @@ -16,7 +16,7 @@ EigenLayer AVSs ("actively validated services") are protocols that make use of E **Currently, each AVS needs to implement one thing on-chain:** registration/deregistration conditions that define how an Operator registers for/deregisters from the AVS. This repo provides building blocks to support these functions. *Eventually,* the core contracts and this repo will be extended to cover other conditions, including: -* payment conditions that define how an Operator is paid for the services it provides +* reward conditions that define how an Operator is rewarded for the services it provides * slashing conditions that define "malicious behavior" in the context of the AVS, and the punishments for this behavior *... however, the design for these conditions is still in progress.* @@ -102,7 +102,7 @@ The main thing that links an AVS to the EigenLayer core contracts is that when E These methods ensure that the Operator registering with the AVS is also registered as an Operator in EigenLayer core. In this repo, these methods are called by the `ServiceManagerBase`. -Eventually, Operator slashing and payment for services will be part of the middleware/core relationship, but these features aren't implemented yet and their design is a work in progress. +Eventually, Operator slashing and rewards for services will be part of the middleware/core relationship, but these features aren't implemented yet and their design is a work in progress. ### System Components diff --git a/docs/ServiceManagerBase.md b/docs/ServiceManagerBase.md index 781b8e03..dc1f1752 100644 --- a/docs/ServiceManagerBase.md +++ b/docs/ServiceManagerBase.md @@ -10,7 +10,7 @@ The `ServiceManagerBase` represents the AVS's address relative to EigenLayer core. When registering or deregistering an operator from an AVS, the AVS's `ServiceManagerBase` communicates this change to the core contracts, allowing the core contracts to maintain an up-to-date view on operator registration status with various AVSs. *As of M2*: -* Currently, this contract is used by the `AVSDirectory` to keep track of operator registration and deregistration. Eventually, this relationship will be expanded to allow operators to opt in to slashing and payments for services. +* Currently, this contract is used by the `AVSDirectory` to keep track of operator registration and deregistration. Eventually, this relationship will be expanded to allow operators to opt in to slashing and rewards for services. --- diff --git a/docs/experimental/AVS-Guide.md b/docs/experimental/AVS-Guide.md index 46dc9a64..b0dec05e 100644 --- a/docs/experimental/AVS-Guide.md +++ b/docs/experimental/AVS-Guide.md @@ -7,7 +7,7 @@ This document aims to describe and summarize how actively validated services (AV - enabling operators to continuously update their commitments to middlewares, and - enabling AVS to freeze operators for the purpose of slashing (the corresponding unfreeze actions are determined by the veto committee). -We are currently in the process of implementing the API for payment flow from AVSs to operators in EigenLayer. Details of this API will be added to this document in the near future. +We are currently in the process of implementing the API for rewards flow from AVSs to operators in EigenLayer. Details of this API will be added to this document in the near future. The following figure summarizes scope of this document: ![Doc Outline](../images/middleware_outline_doc.png) diff --git a/lib/eigenlayer-contracts b/lib/eigenlayer-contracts index 3eec97dd..d8ac41af 160000 --- a/lib/eigenlayer-contracts +++ b/lib/eigenlayer-contracts @@ -1 +1 @@ -Subproject commit 3eec97dd1c0e3b153c89fa3cd6334612679439c3 +Subproject commit d8ac41afbabcc2e136facce344049fb85e29c0a7 diff --git a/src/ServiceManagerBase.sol b/src/ServiceManagerBase.sol index 9b124efa..a2874ac0 100644 --- a/src/ServiceManagerBase.sol +++ b/src/ServiceManagerBase.sol @@ -5,8 +5,7 @@ import {OwnableUpgradeable} from "@openzeppelin-upgrades/contracts/access/Ownabl import {Initializable} from "@openzeppelin-upgrades/contracts/proxy/utils/Initializable.sol"; import {ISignatureUtils} from "eigenlayer-contracts/src/contracts/interfaces/ISignatureUtils.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; -import {IPaymentCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; +import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {ServiceManagerBaseStorage} from "./ServiceManagerBaseStorage.sol"; import {IServiceManager} from "./interfaces/IServiceManager.sol"; @@ -31,10 +30,11 @@ abstract contract ServiceManagerBase is OwnableUpgradeable, ServiceManagerBaseSt _; } - modifier onlyPaymentInitiator() { + /// @notice only rewardsInitiator can call createAVSRewardsSubmission + modifier onlyRewardsInitiator() { require( - msg.sender == paymentInitiator, - "ServiceManagerBase.onlyPaymentInitiator: caller is not the payment initiator" + msg.sender == rewardsInitiator, + "ServiceManagerBase.onlyRewardsInitiator: caller is not the rewards initiator" ); _; } @@ -42,13 +42,13 @@ abstract contract ServiceManagerBase is OwnableUpgradeable, ServiceManagerBaseSt /// @notice Sets the (immutable) `_registryCoordinator` address constructor( IAVSDirectory __avsDirectory, - IPaymentCoordinator ___paymentCoordinator, + IRewardsCoordinator __rewardsCoordinator, IRegistryCoordinator __registryCoordinator, IStakeRegistry __stakeRegistry ) ServiceManagerBaseStorage( __avsDirectory, - ___paymentCoordinator, + __rewardsCoordinator, __registryCoordinator, __stakeRegistry ) @@ -58,10 +58,10 @@ abstract contract ServiceManagerBase is OwnableUpgradeable, ServiceManagerBaseSt function __ServiceManagerBase_init( address initialOwner, - address _paymentInitiator + address _rewardsInitiator ) internal virtual onlyInitializing { _transferOwnership(initialOwner); - _setPaymentInitiator(_paymentInitiator); + _setRewardsInitiator(_rewardsInitiator); } /** @@ -74,35 +74,33 @@ abstract contract ServiceManagerBase is OwnableUpgradeable, ServiceManagerBaseSt } /** - * @notice Creates a new range payment on behalf of an AVS, to be split amongst the - * set of stakers delegated to operators who are registered to the `avs`. - * Note that the owner calling this function must have approved the tokens to be transferred to the ServiceManager - * and of course has the required balances. - * @param rangePayments The range payments being created - * @dev Expected to be called by the ServiceManager of the AVS on behalf of which the payment is being made - * @dev The duration of the `rangePayment` cannot exceed `paymentCoordinator.MAX_PAYMENT_DURATION()` - * @dev The tokens are sent to the `PaymentCoordinator` contract + * @notice Creates a new rewards submission to the EigenLayer RewardsCoordinator contract, to be split amongst the + * set of stakers delegated to operators who are registered to this `avs` + * @param rewardsSubmissions The rewards submissions being created + * @dev Only callabe by the permissioned rewardsInitiator address + * @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION` + * @dev The tokens are sent to the `RewardsCoordinator` contract * @dev Strategies must be in ascending order of addresses to check for duplicates - * @dev This function will revert if the `rangePayment` is malformed, + * @dev This function will revert if the `rewardsSubmission` is malformed, * e.g. if the `strategies` and `weights` arrays are of non-equal lengths */ - function payForRange(IPaymentCoordinator.RangePayment[] calldata rangePayments) + function createAVSRewardsSubmission(IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions) public virtual - onlyPaymentInitiator + onlyRewardsInitiator { - for (uint256 i = 0; i < rangePayments.length; ++i) { - // transfer token to ServiceManager and approve PaymentCoordinator to transfer again - // in payForRange() call - rangePayments[i].token.transferFrom(msg.sender, address(this), rangePayments[i].amount); + for (uint256 i = 0; i < rewardsSubmissions.length; ++i) { + // transfer token to ServiceManager and approve RewardsCoordinator to transfer again + // in createAVSRewardsSubmission() call + rewardsSubmissions[i].token.transferFrom(msg.sender, address(this), rewardsSubmissions[i].amount); uint256 allowance = - rangePayments[i].token.allowance(address(this), address(_paymentCoordinator)); - rangePayments[i].token.approve( - address(_paymentCoordinator), rangePayments[i].amount + allowance + rewardsSubmissions[i].token.allowance(address(this), address(_rewardsCoordinator)); + rewardsSubmissions[i].token.approve( + address(_rewardsCoordinator), rewardsSubmissions[i].amount + allowance ); } - _paymentCoordinator.payForRange(rangePayments); + _rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions); } /** @@ -126,17 +124,17 @@ abstract contract ServiceManagerBase is OwnableUpgradeable, ServiceManagerBaseSt } /** - * @notice Sets the payment initiator address - * @param newPaymentInitiator The new payment initiator address + * @notice Sets the rewards initiator address + * @param newRewardsInitiator The new rewards initiator address * @dev only callable by the owner */ - function setPaymentInitiator(address newPaymentInitiator) external onlyOwner { - _setPaymentInitiator(newPaymentInitiator); + function setRewardsInitiator(address newRewardsInitiator) external onlyOwner { + _setRewardsInitiator(newRewardsInitiator); } - function _setPaymentInitiator(address newPaymentInitiator) internal { - emit PaymentInitiatorUpdated(paymentInitiator, newPaymentInitiator); - paymentInitiator = newPaymentInitiator; + function _setRewardsInitiator(address newRewardsInitiator) internal { + emit RewardsInitiatorUpdated(rewardsInitiator, newRewardsInitiator); + rewardsInitiator = newRewardsInitiator; } /** diff --git a/src/ServiceManagerBaseStorage.sol b/src/ServiceManagerBaseStorage.sol index aabd0d72..4f5360eb 100644 --- a/src/ServiceManagerBaseStorage.sol +++ b/src/ServiceManagerBaseStorage.sol @@ -6,8 +6,7 @@ import {IRegistryCoordinator} from "./interfaces/IRegistryCoordinator.sol"; import {IStakeRegistry} from "./interfaces/IStakeRegistry.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; -import {IPaymentCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; +import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; /** * @title Storage variables for the `ServiceManagerBase` contract. @@ -21,7 +20,7 @@ abstract contract ServiceManagerBaseStorage is IServiceManager { * */ IAVSDirectory internal immutable _avsDirectory; - IPaymentCoordinator internal immutable _paymentCoordinator; + IRewardsCoordinator internal immutable _rewardsCoordinator; IRegistryCoordinator internal immutable _registryCoordinator; IStakeRegistry internal immutable _stakeRegistry; @@ -31,18 +30,18 @@ abstract contract ServiceManagerBaseStorage is IServiceManager { * */ - /// @notice The address of the entity that can initiate payments - address public paymentInitiator; + /// @notice The address of the entity that can initiate rewards + address public rewardsInitiator; - /// @notice Sets the (immutable) `_avsDirectory`, `_paymentCoordinator`, `_registryCoordinator`, and `_stakeRegistry` addresses + /// @notice Sets the (immutable) `_avsDirectory`, `_rewardsCoordinator`, `_registryCoordinator`, and `_stakeRegistry` addresses constructor( IAVSDirectory __avsDirectory, - IPaymentCoordinator __paymentCoordinator, + IRewardsCoordinator __rewardsCoordinator, IRegistryCoordinator __registryCoordinator, IStakeRegistry __stakeRegistry ) { _avsDirectory = __avsDirectory; - _paymentCoordinator = __paymentCoordinator; + _rewardsCoordinator = __rewardsCoordinator; _registryCoordinator = __registryCoordinator; _stakeRegistry = __stakeRegistry; } diff --git a/src/interfaces/IServiceManager.sol b/src/interfaces/IServiceManager.sol index 1cf245b0..ad953ec0 100644 --- a/src/interfaces/IServiceManager.sol +++ b/src/interfaces/IServiceManager.sol @@ -1,8 +1,7 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity >=0.5.0; -import {IPaymentCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; +import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {IServiceManagerUI} from "./IServiceManagerUI.sol"; /** @@ -11,20 +10,18 @@ import {IServiceManagerUI} from "./IServiceManagerUI.sol"; */ interface IServiceManager is IServiceManagerUI { /** - * @notice Creates a new range payment on behalf of an AVS, to be split amongst the - * set of stakers delegated to operators who are registered to the `avs`. - * Note that the owner calling this function must have approved the tokens to be transferred to the ServiceManager - * and of course has the required balances. - * @param rangePayments The range payments being created - * @dev Expected to be called by the ServiceManager of the AVS on behalf of which the payment is being made - * @dev The duration of the `rangePayment` cannot exceed `paymentCoordinator.MAX_PAYMENT_DURATION()` - * @dev The tokens are sent to the `PaymentCoordinator` contract + * @notice Creates a new rewards submission to the EigenLayer RewardsCoordinator contract, to be split amongst the + * set of stakers delegated to operators who are registered to this `avs` + * @param rewardsSubmissions The rewards submissions being created + * @dev Only callabe by the permissioned rewardsInitiator address + * @dev The duration of the `rewardsSubmission` cannot exceed `MAX_REWARDS_DURATION` + * @dev The tokens are sent to the `RewardsCoordinator` contract * @dev Strategies must be in ascending order of addresses to check for duplicates - * @dev This function will revert if the `rangePayment` is malformed, + * @dev This function will revert if the `rewardsSubmission` is malformed, * e.g. if the `strategies` and `weights` arrays are of non-equal lengths */ - function payForRange(IPaymentCoordinator.RangePayment[] calldata rangePayments) external; + function createAVSRewardsSubmission(IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions) external; // EVENTS - event PaymentInitiatorUpdated(address prevPaymentInitiator, address newPaymentInitiator); + event RewardsInitiatorUpdated(address prevRewardsInitiator, address newRewardsInitiator); } diff --git a/src/unaudited/ECDSAServiceManagerBase.sol b/src/unaudited/ECDSAServiceManagerBase.sol index 4a606c87..23a6dc06 100644 --- a/src/unaudited/ECDSAServiceManagerBase.sol +++ b/src/unaudited/ECDSAServiceManagerBase.sol @@ -11,7 +11,7 @@ import {IServiceManagerUI} from "../interfaces/IServiceManagerUI.sol"; import {IDelegationManager} from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategy.sol"; import {IStakeRegistry} from "../interfaces/IStakeRegistry.sol"; -import {IPaymentCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; +import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {Quorum} from "../interfaces/IECDSAStakeRegistryEventsAndErrors.sol"; import {ECDSAStakeRegistry} from "../unaudited/ECDSAStakeRegistry.sol"; @@ -25,8 +25,8 @@ abstract contract ECDSAServiceManagerBase is /// @notice Address of the AVS directory contract, which manages AVS-related data for registered operators. address public immutable avsDirectory; - /// @notice Address of the payment coordinator contract, which handles payment distributions. - address internal immutable paymentCoordinator; + /// @notice Address of the rewards coordinator contract, which handles rewards distributions. + address internal immutable rewardsCoordinator; /// @notice Address of the delegation manager contract, which manages staker delegations to operators. address internal immutable delegationManager; @@ -46,18 +46,18 @@ abstract contract ECDSAServiceManagerBase is * @dev Constructor for ECDSAServiceManagerBase, initializing immutable contract addresses and disabling initializers. * @param _avsDirectory The address of the AVS directory contract, managing AVS-related data for registered operators. * @param _stakeRegistry The address of the stake registry contract, managing registration and stake recording. - * @param _paymentCoordinator The address of the payment coordinator contract, handling payment distributions. + * @param _rewardsCoordinator The address of the rewards coordinator contract, handling rewards distributions. * @param _delegationManager The address of the delegation manager contract, managing staker delegations to operators. */ constructor( address _avsDirectory, address _stakeRegistry, - address _paymentCoordinator, + address _rewardsCoordinator, address _delegationManager ) { avsDirectory = _avsDirectory; stakeRegistry = _stakeRegistry; - paymentCoordinator = _paymentCoordinator; + rewardsCoordinator = _rewardsCoordinator; delegationManager = _delegationManager; _disableInitializers(); } @@ -80,10 +80,10 @@ abstract contract ECDSAServiceManagerBase is } /// @inheritdoc IServiceManager - function payForRange( - IPaymentCoordinator.RangePayment[] calldata rangePayments + function createAVSRewardsSubmission( + IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions ) external virtual onlyOwner { - _payForRange(rangePayments); + _createAVSRewardsSubmission(rewardsSubmissions); } /// @inheritdoc IServiceManagerUI @@ -155,26 +155,26 @@ abstract contract ECDSAServiceManagerBase is } /** - * @notice Processes a batch of range payments by transferring the specified amounts from the sender to this contract and then approving the PaymentCoordinator to use these amounts. - * @dev This function handles the transfer and approval of tokens necessary for range payments. It then delegates the actual payment logic to the PaymentCoordinator contract. - * @param rangePayments An array of `RangePayment` structs, each representing a payment for a specific range. + * @notice Processes a batch of rewards submissions by transferring the specified amounts from the sender to this contract and then approving the RewardsCoordinator to use these amounts. + * @dev This function handles the transfer and approval of tokens necessary for rewards submissions. It then delegates the actual rewards logic to the RewardsCoordinator contract. + * @param rewardsSubmissions An array of `RewardsSubmission` structs, each representing rewards for a specific range. */ - function _payForRange( - IPaymentCoordinator.RangePayment[] calldata rangePayments + function _createAVSRewardsSubmission( + IRewardsCoordinator.RewardsSubmission[] calldata rewardsSubmissions ) internal virtual { - for (uint256 i = 0; i < rangePayments.length; ++i) { - rangePayments[i].token.transferFrom( + for (uint256 i = 0; i < rewardsSubmissions.length; ++i) { + rewardsSubmissions[i].token.transferFrom( msg.sender, address(this), - rangePayments[i].amount + rewardsSubmissions[i].amount ); - rangePayments[i].token.approve( - paymentCoordinator, - rangePayments[i].amount + rewardsSubmissions[i].token.approve( + rewardsCoordinator, + rewardsSubmissions[i].amount ); } - IPaymentCoordinator(paymentCoordinator).payForRange(rangePayments); + IRewardsCoordinator(rewardsCoordinator).createAVSRewardsSubmission(rewardsSubmissions); } /** diff --git a/test/events/IServiceManagerBaseEvents.sol b/test/events/IServiceManagerBaseEvents.sol index 81ac6dc6..6defff0d 100644 --- a/test/events/IServiceManagerBaseEvents.sol +++ b/test/events/IServiceManagerBaseEvents.sol @@ -1,45 +1,47 @@ // SPDX-License-Identifier: BUSL-1.1 pragma solidity ^0.8.12; -import "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; +import { + IRewardsCoordinator, + IERC20 +} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; interface IServiceManagerBaseEvents { - /// PaymentCoordinator EVENTS /// + /// RewardsCoordinator EVENTS /// - /// @notice emitted when an AVS creates a valid RangePayment - event RangePaymentCreated( + /// @notice emitted when an AVS creates a valid RewardsSubmission + event AVSRewardsSubmissionCreated( address indexed avs, - uint256 indexed paymentNonce, - bytes32 indexed rangePaymentHash, - IPaymentCoordinator.RangePayment rangePayment + uint256 indexed submissionNonce, + bytes32 indexed rewardsSubmissionHash, + IRewardsCoordinator.RewardsSubmission rewardsSubmission ); - /// @notice emitted when a valid RangePayment is created for all stakers by a valid submitter - event RangePaymentForAllCreated( + /// @notice emitted when a valid RewardsSubmission is created for all stakers by a valid submitter + event RewardsSubmissionForAllCreated( address indexed submitter, - uint256 indexed paymentNonce, - bytes32 indexed rangePaymentHash, - IPaymentCoordinator.RangePayment rangePayment + uint256 indexed submissionNonce, + bytes32 indexed rewardsSubmissionHash, + IRewardsCoordinator.RewardsSubmission rewardsSubmission ); - /// @notice paymentUpdater is responsible for submiting DistributionRoots, only owner can set paymentUpdater - event PaymentUpdaterSet(address indexed oldPaymentUpdater, address indexed newPaymentUpdater); - event PayAllForRangeSubmitterSet( - address indexed payAllForRangeSubmitter, + /// @notice rewardsUpdater is responsible for submiting DistributionRoots, only owner can set rewardsUpdater + event RewardsUpdaterSet(address indexed oldRewardsUpdater, address indexed newRewardsUpdater); + event RewardsForAllSubmitterSet( + address indexed rewardsForAllSubmitter, bool indexed oldValue, bool indexed newValue ); event ActivationDelaySet(uint32 oldActivationDelay, uint32 newActivationDelay); - event CalculationIntervalSecondsSet(uint32 oldCalculationIntervalSeconds, uint32 newCalculationIntervalSeconds); event GlobalCommissionBipsSet(uint16 oldGlobalCommissionBips, uint16 newGlobalCommissionBips); event ClaimerForSet(address indexed earner, address indexed oldClaimer, address indexed claimer); /// @notice rootIndex is the specific array index of the newly created root in the storage array event DistributionRootSubmitted( uint32 indexed rootIndex, bytes32 indexed root, - uint32 indexed paymentCalculationEndTimestamp, + uint32 indexed rewardsCalculationEndTimestamp, uint32 activatedAt ); /// @notice root is one of the submitted distribution roots that was claimed against - event PaymentClaimed( + event RewardsClaimed( bytes32 root, address indexed earner, address indexed claimer, diff --git a/test/integration/CoreRegistration.t.sol b/test/integration/CoreRegistration.t.sol index 3e6c1dba..3c0561f3 100644 --- a/test/integration/CoreRegistration.t.sol +++ b/test/integration/CoreRegistration.t.sol @@ -6,8 +6,8 @@ import { AVSDirectory } from "eigenlayer-contracts/src/contracts/core/AVSDirecto import { IAVSDirectory } from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; import { DelegationManager } from "eigenlayer-contracts/src/contracts/core/DelegationManager.sol"; import { IDelegationManager } from "eigenlayer-contracts/src/contracts/interfaces/IDelegationManager.sol"; -import { PaymentCoordinator } from "eigenlayer-contracts/src/contracts/core/PaymentCoordinator.sol"; -import { IPaymentCoordinator } from "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; +import { RewardsCoordinator } from "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol"; +import { IRewardsCoordinator } from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; contract Test_CoreRegistration is MockAVSDeployer { // Contracts @@ -64,13 +64,13 @@ contract Test_CoreRegistration is MockAVSDeployer { ) ); - // Deploy Mock PaymentCoordinator - paymentCoordinatorMock = new PaymentCoordinatorMock(); + // Deploy Mock RewardsCoordinator + rewardsCoordinatorMock = new RewardsCoordinatorMock(); // Deploy New ServiceManager & RegistryCoordinator implementations serviceManagerImplementation = new ServiceManagerMock( avsDirectory, - paymentCoordinatorMock, + rewardsCoordinatorMock, registryCoordinator, stakeRegistry ); diff --git a/test/integration/IntegrationDeployer.t.sol b/test/integration/IntegrationDeployer.t.sol index b48dd685..ec9075e9 100644 --- a/test/integration/IntegrationDeployer.t.sol +++ b/test/integration/IntegrationDeployer.t.sol @@ -16,7 +16,7 @@ import "eigenlayer-contracts/src/contracts/core/DelegationManager.sol"; import "eigenlayer-contracts/src/contracts/core/StrategyManager.sol"; import "eigenlayer-contracts/src/contracts/core/Slasher.sol"; import "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol"; -import "eigenlayer-contracts/src/contracts/core/PaymentCoordinator.sol"; +import "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol"; import "eigenlayer-contracts/src/contracts/strategies/StrategyBase.sol"; import "eigenlayer-contracts/src/contracts/pods/EigenPodManager.sol"; import "eigenlayer-contracts/src/contracts/pods/EigenPod.sol"; @@ -52,7 +52,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { AVSDirectory public avsDirectory; StrategyManager strategyManager; EigenPodManager eigenPodManager; - PaymentCoordinator paymentCoordinator; + RewardsCoordinator rewardsCoordinator; PauserRegistry pauserRegistry; Slasher slasher; IBeacon eigenPodBeacon; @@ -89,7 +89,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { uint256 public churnApproverPrivateKey = uint256(keccak256("churnApproverPrivateKey")); address public churnApprover = cheats.addr(churnApproverPrivateKey); address ejector = address(uint160(uint256(keccak256("ejector")))); - address paymentUpdater = address(uint160(uint256(keccak256("paymentUpdater")))); + address rewardsUpdater = address(uint160(uint256(keccak256("rewardsUpdater")))); // Constants/Defaults uint64 constant MAX_RESTAKED_BALANCE_GWEI_PER_VALIDATOR = 32e9; @@ -97,11 +97,11 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { uint256 constant MAX_BALANCE = 5e6; uint256 constant MAX_STRATEGY_COUNT = 32; // From StakeRegistry.MAX_WEIGHING_FUNCTION_LENGTH uint96 constant DEFAULT_STRATEGY_MULTIPLIER = 1e18; - // PaymentCoordinator - uint32 MAX_PAYMENT_DURATION = 70 days; + // RewardsCoordinator + uint32 MAX_REWARDS_DURATION = 70 days; uint32 MAX_RETROACTIVE_LENGTH = 84 days; uint32 MAX_FUTURE_LENGTH = 28 days; - uint32 GENESIS_PAYMENT_TIMESTAMP = 1_712_092_632; + uint32 GENESIS_REWARDS_TIMESTAMP = 1_712_092_632; /// @notice Delay in timestamp before a posted root can be claimed against uint32 activationDelay = 7 days; /// @notice intervals(epochs) are 2 weeks @@ -157,7 +157,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "") ) ); - // paymentCoordinator = PaymentCoordinator( + // RewardsCoordinator = RewardsCoordinator( // address(new TransparentUpgradeableProxy(address(emptyContract), address(proxyAdmin), "")) // ); @@ -184,13 +184,13 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { DelayedWithdrawalRouter delayedWithdrawalRouterImplementation = new DelayedWithdrawalRouter(eigenPodManager); AVSDirectory avsDirectoryImplemntation = new AVSDirectory(delegationManager); - // PaymentCoordinator paymentCoordinatorImplementation = new PaymentCoordinator( + // RewardsCoordinator rewardsCoordinatorImplementation = new RewardsCoordinator( // delegationManager, // IStrategyManager(address(strategyManager)), - // MAX_PAYMENT_DURATION, + // MAX_REWARDS_DURATION, // MAX_RETROACTIVE_LENGTH, // MAX_FUTURE_LENGTH, - // GENESIS_PAYMENT_TIMESTAMP + // GENESIS_REWARDS_TIMESTAMP // ); // Third, upgrade the proxy contracts to point to the implementations @@ -269,16 +269,16 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { 0 // initialPausedStatus ) ); - // // PaymentCoordinator + // // RewardsCoordinator // proxyAdmin.upgradeAndCall( - // TransparentUpgradeableProxy(payable(address(paymentCoordinator))), - // address(paymentCoordinatorImplementation), + // TransparentUpgradeableProxy(payable(address(rewardsCoordinator))), + // address(rewardsCoordinatorImplementation), // abi.encodeWithSelector( - // PaymentCoordinator.initialize.selector, + // RewardsCoordinator.initialize.selector, // eigenLayerReputedMultisig, // initialOwner // pauserRegistry, // 0, // initialPausedStatus - // paymentUpdater, + // rewardsUpdater, // activationDelay, // calculationIntervalSeconds, // globalCommissionBips @@ -338,7 +338,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { new IndexRegistry(IRegistryCoordinator(registryCoordinator)); ServiceManagerMock serviceManagerImplementation = new ServiceManagerMock( IAVSDirectory(avsDirectory), - paymentCoordinator, + rewardsCoordinator, IRegistryCoordinator(registryCoordinator), stakeRegistry ); @@ -365,7 +365,7 @@ abstract contract IntegrationDeployer is Test, IUserDeployer { serviceManager.initialize({ initialOwner: registryCoordinatorOwner, - paymentInitiator: address(proxyAdmin) + rewardsInitiator: address(msg.sender) }); RegistryCoordinator registryCoordinatorImplementation = diff --git a/test/mocks/PaymentCoordinatorMock.sol b/test/mocks/PaymentCoordinatorMock.sol deleted file mode 100644 index 68d8a990..00000000 --- a/test/mocks/PaymentCoordinatorMock.sol +++ /dev/null @@ -1,143 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.12; - -import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; - -import {IPaymentCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; - -contract PaymentCoordinatorMock is IPaymentCoordinator { - /// @notice The address of the entity that can update the contract with new merkle roots - function paymentUpdater() external view returns (address) {} - - /** - * @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 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) {} - - /// @notice max amount of time that a payment can start in the past - function MAX_RETROACTIVE_LENGTH() external view returns (uint32) {} - - /// @notice max amount of time that a payment can start in the future - function MAX_FUTURE_LENGTH() external view returns (uint32) {} - - /// @notice absolute min timestamp that a payment can start at - function GENESIS_PAYMENT_TIMESTAMP() external view returns (uint32) {} - - /// @notice Delay in timestamp before a posted root can be claimed against - function activationDelay() external view returns (uint32) {} - - /// @notice Mapping: earner => the address of the entity to which new payments are directed on behalf of the earner - function claimerFor(address earner) external view returns (address) {} - - /// @notice Mapping: claimer => token => total amount claimed - function cumulativeClaimed(address claimer, IERC20 token) external view returns (uint256) {} - - /// @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) {} - - /// @notice returns the hash of the earner's token leaf - function calculateTokenLeafHash(TokenTreeMerkleLeaf calldata leaf) external pure returns (bytes32) {} - - /// @notice returns 'true' if the claim would currently pass the check in `processClaims` - /// 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 /// - - /** - * @notice Creates a new range payment on behalf of an AVS, to be split amongst the - * set of stakers delegated to operators who are registered to the `avs` - * @param rangePayments The range payments being created - * @dev Expected to be called by the ServiceManager of the AVS on behalf of which the payment is being made - * @dev The duration of the `rangePayment` cannot exceed `MAX_PAYMENT_DURATION` - * @dev The tokens are sent to the `PaymentCoordinator` contract - * @dev Strategies must be in ascending order of addresses to check for duplicates - * @dev This function will revert if the `rangePayment` is malformed, - * e.g. if the `strategies` and `weights` arrays are of non-equal lengths - */ - function payForRange(RangePayment[] calldata rangePayments) external {} - - /** - * @notice similar to `payForRange` except the payment is split amongst *all* stakers - * rather than just those delegated to operators who are registered to a single avs and is - * a permissioned call based on isPayAllForRangeSubmitter mapping. - */ - function payAllForRange(RangePayment[] calldata rangePayment) external {} - - /** - * @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 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, address recipient) external {} - - /** - * @notice Creates a new distribution root. activatedAt is set to block.timestamp + activationDelay - * @param root The merkle root of the distribution - * @param paymentCalculationEndTimestamp The timestamp until which payments have been calculated - * @dev Only callable by the paymentUpdater - */ - function submitRoot( - bytes32 root, - uint32 paymentCalculationEndTimestamp - ) external {} - - /** - * @notice Sets the permissioned `paymentUpdater` address which can post new roots - * @dev Only callable by the contract owner - */ - function setPaymentUpdater(address _paymentUpdater) external {} - - /** - * @notice Sets the delay in timestamp before a posted root can be claimed against - * @param _activationDelay Delay in timestamp before a posted root can be claimed against - * @dev Only callable by the contract owner - */ - function setActivationDelay(uint32 _activationDelay) external {} - - /** - * @notice Sets the global commission for all operators across all avss - * @param _globalCommissionBips The commission for all operators across all avss - * @dev Only callable by the contract owner - */ - function setGlobalOperatorCommission(uint16 _globalCommissionBips) external {} - - /** - * @notice Sets the address of the entity that can claim payments on behalf of the earner (msg.sender) - * @param claimer The address of the entity that can claim payments on behalf of the earner - * @dev Only callable by the `earner` - */ - 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/mocks/RewardsCoordinatorMock.sol b/test/mocks/RewardsCoordinatorMock.sol new file mode 100644 index 00000000..a18d281e --- /dev/null +++ b/test/mocks/RewardsCoordinatorMock.sol @@ -0,0 +1,72 @@ +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.12; + +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; + +import {IRewardsCoordinator} from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; + +contract RewardsCoordinatorMock is IRewardsCoordinator { + /// @notice The address of the entity that can update the contract with new merkle roots + function rewardsUpdater() external view returns (address) {} + + function CALCULATION_INTERVAL_SECONDS() external view returns (uint32) {} + + function MAX_REWARDS_DURATION() external view returns (uint32) {} + + function MAX_RETROACTIVE_LENGTH() external view returns (uint32) {} + + function MAX_FUTURE_LENGTH() external view returns (uint32) {} + + function GENESIS_REWARDS_TIMESTAMP() external view returns (uint32) {} + + function activationDelay() external view returns (uint32) {} + + function claimerFor(address earner) external view returns (address) {} + + function cumulativeClaimed(address claimer, IERC20 token) external view returns (uint256) {} + + function globalOperatorCommissionBips() external view returns (uint16) {} + + function operatorCommissionBips(address operator, address avs) external view returns (uint16) {} + + function calculateEarnerLeafHash(EarnerTreeMerkleLeaf 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 currRewardsCalculationEndTimestamp() external view returns (uint32) {} + + function getRootIndexFromHash(bytes32 rootHash) external view returns (uint32) {} + + function getDistributionRootsLength() external view returns (uint256) {} + + /// EXTERNAL FUNCTIONS /// + + function createAVSRewardsSubmission(RewardsSubmission[] calldata rewardsSubmissions) external {} + + function createRewardsForAllSubmission(RewardsSubmission[] calldata rewardsSubmission) external {} + + function processClaim(RewardsMerkleClaim calldata claim, address recipient) external {} + + function submitRoot( + bytes32 root, + uint32 rewardsCalculationEndTimestamp + ) external {} + + function setRewardsUpdater(address _rewardsUpdater) external {} + + function setActivationDelay(uint32 _activationDelay) external {} + + function setGlobalOperatorCommission(uint16 _globalCommissionBips) external {} + + 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 setRewardsForAllSubmitter(address _submitter, bool _newValue) external {} +} \ No newline at end of file diff --git a/test/mocks/ServiceManagerMock.sol b/test/mocks/ServiceManagerMock.sol index cdca2f9a..8af99426 100644 --- a/test/mocks/ServiceManagerMock.sol +++ b/test/mocks/ServiceManagerMock.sol @@ -6,17 +6,17 @@ import "../../src/ServiceManagerBase.sol"; contract ServiceManagerMock is ServiceManagerBase { constructor( IAVSDirectory _avsDirectory, - IPaymentCoordinator _paymentCoordinator, + IRewardsCoordinator _rewardsCoordinator, IRegistryCoordinator _registryCoordinator, IStakeRegistry _stakeRegistry ) - ServiceManagerBase(_avsDirectory, _paymentCoordinator, _registryCoordinator, _stakeRegistry) + ServiceManagerBase(_avsDirectory, _rewardsCoordinator, _registryCoordinator, _stakeRegistry) {} function initialize( address initialOwner, - address paymentInitiator + address rewardsInitiator ) public virtual initializer { - __ServiceManagerBase_init(initialOwner, paymentInitiator); + __ServiceManagerBase_init(initialOwner, rewardsInitiator); } } diff --git a/test/unit/ServiceManagerBase.t.sol b/test/unit/ServiceManagerBase.t.sol index 1c34c7b5..2b04dabd 100644 --- a/test/unit/ServiceManagerBase.t.sol +++ b/test/unit/ServiceManagerBase.t.sol @@ -3,24 +3,24 @@ pragma solidity ^0.8.12; import "@openzeppelin/contracts/token/ERC20/presets/ERC20PresetFixedSupply.sol"; import { - PaymentCoordinator, - IPaymentCoordinator, + RewardsCoordinator, + IRewardsCoordinator, IERC20 -} from "eigenlayer-contracts/src/contracts/core/PaymentCoordinator.sol"; +} from "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol"; import {StrategyBase} from "eigenlayer-contracts/src/contracts/strategies/StrategyBase.sol"; import {IServiceManagerBaseEvents} from "../events/IServiceManagerBaseEvents.sol"; import "../utils/MockAVSDeployer.sol"; contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEvents { - // PaymentCoordinator config - address paymentUpdater = address(uint160(uint256(keccak256("paymentUpdater")))); + // RewardsCoordinator config + address rewardsUpdater = address(uint160(uint256(keccak256("rewardsUpdater")))); uint32 CALCULATION_INTERVAL_SECONDS = 7 days; - uint32 MAX_PAYMENT_DURATION = 70 days; + uint32 MAX_REWARDS_DURATION = 70 days; uint32 MAX_RETROACTIVE_LENGTH = 84 days; uint32 MAX_FUTURE_LENGTH = 28 days; - uint32 GENESIS_PAYMENT_TIMESTAMP = 1_712_188_800; - uint256 MAX_PAYMENT_AMOUNT = 1e38 - 1; + uint32 GENESIS_REWARDS_TIMESTAMP = 1_712_188_800; + uint256 MAX_REWARDS_AMOUNT = 1e38 - 1; /// @notice Delay in timestamp before a posted root can be claimed against uint32 activationDelay = 7 days; /// @notice the commission for all operators across all avss @@ -28,13 +28,14 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve // Testing Config and Mocks address serviceManagerOwner; - IERC20[] paymentTokens; + address rewardsInitiator = address(uint160(uint256(keccak256("rewardsInitiator")))); + IERC20[] rewardTokens; uint256 mockTokenInitialSupply = 10e50; IStrategy strategyMock1; IStrategy strategyMock2; IStrategy strategyMock3; StrategyBase strategyImplementation; - IPaymentCoordinator.StrategyAndMultiplier[] defaultStrategyAndMultipliers; + IRewardsCoordinator.StrategyAndMultiplier[] defaultStrategyAndMultipliers; // mapping to setting fuzzed inputs mapping(address => bool) public addressIsExcludedFromFuzzedInputs; @@ -46,28 +47,28 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve function setUp() public virtual { _deployMockEigenLayerAndAVS(); - // Deploy paymentcoordinator - paymentCoordinatorImplementation = new PaymentCoordinator( + // Deploy rewards coordinator + rewardsCoordinatorImplementation = new RewardsCoordinator( delegationMock, strategyManagerMock, CALCULATION_INTERVAL_SECONDS, - MAX_PAYMENT_DURATION, + MAX_REWARDS_DURATION, MAX_RETROACTIVE_LENGTH, MAX_FUTURE_LENGTH, - GENESIS_PAYMENT_TIMESTAMP + GENESIS_REWARDS_TIMESTAMP ); - paymentCoordinator = PaymentCoordinator( + rewardsCoordinator = RewardsCoordinator( address( new TransparentUpgradeableProxy( - address(paymentCoordinatorImplementation), + address(rewardsCoordinatorImplementation), address(proxyAdmin), abi.encodeWithSelector( - PaymentCoordinator.initialize.selector, + RewardsCoordinator.initialize.selector, msg.sender, pauserRegistry, 0, /*initialPausedStatus*/ - paymentUpdater, + rewardsUpdater, activationDelay, globalCommissionBips ) @@ -77,7 +78,7 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve // Deploy ServiceManager serviceManagerImplementation = new ServiceManagerMock( avsDirectory, - paymentCoordinator, + rewardsCoordinator, registryCoordinatorImplementation, stakeRegistryImplementation ); @@ -95,22 +96,24 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve ); serviceManagerOwner = serviceManager.owner(); + cheats.prank(serviceManagerOwner); + serviceManager.setRewardsInitiator(rewardsInitiator); _setUpDefaultStrategiesAndMultipliers(); - cheats.warp(GENESIS_PAYMENT_TIMESTAMP + 2 weeks); + cheats.warp(GENESIS_REWARDS_TIMESTAMP + 2 weeks); addressIsExcludedFromFuzzedInputs[address(pauserRegistry)] = true; addressIsExcludedFromFuzzedInputs[address(proxyAdmin)] = true; } - /// @notice deploy token to owner and approve ServiceManager. Used for deploying payment tokens - function _deployMockPaymentTokens(address owner, uint256 numTokens) internal virtual { + /// @notice deploy token to owner and approve ServiceManager. Used for deploying reward tokens + function _deployMockRewardTokens(address owner, uint256 numTokens) internal virtual { cheats.startPrank(owner); for (uint256 i = 0; i < numTokens; ++i) { IERC20 token = new ERC20PresetFixedSupply("dog wif hat", "MOCK1", mockTokenInitialSupply, owner); - paymentTokens.push(token); + rewardTokens.push(token); token.approve(address(serviceManager), mockTokenInitialSupply); } cheats.stopPrank(); @@ -176,13 +179,13 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve strategyManagerMock.setStrategyWhitelist(strategies[2], true); defaultStrategyAndMultipliers.push( - IPaymentCoordinator.StrategyAndMultiplier(IStrategy(address(strategies[0])), 1e18) + IRewardsCoordinator.StrategyAndMultiplier(IStrategy(address(strategies[0])), 1e18) ); defaultStrategyAndMultipliers.push( - IPaymentCoordinator.StrategyAndMultiplier(IStrategy(address(strategies[1])), 2e18) + IRewardsCoordinator.StrategyAndMultiplier(IStrategy(address(strategies[1])), 2e18) ); defaultStrategyAndMultipliers.push( - IPaymentCoordinator.StrategyAndMultiplier(IStrategy(address(strategies[2])), 3e18) + IRewardsCoordinator.StrategyAndMultiplier(IStrategy(address(strategies[2])), 3e18) ); } @@ -205,28 +208,28 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve return timestamp1 > timestamp2 ? timestamp1 : timestamp2; } - function testFuzz_submitPayments_Revert_WhenNotOwner(address caller) + function testFuzz_createAVSRewardsSubmission_Revert_WhenNotOwner(address caller) public filterFuzzedAddressInputs(caller) { - cheats.assume(caller != serviceManagerOwner); - IPaymentCoordinator.RangePayment[] memory rangePayments; + cheats.assume(caller != rewardsInitiator); + IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions; cheats.prank(caller); cheats.expectRevert( - "ServiceManagerBase.onlyPaymentInitiator: caller is not the payment initiator" + "ServiceManagerBase.onlyRewardsInitiator: caller is not the rewards initiator" ); - serviceManager.payForRange(rangePayments); + serviceManager.createAVSRewardsSubmission(rewardsSubmissions); } - function test_submitPayments_Revert_WhenERC20NotApproved() public { + function test_createAVSRewardsSubmission_Revert_WhenERC20NotApproved() public { IERC20 token = new ERC20PresetFixedSupply( - "dog wif hat", "MOCK1", mockTokenInitialSupply, serviceManagerOwner + "dog wif hat", "MOCK1", mockTokenInitialSupply, rewardsInitiator ); - IPaymentCoordinator.RangePayment[] memory rangePayments = - new IPaymentCoordinator.RangePayment[](1); - rangePayments[0] = IPaymentCoordinator.RangePayment({ + IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions = + new IRewardsCoordinator.RewardsSubmission[](1); + rewardsSubmissions[0] = IRewardsCoordinator.RewardsSubmission({ strategiesAndMultipliers: defaultStrategyAndMultipliers, token: token, amount: 100, @@ -234,291 +237,291 @@ contract ServiceManagerBase_UnitTests is MockAVSDeployer, IServiceManagerBaseEve duration: uint32(1 weeks) }); - cheats.prank(serviceManagerOwner); + cheats.prank(rewardsInitiator); cheats.expectRevert("ERC20: insufficient allowance"); - serviceManager.payForRange(rangePayments); + serviceManager.createAVSRewardsSubmission(rewardsSubmissions); } - function test_submitPayments_SingleRangePayment( + function test_createAVSRewardsSubmission_SingleSubmission( uint256 startTimestamp, uint256 duration, uint256 amount ) public { // 1. Bound fuzz inputs to valid ranges and amounts - IERC20 paymentToken = new ERC20PresetFixedSupply( - "dog wif hat", "MOCK1", mockTokenInitialSupply, serviceManagerOwner + IERC20 rewardToken = new ERC20PresetFixedSupply( + "dog wif hat", "MOCK1", mockTokenInitialSupply, rewardsInitiator ); - amount = bound(amount, 1, MAX_PAYMENT_AMOUNT); - duration = bound(duration, 0, MAX_PAYMENT_DURATION); + amount = bound(amount, 1, MAX_REWARDS_AMOUNT); + duration = bound(duration, 0, MAX_REWARDS_DURATION); duration = duration - (duration % CALCULATION_INTERVAL_SECONDS); startTimestamp = bound( startTimestamp, uint256( _maxTimestamp( - GENESIS_PAYMENT_TIMESTAMP, uint32(block.timestamp) - MAX_RETROACTIVE_LENGTH + GENESIS_REWARDS_TIMESTAMP, uint32(block.timestamp) - MAX_RETROACTIVE_LENGTH ) ) + CALCULATION_INTERVAL_SECONDS - 1, block.timestamp + uint256(MAX_FUTURE_LENGTH) ); startTimestamp = startTimestamp - (startTimestamp % CALCULATION_INTERVAL_SECONDS); - // 2. Create range payment input param - IPaymentCoordinator.RangePayment[] memory rangePayments = - new IPaymentCoordinator.RangePayment[](1); - rangePayments[0] = IPaymentCoordinator.RangePayment({ + // 2. Create reward submission input param + IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions = + new IRewardsCoordinator.RewardsSubmission[](1); + rewardsSubmissions[0] = IRewardsCoordinator.RewardsSubmission({ strategiesAndMultipliers: defaultStrategyAndMultipliers, - token: paymentToken, + token: rewardToken, amount: amount, startTimestamp: uint32(startTimestamp), duration: uint32(duration) }); // 3. Approve serviceManager for ERC20 - cheats.startPrank(serviceManagerOwner); - paymentToken.approve(address(serviceManager), amount); - - // 4. call payForRange() with expected event emitted - uint256 serviceManagerOwnerBalanceBefore = - paymentToken.balanceOf(address(serviceManagerOwner)); - uint256 paymentCoordinatorBalanceBefore = - paymentToken.balanceOf(address(paymentCoordinator)); - - paymentToken.approve(address(paymentCoordinator), amount); - uint256 currPaymentNonce = paymentCoordinator.paymentNonce(address(serviceManager)); - bytes32 rangePaymentHash = - keccak256(abi.encode(address(serviceManager), currPaymentNonce, rangePayments[0])); - - cheats.expectEmit(true, true, true, true, address(paymentCoordinator)); - emit RangePaymentCreated( - address(serviceManager), currPaymentNonce, rangePaymentHash, rangePayments[0] + cheats.startPrank(rewardsInitiator); + rewardToken.approve(address(serviceManager), amount); + + // 4. call createAVSRewardsSubmission() with expected event emitted + uint256 rewardsInitiatorBalanceBefore = + rewardToken.balanceOf(address(rewardsInitiator)); + uint256 rewardsCoordinatorBalanceBefore = + rewardToken.balanceOf(address(rewardsCoordinator)); + + rewardToken.approve(address(rewardsCoordinator), amount); + uint256 currSubmissionNonce = rewardsCoordinator.submissionNonce(address(serviceManager)); + bytes32 avsSubmissionHash = + keccak256(abi.encode(address(serviceManager), currSubmissionNonce, rewardsSubmissions[0])); + + cheats.expectEmit(true, true, true, true, address(rewardsCoordinator)); + emit AVSRewardsSubmissionCreated( + address(serviceManager), currSubmissionNonce, avsSubmissionHash, rewardsSubmissions[0] ); - serviceManager.payForRange(rangePayments); + serviceManager.createAVSRewardsSubmission(rewardsSubmissions); cheats.stopPrank(); assertTrue( - paymentCoordinator.isRangePaymentHash(address(serviceManager), rangePaymentHash), - "Range payment hash not submitted" + rewardsCoordinator.isAVSRewardsSubmissionHash(address(serviceManager), avsSubmissionHash), + "reward submission hash not submitted" ); assertEq( - currPaymentNonce + 1, - paymentCoordinator.paymentNonce(address(serviceManager)), - "Payment nonce not incremented" + currSubmissionNonce + 1, + rewardsCoordinator.submissionNonce(address(serviceManager)), + "submission nonce not incremented" ); assertEq( - serviceManagerOwnerBalanceBefore - amount, - paymentToken.balanceOf(serviceManagerOwner), - "serviceManagerOwner balance not decremented by amount of range payment" + rewardsInitiatorBalanceBefore - amount, + rewardToken.balanceOf(rewardsInitiator), + "rewardsInitiator balance not decremented by amount of reward submission" ); assertEq( - paymentCoordinatorBalanceBefore + amount, - paymentToken.balanceOf(address(paymentCoordinator)), - "PaymentCoordinator balance not incremented by amount of range payment" + rewardsCoordinatorBalanceBefore + amount, + rewardToken.balanceOf(address(rewardsCoordinator)), + "RewardsCoordinator balance not incremented by amount of reward submission" ); } - function test_submitPayments_MultipleRangePayments( + function test_createAVSRewardsSubmission_MultipleSubmissions( uint256 startTimestamp, uint256 duration, uint256 amount, - uint256 numPayments + uint256 numSubmissions ) public { - cheats.assume(2 <= numPayments && numPayments <= 10); - cheats.prank(paymentCoordinator.owner()); + cheats.assume(2 <= numSubmissions && numSubmissions <= 10); + cheats.prank(rewardsCoordinator.owner()); - IPaymentCoordinator.RangePayment[] memory rangePayments = - new IPaymentCoordinator.RangePayment[](numPayments); - bytes32[] memory rangePaymentHashes = new bytes32[](numPayments); - uint256 startPaymentNonce = paymentCoordinator.paymentNonce(address(serviceManager)); - _deployMockPaymentTokens(serviceManagerOwner, numPayments); + IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions = + new IRewardsCoordinator.RewardsSubmission[](numSubmissions); + bytes32[] memory avsSubmissionHashes = new bytes32[](numSubmissions); + uint256 startSubmissionNonce = rewardsCoordinator.submissionNonce(address(serviceManager)); + _deployMockRewardTokens(rewardsInitiator, numSubmissions); uint256[] memory avsBalancesBefore = - _getBalanceForTokens(paymentTokens, serviceManagerOwner); - uint256[] memory paymentCoordinatorBalancesBefore = - _getBalanceForTokens(paymentTokens, address(paymentCoordinator)); - uint256[] memory amounts = new uint256[](numPayments); + _getBalanceForTokens(rewardTokens, rewardsInitiator); + uint256[] memory rewardsCoordinatorBalancesBefore = + _getBalanceForTokens(rewardTokens, address(rewardsCoordinator)); + uint256[] memory amounts = new uint256[](numSubmissions); - // Create multiple range payments and their expected event - for (uint256 i = 0; i < numPayments; ++i) { + // Create multiple rewards submissions and their expected event + for (uint256 i = 0; i < numSubmissions; ++i) { // 1. Bound fuzz inputs to valid ranges and amounts using randSeed for each - amount = bound(amount + i, 1, MAX_PAYMENT_AMOUNT); + amount = bound(amount + i, 1, MAX_REWARDS_AMOUNT); amounts[i] = amount; - duration = bound(duration + i, 0, MAX_PAYMENT_DURATION); + duration = bound(duration + i, 0, MAX_REWARDS_DURATION); duration = duration - (duration % CALCULATION_INTERVAL_SECONDS); startTimestamp = bound( startTimestamp + i, uint256( _maxTimestamp( - GENESIS_PAYMENT_TIMESTAMP, uint32(block.timestamp) - MAX_RETROACTIVE_LENGTH + GENESIS_REWARDS_TIMESTAMP, uint32(block.timestamp) - MAX_RETROACTIVE_LENGTH ) ) + CALCULATION_INTERVAL_SECONDS - 1, block.timestamp + uint256(MAX_FUTURE_LENGTH) ); startTimestamp = startTimestamp - (startTimestamp % CALCULATION_INTERVAL_SECONDS); - // 2. Create range payment input param - IPaymentCoordinator.RangePayment memory rangePayment = IPaymentCoordinator.RangePayment({ + // 2. Create reward submission input param + IRewardsCoordinator.RewardsSubmission memory rewardsSubmission = IRewardsCoordinator.RewardsSubmission({ strategiesAndMultipliers: defaultStrategyAndMultipliers, - token: paymentTokens[i], + token: rewardTokens[i], amount: amounts[i], startTimestamp: uint32(startTimestamp), duration: uint32(duration) }); - rangePayments[i] = rangePayment; + rewardsSubmissions[i] = rewardsSubmission; - // 3. expected event emitted for this rangePayment - rangePaymentHashes[i] = keccak256( - abi.encode(address(serviceManager), startPaymentNonce + i, rangePayments[i]) + // 3. expected event emitted for this rewardsSubmission + avsSubmissionHashes[i] = keccak256( + abi.encode(address(serviceManager), startSubmissionNonce + i, rewardsSubmissions[i]) ); - cheats.expectEmit(true, true, true, true, address(paymentCoordinator)); - emit RangePaymentCreated( + cheats.expectEmit(true, true, true, true, address(rewardsCoordinator)); + emit AVSRewardsSubmissionCreated( address(serviceManager), - startPaymentNonce + i, - rangePaymentHashes[i], - rangePayments[i] + startSubmissionNonce + i, + avsSubmissionHashes[i], + rewardsSubmissions[i] ); } - // 4. call payForRange() - cheats.prank(serviceManagerOwner); - serviceManager.payForRange(rangePayments); + // 4. call createAVSRewardsSubmission() + cheats.prank(rewardsInitiator); + serviceManager.createAVSRewardsSubmission(rewardsSubmissions); - // 5. Check for paymentNonce() and rangePaymentHashes being set + // 5. Check for submissionNonce() and avsSubmissionHashes being set assertEq( - startPaymentNonce + numPayments, - paymentCoordinator.paymentNonce(address(serviceManager)), - "Payment nonce not incremented properly" + startSubmissionNonce + numSubmissions, + rewardsCoordinator.submissionNonce(address(serviceManager)), + "avs submission nonce not incremented properly" ); - for (uint256 i = 0; i < numPayments; ++i) { + for (uint256 i = 0; i < numSubmissions; ++i) { assertTrue( - paymentCoordinator.isRangePaymentHash( - address(serviceManager), rangePaymentHashes[i] + rewardsCoordinator.isAVSRewardsSubmissionHash( + address(serviceManager), avsSubmissionHashes[i] ), - "Range payment hash not submitted" + "rewards submission hash not submitted" ); assertEq( avsBalancesBefore[i] - amounts[i], - paymentTokens[i].balanceOf(serviceManagerOwner), - "AVS balance not decremented by amount of range payment" + rewardTokens[i].balanceOf(rewardsInitiator), + "AVS balance not decremented by amount of rewards submission" ); assertEq( - paymentCoordinatorBalancesBefore[i] + amounts[i], - paymentTokens[i].balanceOf(address(paymentCoordinator)), - "PaymentCoordinator balance not incremented by amount of range payment" + rewardsCoordinatorBalancesBefore[i] + amounts[i], + rewardTokens[i].balanceOf(address(rewardsCoordinator)), + "RewardsCoordinator balance not incremented by amount of rewards submission" ); } } - function test_submitPayments_MultipleRangePaymentsSingleToken( + function test_createAVSRewardsSubmission_MultipleSubmissionsSingleToken( uint256 startTimestamp, uint256 duration, uint256 amount, - uint256 numPayments + uint256 numSubmissions ) public { - cheats.assume(2 <= numPayments && numPayments <= 10); - cheats.prank(paymentCoordinator.owner()); - - IPaymentCoordinator.RangePayment[] memory rangePayments = - new IPaymentCoordinator.RangePayment[](numPayments); - bytes32[] memory rangePaymentHashes = new bytes32[](numPayments); - uint256 startPaymentNonce = paymentCoordinator.paymentNonce(address(serviceManager)); - IERC20 paymentToken = new ERC20PresetFixedSupply( - "dog wif hat", "MOCK1", mockTokenInitialSupply, serviceManagerOwner + cheats.assume(2 <= numSubmissions && numSubmissions <= 10); + cheats.prank(rewardsCoordinator.owner()); + + IRewardsCoordinator.RewardsSubmission[] memory rewardsSubmissions = + new IRewardsCoordinator.RewardsSubmission[](numSubmissions); + bytes32[] memory avsSubmissionHashes = new bytes32[](numSubmissions); + uint256 startSubmissionNonce = rewardsCoordinator.submissionNonce(address(serviceManager)); + IERC20 rewardToken = new ERC20PresetFixedSupply( + "dog wif hat", "MOCK1", mockTokenInitialSupply, rewardsInitiator ); - cheats.prank(serviceManagerOwner); - paymentToken.approve(address(serviceManager), mockTokenInitialSupply); - uint256 avsBalanceBefore = paymentToken.balanceOf(serviceManagerOwner); - uint256 paymentCoordinatorBalanceBefore = - paymentToken.balanceOf(address(paymentCoordinator)); + cheats.prank(rewardsInitiator); + rewardToken.approve(address(serviceManager), mockTokenInitialSupply); + uint256 avsBalanceBefore = rewardToken.balanceOf(rewardsInitiator); + uint256 rewardsCoordinatorBalanceBefore = + rewardToken.balanceOf(address(rewardsCoordinator)); uint256 totalAmount = 0; - uint256[] memory amounts = new uint256[](numPayments); + uint256[] memory amounts = new uint256[](numSubmissions); - // Create multiple range payments and their expected event - for (uint256 i = 0; i < numPayments; ++i) { + // Create multiple rewards submissions and their expected event + for (uint256 i = 0; i < numSubmissions; ++i) { // 1. Bound fuzz inputs to valid ranges and amounts using randSeed for each - amount = bound(amount + i, 1, MAX_PAYMENT_AMOUNT); + amount = bound(amount + i, 1, MAX_REWARDS_AMOUNT); amounts[i] = amount; totalAmount += amount; - duration = bound(duration + i, 0, MAX_PAYMENT_DURATION); + duration = bound(duration + i, 0, MAX_REWARDS_DURATION); duration = duration - (duration % CALCULATION_INTERVAL_SECONDS); startTimestamp = bound( startTimestamp + i, uint256( _maxTimestamp( - GENESIS_PAYMENT_TIMESTAMP, uint32(block.timestamp) - MAX_RETROACTIVE_LENGTH + GENESIS_REWARDS_TIMESTAMP, uint32(block.timestamp) - MAX_RETROACTIVE_LENGTH ) ) + CALCULATION_INTERVAL_SECONDS - 1, block.timestamp + uint256(MAX_FUTURE_LENGTH) ); startTimestamp = startTimestamp - (startTimestamp % CALCULATION_INTERVAL_SECONDS); - // 2. Create range payment input param - IPaymentCoordinator.RangePayment memory rangePayment = IPaymentCoordinator.RangePayment({ + // 2. Create reward submission input param + IRewardsCoordinator.RewardsSubmission memory rewardsSubmission = IRewardsCoordinator.RewardsSubmission({ strategiesAndMultipliers: defaultStrategyAndMultipliers, - token: paymentToken, + token: rewardToken, amount: amounts[i], startTimestamp: uint32(startTimestamp), duration: uint32(duration) }); - rangePayments[i] = rangePayment; + rewardsSubmissions[i] = rewardsSubmission; - // 3. expected event emitted for this rangePayment - rangePaymentHashes[i] = keccak256( - abi.encode(address(serviceManager), startPaymentNonce + i, rangePayments[i]) + // 3. expected event emitted for this avs rewards submission + avsSubmissionHashes[i] = keccak256( + abi.encode(address(serviceManager), startSubmissionNonce + i, rewardsSubmissions[i]) ); - cheats.expectEmit(true, true, true, true, address(paymentCoordinator)); - emit RangePaymentCreated( + cheats.expectEmit(true, true, true, true, address(rewardsCoordinator)); + emit AVSRewardsSubmissionCreated( address(serviceManager), - startPaymentNonce + i, - rangePaymentHashes[i], - rangePayments[i] + startSubmissionNonce + i, + avsSubmissionHashes[i], + rewardsSubmissions[i] ); } - // 4. call payForRange() - cheats.prank(serviceManagerOwner); - serviceManager.payForRange(rangePayments); + // 4. call createAVSRewardsSubmission() + cheats.prank(rewardsInitiator); + serviceManager.createAVSRewardsSubmission(rewardsSubmissions); - // 5. Check for paymentNonce() and rangePaymentHashes being set + // 5. Check for submissionNonce() and avsSubmissionHashes being set assertEq( - startPaymentNonce + numPayments, - paymentCoordinator.paymentNonce(address(serviceManager)), - "Payment nonce not incremented properly" + startSubmissionNonce + numSubmissions, + rewardsCoordinator.submissionNonce(address(serviceManager)), + "avs submission nonce not incremented properly" ); assertEq( avsBalanceBefore - totalAmount, - paymentToken.balanceOf(serviceManagerOwner), - "AVS balance not decremented by amount of range payments" + rewardToken.balanceOf(rewardsInitiator), + "AVS balance not decremented by amount of rewards submissions" ); assertEq( - paymentCoordinatorBalanceBefore + totalAmount, - paymentToken.balanceOf(address(paymentCoordinator)), - "PaymentCoordinator balance not incremented by amount of range payments" + rewardsCoordinatorBalanceBefore + totalAmount, + rewardToken.balanceOf(address(rewardsCoordinator)), + "RewardsCoordinator balance not incremented by amount of rewards submissions" ); - for (uint256 i = 0; i < numPayments; ++i) { + for (uint256 i = 0; i < numSubmissions; ++i) { assertTrue( - paymentCoordinator.isRangePaymentHash( - address(serviceManager), rangePaymentHashes[i] + rewardsCoordinator.isAVSRewardsSubmissionHash( + address(serviceManager), avsSubmissionHashes[i] ), - "Range payment hash not submitted" + "rewards submission hash not submitted" ); } } - function test_setPaymentInitiator() public { - address newPaymentInitiator = address(uint160(uint256(keccak256("newPaymentInitiator")))); + function test_setRewardsInitiator() public { + address newRewardsInitiator = address(uint160(uint256(keccak256("newRewardsInitiator")))); cheats.prank(serviceManagerOwner); - serviceManager.setPaymentInitiator(newPaymentInitiator); - assertEq(newPaymentInitiator, serviceManager.paymentInitiator()); + serviceManager.setRewardsInitiator(newRewardsInitiator); + assertEq(newRewardsInitiator, serviceManager.rewardsInitiator()); } - function test_setPaymentInitiator_revert_notOwner() public { + function test_setRewardsInitiator_revert_notOwner() public { address caller = address(uint160(uint256(keccak256("caller")))); - address newPaymentInitiator = address(uint160(uint256(keccak256("newPaymentInitiator")))); + address newRewardsInitiator = address(uint160(uint256(keccak256("newRewardsInitiator")))); cheats.expectRevert("Ownable: caller is not the owner"); cheats.prank(caller); - serviceManager.setPaymentInitiator(newPaymentInitiator); + serviceManager.setRewardsInitiator(newRewardsInitiator); } } diff --git a/test/unit/ServiceManagerRouter.t.sol b/test/unit/ServiceManagerRouter.t.sol index a5649b3c..9fc2c0f7 100644 --- a/test/unit/ServiceManagerRouter.t.sol +++ b/test/unit/ServiceManagerRouter.t.sol @@ -17,7 +17,7 @@ contract ServiceManagerRouter_UnitTests is MockAVSDeployer { // Deploy dummy serviceManager dummyServiceManager = new ServiceManagerMock( avsDirectory, - paymentCoordinatorImplementation, + rewardsCoordinatorImplementation, registryCoordinatorImplementation, stakeRegistryImplementation ); diff --git a/test/utils/MockAVSDeployer.sol b/test/utils/MockAVSDeployer.sol index e3d2a13e..23875760 100644 --- a/test/utils/MockAVSDeployer.sol +++ b/test/utils/MockAVSDeployer.sol @@ -31,10 +31,11 @@ import {AVSDirectoryMock} from "../mocks/AVSDirectoryMock.sol"; import {DelegationMock} from "../mocks/DelegationMock.sol"; import {AVSDirectory} from "eigenlayer-contracts/src/contracts/core/AVSDirectory.sol"; import {IAVSDirectory} from "eigenlayer-contracts/src/contracts/interfaces/IAVSDirectory.sol"; -import {IPaymentCoordinator} from - "eigenlayer-contracts/src/contracts/interfaces/IPaymentCoordinator.sol"; -import {PaymentCoordinator} from "eigenlayer-contracts/src/contracts/core/PaymentCoordinator.sol"; -import {PaymentCoordinatorMock} from "../mocks/PaymentCoordinatorMock.sol"; + +import {RewardsCoordinatorMock} from "../mocks/RewardsCoordinatorMock.sol"; + +import { RewardsCoordinator } from "eigenlayer-contracts/src/contracts/core/RewardsCoordinator.sol"; +import { IRewardsCoordinator } from "eigenlayer-contracts/src/contracts/interfaces/IRewardsCoordinator.sol"; import {BLSApkRegistryHarness} from "../harnesses/BLSApkRegistryHarness.sol"; import {EmptyContract} from "eigenlayer-contracts/src/test/mocks/EmptyContract.sol"; @@ -75,9 +76,9 @@ contract MockAVSDeployer is Test { AVSDirectory public avsDirectory; AVSDirectory public avsDirectoryImplementation; AVSDirectoryMock public avsDirectoryMock; - PaymentCoordinator public paymentCoordinator; - PaymentCoordinator public paymentCoordinatorImplementation; - PaymentCoordinatorMock public paymentCoordinatorMock; + RewardsCoordinator public rewardsCoordinator; + RewardsCoordinator public rewardsCoordinatorImplementation; + RewardsCoordinatorMock public rewardsCoordinatorMock; /// @notice StakeRegistry, Constant used as a divisor in calculating weights. uint256 public constant WEIGHTING_DIVISOR = 1e18; @@ -179,7 +180,7 @@ contract MockAVSDeployer is Test { ) ) ); - paymentCoordinatorMock = new PaymentCoordinatorMock(); + rewardsCoordinatorMock = new RewardsCoordinatorMock(); strategyManagerMock.setAddresses(delegationMock, eigenPodManagerMock, slasher); cheats.stopPrank(); @@ -243,7 +244,7 @@ contract MockAVSDeployer is Test { serviceManagerImplementation = new ServiceManagerMock( avsDirectoryMock, - IPaymentCoordinator(address(paymentCoordinatorMock)), + IRewardsCoordinator(address(rewardsCoordinatorMock)), registryCoordinator, stakeRegistry ); @@ -255,7 +256,7 @@ contract MockAVSDeployer is Test { serviceManager.initialize({ initialOwner: registryCoordinatorOwner, - paymentInitiator: address(proxyAdminOwner) + rewardsInitiator: address(proxyAdminOwner) }); // set the public key for an operator, using harnessed function to bypass checks