Skip to content

Commit

Permalink
old contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 committed Dec 19, 2024
1 parent 212d29a commit 64335e7
Show file tree
Hide file tree
Showing 53 changed files with 787 additions and 3,719 deletions.
57 changes: 22 additions & 35 deletions contracts/script/DeployOpenEigenLayer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ import "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.so
import "@openzeppelin/contracts/proxy/beacon/UpgradeableBeacon.sol";

import "eigenlayer-core/contracts/interfaces/IETHPOSDeposit.sol";
import "eigenlayer-core/contracts/interfaces/IBeaconChainOracle.sol";

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";

import "eigenlayer-core/contracts/pods/EigenPod.sol";
import "eigenlayer-core/contracts/pods/EigenPodManager.sol";
import "eigenlayer-core/contracts/pods/DelayedWithdrawalRouter.sol";

import "eigenlayer-core/contracts/permissions/PauserRegistry.sol";

Expand All @@ -33,15 +34,7 @@ import "forge-std/Test.sol";
// # To deploy and verify our contract
// forge script script/M1_Deploy.s.sol:Deployer_M1 --rpc-url $RPC_URL --private-key $PRIVATE_KEY --broadcast -vvvv
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;
Vm cheats = Vm(HEVM_ADDRESS);

// struct used to encode token info in config file
struct StrategyConfig {
Expand All @@ -62,10 +55,10 @@ contract DeployOpenEigenLayer is Script, Test {
StrategyManager public strategyManagerImplementation;
EigenPodManager public eigenPodManager;
EigenPodManager public eigenPodManagerImplementation;
DelayedWithdrawalRouter public delayedWithdrawalRouter;
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 @@ -119,14 +112,17 @@ contract DeployOpenEigenLayer is Script, Test {
eigenPodManager = EigenPodManager(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
rewardsCoordinator = RewardsCoordinator(
delayedWithdrawalRouter = DelayedWithdrawalRouter(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);

// ETH POS deposit is 0 address
eigenPodImplementation = new EigenPod(
ethPOSDeposit,
delayedWithdrawalRouter,
eigenPodManager,
// uint64(MAX_VALIDATOR_BALANCE_GWEI),
uint64(32 gwei),
1000 // temp genesis time
);

Expand All @@ -135,15 +131,6 @@ 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 All @@ -153,6 +140,7 @@ contract DeployOpenEigenLayer is Script, Test {
slasher,
delegation
);
delayedWithdrawalRouterImplementation = new DelayedWithdrawalRouter(eigenPodManager);

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
IStrategy[] memory _strategies;
Expand All @@ -179,19 +167,6 @@ 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 All @@ -202,11 +177,23 @@ contract DeployOpenEigenLayer is Script, Test {
address(eigenPodManagerImplementation),
abi.encodeWithSelector(
EigenPodManager.initialize.selector,
IBeaconChainOracle(address(0)),
executorMultisig,
eigenLayerPauserReg,
0
)
);
eigenLayerProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(delayedWithdrawalRouter))),
address(delayedWithdrawalRouterImplementation),
abi.encodeWithSelector(
DelayedWithdrawalRouter.initialize.selector,
executorMultisig,
eigenLayerPauserReg,
0,
0
)
);

// deploy StrategyBaseTVLLimits contract implementation
baseStrategyImplementation = new StrategyBaseTVLLimits(strategyManager);
Expand Down
147 changes: 11 additions & 136 deletions contracts/script/EigenDADeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,14 @@ 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, IRewardsCoordinator} from "../src/core/EigenDAServiceManager.sol";

import {EigenDAServiceManager, IAVSDirectory} from "../src/core/EigenDAServiceManager.sol";
import {EigenDAHasher} from "../src/libraries/EigenDAHasher.sol";
import {EigenDAThresholdRegistry} from "../src/core/EigenDAThresholdRegistry.sol";
import {EigenDABlobVerifier} from "../src/core/EigenDABlobVerifier.sol";
import {IEigenDAThresholdRegistry} from "../src/interfaces/IEigenDAThresholdRegistry.sol";
import {IEigenDABatchMetadataStorage} from "../src/interfaces/IEigenDABatchMetadataStorage.sol";
import {IEigenDASignatureVerifier} from "../src/interfaces/IEigenDASignatureVerifier.sol";
import {IEigenDARelayRegistry} from "../src/interfaces/IEigenDARelayRegistry.sol";
import {IPaymentVault} from "../src/interfaces/IPaymentVault.sol";
import {PaymentVault} from "../src/payments/PaymentVault.sol";
import {EigenDADisperserRegistry} from "../src/core/EigenDADisperserRegistry.sol";
import {IEigenDADisperserRegistry} from "../src/interfaces/IEigenDADisperserRegistry.sol";
import {EigenDARelayRegistry} from "../src/core/EigenDARelayRegistry.sol";
import {ISocketRegistry, SocketRegistry} from "eigenlayer-middleware/SocketRegistry.sol";

import {DeployOpenEigenLayer, ProxyAdmin, ERC20PresetFixedSupply, TransparentUpgradeableProxy, IPauserRegistry} from "./DeployOpenEigenLayer.s.sol";
import "forge-std/Test.sol";
import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
import "../src/interfaces/IEigenDAStructs.sol";

// # To load the variables in the .env file
// source .env
Expand All @@ -45,34 +34,16 @@ contract EigenDADeployer is DeployOpenEigenLayer {

BLSApkRegistry public apkRegistry;
EigenDAServiceManager public eigenDAServiceManager;
EigenDAThresholdRegistry public eigenDAThresholdRegistry;
EigenDABlobVerifier public eigenDABlobVerifier;
RegistryCoordinator public registryCoordinator;
IIndexRegistry public indexRegistry;
IStakeRegistry public stakeRegistry;
ISocketRegistry public socketRegistry;
OperatorStateRetriever public operatorStateRetriever;
IPaymentVault public paymentVault;
EigenDARelayRegistry public eigenDARelayRegistry;
IEigenDADisperserRegistry public eigenDADisperserRegistry;

BLSApkRegistry public apkRegistryImplementation;
EigenDAServiceManager public eigenDAServiceManagerImplementation;
IRegistryCoordinator public registryCoordinatorImplementation;
IIndexRegistry public indexRegistryImplementation;
IStakeRegistry public stakeRegistryImplementation;
EigenDAThresholdRegistry public eigenDAThresholdRegistryImplementation;
EigenDARelayRegistry public eigenDARelayRegistryImplementation;
ISocketRegistry public socketRegistryImplementation;
IPaymentVault public paymentVaultImplementation;
IEigenDADisperserRegistry public eigenDADisperserRegistryImplementation;

uint64 _minNumSymbols = 4096;
uint64 _pricePerSymbol = 0.4470 gwei;
uint64 _priceUpdateCooldown = 1;
uint64 _globalSymbolsPerPeriod = 131072;
uint64 _reservationPeriodInterval = 300;
uint64 _globalRatePeriodInterval = 30;

struct AddressConfig {
address eigenLayerCommunityMultisig;
Expand Down Expand Up @@ -118,21 +89,16 @@ contract EigenDADeployer is DeployOpenEigenLayer {
}

emptyContract = new EmptyContract();


// hard-coded inputs

/**
* First, deploy upgradeable proxy contracts that **will point** to the implementations. Since the implementation contracts are
* not yet deployed, we give these proxies an empty contract as the initial implementation, to act as if they have no code.
*/
eigenDAServiceManager = EigenDAServiceManager(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);
eigenDAThresholdRegistry = EigenDAThresholdRegistry(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);
eigenDARelayRegistry = EigenDARelayRegistry(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);

registryCoordinator = RegistryCoordinator(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);
Expand All @@ -145,47 +111,6 @@ contract EigenDADeployer is DeployOpenEigenLayer {
apkRegistry = BLSApkRegistry(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);
socketRegistry = ISocketRegistry(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);

{
paymentVault = IPaymentVault(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);

eigenDADisperserRegistry = IEigenDADisperserRegistry(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);

paymentVaultImplementation = new PaymentVault();

eigenDAProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(paymentVault))),
address(paymentVaultImplementation),
abi.encodeWithSelector(
PaymentVault.initialize.selector,
addressConfig.eigenDACommunityMultisig,
_minNumSymbols,
_pricePerSymbol,
_priceUpdateCooldown,
_globalSymbolsPerPeriod,
_reservationPeriodInterval,
_globalRatePeriodInterval
)
);
}

eigenDADisperserRegistryImplementation = new EigenDADisperserRegistry();

eigenDAProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(eigenDADisperserRegistry))),
address(eigenDADisperserRegistryImplementation),
abi.encodeWithSelector(
EigenDADisperserRegistry.initialize.selector,
addressConfig.eigenDACommunityMultisig
)
);

indexRegistryImplementation = new IndexRegistry(
registryCoordinator
Expand Down Expand Up @@ -215,19 +140,11 @@ contract EigenDADeployer is DeployOpenEigenLayer {
address(apkRegistryImplementation)
);

socketRegistryImplementation = new SocketRegistry(registryCoordinator);

eigenDAProxyAdmin.upgrade(
TransparentUpgradeableProxy(payable(address(socketRegistry))),
address(socketRegistryImplementation)
);

registryCoordinatorImplementation = new RegistryCoordinator(
IServiceManager(address(eigenDAServiceManager)),
stakeRegistry,
apkRegistry,
indexRegistry,
socketRegistry
indexRegistry
);

{
Expand Down Expand Up @@ -269,14 +186,9 @@ contract EigenDADeployer is DeployOpenEigenLayer {
}

eigenDAServiceManagerImplementation = new EigenDAServiceManager(
avsDirectory,
rewardsCoordinator,
IAVSDirectory(address(avsDirectory)),
registryCoordinator,
stakeRegistry,
eigenDAThresholdRegistry,
eigenDARelayRegistry,
paymentVault,
eigenDADisperserRegistry
stakeRegistry
);

address[] memory confirmers = new address[](1);
Expand All @@ -291,47 +203,10 @@ contract EigenDADeployer is DeployOpenEigenLayer {
eigenDAPauserReg,
0,
addressConfig.eigenDACommunityMultisig,
confirmers,
addressConfig.eigenDACommunityMultisig
)
);

eigenDAThresholdRegistryImplementation = new EigenDAThresholdRegistry();

VersionedBlobParams[] memory versionedBlobParams = new VersionedBlobParams[](0);
SecurityThresholds memory defaultSecurityThresholds = SecurityThresholds(33, 55);

eigenDAProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(eigenDAThresholdRegistry))),
address(eigenDAThresholdRegistryImplementation),
abi.encodeWithSelector(
EigenDAThresholdRegistry.initialize.selector,
addressConfig.eigenDACommunityMultisig,
hex"212121",
hex"373737",
hex"0001",
versionedBlobParams,
defaultSecurityThresholds
confirmers
)
);

operatorStateRetriever = new OperatorStateRetriever();

eigenDABlobVerifier = new EigenDABlobVerifier(
IEigenDAThresholdRegistry(address(eigenDAThresholdRegistry)),
IEigenDABatchMetadataStorage(address(eigenDAServiceManager)),
IEigenDASignatureVerifier(address(eigenDAServiceManager)),
IEigenDARelayRegistry(address(eigenDARelayRegistry)),
OperatorStateRetriever(address(operatorStateRetriever)),
IRegistryCoordinator(address(registryCoordinator))
);

eigenDARelayRegistryImplementation = new EigenDARelayRegistry();

eigenDAProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(eigenDARelayRegistry))),
address(eigenDARelayRegistryImplementation),
abi.encodeWithSelector(EigenDARelayRegistry.initialize.selector, addressConfig.eigenDACommunityMultisig)
);
}
}
}
Loading

0 comments on commit 64335e7

Please sign in to comment.