diff --git a/.github/workflows/reusable-build-and-test.yml b/.github/workflows/reusable-build-and-test.yml index 9e316306..ce5641e4 100644 --- a/.github/workflows/reusable-build-and-test.yml +++ b/.github/workflows/reusable-build-and-test.yml @@ -27,9 +27,21 @@ jobs: run: forge install - uses: foundry-rs/foundry-toolchain@v1 - - name: Run forge tests + - name: Run forge tests - Contract working-directory: contracts - run: forge test + run: forge test --no-match-contract 'Integration' + + - name: Run forge tests - Integration folder + run: | + make start-anvil-and-deploy + cd contracts + forge test -vvv --fork-url=http://localhost:8545 --match-contract 'Integration' + + - name: kill anvil + if: success() || failure() + run: | + pkill anvil + build-foundry-deployer-image: name: Build foundry deployer Docker image with smart contracts code diff --git a/avs-eigensdk-go b/avs-eigensdk-go index 5f7ce8c5..acb76592 160000 --- a/avs-eigensdk-go +++ b/avs-eigensdk-go @@ -1 +1 @@ -Subproject commit 5f7ce8c51d35fd4ea297565598286b0c3c600e52 +Subproject commit acb76592b03410a0ed653fa38c2d777c778d4d93 diff --git a/contracts/script/output/31337/strategy_output.json b/contracts/script/output/31337/strategy_output.json deleted file mode 100644 index 6fb30090..00000000 --- a/contracts/script/output/31337/strategy_output.json +++ /dev/null @@ -1,33 +0,0 @@ -{ - "addresses": { - "avsDirectory": "0x5FC8d32690cc91D4c39d9d3abcBD16989F875707", - "avsDirectoryImplementation": "0x0DCd1Bf9A1b36cE34237eEaFef220932846BCD82", - "baseStrategyImplementation": "0x322813Fd9A801c5507c9de605d63CEA4f2CE6c44", - "delayedWithdrawalRouter": "0x2279B7A0a67DB372996a5FaB50D91eAA73d2eBe6", - "delayedWithdrawalRouterImplementation": "0x959922bE3CAee4b8Cd9a407cc3ac1C251C2007B1", - "delegationImplementation": "0xB7f8BC63BbcaD18155201308C8f3540b07f84F5e", - "delegationManager": "0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9", - "eigenLayerPauserReg": "0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512", - "eigenLayerProxyAdmin": "0x5FbDB2315678afecb367f032d93F642f64180aa3", - "eigenPodBeacon": "0x610178dA211FEF7D417bC0e6FeD39F05609AD788", - "eigenPodImplementation": "0x8A791620dd6260079BF849Dc5567aDC3F2FdC318", - "eigenPodManager": "0xa513E6E4b8f2a923D98304ec87F64353C4D5C853", - "eigenPodManagerImplementation": "0x0B306BF915C4d645ff596e518fAf3F9669b97016", - "emptyContract": "0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0", - "erc20Mock": "0x7a2088a1bFc9d81c55368AE168C2C02570cB814F", - "erc20MockStrategy": "0x09635F643e140090A9A8Dcd712eD6285858ceBef", - "slasher": "0x0165878A594ca255338adfa4d48449f69242Eb8F", - "slasherImplementation": "0x9A676e781A523b5d0C0e43731313A708CB607508", - "strategies": "", - "strategyManager": "0xDc64a140Aa3E981100a9becA4E685f962f0cF6C9", - "strategyManagerImplementation": "0xA51c1fc2f0D1a1b8494Ed1FE312d7C3a78Ed91C0" - }, - "chainInfo": { - "chainId": 31337, - "deploymentBlock": 0 - }, - "parameters": { - "executorMultisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", - "operationsMultisig": "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266" - } -} \ No newline at end of file diff --git a/contracts/test/integration/TestUtils.sol b/contracts/test/integration/TestUtils.sol new file mode 100644 index 00000000..81ab1910 --- /dev/null +++ b/contracts/test/integration/TestUtils.sol @@ -0,0 +1,26 @@ +pragma solidity =0.8.12; + +import "forge-std/Test.sol"; +import "forge-std/Script.sol"; +import "forge-std/StdJson.sol"; +import "forge-std/console.sol"; + +contract TestUtils is Script, Test { + + function getAvsConfigFile() view public returns (string memory){ + string memory configData = vm.readFile("script/output/31337/avs_deployment_output.json"); + return configData; + } + function getRollDownConfigFileEth() view public returns (string memory){ + string memory configData = vm.readFile("script/output/31337/ethereum_rolldown_output.json"); + return configData; + } + function getRollDownConfigFileArb() view public returns (string memory){ + string memory configData = vm.readFile("script/output/31337/arbitrum_rolldown_output.json"); + return configData; + } + function getErc20ConfigFile() view public returns (string memory){ + string memory configData = vm.readFile("script/output/31337/strategy_output.json"); + return configData; + } +} \ No newline at end of file diff --git a/contracts/test/integration/ejector.t.sol b/contracts/test/integration/ejector.t.sol new file mode 100644 index 00000000..69cc68e2 --- /dev/null +++ b/contracts/test/integration/ejector.t.sol @@ -0,0 +1,92 @@ +// SPDX-License-Identifier: BUSL-1.1 +// ::: How to run::: +//cd contracts ; pkill anvil ; clear ; cd ../ ; make start-anvil-and-deploy ; cd contracts ; forge test -vvv --fork-url=http://localhost:8545 --match-contract 'Integration' +pragma solidity =0.8.12; + +import { FinalizerServiceManager } from "../../src/FinalizerServiceManager.sol"; +import {BitmapUtils} from "@eigenlayer-middleware/src/libraries/BitmapUtils.sol"; +import { TestUtils } from "./TestUtils.sol"; +import "forge-std/StdJson.sol"; +import "forge-std/Test.sol"; + +contract IntegrationEjectorAdminRuleTest is Test { + + address deployer = address(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266); + + function testEjectorCanBeResetByDeployer() public { + + address tu = address(deployer); + + FinalizerServiceManager fsm = FinalizerServiceManager(stdJson.readAddress(new TestUtils().getRollDownConfigFileEth(), ".addresses.serviceManager")); + address ejectorAddr = fsm.ejector(); + emit log_address(ejectorAddr); + + vm.startBroadcast(tu); + fsm.setEjector(tu); + vm.stopBroadcast(); + + address ejectorAddr2 = fsm.ejector(); + emit log_address(ejectorAddr2); + assert(ejectorAddr != ejectorAddr2); + + } + function testEjectorCanNotBeResetByaNonDeployer() public { + + address tu = address(101); + + FinalizerServiceManager fsm = FinalizerServiceManager(stdJson.readAddress(new TestUtils().getRollDownConfigFileEth(), ".addresses.serviceManager")); + address ejectorAddr = fsm.ejector(); + emit log_address(ejectorAddr); + + vm.startBroadcast(tu); + vm.expectRevert("Ownable: caller is not the owner"); + fsm.setEjector(tu); + vm.stopBroadcast(); + + address ejectorAddr2 = fsm.ejector(); + emit log_address(ejectorAddr2); + assert(ejectorAddr == ejectorAddr2); + + } + function testEjectorCanEject() public { + + FinalizerServiceManager fsm = FinalizerServiceManager(stdJson.readAddress(new TestUtils().getRollDownConfigFileEth(), ".addresses.serviceManager")); + address ejectorAddr = fsm.ejector(); + + address[] memory operators = new address[](2); + operators[0] = address(0x1); + operators[1] = address(0x2); + + bytes[] memory quorumNumbers = new bytes[](2) ; + quorumNumbers[0] = BitmapUtils.bitmapToBytesArray(0); + quorumNumbers[1] = BitmapUtils.bitmapToBytesArray(1); + console.log("quorumNumbers"); + + vm.startBroadcast(ejectorAddr); + vm.expectRevert("RegistryCoordinator._deregisterOperator: operator is not registered"); + fsm.ejectOperators(operators, quorumNumbers); + vm.stopBroadcast(); + + } + //https://mangatafinance.atlassian.net/browse/MGX-1315 + function testOwnerCanEject() public { + + FinalizerServiceManager fsm = FinalizerServiceManager(stdJson.readAddress(new TestUtils().getRollDownConfigFileEth(), ".addresses.serviceManager")); + address ejectorAddr = fsm.ejector(); + + address[] memory operators = new address[](2); + operators[0] = address(0x1); + operators[1] = address(0x2); + + bytes[] memory quorumNumbers = new bytes[](2) ; + quorumNumbers[0] = BitmapUtils.bitmapToBytesArray(0); + quorumNumbers[1] = BitmapUtils.bitmapToBytesArray(1); + console.log("quorumNumbers"); + + vm.startBroadcast(deployer); + vm.expectRevert("RegistryCoordinator._deregisterOperator: operator is not registered"); + fsm.ejectOperators(operators, quorumNumbers); + vm.stopBroadcast(); + + } +} \ No newline at end of file diff --git a/contracts/test/TaskManager.t.sol b/contracts/test/taskManager.t.sol similarity index 100% rename from contracts/test/TaskManager.t.sol rename to contracts/test/taskManager.t.sol