Skip to content

Commit

Permalink
Rewards Integration (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 authored Jun 17, 2024
1 parent 733ebbf commit 2ade913
Show file tree
Hide file tree
Showing 23 changed files with 499 additions and 136 deletions.
2 changes: 1 addition & 1 deletion contracts/bindings/AVSDirectory/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/BLSApkRegistry/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/BN254/binding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/bindings/BitmapUtils/binding.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion contracts/bindings/DelegationManager/binding.go

Large diffs are not rendered by default.

271 changes: 229 additions & 42 deletions contracts/bindings/EigenDAServiceManager/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/EjectionManager/binding.go

Large diffs are not rendered by default.

189 changes: 162 additions & 27 deletions contracts/bindings/IEigenDAServiceManager/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/IndexRegistry/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/MockRollup/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/OperatorStateRetriever/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/RegistryCoordinator/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/StakeRegistry/binding.go

Large diffs are not rendered by default.

36 changes: 36 additions & 0 deletions contracts/script/DeployOpenEigenLayer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import "eigenlayer-core/contracts/core/StrategyManager.sol";
import "eigenlayer-core/contracts/core/Slasher.sol";
import "eigenlayer-core/contracts/core/DelegationManager.sol";
import "eigenlayer-core/contracts/core/AVSDirectory.sol";
import "eigenlayer-core/contracts/core/RewardsCoordinator.sol";

import "eigenlayer-core/contracts/strategies/StrategyBaseTVLLimits.sol";

Expand All @@ -36,6 +37,14 @@ import "forge-std/Test.sol";
contract DeployOpenEigenLayer is Script, Test {
Vm cheats = Vm(VM_ADDRESS);

uint32 CALCULATION_INTERVAL_SECONDS = 7 days;
uint32 MAX_REWARDS_DURATION = 70 days;
uint32 MAX_RETROACTIVE_LENGTH = 84 days;
uint32 MAX_FUTURE_LENGTH = 28 days;
uint32 GENESIS_REWARDS_TIMESTAMP = 1712188800;
uint32 activationDelay = 7 days;
uint16 globalCommissionBips = 1000;

// struct used to encode token info in config file
struct StrategyConfig {
uint256 maxDeposits;
Expand All @@ -59,6 +68,8 @@ contract DeployOpenEigenLayer is Script, Test {
DelayedWithdrawalRouter public delayedWithdrawalRouterImplementation;
AVSDirectory public avsDirectory;
AVSDirectory public avsDirectoryImplementation;
RewardsCoordinator public rewardsCoordinator;
RewardsCoordinator public rewardsCoordinatorImplementation;
UpgradeableBeacon public eigenPodBeacon;
EigenPod public eigenPodImplementation;
StrategyBase public baseStrategyImplementation;
Expand Down Expand Up @@ -115,6 +126,9 @@ contract DeployOpenEigenLayer is Script, Test {
delayedWithdrawalRouter = DelayedWithdrawalRouter(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
rewardsCoordinator = RewardsCoordinator(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);

// ETH POS deposit is 0 address
eigenPodImplementation = new EigenPod(
Expand All @@ -131,6 +145,15 @@ contract DeployOpenEigenLayer is Script, Test {
// Second, deploy the *implementation* contracts, using the *proxy contracts* as inputs
delegationImplementation = new DelegationManager(strategyManager, slasher, eigenPodManager);
avsDirectoryImplementation = new AVSDirectory(delegation);
rewardsCoordinatorImplementation = new RewardsCoordinator(
delegation,
strategyManager,
CALCULATION_INTERVAL_SECONDS,
MAX_REWARDS_DURATION,
MAX_RETROACTIVE_LENGTH,
MAX_FUTURE_LENGTH,
GENESIS_REWARDS_TIMESTAMP
);
strategyManagerImplementation = new StrategyManager(delegation, eigenPodManager, slasher);
slasherImplementation = new Slasher(strategyManager, delegation);
eigenPodManagerImplementation = new EigenPodManager(
Expand Down Expand Up @@ -167,6 +190,19 @@ contract DeployOpenEigenLayer is Script, Test {
0
)
);
eigenLayerProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(rewardsCoordinator))),
address(rewardsCoordinatorImplementation),
abi.encodeWithSelector(
RewardsCoordinator.initialize.selector,
executorMultisig,
eigenLayerPauserReg,
0,
executorMultisig,
activationDelay,
globalCommissionBips
)
);
eigenLayerProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(slasher))),
address(slasherImplementation),
Expand Down
10 changes: 5 additions & 5 deletions contracts/script/EigenDADeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ import {StakeRegistry, IStrategy} from "eigenlayer-middleware/StakeRegistry.sol"
import {IStakeRegistry, IDelegationManager} from "eigenlayer-middleware/interfaces/IStakeRegistry.sol";
import {IServiceManager} from "eigenlayer-middleware/interfaces/IServiceManager.sol";
import {IBLSApkRegistry} from "eigenlayer-middleware/interfaces/IBLSApkRegistry.sol";

import {EigenDAServiceManager, IAVSDirectory, IPaymentCoordinator} from "../src/core/EigenDAServiceManager.sol";
import {EigenDAServiceManager, IAVSDirectory, IRewardsCoordinator} from "../src/core/EigenDAServiceManager.sol";
import {EigenDAHasher} from "../src/libraries/EigenDAHasher.sol";

import {DeployOpenEigenLayer, ProxyAdmin, ERC20PresetFixedSupply, TransparentUpgradeableProxy, IPauserRegistry} from "./DeployOpenEigenLayer.s.sol";
Expand Down Expand Up @@ -186,8 +185,8 @@ contract EigenDADeployer is DeployOpenEigenLayer {
}

eigenDAServiceManagerImplementation = new EigenDAServiceManager(
IAVSDirectory(address(avsDirectory)),
IPaymentCoordinator(address(0)),
avsDirectory,
rewardsCoordinator,
registryCoordinator,
stakeRegistry
);
Expand All @@ -204,7 +203,8 @@ contract EigenDADeployer is DeployOpenEigenLayer {
eigenDAPauserReg,
0,
addressConfig.eigenDACommunityMultisig,
confirmers
confirmers,
addressConfig.eigenDACommunityMultisig
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,32 @@ import {ERC20PresetFixedSupply} from "@openzeppelin/contracts/token/ERC20/preset
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import {
ExistingDeploymentParser,
PaymentCoordinator,
IPaymentCoordinator,
RewardsCoordinator,
IRewardsCoordinator,
IPauserRegistry,
IStrategy,
IERC20
} from "eigenlayer-scripts/utils/ExistingDeploymentParser.sol";
import {IRegistryCoordinator} from "eigenlayer-middleware/interfaces/IRegistryCoordinator.sol";
import {IStakeRegistry} from "eigenlayer-middleware/interfaces/IStakeRegistry.sol";

import {EigenDAServiceManager} from "../../../src/core/EigenDAServiceManager.sol";

/**
* @title ServiceManagerBaseUpgrade for Preprod contracts.
* Assumes EOA deploying has permissions to call the proxyAdmin to upgrade.
*
*
* Local Fork: Deploy/Upgrade PaymentCoordinator
* Local Fork: Deploy/Upgrade RewardsCoordinator
* anvil --fork-url $RPC_HOLESKY
* forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" upgrade
* forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" deploy
* forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" payForRange
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" upgrade
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" deploy
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url http://127.0.0.1:8545 --private-key $PRIVATE_KEY --broadcast -vvvv --sig "run(string memory deployArg)" createAVSRewardsSubmission
*
* Upgrade Holesky testnet: Deploy/Upgrade PaymentCoordinator
* forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" upgrade
* forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" deploy
* forge script script/deploy/holesky/EigenDASM_PaymentsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" payForRange
* Upgrade Holesky testnet: Deploy/Upgrade RewardsCoordinator
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" upgrade
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" deploy
* forge script script/deploy/holesky/EigenDASM_RewardsUpgrade.s.sol:ServiceManagerBaseUpgrade --rpc-url $RPC_HOLESKY --private-key $PRIVATE_KEY --broadcast --verify -vvvv --sig "run(string memory deployArg)" createAVSRewardsSubmission
*/
contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
// Hardcode these values to your needs
Expand Down Expand Up @@ -60,8 +60,8 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
_upgradeServiceManager();
} else if (keccak256(abi.encode(deployArg)) == keccak256(abi.encode("deploy"))) {
_deployServiceManager();
} else if (keccak256(abi.encode(deployArg)) == keccak256(abi.encode("payForRange"))) {
_payForRange();
} else if (keccak256(abi.encode(deployArg)) == keccak256(abi.encode("createAVSRewardsSubmission"))) {
_createAVSRewardsSubmission();
}

vm.stopBroadcast();
Expand All @@ -82,7 +82,7 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
serviceManagerImplementation = address(
new EigenDAServiceManager(
avsDirectory,
paymentCoordinator,
rewardsCoordinator,
IRegistryCoordinator(registryCoordinator),
IStakeRegistry(stakeRegistry)
)
Expand All @@ -106,7 +106,7 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
serviceManagerImplementation = address(
new EigenDAServiceManager(
avsDirectory,
paymentCoordinator,
rewardsCoordinator,
IRegistryCoordinator(registryCoordinator),
IStakeRegistry(stakeRegistry)
)
Expand All @@ -130,19 +130,19 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
);
}

/// @notice Example payForRange call with the ServiceManager
function _payForRange() internal {
/// @notice Example createAVSRewardsSubmission call with the ServiceManager
function _createAVSRewardsSubmission() internal {
uint256 mockTokenInitialSupply = 1e30;
address stETHStrategy = 0x5C8b55722f421556a2AAfb7A3EA63d4c3e514312;
address rETHStrategy = 0x87f6C7d24b109919eB38295e3F8298425e6331D9;

IPaymentCoordinator.StrategyAndMultiplier[] memory strategyAndMultipliers = new IPaymentCoordinator.StrategyAndMultiplier[](2);
IRewardsCoordinator.StrategyAndMultiplier[] memory strategyAndMultipliers = new IRewardsCoordinator.StrategyAndMultiplier[](2);
// Strategy addresses must be in ascending order
strategyAndMultipliers[0] = IPaymentCoordinator.StrategyAndMultiplier({
strategyAndMultipliers[0] = IRewardsCoordinator.StrategyAndMultiplier({
strategy: IStrategy(stETHStrategy),
multiplier: 1e18
});
strategyAndMultipliers[1] = IPaymentCoordinator.StrategyAndMultiplier({
strategyAndMultipliers[1] = IRewardsCoordinator.StrategyAndMultiplier({
strategy: IStrategy(rETHStrategy),
multiplier: 1e18
});
Expand All @@ -160,10 +160,10 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
// amount <= 1e38 - 1
uint256 amount = 100e18;

// 2. Create range payment input param
IPaymentCoordinator.RangePayment[]
memory rangePayments = new IPaymentCoordinator.RangePayment[](1);
rangePayments[0] = IPaymentCoordinator.RangePayment({
// 2. Create RewardsSubmission input param
IRewardsCoordinator.RewardsSubmission[]
memory rewardsSubmissions = new IRewardsCoordinator.RewardsSubmission[](1);
rewardsSubmissions[0] = IRewardsCoordinator.RewardsSubmission({
strategiesAndMultipliers: strategyAndMultipliers,
token: token,
amount: amount,
Expand All @@ -172,15 +172,15 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
});

token.approve(serviceManager, amount);
EigenDAServiceManager(serviceManager).payForRange(rangePayments);
EigenDAServiceManager(serviceManager).createAVSRewardsSubmission(rewardsSubmissions);
}

/// @dev check implementation address set properly
function _verifyUpgrade() internal virtual {
// Preprod PaymentCoordinator
// Preprod RewardsCoordinator
require(
address(paymentCoordinator) == 0xb22Ef643e1E067c994019A4C19e403253C05c2B0,
"ServiceManagerBaseUpgrade: PaymentCoordinator address is incorrect"
address(rewardsCoordinator) == 0xb22Ef643e1E067c994019A4C19e403253C05c2B0,
"ServiceManagerBaseUpgrade: RewardsCoordinator address is incorrect"
);
require(
avsProxyAdmin.getProxyImplementation(
Expand All @@ -193,4 +193,4 @@ contract ServiceManagerBaseUpgrade is ExistingDeploymentParser {
"ServiceManagerBaseUpgrade: deployer address is incorrect"
);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,14 @@
"init_paused_status": 0,
"init_minWithdrawalDelayBlocks": 10
},
"paymentCoordinator": {
"rewardsCoordinator": {
"init_paused_status": 0,
"CALCULATION_INTERVAL_SECONDS": 604800,
"MAX_PAYMENT_DURATION": 6048000,
"MAX_REWARDS_DURATION": 6048000,
"MAX_RETROACTIVE_LENGTH": 7776000,
"MAX_FUTURE_LENGTH": 2592000,
"GENESIS_PAYMENT_TIMESTAMP": 1710979200,
"payment_updater_address": "0x02d9bd32ec711AC8782aEaBF9e1E1309F0965c11",
"GENESIS_REWARDS_TIMESTAMP": 1710979200,
"rewards_updater_address": "0x18a0f92Ad9645385E8A8f3db7d0f6CF7aBBb0aD4",
"activation_delay": 120,
"calculation_interval_seconds": 604800,
"global_operator_commission_bips": 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"eigenPodManager": "0xB8d8952f572e67B11e43bC21250967772fa883Ff",
"eigenPodManagerImplementation": "0xc5B857A92245f64e9D90cCc5b096Db82eB77eB5c",
"emptyContract": "0x9690d52B1Ce155DB2ec5eCbF5a262ccCc7B3A6D2",
"paymentCoordinator": "0xb22Ef643e1E067c994019A4C19e403253C05c2B0",
"paymentCoordinatorImplementation": "0xC9366ab4A299e0937EC15A6C256C4481C05A24fD",
"rewardsCoordinator": "0xb22Ef643e1E067c994019A4C19e403253C05c2B0",
"rewardsCoordinatorImplementation": "0x76d4D84c90a2AFf213F7D859d2a288685A1a2Ede",
"slasher": "0x12699471dF8dca329C76D72823B1b79d55709384",
"slasherImplementation": "0x9460fCe11E1e0365419fa860599903B4E5097cf0",
"numStrategiesDeployed": 0,
Expand Down
10 changes: 6 additions & 4 deletions contracts/src/core/EigenDAServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ pragma solidity ^0.8.9;
import {Pausable} from "eigenlayer-core/contracts/permissions/Pausable.sol";
import {IPauserRegistry} from "eigenlayer-core/contracts/interfaces/IPauserRegistry.sol";

import {ServiceManagerBase, IAVSDirectory, IPaymentCoordinator} from "eigenlayer-middleware/ServiceManagerBase.sol";
import {ServiceManagerBase, IAVSDirectory, IRewardsCoordinator, IServiceManager} from "eigenlayer-middleware/ServiceManagerBase.sol";
import {BLSSignatureChecker} from "eigenlayer-middleware/BLSSignatureChecker.sol";
import {IRegistryCoordinator} from "eigenlayer-middleware/interfaces/IRegistryCoordinator.sol";
import {IStakeRegistry} from "eigenlayer-middleware/interfaces/IStakeRegistry.sol";
Expand Down Expand Up @@ -34,12 +34,12 @@ contract EigenDAServiceManager is EigenDAServiceManagerStorage, ServiceManagerBa

constructor(
IAVSDirectory __avsDirectory,
IPaymentCoordinator __paymentCoordinator,
IRewardsCoordinator __rewardsCoordinator,
IRegistryCoordinator __registryCoordinator,
IStakeRegistry __stakeRegistry
)
BLSSignatureChecker(__registryCoordinator)
ServiceManagerBase(__avsDirectory, __paymentCoordinator, __registryCoordinator, __stakeRegistry)
ServiceManagerBase(__avsDirectory, __rewardsCoordinator, __registryCoordinator, __stakeRegistry)
{
_disableInitializers();
}
Expand All @@ -48,13 +48,15 @@ contract EigenDAServiceManager is EigenDAServiceManagerStorage, ServiceManagerBa
IPauserRegistry _pauserRegistry,
uint256 _initialPausedStatus,
address _initialOwner,
address[] memory _batchConfirmers
address[] memory _batchConfirmers,
address _rewardsInitiator
)
public
initializer
{
_initializePauser(_pauserRegistry, _initialPausedStatus);
_transferOwnership(_initialOwner);
_setRewardsInitiator(_rewardsInitiator);
for (uint i = 0; i < _batchConfirmers.length; ++i) {
_setBatchConfirmer(_batchConfirmers[i]);
}
Expand Down
Loading

0 comments on commit 2ade913

Please sign in to comment.