Skip to content

Commit

Permalink
Merge pull request #92 from Layr-Labs/route-thru-sm
Browse files Browse the repository at this point in the history
feat: rewards and rewards v2 integration for hello world
  • Loading branch information
Sidu28 authored Jan 18, 2025
2 parents 4626e20 + 3f44fb4 commit b8148c7
Show file tree
Hide file tree
Showing 26 changed files with 485 additions and 89 deletions.
Binary file added .DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
- name: Run Forge build
run: |
forge --version
forge build --sizes
forge build --optimize --optimizer-runs 200 --via-ir --sizes
id: build

- name: Run Forge tests
Expand Down
38 changes: 38 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,44 @@ npm run start:operator

```

### Create and Claim Payments

In a terminal, start a new instance of anvil and deploy the core and avs contracts
```sh
# Start anvil
npm run start:anvil-quick
# Deploy the EigenLayer contracts
npm run deploy:core

# Deploy the Hello World AVS contracts
npm run deploy:hello-world

```

In another terminal, run:

```sh
# Create payment roots
npm run create-payments-root

# Claim created payment
npm run claim-payments
```

To run operator directed payments, run:
```sh
#Create payment roots
npm run create-operator-directed-payments-root

# Claim created payment
npm run claim-payments
```

In order to create and claim multiple payments (run the above two commands more than once), you must wait up to 5 minutes.




### Create Hello-World-AVS Tasks

Open a separate terminal window #3, execute the following commands
Expand Down
29 changes: 29 additions & 0 deletions contracts/config/core/31337.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"strategyManager": {
"init_paused_status": 0,
"init_withdrawal_delay_blocks": 50400
},
"delegation": {
"init_paused_status": 0,
"init_withdrawal_delay_blocks": 50400
},
"slasher": {
"init_paused_status": 0
},
"eigenPodManager": {
"init_paused_status": 0
},
"rewardsCoordinator": {
"init_paused_status": 0,
"MAX_REWARDS_DURATION": 864000,
"MAX_RETROACTIVE_LENGTH": 86400,
"MAX_FUTURE_LENGTH": 86400,
"GENESIS_REWARDS_TIMESTAMP": 1672531200,
"rewards_updater_address": "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955",
"rewards_updater_key": "0x4bbbf85ce3377467afe5d46f804f221813b2bb87f24d81f60f1fcdbf7cbf4356",
"activation_delay": 0,
"calculation_interval_seconds": 86400,
"global_operator_commission_bips": 1000
}
}

10 changes: 10 additions & 0 deletions contracts/config/hello-world/31337.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"addresses": {
"rewardsOwner": "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f",
"rewardsInitiator": "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720"
},
"keys": {
"rewardsOwner": "0xdbda1821b80551c9d65939329250298aa3472ba22feea921c0cf5d620ea67b97",
"rewardsInitiator": "0x2a871d0798f97d79848a013d4936a73bf4cc922c825d33c1cf7073dff6d409c6"
}
}
9 changes: 8 additions & 1 deletion contracts/script/DeployEigenLayerCore.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {Script} from "forge-std/Script.sol";
import {CoreDeploymentLib} from "./utils/CoreDeploymentLib.sol";
import {UpgradeableProxyLib} from "./utils/UpgradeableProxyLib.sol";

contract DeployEigenLayerCore is Script {
import {IRewardsCoordinator} from "@eigenlayer/contracts/interfaces/IRewardsCoordinator.sol";

import "forge-std/Test.sol";

contract DeployEigenlayerCore is Script, Test {
using CoreDeploymentLib for *;
using UpgradeableProxyLib for address;

Expand All @@ -22,6 +26,9 @@ contract DeployEigenLayerCore is Script {

function run() external {
vm.startBroadcast(deployer);
//set the rewards updater to the deployer address for payment flow
configData = CoreDeploymentLib.readDeploymentConfigValues("config/core/", block.chainid);
configData.rewardsCoordinator.updater = deployer;
proxyAdmin = UpgradeableProxyLib.deployProxyAdmin();
deploymentData = CoreDeploymentLib.deployContracts(proxyAdmin, configData);
vm.stopBroadcast();
Expand Down
27 changes: 22 additions & 5 deletions contracts/script/HelloWorldDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import {TransparentUpgradeableProxy} from
"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol";
import {StrategyFactory} from "@eigenlayer/contracts/strategies/StrategyFactory.sol";
import {StrategyManager} from "@eigenlayer/contracts/core/StrategyManager.sol";
import {IRewardsCoordinator} from "@eigenlayer/contracts/interfaces/IRewardsCoordinator.sol";



import {
Expand All @@ -20,41 +22,56 @@ import {
IStrategy
} from "@eigenlayer-middleware/src/interfaces/IECDSAStakeRegistryEventsAndErrors.sol";

contract HelloWorldDeployer is Script {
import "forge-std/Test.sol";

contract HelloWorldDeployer is Script, Test {
using CoreDeploymentLib for *;
using UpgradeableProxyLib for address;

address private deployer;
address proxyAdmin;
address rewardsOwner;
address rewardsInitiator;
IStrategy helloWorldStrategy;
CoreDeploymentLib.DeploymentData coreDeployment;
HelloWorldDeploymentLib.DeploymentData helloWorldDeployment;
HelloWorldDeploymentLib.DeploymentConfigData helloWorldConfig;
Quorum internal quorum;
ERC20Mock token;
function setUp() public virtual {
deployer = vm.rememberKey(vm.envUint("PRIVATE_KEY"));
vm.label(deployer, "Deployer");

helloWorldConfig = HelloWorldDeploymentLib.readDeploymentConfigValues("config/hello-world/", block.chainid);


coreDeployment = CoreDeploymentLib.readDeploymentJson("deployments/core/", block.chainid);
}

function run() external {
vm.startBroadcast(deployer);
proxyAdmin = UpgradeableProxyLib.deployProxyAdmin();
rewardsOwner = helloWorldConfig.rewardsOwner;
rewardsInitiator = helloWorldConfig.rewardsInitiator;

token = new ERC20Mock();
helloWorldStrategy = IStrategy(StrategyFactory(coreDeployment.strategyFactory).deployNewStrategy(token));


quorum.strategies.push(
StrategyParams({strategy: helloWorldStrategy, multiplier: 10_000})
);


proxyAdmin = UpgradeableProxyLib.deployProxyAdmin();


helloWorldDeployment =
HelloWorldDeploymentLib.deployContracts(proxyAdmin, coreDeployment, quorum);
HelloWorldDeploymentLib.deployContracts(proxyAdmin, coreDeployment, quorum, rewardsInitiator, rewardsOwner);

helloWorldDeployment.strategy = address(helloWorldStrategy);
helloWorldDeployment.token = address(token);
vm.stopBroadcast();

vm.stopBroadcast();
verifyDeployment();
HelloWorldDeploymentLib.writeDeploymentJson(helloWorldDeployment);
}
Expand All @@ -75,4 +92,4 @@ contract HelloWorldDeployer is Script {
);
require(coreDeployment.avsDirectory != address(0), "AVSDirectory address cannot be zero");
}
}
}
Loading

0 comments on commit b8148c7

Please sign in to comment.