Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Rewards V2 #12

Merged
merged 67 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
157721d
update submodule to 0.2.1
Oct 22, 2024
83d329c
use latest sdk
Oct 22, 2024
1548335
remove state dump, add eigenlayer-contracts submodule v0.4.3-mainnet-…
Oct 23, 2024
20db56d
scripts WIP
Oct 24, 2024
edc1c89
scripts working
Oct 28, 2024
f7f984e
makefile update, some cilppy
Oct 28, 2024
b551f89
chore: update integration tests deps
Oct 28, 2024
baa9093
Merge branch 'master' into nova/rewards
supernovahs Oct 28, 2024
daf49de
Merge branch 'master' into nova/rewards
supernovahs Oct 28, 2024
376d407
exclude incredible-binding crate in ci
Oct 28, 2024
ad4b48a
exclude incredible-binding in cargo check ci
Oct 28, 2024
f2c23aa
ignore clippy in bindings crate
Oct 28, 2024
b9c2ee2
fmt
Oct 29, 2024
483e9a3
install forge in ci
Oct 29, 2024
d1adb96
add docker anvil in ci, comment the failing test for now
Oct 29, 2024
6701f30
fix:enter correct directory in ci
Oct 29, 2024
a8291bc
port the rewards scripts and tests from hello world, use foundry-tool…
Oct 30, 2024
d6233ac
nudge ci
Oct 30, 2024
4bdeb20
fix : payment script revert, todo: write correct reward params
Nov 5, 2024
f977ab5
payment script working
Nov 7, 2024
d292325
add payment script in make file
Nov 7, 2024
8bf7c3a
cleanup
Nov 7, 2024
10080cd
remove eigenlayer-contracts from gitmodules
Nov 7, 2024
f2ecb46
use get_signer, fmt
Nov 7, 2024
f90fe9b
readme update
Nov 7, 2024
678246e
remapping
Nov 7, 2024
87263e1
remove foundry toolchain ,install foundry using cargo
Nov 7, 2024
21ae560
fix: yml
Nov 7, 2024
94ea2a1
modify contract path in sh file, dd back toolchain for foundry
Nov 7, 2024
6cbf25d
update deploy-eigenlayer.sh
Nov 8, 2024
59b3c37
update rev
Nov 8, 2024
54b909e
fix: submodule in ci, update readme
Nov 8, 2024
0fc28ca
add submodules in yml
Nov 8, 2024
bd11394
update middleware
Nov 8, 2024
d1c3365
middleware update
Nov 8, 2024
33f4857
add forge-std
Nov 8, 2024
e4815ae
testing ci
Nov 8, 2024
5874cf7
update rev
Nov 8, 2024
9daeea4
checking
Nov 8, 2024
63e3a7d
update middleware
Nov 8, 2024
bddf5d3
cd into contracts
Nov 8, 2024
d415df7
update .sh
Nov 8, 2024
adae44b
cd into contracts only once
Nov 8, 2024
a8668e4
hit and trial
Nov 8, 2024
690cd6c
fix: eigenlayer.sh script
Nov 8, 2024
2a09850
vv
Nov 8, 2024
dcaa408
add submodule in ci
Nov 8, 2024
59b16d3
env in ci
Nov 8, 2024
ee24a5b
2 operators support
Nov 14, 2024
3fc418e
clean up
Nov 14, 2024
008c8d1
fix quorum, client
Nov 20, 2024
5ae9c53
fix:tests
Nov 20, 2024
07f5092
update readme
Nov 20, 2024
e2a8eb2
Merge branch 'master' into nova/2_operators
Nov 21, 2024
490d380
fix:merge conflicts
Nov 21, 2024
5f4e3d7
remove unwrap
Nov 22, 2024
36eea21
use separate config file and reuse error
Nov 22, 2024
ccf00d9
clippy
Nov 22, 2024
f0135e7
common config for test in operators
Nov 22, 2024
f98f8b2
deploy-eigenlayer with debug comments
pablodeymo Nov 22, 2024
05b26a6
print return value in deploy-eigenlayer.sh
pablodeymo Nov 22, 2024
57313a9
change foundry image to latest
Nov 23, 2024
036b28b
clean up
Nov 26, 2024
f197a28
update middleware to latest dev
Nov 26, 2024
5fbd084
add createOperatorDirectedAVSRewardsSubmissions in paymentslib
Nov 26, 2024
235223f
Merge branch 'master' into nova/rewardsv2
supernovahs Nov 27, 2024
1013b93
createOperatorDirectedAVSRewardsSubmissions in payment script working
Nov 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contracts/anvil/deploy-avs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ forge script script/ContractsRegistry.s.sol --rpc-url $RPC_URL --private-key $PR

forge script script/SetupPayments.s.sol --rpc-url $RPC_URL --broadcast --slow --private-key $PRIVATE_KEY

forge script script/OperatorDirectedPayments.s.sol --rpc-url $RPC_URL --broadcast --slow --private-key $PRIVATE_KEY
4 changes: 4 additions & 0 deletions contracts/operator_reward_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"operator_addresses": ["0x0000000000000000000000000000000000000001"],
"amount": [1]
}
5 changes: 4 additions & 1 deletion contracts/script/IncredibleSquaringDeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ contract IncredibleSquaringDeployer is Script {
FundOperator.fund_operator(address(erc20Mock), isConfig.operator_addr, 10e18);
FundOperator.fund_operator(address(erc20Mock), isConfig.operator_2_addr, 10e18);
console.log(isConfig.operator_2_addr);
(bool s ,) = isConfig.operator_2_addr.call{value: 0.1 ether}("");
(bool s,) = isConfig.operator_2_addr.call{value: 0.1 ether}("");
require(s);
console.log(isConfig.operator_2_addr.balance);
incredibleSquaringStrategy = IStrategy(StrategyFactory(configData.strategyFactory).deployNewStrategy(erc20Mock));
Expand All @@ -117,6 +117,9 @@ contract IncredibleSquaringDeployer is Script {
incrediblSquaringDeployment = IncredibleSquaringDeploymentLib.deployContracts(
proxyAdmin, configData, address(incredibleSquaringStrategy), isConfig, msg.sender
);
FundOperator.fund_operator(
address(erc20Mock), incrediblSquaringDeployment.incredibleSquaringServiceManager, 1e18
);

IncredibleSquaringDeploymentLib.writeDeploymentJson(incrediblSquaringDeployment);

Expand Down
81 changes: 81 additions & 0 deletions contracts/script/OperatorDirectedPayments.s.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.12;

import {Script} from "forge-std/Script.sol";
import {IncredibleSquaringDeploymentLib} from "./utils/IncredibleSquaringDeploymentLib.sol";
import {CoreDeploymentLib} from "./utils/CoreDeploymentLib.sol";
import {SetupPaymentsLib} from "./utils/SetupPaymentsLib.sol";
import {IRewardsCoordinator} from "@eigenlayer/contracts/interfaces/IRewardsCoordinator.sol";
import {console2} from "forge-std/console2.sol";
import {UpgradeableProxyLib} from "./utils/UpgradeableProxyLib.sol";
import {ProxyAdmin} from "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
import {stdJson} from "forge-std/StdJson.sol";

contract OperatorDirectedPayments is Script {
using stdJson for string;

address private deployer;
CoreDeploymentLib.DeploymentData coreDeployment;
IncredibleSquaringDeploymentLib.DeploymentData incredibleSquaringDeployment;
SetupPaymentsLib.OperatorConfig operatorRewardConfig;
string internal constant filePath = "test/mockData/scratch/payment_info.json";

function setUp() public {
deployer = vm.rememberKey(vm.envUint("PRIVATE_KEY"));
vm.label(deployer, "Deployer");

coreDeployment = CoreDeploymentLib.readDeploymentJson("script/deployments/core/", block.chainid);
incredibleSquaringDeployment =
IncredibleSquaringDeploymentLib.readDeploymentJson("script/deployments/incredible-squaring/", block.chainid);
operatorRewardConfig = SetupPaymentsLib.readOperatorConfig("operator_reward_config");
}

function run() external {
vm.startBroadcast(deployer);

string memory json = vm.readFile(filePath);
uint32 duration = uint32(json.readUint(".duration"));
uint32 index_to_prove = uint32(json.readUint(".indexToProve"));
uint256 num_payments = json.readUint(".numPayments");
address recipient = json.readAddress(".recipient");
address[] memory earners = json.readAddressArray(".earners");
bytes32[] memory earner_token_roots = json.readBytes32Array(".earnerTokenRoots");
uint32 start_time = uint32(previousDivisibleTimestamp(block.timestamp));

IRewardsCoordinator.OperatorReward[] memory operator_reward =
new IRewardsCoordinator.OperatorReward[](operatorRewardConfig.operator_addr.length);

for (uint256 i = 0; i < operator_reward.length; i++) {
operator_reward[i] = IRewardsCoordinator.OperatorReward({
operator: operatorRewardConfig.operator_addr[i],
amount: operatorRewardConfig.amount[i]
});
}

SetupPaymentsLib.createOperatorDirectedAVSRewardsSubmissions(
incredibleSquaringDeployment.strategy,
incredibleSquaringDeployment.incredibleSquaringServiceManager,
operator_reward,
num_payments,
duration,
start_time
);

vm.stopBroadcast();
}

function previousDivisibleTimestamp(uint256 blockTimestamp) public pure returns (uint256) {
uint256 daySeconds = 86400;

// Calculate the remainder to check how far blockTimestamp is from the nearest multiple of daySeconds
uint256 remainder = blockTimestamp % daySeconds;

if (remainder == 0) {
// If blockTimestamp is already divisible by daySeconds, go two steps back
return blockTimestamp - (2 * daySeconds);
} else {
// Otherwise, move back to the previous divisible timestamp and then one more step
return blockTimestamp - remainder - daySeconds;
}
}
}
2 changes: 1 addition & 1 deletion contracts/script/deployments/core/31337.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"lastUpdate":{"timestamp":"1732362263","block_number":"1"},"addresses":{"proxyAdmin":"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512","delegation":"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9","delegationManagerImpl":"0x68b1d87f95878fe05b998f19b66f4baba5de1aed","avsDirectory":"0x5fc8d32690cc91d4c39d9d3abcbd16989f875707","avsDirectoryImpl":"0x3aa5ebb10dc797cac828524e59a333d0a371443c","strategyManager":"0xa513e6e4b8f2a923d98304ec87f64353c4d5c853","strategyManagerImpl":"0xc6e7df5e7b4f2a278906862b61205850344d4e7d","eigenPodManager":"0x8a791620dd6260079bf849dc5567adc3f2fdc318","eigenPodManagerImpl":"0x4ed7c70f96b99c776995fb64377f0d4ab3b0e1c1","strategyFactory":"0x9a9f2ccfde556a7e9ff0848998aa4a0cfd8863ae","rewardsCoordinator":"0xb7f8bc63bbcad18155201308c8f3540b07f84f5e","strategyBeacon":"0xc5a5c42992decbae36851359345fe25997f5c42d"}}
{"lastUpdate":{"timestamp":"1732699447","block_number":"1"},"addresses":{"proxyAdmin":"0xe7f1725e7734ce288f8367e1bb143e90bb3f0512","delegation":"0xcf7ed3acca5a467e9e704c703e8d87f634fb0fc9","delegationManagerImpl":"0x68b1d87f95878fe05b998f19b66f4baba5de1aed","avsDirectory":"0x5fc8d32690cc91d4c39d9d3abcbd16989f875707","avsDirectoryImpl":"0x3aa5ebb10dc797cac828524e59a333d0a371443c","strategyManager":"0xa513e6e4b8f2a923d98304ec87f64353c4d5c853","strategyManagerImpl":"0xc6e7df5e7b4f2a278906862b61205850344d4e7d","eigenPodManager":"0x8a791620dd6260079bf849dc5567adc3f2fdc318","eigenPodManagerImpl":"0x4ed7c70f96b99c776995fb64377f0d4ab3b0e1c1","strategyFactory":"0x9a9f2ccfde556a7e9ff0848998aa4a0cfd8863ae","rewardsCoordinator":"0xb7f8bc63bbcad18155201308c8f3540b07f84f5e","strategyBeacon":"0xc5a5c42992decbae36851359345fe25997f5c42d"}}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"lastUpdate":{"timestamp":"1732362303","block_number":"36"},"addresses":{"proxyAdmin":"0x99bba657f2bbc93c02d617f8ba121cb8fc104acf","IncredibleSquaringServiceManager":"0x8f86403a4de0bb5791fa46b8e795c547942fe4cf","incredibleSquaringServiceManagerImpl":"0x4c4a2f8c81640e47606d3fd77b353e87ba015584","IncredibleSquaringTaskManager":"0x809d550fca64d94bd9f66e60752a544199cfac3d","registryCoordinator":"0x1291be112d480055dafd8a610b7d1e203891c274","blsapkRegistry":"0xb7278a61aa25c888815afc32ad3cc52ff24fe575","indexRegistry":"0x82e01223d51eb87e16a03e24687edf0f294da6f1","stakeRegistry":"0x5eb3bc0a489c5a8288765d2336659ebca68fcd00","operatorStateRetriever":"0x7bc06c482dead17c0e297afbc32f6e63d3846650","strategy":"0x2b961e3959b79326a8e7f64ef0d2d825707669b5","token":"0x0000000000000000000000000000000000000000"}}
{"lastUpdate":{"timestamp":"1732699449","block_number":"36"},"addresses":{"proxyAdmin":"0x99bba657f2bbc93c02d617f8ba121cb8fc104acf","IncredibleSquaringServiceManager":"0x8f86403a4de0bb5791fa46b8e795c547942fe4cf","incredibleSquaringServiceManagerImpl":"0x4c4a2f8c81640e47606d3fd77b353e87ba015584","IncredibleSquaringTaskManager":"0x809d550fca64d94bd9f66e60752a544199cfac3d","registryCoordinator":"0x1291be112d480055dafd8a610b7d1e203891c274","blsapkRegistry":"0xb7278a61aa25c888815afc32ad3cc52ff24fe575","indexRegistry":"0x82e01223d51eb87e16a03e24687edf0f294da6f1","stakeRegistry":"0x5eb3bc0a489c5a8288765d2336659ebca68fcd00","operatorStateRetriever":"0x7bc06c482dead17c0e297afbc32f6e63d3846650","strategy":"0x2b961e3959b79326a8e7f64ef0d2d825707669b5","token":"0x0000000000000000000000000000000000000000"}}
2 changes: 1 addition & 1 deletion contracts/script/utils/CoreDeploymentLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ library CoreDeploymentLib {
/// TODO: Get actual values
uint32 CALCULATION_INTERVAL_SECONDS = 1 days;
uint32 MAX_REWARDS_DURATION = 1 days;
uint32 MAX_RETROACTIVE_LENGTH = 1;
uint32 MAX_RETROACTIVE_LENGTH = 3 days;
uint32 MAX_FUTURE_LENGTH = 1 days;
uint32 GENESIS_REWARDS_TIMESTAMP = 10 days;
address rewardsCoordinatorImpl = address(
Expand Down
54 changes: 54 additions & 0 deletions contracts/script/utils/SetupPaymentsLib.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,35 @@ import {IRewardsCoordinator} from "@eigenlayer/contracts/interfaces/IRewardsCoor
import {IStrategy} from "eigenlayer-contracts/src/contracts/interfaces/IStrategyManager.sol";
import {Vm} from "forge-std/Vm.sol";
import {console} from "forge-std/console.sol";
import {stdJson} from "forge-std/StdJson.sol";
import {IncredibleSquaringServiceManager} from "../../src/IncredibleSquaringServiceManager.sol";

library SetupPaymentsLib {
Vm internal constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));

using stdJson for string;

struct PaymentLeaves {
bytes32[] leaves;
bytes32[] tokenLeaves;
}

struct OperatorConfig {
address[] operator_addr;
uint256[] amount;
}

function readOperatorConfig(string memory path) internal returns (OperatorConfig memory config) {
string memory pathToFile = string.concat(path, ".json");
require(vm.exists(pathToFile), "Deployment file does not exist");
string memory json = vm.readFile(pathToFile);

config.operator_addr = json.readAddressArray(".operator_addresses");
config.amount = json.readUintArray(".amount");

return config;
}

function createAVSRewardsSubmissions(
IRewardsCoordinator rewardsCoordinator,
address strategy,
Expand Down Expand Up @@ -45,6 +65,40 @@ library SetupPaymentsLib {
rewardsCoordinator.createAVSRewardsSubmission(rewardsSubmissions);
}

function createOperatorDirectedAVSRewardsSubmissions(
address strategy,
address avs,
IRewardsCoordinator.OperatorReward[] memory operatorRewards,
uint256 numPayments,
uint32 duration,
uint32 startTimestamp
) internal {
IStrategy(strategy).underlyingToken();
IRewardsCoordinator.OperatorDirectedRewardsSubmission[] memory operatorDirectedRewardsSubmissions =
new IRewardsCoordinator.OperatorDirectedRewardsSubmission[](numPayments);
for (uint256 i = 0; i < numPayments; i++) {
IRewardsCoordinator.StrategyAndMultiplier[] memory strategiesAndMultipliers =
new IRewardsCoordinator.StrategyAndMultiplier[](1);
strategiesAndMultipliers[0] =
IRewardsCoordinator.StrategyAndMultiplier({strategy: IStrategy(strategy), multiplier: 10000});

IRewardsCoordinator.OperatorDirectedRewardsSubmission memory rewardSubmission = IRewardsCoordinator
.OperatorDirectedRewardsSubmission({
strategiesAndMultipliers: strategiesAndMultipliers,
token: IStrategy(strategy).underlyingToken(),
operatorRewards: operatorRewards,
startTimestamp: startTimestamp,
duration: duration,
description: ""
});

operatorDirectedRewardsSubmissions[i] = rewardSubmission;
}
IncredibleSquaringServiceManager(avs).createOperatorDirectedAVSRewardsSubmission(
avs, operatorDirectedRewardsSubmissions
);
}

function processClaim(
IRewardsCoordinator rewardsCoordinator,
string memory filePath,
Expand Down
7 changes: 7 additions & 0 deletions contracts/src/IncredibleSquaringServiceManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,13 @@ contract IncredibleSquaringServiceManager is ServiceManagerBase {
incredibleSquaringTaskManager = _incredibleSquaringTaskManager;
}

function createOperatorDirectedAVSRewardsSubmission(
address avs,
IRewardsCoordinator.OperatorDirectedRewardsSubmission[] memory operatorDirectedRewardsSubmission
) public {
_rewardsCoordinator.createOperatorDirectedAVSRewardsSubmission(avs, operatorDirectedRewardsSubmission);
}

/// @notice Called in the event of challenge resolution, in order to forward a call to the Slasher, which 'freezes' the `operator`.
/// @dev The Slasher contract is under active development and its interface expected to change.
/// We recommend writing slashing logic without integrating with the Slasher at this point in time.
Expand Down
Loading