Skip to content

Commit

Permalink
contract diff
Browse files Browse the repository at this point in the history
  • Loading branch information
0x0aa0 committed Dec 19, 2024
1 parent 543bc14 commit 3ececb7
Show file tree
Hide file tree
Showing 55 changed files with 3,721 additions and 789 deletions.
2 changes: 1 addition & 1 deletion contracts/lib/eigenlayer-middleware
Submodule eigenlayer-middleware updated 98 files
+0 −3 .gitmodules
+29 −3 LICENSE
+24 −10 README.md
+ audits/M2 Mainnet - Dedaub - Feb 2024.pdf
+2 −2 docs/README.md
+1 −1 docs/ServiceManagerBase.md
+1 −1 docs/experimental/AVS-Guide.md
+7 −0 foundry.toml
+0 −1 lib/ds-test
+1 −1 lib/eigenlayer-contracts
+1 −1 lib/forge-std
+2 −2 script/ServiceManagerRouterDeploy.s.sol
+9 −5 src/BLSApkRegistry.sol
+1 −1 src/BLSApkRegistryStorage.sol
+117 −63 src/BLSSignatureChecker.sol
+184 −0 src/EjectionManager.sol
+6 −2 src/IndexRegistry.sol
+1 −1 src/IndexRegistryStorage.sol
+34 −1 src/OperatorStateRetriever.sol
+88 −40 src/RegistryCoordinator.sol
+14 −4 src/RegistryCoordinatorStorage.sol
+197 −37 src/ServiceManagerBase.sol
+53 −0 src/ServiceManagerBaseStorage.sol
+5 −5 src/ServiceManagerRouter.sol
+52 −0 src/SocketRegistry.sol
+23 −11 src/StakeRegistry.sol
+1 −1 src/StakeRegistryStorage.sol
+1 −1 src/interfaces/IBLSApkRegistry.sol
+1 −1 src/interfaces/IBLSSignatureChecker.sol
+24 −3 src/interfaces/IECDSAStakeRegistryEventsAndErrors.sol
+55 −0 src/interfaces/IEjectionManager.sol
+2 −2 src/interfaces/IIndexRegistry.sol
+9 −1 src/interfaces/IRegistryCoordinator.sol
+37 −34 src/interfaces/IServiceManager.sol
+61 −0 src/interfaces/IServiceManagerUI.sol
+10 −0 src/interfaces/ISocketRegistry.sol
+0 −20 src/interfaces/ISocketUpdater.sol
+2 −2 src/interfaces/IStakeRegistry.sol
+1 −1 src/libraries/BN254.sol
+2 −2 src/libraries/BitmapUtils.sol
+356 −0 src/unaudited/ECDSAServiceManagerBase.sol
+204 −75 src/unaudited/ECDSAStakeRegistry.sol
+10 −3 src/unaudited/ECDSAStakeRegistryStorage.sol
+14 −10 src/unaudited/examples/ECDSAStakeRegistryPermissioned.sol
+1 −1 test/events/IBLSApkRegistryEvents.sol
+1 −1 test/events/IIndexRegistryEvents.sol
+128 −0 test/events/IServiceManagerBaseEvents.sol
+2 −2 test/events/IStakeRegistryEvents.sol
+2 −2 test/ffi/BLSPubKeyCompendiumFFI.t.sol
+1 −1 test/ffi/BLSSignatureCheckerFFI.t.sol
+2 −2 test/ffi/UpdateOperators.t.sol
+1 −1 test/ffi/util/G2Operations.sol
+1 −1 test/harnesses/BLSApkRegistryHarness.sol
+1 −1 test/harnesses/BitmapUtilsWrapper.sol
+4 −3 test/harnesses/RegistryCoordinatorHarness.t.sol
+1 −1 test/harnesses/StakeRegistryHarness.sol
+9 −3 test/integration/CoreRegistration.t.sol
+2 −2 test/integration/IntegrationBase.t.sol
+2 −2 test/integration/IntegrationChecks.t.sol
+2 −2 test/integration/IntegrationConfig.t.sol
+131 −87 test/integration/IntegrationDeployer.t.sol
+3 −3 test/integration/TimeMachine.t.sol
+7 −5 test/integration/User.t.sol
+0 −20 test/integration/mocks/BeaconChainOracleMock.t.sol
+2 −2 test/integration/tests/Full_Register_Deregister.t.sol
+2 −2 test/integration/tests/NonFull_Register_CoreBalanceChange_Update.t.sol
+2 −2 test/integration/tests/NonFull_Register_Deregister.t.sol
+2 −2 test/integration/utils/BitmapStrings.t.sol
+18 −17 test/integration/utils/Sort.t.sol
+12 −30 test/mocks/AVSDirectoryMock.sol
+28 −22 test/mocks/DelegationMock.sol
+22 −0 test/mocks/ECDSAServiceManagerMock.sol
+14 −0 test/mocks/ECDSAStakeRegistryMock.sol
+3 −1 test/mocks/RegistryCoordinatorMock.sol
+138 −0 test/mocks/RewardsCoordinatorMock.sol
+10 −4 test/mocks/ServiceManagerMock.sol
+1 −1 test/mocks/StakeRegistryMock.sol
+369 −147 test/unit/BLSApkRegistryUnit.t.sol
+3 −2 test/unit/BLSSignatureCheckerUnit.t.sol
+2 −2 test/unit/BitmapUtils.t.sol
+186 −0 test/unit/ECDSAServiceManager.t.sol
+60 −14 test/unit/ECDSAStakeRegistryEqualWeightUnit.t.sol
+48 −16 test/unit/ECDSAStakeRegistryPermissionedUnit.t.sol
+472 −105 test/unit/ECDSAStakeRegistryUnit.t.sol
+448 −0 test/unit/EjectionManagerUnit.t.sol
+268 −112 test/unit/OperatorStateRetrieverUnit.t.sol
+86 −30 test/unit/RegistryCoordinatorUnit.t.sol
+1,082 −0 test/unit/ServiceManagerBase.t.sol
+3 −2 test/unit/ServiceManagerRouter.t.sol
+49 −0 test/unit/SocketRegistryUnit.t.sol
+823 −413 test/unit/StakeRegistryUnit.t.sol
+1 −1 test/unit/Utils.sol
+1 −1 test/utils/BLSMockAVSDeployer.sol
+139 −92 test/utils/MockAVSDeployer.sol
+1 −1 test/utils/Operators.sol
+1 −1 test/utils/Owners.sol
+1 −1 test/utils/ProofParsing.sol
+1 −1 test/utils/SignatureCompaction.sol
57 changes: 35 additions & 22 deletions contracts/script/DeployOpenEigenLayer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,17 @@ 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 @@ -34,7 +33,15 @@ 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(HEVM_ADDRESS);
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 {
Expand All @@ -55,10 +62,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 @@ -112,17 +119,14 @@ contract DeployOpenEigenLayer is Script, Test {
eigenPodManager = EigenPodManager(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
delayedWithdrawalRouter = DelayedWithdrawalRouter(
rewardsCoordinator = RewardsCoordinator(
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 @@ -131,6 +135,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 All @@ -140,7 +153,6 @@ 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 @@ -167,6 +179,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 All @@ -177,23 +202,11 @@ 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: 136 additions & 11 deletions contracts/script/EigenDADeployer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,25 @@ 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} from "../src/core/EigenDAServiceManager.sol";
import {EigenDAServiceManager, IAVSDirectory, IRewardsCoordinator} 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 @@ -34,16 +45,34 @@ 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 @@ -89,16 +118,21 @@ 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 @@ -111,6 +145,47 @@ 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 @@ -140,11 +215,19 @@ 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
indexRegistry,
socketRegistry
);

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

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

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

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 3ececb7

Please sign in to comment.