From 3e275038c7ad6e38f6f862d3ed1386ec3d9464db Mon Sep 17 00:00:00 2001 From: xiaohuo Date: Tue, 2 Apr 2024 15:58:44 +0800 Subject: [PATCH] feat: support chain id --- contracts/script/MachServiceManagerDeployer.s.sol | 5 ++++- contracts/src/core/MachServiceManager.sol | 4 +++- contracts/src/core/MachServiceManagerStorage.sol | 7 +++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/contracts/script/MachServiceManagerDeployer.s.sol b/contracts/script/MachServiceManagerDeployer.s.sol index 72020ac..1990e07 100644 --- a/contracts/script/MachServiceManagerDeployer.s.sol +++ b/contracts/script/MachServiceManagerDeployer.s.sol @@ -55,6 +55,7 @@ contract MachServiceManagerDeployer is Script { address churner; address ejector; address confirmer; + uint256 chainId; // from eigenlayer contracts address avsDirectory; address delegationManager; @@ -103,6 +104,7 @@ contract MachServiceManagerDeployer is Script { addressConfig.churner = msg.sender; addressConfig.ejector = msg.sender; addressConfig.confirmer = msg.sender; + addressConfig.chainId = 1; addressConfig.avsDirectory = address(eigenLayerContracts.avsDirectory); addressConfig.delegationManager = address(eigenLayerContracts.delegationManager); @@ -206,7 +208,8 @@ contract MachServiceManagerDeployer is Script { machServiceContract.machServiceManagerImplementation = new MachServiceManager( IAVSDirectory(addressConfig.avsDirectory), machServiceContract.registryCoordinator, - machServiceContract.stakeRegistry + machServiceContract.stakeRegistry, + addressConfig.chainId ); // Third, upgrade the proxy contracts to use the correct implementation contracts and initialize them. machAVSProxyAdmin.upgradeAndCall( diff --git a/contracts/src/core/MachServiceManager.sol b/contracts/src/core/MachServiceManager.sol index b206a9c..e1e1a58 100644 --- a/contracts/src/core/MachServiceManager.sol +++ b/contracts/src/core/MachServiceManager.sol @@ -61,10 +61,12 @@ contract MachServiceManager is constructor( IAVSDirectory __avsDirectory, IRegistryCoordinator __registryCoordinator, - IStakeRegistry __stakeRegistry + IStakeRegistry __stakeRegistry, + uint256 __chainId ) BLSSignatureChecker(__registryCoordinator) ServiceManagerBase(__avsDirectory, __registryCoordinator, __stakeRegistry) + MachServiceManagerStorage(__chainId) { _disableInitializers(); } diff --git a/contracts/src/core/MachServiceManagerStorage.sol b/contracts/src/core/MachServiceManagerStorage.sol index ef7a0f8..5f657f9 100644 --- a/contracts/src/core/MachServiceManagerStorage.sol +++ b/contracts/src/core/MachServiceManagerStorage.sol @@ -14,6 +14,9 @@ abstract contract MachServiceManagerStorage { // CONSTANTS uint256 public constant THRESHOLD_DENOMINATOR = 100; + /// @notice Rollup chain id, it is different from block.chainid + uint256 public immutable chainId; + EnumerableSet.Bytes32Set internal _messageHashes; /// @notice Ethereum addresses of currently register operators @@ -34,4 +37,8 @@ abstract contract MachServiceManagerStorage { // storage gap for upgradeability // slither-disable-next-line shadowing-state uint256[46] private __GAP; + + constructor(uint256 _chainId) { + chainId = _chainId; + } }