Skip to content

Commit

Permalink
feat: add SemVerMixin (#1034)
Browse files Browse the repository at this point in the history
* feat: add `SemVerMixin`

* refactor: add `_majorVersion` helper for `SignatureUtils`

* test: passing

* test: passing

* refactor: rename EIP712_VERSION

* refactor: review changes
  • Loading branch information
0xClandestine authored Jan 21, 2025
1 parent 6920ec1 commit 943d7ee
Show file tree
Hide file tree
Showing 26 changed files with 327 additions and 172 deletions.
44 changes: 27 additions & 17 deletions script/deploy/devnet/deploy_from_scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ contract DeployFromScratch is Script, Test {
// strategies deployed
StrategyBaseTVLLimits[] public deployedStrategyArray;

string EIP712_VERSION;
string SEMVER;

// IMMUTABLES TO SET
uint64 GOERLI_GENESIS_TIME = 1616508000;
Expand Down Expand Up @@ -123,7 +123,7 @@ contract DeployFromScratch is Script, Test {
string memory config_data = vm.readFile(deployConfigPath);
// bytes memory parsedData = vm.parseJson(config_data);

EIP712_VERSION = stdJson.readString(config_data, ".eip712_version");
SEMVER = stdJson.readString(config_data, ".SEMVER");

STRATEGY_MANAGER_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".strategyManager.init_paused_status");
DELEGATION_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".delegation.init_paused_status");
Expand Down Expand Up @@ -245,30 +245,40 @@ contract DeployFromScratch is Script, Test {
eigenLayerPauserReg,
permissionController,
MIN_WITHDRAWAL_DELAY,
EIP712_VERSION
SEMVER
);

strategyManagerImplementation = new StrategyManager(delegation, eigenLayerPauserReg, EIP712_VERSION);
avsDirectoryImplementation = new AVSDirectory(delegation, eigenLayerPauserReg, EIP712_VERSION);
strategyManagerImplementation = new StrategyManager(delegation, eigenLayerPauserReg, SEMVER);
avsDirectoryImplementation = new AVSDirectory(delegation, eigenLayerPauserReg, SEMVER);
eigenPodManagerImplementation = new EigenPodManager(
ethPOSDeposit,
eigenPodBeacon,
delegation,
eigenLayerPauserReg
);
rewardsCoordinatorImplementation = new RewardsCoordinator(
delegation,
strategyManager,
allocationManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP
);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams(
delegation,
strategyManager,
allocationManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP,
SEMVER
)
);
allocationManagerImplementation = new AllocationManager(
delegation,
eigenLayerPauserReg,
permissionController,
DEALLOCATION_DELAY,
ALLOCATION_CONFIGURATION_DELAY,
SEMVER
);
permissionControllerImplementation = new PermissionController();
strategyFactoryImplementation = new StrategyFactory(strategyManager, eigenLayerPauserReg);

Expand Down
44 changes: 27 additions & 17 deletions script/deploy/local/Deploy_From_Scratch.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ contract DeployFromScratch is Script, Test {
// strategies deployed
StrategyBaseTVLLimits[] public deployedStrategyArray;

string EIP712_VERSION;
string SEMVER;

// IMMUTABLES TO SET
uint64 GOERLI_GENESIS_TIME = 1616508000;
Expand Down Expand Up @@ -126,7 +126,7 @@ contract DeployFromScratch is Script, Test {
string memory config_data = vm.readFile(deployConfigPath);
// bytes memory parsedData = vm.parseJson(config_data);

EIP712_VERSION = stdJson.readString(config_data, ".eip712_version");
SEMVER = stdJson.readString(config_data, ".SEMVER");

STRATEGY_MANAGER_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".strategyManager.init_paused_status");
DELEGATION_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".delegation.init_paused_status");
Expand Down Expand Up @@ -257,29 +257,39 @@ contract DeployFromScratch is Script, Test {
eigenLayerPauserReg,
permissionController,
MIN_WITHDRAWAL_DELAY,
EIP712_VERSION
SEMVER
);
strategyManagerImplementation = new StrategyManager(delegation, eigenLayerPauserReg, EIP712_VERSION);
avsDirectoryImplementation = new AVSDirectory(delegation, eigenLayerPauserReg, EIP712_VERSION);
strategyManagerImplementation = new StrategyManager(delegation, eigenLayerPauserReg, SEMVER);
avsDirectoryImplementation = new AVSDirectory(delegation, eigenLayerPauserReg, SEMVER);
eigenPodManagerImplementation = new EigenPodManager(
ethPOSDeposit,
eigenPodBeacon,
delegation,
eigenLayerPauserReg
);
rewardsCoordinatorImplementation = new RewardsCoordinator(
delegation,
strategyManager,
allocationManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP
);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams(
delegation,
strategyManager,
allocationManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP,
SEMVER
)
);
allocationManagerImplementation = new AllocationManager(
delegation,
eigenLayerPauserReg,
permissionController,
DEALLOCATION_DELAY,
ALLOCATION_CONFIGURATION_DELAY,
SEMVER
);
permissionControllerImplementation = new PermissionController();

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
Expand Down
44 changes: 27 additions & 17 deletions script/deploy/local/deploy_from_scratch.slashing.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ contract DeployFromScratch is Script, Test {
address operationsMultisig;
address pauserMultisig;

string EIP712_VERSION;
string SEMVER;

// the ETH2 deposit contract -- if not on mainnet, we deploy a mock as stand-in
IETHPOSDeposit public ethPOSDeposit;
Expand Down Expand Up @@ -126,7 +126,7 @@ contract DeployFromScratch is Script, Test {
string memory config_data = vm.readFile(deployConfigPath);
// bytes memory parsedData = vm.parseJson(config_data);

EIP712_VERSION = stdJson.readString(config_data, ".eip712_version");
SEMVER = stdJson.readString(config_data, ".SEMVER");

MIN_WITHDRAWAL_DELAY = uint32(stdJson.readUint(config_data, ".delegation.withdrawal_delay_blocks"));
STRATEGY_MANAGER_INIT_PAUSED_STATUS = stdJson.readUint(config_data, ".strategyManager.init_paused_status");
Expand Down Expand Up @@ -252,29 +252,39 @@ contract DeployFromScratch is Script, Test {
eigenLayerPauserReg,
permissionController,
MIN_WITHDRAWAL_DELAY,
EIP712_VERSION
SEMVER
);
strategyManagerImplementation = new StrategyManager(delegation, eigenLayerPauserReg, EIP712_VERSION);
avsDirectoryImplementation = new AVSDirectory(delegation, eigenLayerPauserReg, EIP712_VERSION);
strategyManagerImplementation = new StrategyManager(delegation, eigenLayerPauserReg, SEMVER);
avsDirectoryImplementation = new AVSDirectory(delegation, eigenLayerPauserReg, SEMVER);
eigenPodManagerImplementation = new EigenPodManager(
ethPOSDeposit,
eigenPodBeacon,
delegation,
eigenLayerPauserReg
);
rewardsCoordinatorImplementation = new RewardsCoordinator(
delegation,
strategyManager,
allocationManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP
);
allocationManagerImplementation = new AllocationManager(delegation, eigenLayerPauserReg, permissionController, DEALLOCATION_DELAY, ALLOCATION_CONFIGURATION_DELAY);
IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams(
delegation,
strategyManager,
allocationManager,
eigenLayerPauserReg,
permissionController,
REWARDS_COORDINATOR_CALCULATION_INTERVAL_SECONDS,
REWARDS_COORDINATOR_MAX_REWARDS_DURATION,
REWARDS_COORDINATOR_MAX_RETROACTIVE_LENGTH,
REWARDS_COORDINATOR_MAX_FUTURE_LENGTH,
REWARDS_COORDINATOR_GENESIS_REWARDS_TIMESTAMP,
SEMVER
)
);
allocationManagerImplementation = new AllocationManager(
delegation,
eigenLayerPauserReg,
permissionController,
DEALLOCATION_DELAY,
ALLOCATION_CONFIGURATION_DELAY,
SEMVER
);
permissionControllerImplementation = new PermissionController();

// Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them.
Expand Down
30 changes: 17 additions & 13 deletions script/releases/v1.0.0-slashing/1-deployContracts.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ contract Deploy is EOADeployer {
_pauserRegistry: Env.impl.pauserRegistry(),
_permissionController: Env.proxy.permissionController(),
_DEALLOCATION_DELAY: Env.MIN_WITHDRAWAL_DELAY(),
_ALLOCATION_CONFIGURATION_DELAY: Env.ALLOCATION_CONFIGURATION_DELAY()
_ALLOCATION_CONFIGURATION_DELAY: Env.ALLOCATION_CONFIGURATION_DELAY(),
_version: Env.version()
}))
});

Expand Down Expand Up @@ -99,18 +100,21 @@ contract Deploy is EOADeployer {

deployImpl({
name: type(RewardsCoordinator).name,
deployedTo: address(new RewardsCoordinator({
_delegationManager: Env.proxy.delegationManager(),
_strategyManager: Env.proxy.strategyManager(),
_allocationManager: Env.proxy.allocationManager(),
_pauserRegistry: Env.impl.pauserRegistry(),
_permissionController: Env.proxy.permissionController(),
_CALCULATION_INTERVAL_SECONDS: Env.CALCULATION_INTERVAL_SECONDS(),
_MAX_REWARDS_DURATION: Env.MAX_REWARDS_DURATION(),
_MAX_RETROACTIVE_LENGTH: Env.MAX_RETROACTIVE_LENGTH(),
_MAX_FUTURE_LENGTH: Env.MAX_FUTURE_LENGTH(),
_GENESIS_REWARDS_TIMESTAMP: Env.GENESIS_REWARDS_TIMESTAMP()
}))
deployedTo: address(new RewardsCoordinator(
IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams({
delegationManager: Env.proxy.delegationManager(),
strategyManager: Env.proxy.strategyManager(),
allocationManager: Env.proxy.allocationManager(),
pauserRegistry: Env.impl.pauserRegistry(),
permissionController: Env.proxy.permissionController(),
CALCULATION_INTERVAL_SECONDS: Env.CALCULATION_INTERVAL_SECONDS(),
MAX_REWARDS_DURATION: Env.MAX_REWARDS_DURATION(),
MAX_RETROACTIVE_LENGTH: Env.MAX_RETROACTIVE_LENGTH(),
MAX_FUTURE_LENGTH: Env.MAX_FUTURE_LENGTH(),
GENESIS_REWARDS_TIMESTAMP: Env.GENESIS_REWARDS_TIMESTAMP(),
version: Env.version()
})
))
});

deployImpl({
Expand Down
3 changes: 2 additions & 1 deletion script/releases/v1.0.1-slashing/1-eoa.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ contract Deploy is EOADeployer {
_pauserRegistry: Env.impl.pauserRegistry(),
_permissionController: Env.proxy.permissionController(),
_DEALLOCATION_DELAY: Env.MIN_WITHDRAWAL_DELAY(),
_ALLOCATION_CONFIGURATION_DELAY: Env.ALLOCATION_CONFIGURATION_DELAY()
_ALLOCATION_CONFIGURATION_DELAY: Env.ALLOCATION_CONFIGURATION_DELAY(),
_version: Env.version()
}))
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ contract Deploy is EOADeployer {
_pauserRegistry: Env.impl.pauserRegistry(),
_permissionController: Env.proxy.permissionController(),
_DEALLOCATION_DELAY: Env.MIN_WITHDRAWAL_DELAY(),
_ALLOCATION_CONFIGURATION_DELAY: Env.ALLOCATION_CONFIGURATION_DELAY()
_ALLOCATION_CONFIGURATION_DELAY: Env.ALLOCATION_CONFIGURATION_DELAY(),
_version: Env.version()
}))
});

Expand Down Expand Up @@ -99,18 +100,21 @@ contract Deploy is EOADeployer {

deployImpl({
name: type(RewardsCoordinator).name,
deployedTo: address(new RewardsCoordinator({
_delegationManager: Env.proxy.delegationManager(),
_strategyManager: Env.proxy.strategyManager(),
_allocationManager: Env.proxy.allocationManager(),
_pauserRegistry: Env.impl.pauserRegistry(),
_permissionController: Env.proxy.permissionController(),
_CALCULATION_INTERVAL_SECONDS: Env.CALCULATION_INTERVAL_SECONDS(),
_MAX_REWARDS_DURATION: Env.MAX_REWARDS_DURATION(),
_MAX_RETROACTIVE_LENGTH: Env.MAX_RETROACTIVE_LENGTH(),
_MAX_FUTURE_LENGTH: Env.MAX_FUTURE_LENGTH(),
_GENESIS_REWARDS_TIMESTAMP: Env.GENESIS_REWARDS_TIMESTAMP()
}))
deployedTo: address(new RewardsCoordinator(
IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams({
delegationManager: Env.proxy.delegationManager(),
strategyManager: Env.proxy.strategyManager(),
allocationManager: Env.proxy.allocationManager(),
pauserRegistry: Env.impl.pauserRegistry(),
permissionController: Env.proxy.permissionController(),
CALCULATION_INTERVAL_SECONDS: Env.CALCULATION_INTERVAL_SECONDS(),
MAX_REWARDS_DURATION: Env.MAX_REWARDS_DURATION(),
MAX_RETROACTIVE_LENGTH: Env.MAX_RETROACTIVE_LENGTH(),
MAX_FUTURE_LENGTH: Env.MAX_FUTURE_LENGTH(),
GENESIS_REWARDS_TIMESTAMP: Env.GENESIS_REWARDS_TIMESTAMP(),
version: Env.version()
})
))
});

deployImpl({
Expand Down
27 changes: 15 additions & 12 deletions script/releases/v1.0.3-slashing/1-eoa.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,21 @@ contract Deploy is EOADeployer {
// Deploy RC
deployImpl({
name: type(RewardsCoordinator).name,
deployedTo: address(new RewardsCoordinator({
_delegationManager: Env.proxy.delegationManager(),
_strategyManager: Env.proxy.strategyManager(),
_allocationManager: Env.proxy.allocationManager(),
_pauserRegistry: Env.impl.pauserRegistry(),
_permissionController: Env.proxy.permissionController(),
_CALCULATION_INTERVAL_SECONDS: Env.CALCULATION_INTERVAL_SECONDS(),
_MAX_REWARDS_DURATION: Env.MAX_REWARDS_DURATION(),
_MAX_RETROACTIVE_LENGTH: Env.MAX_RETROACTIVE_LENGTH(),
_MAX_FUTURE_LENGTH: Env.MAX_FUTURE_LENGTH(),
_GENESIS_REWARDS_TIMESTAMP: Env.GENESIS_REWARDS_TIMESTAMP()
}))
deployedTo: address(new RewardsCoordinator(
IRewardsCoordinatorTypes.RewardsCoordinatorConstructorParams({
delegationManager: Env.proxy.delegationManager(),
strategyManager: Env.proxy.strategyManager(),
allocationManager: Env.proxy.allocationManager(),
pauserRegistry: Env.impl.pauserRegistry(),
permissionController: Env.proxy.permissionController(),
CALCULATION_INTERVAL_SECONDS: Env.CALCULATION_INTERVAL_SECONDS(),
MAX_REWARDS_DURATION: Env.MAX_REWARDS_DURATION(),
MAX_RETROACTIVE_LENGTH: Env.MAX_RETROACTIVE_LENGTH(),
MAX_FUTURE_LENGTH: Env.MAX_FUTURE_LENGTH(),
GENESIS_REWARDS_TIMESTAMP: Env.GENESIS_REWARDS_TIMESTAMP(),
version: Env.version()
})
))
});

vm.stopBroadcast();
Expand Down
6 changes: 5 additions & 1 deletion script/utils/ExistingDeploymentParser.sol
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ contract ExistingDeploymentParser is Script, Logger {
/// EigenLayer Contract Parameters
/// -----------------------------------------------------------------------

string public SEMVER;
/// @dev AllocationManager
uint256 ALLOCATION_MANAGER_INIT_PAUSED_STATUS;
uint32 DEALLOCATION_DELAY;
Expand Down Expand Up @@ -193,6 +194,8 @@ contract ExistingDeploymentParser is Script, Logger {
// READ JSON CONFIG DATA
string memory json = cheats.readFile(existingDeploymentInfoPath);

SEMVER = stdJson.readString(json, ".parameters.version");

// check that the chainID matches the one in the config
uint256 configChainId = json.readUint(".chainInfo.chainId");
assertEq(configChainId, currentChainId, "You are on the wrong chain for this config");
Expand Down Expand Up @@ -221,7 +224,8 @@ contract ExistingDeploymentParser is Script, Logger {
eigenLayerPauserReg,
permissionController,
DEALLOCATION_DELAY,
ALLOCATION_CONFIGURATION_DELAY
ALLOCATION_CONFIGURATION_DELAY,
SEMVER
);
allocationManager = AllocationManager(
address(new TransparentUpgradeableProxy(address(allocationManagerImplementation), address(eigenLayerProxyAdmin), ""))
Expand Down
Loading

0 comments on commit 943d7ee

Please sign in to comment.