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

chore(contracts): Add foundry fmt step to CI #1237

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 6 additions & 1 deletion .github/workflows/test-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ concurrency:
cancel-in-progress: true

jobs:
check:
test:
name: Foundry Project
runs-on: ubuntu-22.04
steps:
Expand All @@ -26,6 +26,11 @@ jobs:
with:
version: nightly

- name: "Forge Fmt"
run: |
forge fmt --check
working-directory: ./contracts

- name: Install forge dependencies
run: forge install
working-directory: ./contracts
Expand Down
44 changes: 18 additions & 26 deletions contracts/script/DeployOpenEigenLayer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,8 @@ contract DeployOpenEigenLayer is Script, Test {
strategyManager = StrategyManager(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
slasher = Slasher(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
slasher =
Slasher(address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), "")));
eigenPodManager = EigenPodManager(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenLayerProxyAdmin), ""))
);
Expand Down Expand Up @@ -146,21 +145,24 @@ contract DeployOpenEigenLayer is Script, Test {
);
strategyManagerImplementation = new StrategyManager(delegation, eigenPodManager, slasher);
slasherImplementation = new Slasher(strategyManager, delegation);
eigenPodManagerImplementation = new EigenPodManager(
ethPOSDeposit,
eigenPodBeacon,
strategyManager,
slasher,
delegation
);
eigenPodManagerImplementation =
new EigenPodManager(ethPOSDeposit, eigenPodBeacon, strategyManager, slasher, delegation);

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
IStrategy[] memory _strategies;
uint256[] memory _withdrawalDelayBlocks;
eigenLayerProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(delegation))),
address(delegationImplementation),
abi.encodeWithSelector(DelegationManager.initialize.selector, executorMultisig, eigenLayerPauserReg, 0, 0, _strategies, _withdrawalDelayBlocks)
abi.encodeWithSelector(
DelegationManager.initialize.selector,
executorMultisig,
eigenLayerPauserReg,
0,
0,
_strategies,
_withdrawalDelayBlocks
)
);
eigenLayerProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(avsDirectory))),
Expand All @@ -171,22 +173,17 @@ contract DeployOpenEigenLayer is Script, Test {
TransparentUpgradeableProxy(payable(address(strategyManager))),
address(strategyManagerImplementation),
abi.encodeWithSelector(
StrategyManager.initialize.selector,
executorMultisig,
operationsMultisig,
eigenLayerPauserReg,
0,
0
StrategyManager.initialize.selector, executorMultisig, operationsMultisig, eigenLayerPauserReg, 0, 0
)
);
eigenLayerProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(rewardsCoordinator))),
address(rewardsCoordinatorImplementation),
abi.encodeWithSelector(
RewardsCoordinator.initialize.selector,
executorMultisig,
executorMultisig,
eigenLayerPauserReg,
0,
0,
executorMultisig,
activationDelay,
globalCommissionBips
Expand All @@ -200,12 +197,7 @@ contract DeployOpenEigenLayer is Script, Test {
eigenLayerProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(eigenPodManager))),
address(eigenPodManagerImplementation),
abi.encodeWithSelector(
EigenPodManager.initialize.selector,
executorMultisig,
eigenLayerPauserReg,
0
)
abi.encodeWithSelector(EigenPodManager.initialize.selector, executorMultisig, eigenLayerPauserReg, 0)
);

// deploy StrategyBaseTVLLimits contract implementation
Expand Down Expand Up @@ -234,4 +226,4 @@ contract DeployOpenEigenLayer is Script, Test {
eigenLayerProxyAdmin.transferOwnership(executorMultisig);
eigenPodBeacon.transferOwnership(executorMultisig);
}
}
}
125 changes: 62 additions & 63 deletions contracts/script/EigenDADeployer.s.sol
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// SPDX-License-Identifier: UNLICENSED
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.9;

import {PauserRegistry} from "eigenlayer-core/contracts/permissions/PauserRegistry.sol";
Expand Down Expand Up @@ -28,7 +28,13 @@ 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 {
DeployOpenEigenLayer,
ProxyAdmin,
ERC20PresetFixedSupply,
TransparentUpgradeableProxy,
IPauserRegistry
} from "./DeployOpenEigenLayer.s.sol";
import "forge-std/Test.sol";
import "forge-std/Script.sol";
import "forge-std/StdJson.sol";
Expand Down Expand Up @@ -68,7 +74,7 @@ contract EigenDADeployer is DeployOpenEigenLayer {
IEigenDADisperserRegistry public eigenDADisperserRegistryImplementation;

uint64 _minNumSymbols = 4096;
uint64 _pricePerSymbol = 0.4470 gwei;
uint64 _pricePerSymbol = 0.447 gwei;
uint64 _priceUpdateCooldown = 1;
uint64 _globalSymbolsPerPeriod = 131072;
uint64 _reservationPeriodInterval = 300;
Expand All @@ -84,7 +90,7 @@ contract EigenDADeployer is DeployOpenEigenLayer {
address ejector;
address confirmer;
}

function _deployEigenDAAndEigenLayerContracts(
AddressConfig memory addressConfig,
uint8 numStrategies,
Expand All @@ -95,7 +101,11 @@ contract EigenDADeployer is DeployOpenEigenLayer {
StrategyConfig[] memory strategyConfigs = new StrategyConfig[](numStrategies);
// deploy a token and create a strategy config for each token
for (uint8 i = 0; i < numStrategies; i++) {
address tokenAddress = address(new ERC20PresetFixedSupply(string(abi.encodePacked("Token", i)), string(abi.encodePacked("TOK", i)), initialSupply, tokenOwner));
address tokenAddress = address(
new ERC20PresetFixedSupply(
string(abi.encodePacked("Token", i)), string(abi.encodePacked("TOK", i)), initialSupply, tokenOwner
)
);
strategyConfigs[i] = StrategyConfig({
maxDeposits: type(uint256).max,
maxPerDeposit: type(uint256).max,
Expand All @@ -104,7 +114,12 @@ contract EigenDADeployer is DeployOpenEigenLayer {
});
}

_deployEigenLayer(addressConfig.eigenLayerCommunityMultisig, addressConfig.eigenLayerOperationsMultisig, addressConfig.eigenLayerPauserMultisig, strategyConfigs);
_deployEigenLayer(
addressConfig.eigenLayerCommunityMultisig,
addressConfig.eigenLayerOperationsMultisig,
addressConfig.eigenLayerPauserMultisig,
strategyConfigs
);

// deploy proxy admin for ability to upgrade proxy contracts
eigenDAProxyAdmin = new ProxyAdmin();
Expand All @@ -118,7 +133,7 @@ contract EigenDADeployer is DeployOpenEigenLayer {
}

emptyContract = new EmptyContract();

/**
* 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.
Expand Down Expand Up @@ -150,89 +165,72 @@ contract EigenDADeployer is DeployOpenEigenLayer {
);

{
paymentVault = IPaymentVault(
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), ""))
);
eigenDADisperserRegistry = IEigenDADisperserRegistry(
address(new TransparentUpgradeableProxy(address(emptyContract), address(eigenDAProxyAdmin), ""))
);

paymentVaultImplementation = new PaymentVault();
paymentVaultImplementation = new PaymentVault();

eigenDAProxyAdmin.upgradeAndCall(
TransparentUpgradeableProxy(payable(address(paymentVault))),
address(paymentVaultImplementation),
abi.encodeWithSelector(
PaymentVault.initialize.selector,
addressConfig.eigenDACommunityMultisig,
_minNumSymbols,
_pricePerSymbol,
_priceUpdateCooldown,
_globalSymbolsPerPeriod,
_reservationPeriodInterval,
_globalRatePeriodInterval
)
);
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
)
abi.encodeWithSelector(EigenDADisperserRegistry.initialize.selector, addressConfig.eigenDACommunityMultisig)
);

indexRegistryImplementation = new IndexRegistry(
registryCoordinator
);
indexRegistryImplementation = new IndexRegistry(registryCoordinator);

eigenDAProxyAdmin.upgrade(
TransparentUpgradeableProxy(payable(address(indexRegistry))),
address(indexRegistryImplementation)
TransparentUpgradeableProxy(payable(address(indexRegistry))), address(indexRegistryImplementation)
);

stakeRegistryImplementation = new StakeRegistry(
registryCoordinator,
IDelegationManager(address(delegation))
);
stakeRegistryImplementation = new StakeRegistry(registryCoordinator, IDelegationManager(address(delegation)));

eigenDAProxyAdmin.upgrade(
TransparentUpgradeableProxy(payable(address(stakeRegistry))),
address(stakeRegistryImplementation)
TransparentUpgradeableProxy(payable(address(stakeRegistry))), address(stakeRegistryImplementation)
);

apkRegistryImplementation = new BLSApkRegistry(
registryCoordinator
);
apkRegistryImplementation = new BLSApkRegistry(registryCoordinator);

eigenDAProxyAdmin.upgrade(
TransparentUpgradeableProxy(payable(address(apkRegistry))),
address(apkRegistryImplementation)
TransparentUpgradeableProxy(payable(address(apkRegistry))), address(apkRegistryImplementation)
);

socketRegistryImplementation = new SocketRegistry(registryCoordinator);

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

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

{
IRegistryCoordinator.OperatorSetParam[] memory operatorSetParams = new IRegistryCoordinator.OperatorSetParam[](numStrategies);
for (uint i = 0; i < numStrategies; i++) {
IRegistryCoordinator.OperatorSetParam[] memory operatorSetParams =
new IRegistryCoordinator.OperatorSetParam[](numStrategies);
for (uint256 i = 0; i < numStrategies; i++) {
// hard code these for now
operatorSetParams[i] = IRegistryCoordinator.OperatorSetParam({
maxOperatorCount: uint32(maxOperatorCount),
Expand All @@ -242,8 +240,9 @@ contract EigenDADeployer is DeployOpenEigenLayer {
}

uint96[] memory minimumStakeForQuourm = new uint96[](numStrategies);
IStakeRegistry.StrategyParams[][] memory strategyAndWeightingMultipliers = new IStakeRegistry.StrategyParams[][](numStrategies);
for (uint i = 0; i < numStrategies; i++) {
IStakeRegistry.StrategyParams[][] memory strategyAndWeightingMultipliers =
new IStakeRegistry.StrategyParams[][](numStrategies);
for (uint256 i = 0; i < numStrategies; i++) {
strategyAndWeightingMultipliers[i] = new IStakeRegistry.StrategyParams[](1);
strategyAndWeightingMultipliers[i][0] = IStakeRegistry.StrategyParams({
strategy: IStrategy(address(deployedStrategyArray[i])),
Expand All @@ -261,9 +260,9 @@ contract EigenDADeployer is DeployOpenEigenLayer {
addressConfig.ejector,
IPauserRegistry(address(eigenDAPauserReg)),
0, // initial paused status is nothing paused
operatorSetParams,
operatorSetParams,
minimumStakeForQuourm,
strategyAndWeightingMultipliers
strategyAndWeightingMultipliers
)
);
}
Expand Down Expand Up @@ -335,4 +334,4 @@ contract EigenDADeployer is DeployOpenEigenLayer {
abi.encodeWithSelector(EigenDARelayRegistry.initialize.selector, addressConfig.eigenDACommunityMultisig)
);
}
}
}
4 changes: 2 additions & 2 deletions contracts/script/EigenLayerUtils.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ import "forge-std/StdJson.sol";
contract EigenLayerUtils {
function _allocate(IERC20 token, address[] memory tos, uint256[] memory amounts) internal {
for (uint256 i = 0; i < tos.length; i++) {
if(token == IERC20(address(0))) {
if (token == IERC20(address(0))) {
payable(tos[i]).transfer(amounts[i]);
} else {
token.transfer(tos[i], amounts[i]);
}
}
}
}
}
Loading
Loading