diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ee331f09..88f969af 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,8 +16,6 @@ jobs: - name: Install Foundry uses: foundry-rs/foundry-toolchain@v1 - with: - version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d - name: Install deps run: forge install diff --git a/foundry.toml b/foundry.toml index 898a696b..6d325086 100644 --- a/foundry.toml +++ b/foundry.toml @@ -16,8 +16,8 @@ cbor_metadata = false bytecode_hash = "none" optimizer = true optimizer_runs = 200 -solc = "0.8.20" -evm_version = "shanghai" +solc = "0.8.23" +# evm_version = "shanghai" [fmt] line_length = 120 diff --git a/lib/eigenlayer-contracts b/lib/eigenlayer-contracts index 24bffe1b..db4506d0 160000 --- a/lib/eigenlayer-contracts +++ b/lib/eigenlayer-contracts @@ -1 +1 @@ -Subproject commit 24bffe1b528c3919f3fd15d0cd4835060240b19d +Subproject commit db4506d07b2b9029c31d583d5da6b790484c2b95 diff --git a/lib/forge-std b/lib/forge-std index 74cfb77e..37a37ab7 160000 --- a/lib/forge-std +++ b/lib/forge-std @@ -1 +1 @@ -Subproject commit 74cfb77e308dd188d2f58864aaf44963ae6b88b1 +Subproject commit 37a37ab73364d6644bfe11edf88a07880f99bd56 diff --git a/lib/openzeppelin-contracts b/lib/openzeppelin-contracts index 932fddf6..4e419d40 160000 --- a/lib/openzeppelin-contracts +++ b/lib/openzeppelin-contracts @@ -1 +1 @@ -Subproject commit 932fddf69a699a9a80fd2396fd1a2ab91cdda123 +Subproject commit 4e419d407cb13c4ebd64d3f47faa78964cbbdd71 diff --git a/lib/openzeppelin-contracts-upgradeable b/lib/openzeppelin-contracts-upgradeable index 625fb3c2..74a5d4d4 160000 --- a/lib/openzeppelin-contracts-upgradeable +++ b/lib/openzeppelin-contracts-upgradeable @@ -1 +1 @@ -Subproject commit 625fb3c2b2696f1747ba2e72d1e1113066e6c177 +Subproject commit 74a5d4d4348effabf220ee15909a3aa4467267d5 diff --git a/lib/safe-contracts b/lib/safe-contracts index bf943f80..5aad84f1 160000 --- a/lib/safe-contracts +++ b/lib/safe-contracts @@ -1 +1 @@ -Subproject commit bf943f80fec5ac647159d26161446ac5d716a294 +Subproject commit 5aad84f1c7b8cbc62efe02e3d677071982afe7e2 diff --git a/lib/solady b/lib/solady index 6c54795e..23cb3cb1 160000 --- a/lib/solady +++ b/lib/solady @@ -1 +1 @@ -Subproject commit 6c54795ef69838e233020e9ab29f3f6288efdf06 +Subproject commit 23cb3cb13ea32bc94d9d136666090b36d0485e1c diff --git a/script/DeployEverything.s.sol b/script/DeployEverything.s.sol new file mode 100644 index 00000000..20aad784 --- /dev/null +++ b/script/DeployEverything.s.sol @@ -0,0 +1,23 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.8.0 <0.9.0; + +import { BaseScript } from "script/BaseScript.s.sol"; +import { DeployGuardians } from "script/DeployGuardians.s.sol"; +import { DeployPuffer } from "script/DeployPuffer.s.sol"; +import { SetupAccess } from "script/SetupAccess.s.sol"; +import { GuardiansDeployment, PufferDeployment } from "./DeploymentStructs.sol"; + +contract DeployEverything is BaseScript { + function run(address[] calldata guardians, uint256 threshold) public returns (PufferDeployment memory) { + // Deploy guardians + GuardiansDeployment memory guardiansDeployment = new DeployGuardians().run(guardians, threshold, ""); + + PufferDeployment memory pufferDeployment = new DeployPuffer().run(guardiansDeployment); + + address DAO = makeAddr("DAO"); + + new SetupAccess().run(pufferDeployment, DAO); + + return pufferDeployment; + } +} diff --git a/script/1_DeployGuardians.s.sol b/script/DeployGuardians.s.sol similarity index 83% rename from script/1_DeployGuardians.s.sol rename to script/DeployGuardians.s.sol index 939309a5..058d00f8 100644 --- a/script/1_DeployGuardians.s.sol +++ b/script/DeployGuardians.s.sol @@ -9,6 +9,7 @@ import { SafeProxy } from "safe-contracts/proxies/SafeProxy.sol"; import { SafeProxyFactory } from "safe-contracts/proxies/SafeProxyFactory.sol"; import { AccessManager } from "openzeppelin/access/manager/AccessManager.sol"; import { Strings } from "openzeppelin/utils/Strings.sol"; +import { GuardiansDeployment } from "./DeploymentStructs.sol"; // forge script script/1_DeployGuardians.s.sol:DeployGuardians --rpc-url=$EPHEMERY_RPC_URL --sig 'run(address[] calldata, uint256)' "[0x5F9a7EA6A79Ef04F103bfe7BD45dA65476a5155C]" 1 contract DeployGuardians is BaseScript { @@ -18,7 +19,7 @@ contract DeployGuardians is BaseScript { function run(address[] calldata guardians, uint256 threshold, bytes calldata emptyData) public broadcast - returns (Safe, GuardianModule) + returns (GuardiansDeployment memory) { safeProxy = vm.envOr("SAFE_PROXY_ADDRESS", address(new SafeProxyFactory())); safeImplementation = vm.envOr("SAFE_IMPLEMENTATION_ADDRESS", address(new Safe())); @@ -46,7 +47,16 @@ contract DeployGuardians is BaseScript { vm.writeJson(finalJson, string.concat("./output/", Strings.toString(block.chainid), "-guardians.json")); - return (guardiansSafe, module); + GuardiansDeployment memory deployment; + deployment.guardians = address(guardiansSafe); + deployment.accessManager = address(accessManager); + deployment.guardianModule = address(module); + deployment.safeProxyFactory = address(safeProxy); + deployment.safeImplementation = address(safeImplementation); + deployment.enclaveVerifier = address(verifier); + deployment.pauser = 0x98BDB87fCF3697F4b356C36Cd621ffF94Ee3Aa19; + + return deployment; } function deploySafe(address[] calldata owners, uint256 threshold, address to, bytes calldata data) diff --git a/script/DeployPuffer.s.sol b/script/DeployPuffer.s.sol index 9ce6f771..0a53ff91 100644 --- a/script/DeployPuffer.s.sol +++ b/script/DeployPuffer.s.sol @@ -16,6 +16,7 @@ import { IEigenPodManager } from "eigenlayer/interfaces/IEigenPodManager.sol"; import { Strings } from "openzeppelin/utils/Strings.sol"; import { AccessManager } from "openzeppelin/access/manager/AccessManager.sol"; import { UpgradeableBeacon } from "openzeppelin/proxy/beacon/UpgradeableBeacon.sol"; +import { GuardiansDeployment, PufferDeployment } from "./DeploymentStructs.sol"; /** * @title DeployPuffer @@ -33,25 +34,29 @@ import { UpgradeableBeacon } from "openzeppelin/proxy/beacon/UpgradeableBeacon.s * forge script script/DeployPuffer.s.sol:DeployPuffer -vvvv --rpc-url=$EPHEMERY_RPC_URL --broadcast */ contract DeployPuffer is BaseScript { - function run() public broadcast returns (PufferProtocol, PufferPool, AccessManager) { - string memory guardiansDeployment = - vm.readFile(string.concat("./output/", Strings.toString(block.chainid), "-guardians.json")); + PufferProtocol pufferProtocolImpl; + AccessManager accessManager; + ERC1967Proxy proxy; + PufferProtocol pufferProtocol; + PufferPool pool; + WithdrawalPool withdrawalPool; + UpgradeableBeacon beacon; + + function run(GuardiansDeployment calldata guardiansDeployment) public broadcast returns (PufferDeployment memory) { string memory obj = ""; - PufferProtocol pufferProtocolImpl; - - AccessManager accessManager = AccessManager(stdJson.readAddress(guardiansDeployment, ".accessManager")); + accessManager = AccessManager(guardiansDeployment.accessManager); { // PufferTreasury address payable treasury = payable(vm.envOr("TREASURY", address(1337))); - address payable guardians = payable(stdJson.readAddress(guardiansDeployment, ".guardians")); + address payable guardians = payable(guardiansDeployment.guardians); address eigenPodManager = vm.envOr("EIGENPOD_MANAGER", address(new EigenPodManagerMock())); PufferStrategy strategyImplementation = new PufferStrategy(IEigenPodManager(eigenPodManager)); - UpgradeableBeacon beacon = new UpgradeableBeacon(address(strategyImplementation), address(accessManager)); + beacon = new UpgradeableBeacon(address(strategyImplementation), address(accessManager)); vm.serializeAddress(obj, "PufferStrategyBeacon", address(beacon)); // Puffer Service implementation @@ -60,16 +65,16 @@ contract DeployPuffer is BaseScript { } // UUPS proxy for PufferProtocol - ERC1967Proxy proxy = new ERC1967Proxy(address(pufferProtocolImpl), ""); + proxy = new ERC1967Proxy(address(pufferProtocolImpl), ""); - PufferProtocol pufferProtocol = PufferProtocol(payable(address(proxy))); + pufferProtocol = PufferProtocol(payable(address(proxy))); // Deploy pool - PufferPool pool = new PufferPool(pufferProtocol, address(accessManager)); + pool = new PufferPool(pufferProtocol, address(accessManager)); - WithdrawalPool withdrawalPool = new WithdrawalPool(pool, address(accessManager)); + withdrawalPool = new WithdrawalPool(pool, address(accessManager)); // Read guardians module variable - address payable guardiansModule = payable(stdJson.readAddress(guardiansDeployment, ".guardianModule")); + address payable guardiansModule = payable(guardiansDeployment.guardianModule); NoRestakingStrategy noRestaking = new NoRestakingStrategy(address(accessManager), pufferProtocol, getStakingContract()); @@ -106,12 +111,27 @@ contract DeployPuffer is BaseScript { vm.serializeAddress(obj, "pufferPool", address(pool)); vm.serializeAddress(obj, "withdrawalPool", address(withdrawalPool)); vm.serializeAddress(obj, "PufferProtocol", address(proxy)); + vm.serializeAddress(obj, "guardianModule", guardiansDeployment.guardianModule); + vm.serializeAddress(obj, "guardians", guardiansDeployment.guardians); + vm.serializeAddress(obj, "accessManager", guardiansDeployment.accessManager); string memory finalJson = vm.serializeString(obj, "", ""); vm.writeJson(finalJson, "./output/puffer.json"); - - return (pufferProtocol, pool, accessManager); + // return (pufferProtocol, pool, accessManager); + return PufferDeployment({ + pufferProtocolImplementation: address(pufferProtocolImpl), + noRestakingStrategy: address(noRestaking), + pufferPool: address(pool), + withdrawalPool: address(withdrawalPool), + pufferProtocol: address(proxy), + guardianModule: guardiansDeployment.guardianModule, + guardians: guardiansDeployment.guardians, + accessManager: guardiansDeployment.accessManager, + enclaveVerifier: guardiansDeployment.enclaveVerifier, + pauser: guardiansDeployment.pauser, + beacon: address(beacon) + }); } function getStakingContract() internal returns (address) { diff --git a/script/DeploymentStructs.sol b/script/DeploymentStructs.sol new file mode 100644 index 00000000..cf69e6bf --- /dev/null +++ b/script/DeploymentStructs.sol @@ -0,0 +1,32 @@ +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.8.0 <0.9.0; + +/** + * @notice Guardians deployment struct + */ +struct GuardiansDeployment { + address guardians; + address accessManager; + address guardianModule; + address safeProxyFactory; + address safeImplementation; + address enclaveVerifier; + address pauser; +} + +/** + * @notice PufferDeployment + */ +struct PufferDeployment { + address pufferProtocolImplementation; + address noRestakingStrategy; + address pufferPool; + address withdrawalPool; + address pufferProtocol; + address guardianModule; + address guardians; + address accessManager; + address enclaveVerifier; + address pauser; + address beacon; // Beacon for Puffer startegies +} diff --git a/script/SetupAccess.s.sol b/script/SetupAccess.s.sol index 1707da4a..61c0a7b1 100644 --- a/script/SetupAccess.s.sol +++ b/script/SetupAccess.s.sol @@ -2,8 +2,6 @@ pragma solidity >=0.8.0 <0.9.0; import { BaseScript } from "script/BaseScript.s.sol"; -import { Strings } from "openzeppelin/utils/Strings.sol"; -import { stdJson } from "forge-std/StdJson.sol"; import { AccessManager } from "openzeppelin/access/manager/AccessManager.sol"; import { PufferProtocol } from "puffer/PufferProtocol.sol"; import { PufferPool } from "puffer/PufferPool.sol"; @@ -12,6 +10,7 @@ import { GuardianModule } from "puffer/GuardianModule.sol"; import { IPufferStrategy } from "puffer/interface/IPufferStrategy.sol"; import { UpgradeableBeacon } from "openzeppelin/proxy/beacon/UpgradeableBeacon.sol"; import { EnclaveVerifier } from "puffer/EnclaveVerifier.sol"; +import { PufferDeployment } from "./DeploymentStructs.sol"; uint64 constant ROLE_ID_PUFFER_PROTOCOL = 1; uint64 constant ROLE_ID_DAO = 77; @@ -19,23 +18,14 @@ uint64 constant ROLE_ID_GUARDIANS = 88; uint64 constant ROLE_ID_PAUSER = 999; contract SetupAccess is BaseScript { - string internal pufferDeployment = vm.readFile(string.concat("./output/puffer.json")); + AccessManager internal accessManager; - string internal guardiansDeployment = guardiansDeployment = - vm.readFile(string.concat("./output/", Strings.toString(block.chainid), "-guardians.json")); + PufferDeployment internal pufferDeployment; - AccessManager internal accessManager = AccessManager(stdJson.readAddress(guardiansDeployment, ".accessManager")); + function run(PufferDeployment memory deployment, address DAO) external broadcast { + pufferDeployment = deployment; + accessManager = AccessManager(payable(deployment.accessManager)); - address internal guardians = stdJson.readAddress(guardiansDeployment, ".guardians"); - address internal guardianModule = stdJson.readAddress(guardiansDeployment, ".guardianModule"); - address internal pufferProtocol = stdJson.readAddress(pufferDeployment, ".PufferProtocol"); - address internal noRestakingStrategy = stdJson.readAddress(pufferDeployment, ".noRestakingStrategy"); - address internal withdrawalPool = stdJson.readAddress(pufferDeployment, ".withdrawalPool"); - address internal pufferPool = stdJson.readAddress(pufferDeployment, ".pufferPool"); - address internal enclaveVerifier = stdJson.readAddress(guardiansDeployment, ".enclaveVerifier"); - address internal pauser = stdJson.readAddress(guardiansDeployment, ".pauser"); - - function run(address DAO) external broadcast { // We do one multicall to setup everything bytes[] memory rolesCalldatas = _grantRoles(DAO); bytes[] memory pufferProtocolRoles = _setupPufferProtocolRoles(); @@ -83,7 +73,10 @@ contract SetupAccess is BaseScript { selectors[1] = bytes4(hex"945fca09"); // IWithdrawalPool.withdrawETH Permit version return abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, withdrawalPool, selectors, accessManager.PUBLIC_ROLE() + AccessManager.setTargetFunctionRole.selector, + pufferDeployment.withdrawalPool, + selectors, + accessManager.PUBLIC_ROLE() ); } @@ -91,25 +84,32 @@ contract SetupAccess is BaseScript { bytes4[] memory selectors = new bytes4[](1); selectors[0] = GuardianModule.setGuardianEnclaveMeasurements.selector; - return - abi.encodeWithSelector(AccessManager.setTargetFunctionRole.selector, guardianModule, selectors, ROLE_ID_DAO); + return abi.encodeWithSelector( + AccessManager.setTargetFunctionRole.selector, pufferDeployment.guardianModule, selectors, ROLE_ID_DAO + ); } - function _setupPufferPoolRoles() internal returns (bytes[] memory) { + function _setupPufferPoolRoles() internal view returns (bytes[] memory) { bytes[] memory calldatas = new bytes[](2); bytes4[] memory selectors = new bytes4[](1); selectors[0] = PufferPool.transferETH.selector; calldatas[0] = abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, pufferPool, selectors, ROLE_ID_PUFFER_PROTOCOL + AccessManager.setTargetFunctionRole.selector, + pufferDeployment.pufferPool, + selectors, + ROLE_ID_PUFFER_PROTOCOL ); bytes4[] memory publicSelectors = new bytes4[](1); publicSelectors[0] = PufferPool.depositETH.selector; calldatas[1] = abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, pufferPool, publicSelectors, accessManager.PUBLIC_ROLE() + AccessManager.setTargetFunctionRole.selector, + pufferDeployment.pufferPool, + publicSelectors, + accessManager.PUBLIC_ROLE() ); return calldatas; @@ -121,7 +121,7 @@ contract SetupAccess is BaseScript { return abi.encodeWithSelector( AccessManager.setTargetFunctionRole.selector, - PufferProtocol(pufferProtocol).PUFFER_STRATEGY_BEACON(), + PufferProtocol(pufferDeployment.pufferProtocol).PUFFER_STRATEGY_BEACON(), selectors, ROLE_ID_DAO ); @@ -134,14 +134,20 @@ contract SetupAccess is BaseScript { selectors[0] = IPufferStrategy.callStake.selector; calldatas[0] = abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, noRestakingStrategy, selectors, ROLE_ID_PUFFER_PROTOCOL + AccessManager.setTargetFunctionRole.selector, + pufferDeployment.noRestakingStrategy, + selectors, + ROLE_ID_PUFFER_PROTOCOL ); bytes4[] memory selectorsForGuardians = new bytes4[](1); selectorsForGuardians[0] = bytes4(hex"abfaad62"); // signature for `function postRewardsRoot(bytes32 root, uint256 blockNumber)` calldatas[1] = abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, noRestakingStrategy, selectorsForGuardians, ROLE_ID_GUARDIANS + AccessManager.setTargetFunctionRole.selector, + pufferDeployment.noRestakingStrategy, + selectorsForGuardians, + ROLE_ID_GUARDIANS ); bytes4[] memory publicSelectors = new bytes4[](1); @@ -149,7 +155,7 @@ contract SetupAccess is BaseScript { calldatas[2] = abi.encodeWithSelector( AccessManager.setTargetFunctionRole.selector, - noRestakingStrategy, + pufferDeployment.noRestakingStrategy, publicSelectors, accessManager.PUBLIC_ROLE() ); @@ -162,7 +168,7 @@ contract SetupAccess is BaseScript { selectors[0] = EnclaveVerifier.removeLeafX509.selector; return abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, enclaveVerifier, selectors, ROLE_ID_DAO + AccessManager.setTargetFunctionRole.selector, pufferDeployment.enclaveVerifier, selectors, ROLE_ID_DAO ); } @@ -181,7 +187,10 @@ contract SetupAccess is BaseScript { selectors[8] = PufferProtocol.setWithdrawalPoolRate.selector; calldatas[0] = abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, address(pufferProtocol), selectors, ROLE_ID_DAO + AccessManager.setTargetFunctionRole.selector, + address(pufferDeployment.pufferProtocol), + selectors, + ROLE_ID_DAO ); bytes4[] memory guardianSelectors = new bytes4[](4); @@ -191,7 +200,10 @@ contract SetupAccess is BaseScript { guardianSelectors[3] = PufferProtocol.postFullWithdrawalsRoot.selector; calldatas[1] = abi.encodeWithSelector( - AccessManager.setTargetFunctionRole.selector, address(pufferProtocol), guardianSelectors, ROLE_ID_GUARDIANS + AccessManager.setTargetFunctionRole.selector, + address(pufferDeployment.pufferProtocol), + guardianSelectors, + ROLE_ID_GUARDIANS ); bytes4[] memory publicSelectors = new bytes4[](1); @@ -199,7 +211,7 @@ contract SetupAccess is BaseScript { calldatas[2] = abi.encodeWithSelector( AccessManager.setTargetFunctionRole.selector, - address(pufferProtocol), + address(pufferDeployment.pufferProtocol), publicSelectors, accessManager.PUBLIC_ROLE() ); @@ -211,10 +223,13 @@ contract SetupAccess is BaseScript { bytes[] memory calldatas = new bytes[](4); calldatas[0] = abi.encodeWithSelector(AccessManager.grantRole.selector, ROLE_ID_DAO, DAO, 0); - calldatas[1] = abi.encodeWithSelector(AccessManager.grantRole.selector, ROLE_ID_GUARDIANS, guardians, 0); - calldatas[2] = - abi.encodeWithSelector(AccessManager.grantRole.selector, ROLE_ID_PUFFER_PROTOCOL, pufferProtocol, 0); - calldatas[3] = abi.encodeWithSelector(AccessManager.grantRole.selector, ROLE_ID_PAUSER, pauser, 0); + calldatas[1] = + abi.encodeWithSelector(AccessManager.grantRole.selector, ROLE_ID_GUARDIANS, pufferDeployment.guardians, 0); + calldatas[2] = abi.encodeWithSelector( + AccessManager.grantRole.selector, ROLE_ID_PUFFER_PROTOCOL, pufferDeployment.pufferProtocol, 0 + ); + calldatas[3] = + abi.encodeWithSelector(AccessManager.grantRole.selector, ROLE_ID_PAUSER, pufferDeployment.pauser, 0); return calldatas; } diff --git a/test/gas-tests/ABIEncode.t.sol b/test/gas-tests/ABIEncode.t.sol index b0199994..edb2a53e 100644 --- a/test/gas-tests/ABIEncode.t.sol +++ b/test/gas-tests/ABIEncode.t.sol @@ -1,5 +1,5 @@ -// // SPDX-License-Identifier: GPL-3.0 -// pragma solidity >=0.8.0 <0.9.0; +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.8.0 <0.9.0; // import { Test } from "forge-std/Test.sol"; // import { console } from "forge-std/console.sol"; diff --git a/test/gas-tests/ReturnValue.t.sol b/test/gas-tests/ReturnValue.t.sol index 7ed0ea10..9771df2a 100644 --- a/test/gas-tests/ReturnValue.t.sol +++ b/test/gas-tests/ReturnValue.t.sol @@ -1,5 +1,5 @@ -// // SPDX-License-Identifier: GPL-3.0 -// pragma solidity >=0.8.0 <0.9.0; +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.8.0 <0.9.0; // import { Test } from "forge-std/Test.sol"; diff --git a/test/helpers/GuardiansRaveEvidence.sol b/test/helpers/GuardiansRaveEvidence.sol index 67ee3bf5..b12f1af3 100644 --- a/test/helpers/GuardiansRaveEvidence.sol +++ b/test/helpers/GuardiansRaveEvidence.sol @@ -7,15 +7,15 @@ contract Guardian3RaveEvidence is MockEvidence { function report() public pure override returns (bytes memory) { // Report is inputted as abi-encoded JSON values return abi.encode( - "317003438820305668509883748002428467346", - "2023-09-06T09:02:57.885887", + "186453210057823126547835745110511429060", + "2023-10-16T20:17:59.516859", "4", - "EbrM6X6YCH3brjPXT23gVh/I2EG5sVfHYh+S54fb0rrAqVRTiRTOSfLsWSVTZc8wrazGG7oooGoMU7Gj5TEhsrBrnh3hi7JBOga+j9dMkQCRClbEbCpuX8/+B244fKMo9sMqW1PAPAgorY4sg6/wTgZGaYrX6B7ITfYqY8jfs/Q=", + "EbrM6X6YCH3brjPXT23gVh/I2EG5sVfHYh+S54fb0rrAqVRTiRTOSfLsWSVTZc8wrazGG7oooGoMU7Gj5TEhspNWPNBkpcmwf+3WZYsuncw6eX6Uijk+PzPp3dBQSebHsOEQYDRxGeFuWowvkTo2Z5HTavyoRIrSupBTqDE78HA=", "https://security-center.intel.com", "[\"INTEL-SA-00334\",\"INTEL-SA-00615\"]", "SW_HARDENING_NEEDED", // Already Base64 decoded off-chain - hex"02000100ac0c00000d000d000000000042616c98d53c9712639447c9b0e7003f0000000000000000000000000000000015150b07ff800e000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000001f00000000000000b8a5f3f33abd56aec48109c3ed1b45610b7958780cb96ddcabfe3b294ab49079000000000000000000000000000000000000000000000000000000000000000083d719e77deaca1470f6baf62a4d774303c899db69020f9c70ee1dfc08c7ce9e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000006e8004d8b521bd18a633c2d9334c7deb39ca51c3b53452b146193494a6f1e624290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563" + hex"02000100ac0c00000d000d000000000042616c98d53c9712639447c9b0e7003f0000000000000000000000000000000015150b07ff800e000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000001f000000000000008eb70e76a34bf6cbf9deed7f467b4888cc187f1f1f34cce2d11ca54014149a35000000000000000000000000000000000000000000000000000000000000000083d719e77deaca1470f6baf62a4d774303c899db69020f9c70ee1dfc08c7ce9e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008619f6cd837e7e0c5c182235222a6fbce0af1b7aa452ee117f08ee1e2ab8f5600000000000000000000000000000000000000000000000000000000000000000" ); } @@ -23,7 +23,7 @@ contract Guardian3RaveEvidence is MockEvidence { function sig() public pure override returns (bytes memory) { // base64 decoded signature as hex return - hex"39941b44e603d0eb84cda521fa3c843ff271ebf31b8d1e4656e2e4c9797ca3570360ab6d41cdf9e8e1dd8264ccf716e33f18521154fd9ef0d1cc1add931da4820206963166e5ce8992b3ac4f1f7d5b7a79b476147261f704e5aa6abdf6bddae8a51a140d9787c977aae216cf59f872b26395fcde265fb739c67bd7262a3a51fe23f0ac9fec7f88ffac0b3f1c1f72142cbb7ebb8c146b92569a270f02afcada94efa1b5b0678d09a6dc5392a4085263620a31715b91fb5f3e859bffda4bb5767699264f1d35bb87ac1752f2087e477a849e8391176afe6a47f676a2a7741635d8f734ab5125cb62965e7b3ba1c8e3b29849207dd654114dae7a64ee0b698a96ae"; + hex"2c3c7862299e87f941e5a9a49b96a1bc9e2fec4fc15e9ea64e8c3d6a4894cbef433248ac21402f165062936b12ffd75e6b8c4015c34991b75a558390434dcb70a184e24fec38f50929826281ae31793ea02fc3b51f009906e9febbf20abecee32b2dbb831f677babacbc4057030c4650ad4d83dc5b6b28aef78b49c26777c04820856bd36c514f0e8693c0ba7cd94a191d2418f2b0d7d2533013e5a9815b3cb785b0575648267b7990c070b26614b1de1896ade6391364157ebe06112b7a884ff059586cba4f68a02a2440136e16f5b9b65be0d20823ceb773c92191fc615cbab568b809b5beead47201161238b96815f0e9d2c37c4400e4ac794dcf2b1b3599"; } // The leaf x509 signing certificate used to sign the report @@ -45,7 +45,7 @@ contract Guardian3RaveEvidence is MockEvidence { // The expected MRENCLAVE value in this specific report function mrenclave() public pure override returns (bytes32) { - return hex"b8a5f3f33abd56aec48109c3ed1b45610b7958780cb96ddcabfe3b294ab49079"; + return hex"8eb70e76a34bf6cbf9deed7f467b4888cc187f1f1f34cce2d11ca54014149a35"; } // The expected MRSIGNER value in this specific report @@ -57,7 +57,7 @@ contract Guardian3RaveEvidence is MockEvidence { function payload() public pure override returns (bytes memory) { // This is a hex-encoded 48 byte BLS public key return - hex"049777a708d71e0b211eff7d44acc9d81be7bbd1bffdc14f60e784c86b64037c745b82cc5d9da0e93dd96d2fb955c32239b2d1d56a456681d4cef88bd603b9b407"; + hex"04a55b152177219971a93a64aafc2d61baeaf86526963caa260e71efa2b865527e0307d7bda85312dd6ff23bcc88f2bf228da6295239f72c31b686c48b7b69cdfd"; } } @@ -65,15 +65,15 @@ contract Guardian2RaveEvidence is MockEvidence { function report() public pure override returns (bytes memory) { // Report is inputted as abi-encoded JSON values return abi.encode( - "255638962332323068350582484765465521313", - "2023-09-06T09:02:36.125204", + "209759971368149731737954685751527072004", + "2023-10-16T20:17:08.742105", "4", - "EbrM6X6YCH3brjPXT23gVh/I2EG5sVfHYh+S54fb0rrAqVRTiRTOSfLsWSVTZc8wrazGG7oooGoMU7Gj5TEhsrBrnh3hi7JBOga+j9dMkQCRClbEbCpuX8/+B244fKMo9sMqW1PAPAgorY4sg6/wTgZGaYrX6B7ITfYqY8jfs/Q=", + "EbrM6X6YCH3brjPXT23gVh/I2EG5sVfHYh+S54fb0rrAqVRTiRTOSfLsWSVTZc8wrazGG7oooGoMU7Gj5TEhspNWPNBkpcmwf+3WZYsuncw6eX6Uijk+PzPp3dBQSebHsOEQYDRxGeFuWowvkTo2Z5HTavyoRIrSupBTqDE78HA=", "https://security-center.intel.com", "[\"INTEL-SA-00334\",\"INTEL-SA-00615\"]", "SW_HARDENING_NEEDED", // Already Base64 decoded off-chain - hex"02000100ac0c00000d000d000000000042616c98d53c9712639447c9b0e7003f0000000000000000000000000000000015150b07ff800e000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000001f00000000000000b8a5f3f33abd56aec48109c3ed1b45610b7958780cb96ddcabfe3b294ab49079000000000000000000000000000000000000000000000000000000000000000083d719e77deaca1470f6baf62a4d774303c899db69020f9c70ee1dfc08c7ce9e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000e5157e8a0f297cea8f3ffb1ebc7b31ca040fc331a03f93ea67d2d974117da85b290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563" + hex"02000100ac0c00000d000d000000000042616c98d53c9712639447c9b0e7003f0000000000000000000000000000000015150b07ff800e000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000001f000000000000008eb70e76a34bf6cbf9deed7f467b4888cc187f1f1f34cce2d11ca54014149a35000000000000000000000000000000000000000000000000000000000000000083d719e77deaca1470f6baf62a4d774303c899db69020f9c70ee1dfc08c7ce9e00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000bc3029f55f939dfad86a268c340aeba8d87daaa3fdc204a0ca36c839aaf0f26c0000000000000000000000000000000000000000000000000000000000000000" ); } @@ -81,7 +81,7 @@ contract Guardian2RaveEvidence is MockEvidence { function sig() public pure override returns (bytes memory) { // base64 decoded signature as hex return - hex"2ee083e11795e39d4326d1289790f6bbe750731bc30406d98180ee9c7999fd397cd005f38a557ffe43aba8ff9ceec74b3d55ebb1e3f7d585dd108281392aaa692e8e54f91fa64bfc74fc6d96bbe452db541994794e511a72655bdfa80ac254bf61d43691ef7b69b6d6be86c439612df75383a4a932457920098f60a0c7f3f757c5e769e57c8a14f8fa6b5511574df4cb720c1d663efde28c1d42daa104dbdd71f256e7ee87439ab51f361bd0623d837ea984d0a7f3dc2b12fa67cad415c7fa2149273e431b8b8f37d0961fb842fed178b7564ce689d4fde646dd0a22ffc0fc254e20065174bc58501b15b854a690e03272a8987d8ea792d628d8ba13a0a46356"; + hex"77d614e10b4f29730c14681ea0808758c22f3ffd833020fcd572dc445ca9abd2ea3e2abdcfd5a04f0975202c5f8c17812a5701346d8f75427b16455da264673e02bedb15d06945ab566d39788e586b73a0259f024a68a27b1fa40964f0b695f3394a5cd3a7af283447f5ff8adccf8091640086de1067cf85fb8ee5db5073bb6894478a9a8bee8292bcb839a10529d82300f3c9cbd548279eae92809f99d0fd6dd7280fe1a6b250d5c1e5219afa7032c4771b393d7fb0269027184013cc6bec4ec40a6699bdc967d67c57035c12f129d59559b98c7f6588aa3658bcf3542a221941ee91b100b80ca895b19464b5570537573ddb0426a09a88b2eca50875809b0e"; } // The leaf x509 signing certificate used to sign the report @@ -103,7 +103,7 @@ contract Guardian2RaveEvidence is MockEvidence { // The expected MRENCLAVE value in this specific report function mrenclave() public pure override returns (bytes32) { - return hex"b8a5f3f33abd56aec48109c3ed1b45610b7958780cb96ddcabfe3b294ab49079"; + return hex"8eb70e76a34bf6cbf9deed7f467b4888cc187f1f1f34cce2d11ca54014149a35"; } // The expected MRSIGNER value in this specific report @@ -115,7 +115,7 @@ contract Guardian2RaveEvidence is MockEvidence { function payload() public pure override returns (bytes memory) { // This is a hex-encoded 48 byte BLS public key return - hex"0440ba2fa6602bdb09e40d8b400b0c82124c14c8666659c0c78d8e474f3e230d92597cd4811484e1a15d6886745ed6d3fbde7e66f1376e396d8d4e8fa67458a140"; + hex"04f050c3ce5d575600af388f41876e2962499a97bc8fcfa4a12adf7e4a486a3be9a1db0efd899c09723f83fe490e8215fd596a5f03c819e28a8b95f3cce6238613"; } } @@ -123,15 +123,15 @@ contract Guardian1RaveEvidence is MockEvidence { function report() public pure override returns (bytes memory) { // Report is inputted as abi-encoded JSON values return abi.encode( - "56763225389687359246706216746732829064", - "2023-09-06T09:02:14.764248", + "171541400247265784450028677784105405930", + "2023-10-16T20:13:06.744812", "4", - "EbrM6X6YCH3brjPXT23gVh/I2EG5sVfHYh+S54fb0rrAqVRTiRTOSfLsWSVTZc8wrazGG7oooGoMU7Gj5TEhsrBrnh3hi7JBOga+j9dMkQCRClbEbCpuX8/+B244fKMo9sMqW1PAPAgorY4sg6/wTgZGaYrX6B7ITfYqY8jfs/Q=", + "EbrM6X6YCH3brjPXT23gVh/I2EG5sVfHYh+S54fb0rrAqVRTiRTOSfLsWSVTZc8wrazGG7oooGoMU7Gj5TEhspNWPNBkpcmwf+3WZYsuncw6eX6Uijk+PzPp3dBQSebHsOEQYDRxGeFuWowvkTo2Z5HTavyoRIrSupBTqDE78HA=", "https://security-center.intel.com", "[\"INTEL-SA-00334\",\"INTEL-SA-00615\"]", "SW_HARDENING_NEEDED", // Already Base64 decoded off-chain - hex"02000100ac0c00000d000d000000000042616c98d53c9712639447c9b0e7003f0000000000000000000000000000000015150b07ff800e000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000001f00000000000000b8a5f3f33abd56aec48109c3ed1b45610b7958780cb96ddcabfe3b294ab49079000000000000000000000000000000000000000000000000000000000000000083d719e77deaca1470f6baf62a4d774303c899db69020f9c70ee1dfc08c7ce9e000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002fa89a3fddf87e84ca0bafec51d878fdd28df71449be034627033a7fa4858b4c290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e563" + hex"02000100ac0c00000d000d000000000042616c98d53c9712639447c9b0e7003f0000000000000000000000000000000015150b07ff800e000000000000000000000000000000000000000000000000000000000000000000000000000000000005000000000000001f000000000000008eb70e76a34bf6cbf9deed7f467b4888cc187f1f1f34cce2d11ca54014149a35000000000000000000000000000000000000000000000000000000000000000083d719e77deaca1470f6baf62a4d774303c899db69020f9c70ee1dfc08c7ce9e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003af0644b0725449c3def3104fd7428c3ea005f4607e13453d3c05f3aac07b600000000000000000000000000000000000000000000000000000000000000000" ); } @@ -139,7 +139,7 @@ contract Guardian1RaveEvidence is MockEvidence { function sig() public pure override returns (bytes memory) { // base64 decoded signature as hex return - hex"8fe8dd7c2e9a2247f1a08ca581e9988f2e0faa0b724e3c227cb2fc9d370b36ac9651c9b104deb2c6ccf27bf2368c157fbfaccf23dd498e3724e174c7e51aa2727cfa5a0276573faa45e6c3669c7daaea49d90c3ca62c50fdace9100be117031aa4447110eb1665d9afd7133c7f9344985a07b46254bebb7020b4c9b81a0ff331c0b3ad03c50e7c3072e103f44650fe10a1acb80ee91fde12fe579ddf8a8a661ecb84d309236abbc5668a886345c21e81a525ef641e0df9a3b3bf8efcc1728fa5aebdc084a6b392a50e1f0aa517fd6084de5a9de2f4fc61f5742e53ee20300430f4eb143dd29e3840c6b90076c71fcc71aca392dafe4c488b102367f1f1cdbfa2"; + hex"6cc5a3354c3504677252a3ee19a9d4c64eb8e8ed2bcdd8a7fcfeee88eb8214c0975730b03aeec9b1f56e7cd37030da73b63c8fefb85de1fd2ae70f4d485db8228c76c6dc5da2ce5458c172852d2faec9cca97a1ef4cc19280b84b841e05a7ee33207db18496a3fb515f978ed161d4b7e4c585e76641605be2c31418e04ac35686fa0841b3680d24dac35d8edbfa4c7549b712830b1c0064ae4c0463428ebd0ee833f341fcb2125e9c06d9e67d41f2dc3afe26b1e81d5dbaed1eab6a656e40b9188206f8fdc2745d90db2ebcb671ee44932b9ca7f607c8107bd0c96689bd6aaf9dcdd03afcb433925cacf994527121b79a425a32a86984af5434005b8f422faaa"; } // The leaf x509 signing certificate used to sign the report @@ -161,7 +161,7 @@ contract Guardian1RaveEvidence is MockEvidence { // The expected MRENCLAVE value in this specific report function mrenclave() public pure override returns (bytes32) { - return hex"b8a5f3f33abd56aec48109c3ed1b45610b7958780cb96ddcabfe3b294ab49079"; + return hex"8eb70e76a34bf6cbf9deed7f467b4888cc187f1f1f34cce2d11ca54014149a35"; } // The expected MRSIGNER value in this specific report @@ -173,6 +173,6 @@ contract Guardian1RaveEvidence is MockEvidence { function payload() public pure override returns (bytes memory) { // This is a hex-encoded 48 byte BLS public key return - hex"048289b999a1a6bc0cc6550ea018d03adee9bfeae6441e53e2e5eed22232a2b8f2d87cf1619c263971a6ada43f7310f37f473de7262ab63778fe3a859c68dc2e27"; + hex"04caf1f9cd82a1284626d405d285250fd6c4f58c469fda05d7fd4f29318aae38e7ccc6f4eaced74d3e2aa3fc0576093860d3045263c4183d694a39911ee9031c73"; } } diff --git a/test/helpers/IntegrationTestHelper.sol b/test/helpers/IntegrationTestHelper.sol index 6e219a53..7ad4805b 100644 --- a/test/helpers/IntegrationTestHelper.sol +++ b/test/helpers/IntegrationTestHelper.sol @@ -4,7 +4,8 @@ pragma solidity >=0.8.0 <0.9.0; import "forge-std/Test.sol"; import { DeployPuffer } from "script/DeployPuffer.s.sol"; import { PufferPool } from "puffer/PufferPool.sol"; -import { DeployGuardians } from "script/1_DeployGuardians.s.sol"; +import { DeployGuardians } from "script/DeployGuardians.s.sol"; +import { GuardiansDeployment } from "script/DeploymentStructs.sol"; contract IntegrationTestHelper is Test { address safeProxyFactory = 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2; // mainnet @@ -19,9 +20,9 @@ contract IntegrationTestHelper is Test { guardians[0] = address(this); // 1. Deploy guardians safe - new DeployGuardians().run(guardians, 1, ""); + GuardiansDeployment memory guardiansDeployment = new DeployGuardians().run(guardians, 1, ""); - new DeployPuffer().run(); + new DeployPuffer().run(guardiansDeployment); // vm.label(address(pool), "PufferPool"); } @@ -31,8 +32,9 @@ contract IntegrationTestHelper is Test { address[] memory guardians = new address[](1); guardians[0] = address(this); - new DeployGuardians().run(guardians, 1, ""); - new DeployPuffer().run(); + GuardiansDeployment memory guardiansDeployment = new DeployGuardians().run(guardians, 1, ""); + + new DeployPuffer().run(guardiansDeployment); // vm.label(address(pool), "PufferPool"); } } diff --git a/test/helpers/TestHelper.sol b/test/helpers/TestHelper.sol index 41951887..ca9285c4 100644 --- a/test/helpers/TestHelper.sol +++ b/test/helpers/TestHelper.sol @@ -1,19 +1,17 @@ // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.8.0 <0.9.0; +import { Test } from "forge-std/Test.sol"; +import { BaseScript } from "script/BaseScript.s.sol"; import { GuardianModule } from "puffer/GuardianModule.sol"; import { Safe } from "safe-contracts/Safe.sol"; -import { Test } from "forge-std/Test.sol"; import { PufferPool } from "puffer/PufferPool.sol"; import { PufferProtocol } from "puffer/PufferProtocol.sol"; import { RaveEvidence } from "puffer/struct/RaveEvidence.sol"; -import { BaseScript } from "script/BaseScript.s.sol"; -// import { WithdrawalPool } from "puffer/WithdrawalPool.sol"; import { IWithdrawalPool } from "puffer/interface/IWithdrawalPool.sol"; import { UpgradeableBeacon } from "openzeppelin/proxy/beacon/UpgradeableBeacon.sol"; -import { DeployPuffer } from "script/DeployPuffer.s.sol"; -import { DeployGuardians } from "script/1_DeployGuardians.s.sol"; -import { SetupAccess } from "script/SetupAccess.s.sol"; +import { DeployEverything } from "script/DeployEverything.s.sol"; +import { PufferDeployment } from "script/DeploymentStructs.sol"; import { IEnclaveVerifier } from "puffer/interface/IEnclaveVerifier.sol"; import { Guardian1RaveEvidence, Guardian2RaveEvidence, Guardian3RaveEvidence } from "./GuardiansRaveEvidence.sol"; import { AccessManager } from "openzeppelin/access/manager/AccessManager.sol"; @@ -39,15 +37,15 @@ contract TestHelper is Test, BaseScript { uint256 public guardian1SKEnclave; // PubKey is hardcoded because we are creating guardian enclaves deterministically bytes public guardian1EnclavePubKey = - hex"048289b999a1a6bc0cc6550ea018d03adee9bfeae6441e53e2e5eed22232a2b8f2d87cf1619c263971a6ada43f7310f37f473de7262ab63778fe3a859c68dc2e27"; + hex"04caf1f9cd82a1284626d405d285250fd6c4f58c469fda05d7fd4f29318aae38e7ccc6f4eaced74d3e2aa3fc0576093860d3045263c4183d694a39911ee9031c73"; address public guardian2Enclave; uint256 public guardian2SKEnclave; bytes public guardian2EnclavePubKey = - hex"0440ba2fa6602bdb09e40d8b400b0c82124c14c8666659c0c78d8e474f3e230d92597cd4811484e1a15d6886745ed6d3fbde7e66f1376e396d8d4e8fa67458a140"; + hex"04f050c3ce5d575600af388f41876e2962499a97bc8fcfa4a12adf7e4a486a3be9a1db0efd899c09723f83fe490e8215fd596a5f03c819e28a8b95f3cce6238613"; address public guardian3Enclave; uint256 public guardian3SKEnclave; bytes public guardian3EnclavePubKey = - hex"049777a708d71e0b211eff7d44acc9d81be7bbd1bffdc14f60e784c86b64037c745b82cc5d9da0e93dd96d2fb955c32239b2d1d56a456681d4cef88bd603b9b407"; + hex"04a55b152177219971a93a64aafc2d61baeaf86526963caa260e71efa2b865527e0307d7bda85312dd6ff23bcc88f2bf228da6295239f72c31b686c48b7b69cdfd"; PufferPool public pool; PufferProtocol public pufferProtocol; @@ -106,13 +104,18 @@ contract TestHelper is Test, BaseScript { function _deployContractAndSetupGuardians() public { // Create Guardian wallets (guardian1, guardian1SK) = makeAddrAndKey("guardian1"); - (guardian1Enclave, guardian1SKEnclave) = makeAddrAndKey("guardian1enclave"); - guardiansEnclavePks.push(guardian1SKEnclave); (guardian2, guardian2SK) = makeAddrAndKey("guardian2"); - (guardian2Enclave, guardian2SKEnclave) = makeAddrAndKey("guardian2enclave"); - guardiansEnclavePks.push(guardian2SKEnclave); (guardian3, guardian3SK) = makeAddrAndKey("guardian3"); - (guardian3Enclave, guardian3SKEnclave) = makeAddrAndKey("guardian3enclave"); + + // Hardcode enclave secret keys + guardian1SKEnclave = 81165043675487275545095207072241430673874640255053335052777448899322561824201; + guardian1Enclave = vm.addr(guardian1SKEnclave); + guardian2SKEnclave = 90480947395980135991870782913815514305328820213706480966227475230529794843518; + guardian2Enclave = vm.addr(guardian2SKEnclave); + guardian3SKEnclave = 56094429399408807348734910221877888701411489680816282162734349635927251229227; + guardian3Enclave = vm.addr(guardian3SKEnclave); + guardiansEnclavePks.push(guardian1SKEnclave); + guardiansEnclavePks.push(guardian2SKEnclave); guardiansEnclavePks.push(guardian3SKEnclave); address[] memory guardians = new address[](3); @@ -120,17 +123,17 @@ contract TestHelper is Test, BaseScript { guardians[1] = guardian2; guardians[2] = guardian3; - // 1. Deploy guardians safe - (guardiansSafe, module) = new DeployGuardians().run(guardians, 1, ""); + // Deploy everything with one script + PufferDeployment memory pufferDeployment = new DeployEverything().run(guardians, 1); - // Deploy puffer protocol - (pufferProtocol, pool, accessManager) = new DeployPuffer().run(); - - // Setup roles and access - new SetupAccess().run(DAO); - - withdrawalPool = pufferProtocol.getWithdrawalPool(); - verifier = module.ENCLAVE_VERIFIER(); + pufferProtocol = PufferProtocol(pufferDeployment.pufferProtocol); + accessManager = AccessManager(pufferDeployment.accessManager); + pool = PufferPool(payable(pufferDeployment.pufferPool)); + withdrawalPool = IWithdrawalPool(pufferDeployment.withdrawalPool); + verifier = IEnclaveVerifier(pufferDeployment.enclaveVerifier); + module = GuardianModule(pufferDeployment.guardianModule); + beacon = UpgradeableBeacon(pufferDeployment.beacon); + guardiansSafe = Safe(payable(pufferDeployment.guardians)); vm.label(address(pool), "PufferPool"); vm.label(address(pufferProtocol), "PufferProtocol"); @@ -153,6 +156,12 @@ contract TestHelper is Test, BaseScript { require(keccak256(guardian1EnclavePubKey) == keccak256(guardian1Rave.payload()), "pubkeys dont match"); + assertEq( + blockhash(block.number), + hex"0000000000000000000000000000000000000000000000000000000000000000", + "bad blockhash" + ); + // Register enclave keys for guardians vm.startPrank(guardians[0]); module.rotateGuardianKey( diff --git a/test/mocks/EigenPodManagerMock.sol b/test/mocks/EigenPodManagerMock.sol index 88545b40..5c231bb9 100644 --- a/test/mocks/EigenPodManagerMock.sol +++ b/test/mocks/EigenPodManagerMock.sol @@ -1,5 +1,5 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.9; +// SPDX-License-Identifier: GPL-3.0 +pragma solidity >=0.8.0 <0.9.0; import "forge-std/Test.sol"; import "eigenlayer/interfaces/IEigenPodManager.sol"; @@ -7,7 +7,43 @@ import "eigenlayer/interfaces/IEigenPodManager.sol"; contract EigenPodManagerMock is IEigenPodManager, Test { function slasher() external view returns (ISlasher) { } - function createPod() external pure { } + function createPod() external pure returns (address) { + return (address(123123123)); + } + + function addShares(address podOwner, uint256 shares) external returns (uint256) { + return 55; + } + + function beaconChainETHStrategy() external view returns (IStrategy) { } + + function eigenPodBeacon() external view returns (IBeacon) { + return IBeacon(address(99)); + } + + function ethPOS() external view returns (IETHPOSDeposit) { + return IETHPOSDeposit(address(99)); + } + + function getBlockRootAtTimestamp(uint64 timestamp) external view returns (bytes32) { + return bytes32("asdf"); + } + + function maxPods() external view returns (uint256) { + return 100; + } + + function numPods() external view returns (uint256) { + return 10; + } + + function podOwnerShares(address podOwner) external view returns (int256) { + return 5; + } + + function recordBeaconChainETHBalanceUpdate(address podOwner, int256 sharesDelta) external { } + function removeShares(address podOwner, uint256 shares) external { } + function withdrawSharesAsTokens(address podOwner, address destination, uint256 shares) external { } function stake(bytes calldata, /*pubkey*/ bytes calldata, /*signature*/ bytes32 /*depositDataRoot*/ ) external diff --git a/test/mocks/PausableMock.sol b/test/mocks/PausableMock.sol index 358ae215..c69d9541 100644 --- a/test/mocks/PausableMock.sol +++ b/test/mocks/PausableMock.sol @@ -30,15 +30,6 @@ contract PausableMock is IPausable { uint256 internal constant UNPAUSE_ALL = 0; uint256 internal constant PAUSE_ALL = type(uint256).max; - /// @notice Emitted when the `pauserRegistry` is set to `newPauserRegistry`. - event PauserRegistrySet(IPauserRegistry pauserRegistry, IPauserRegistry newPauserRegistry); - - /// @notice Emitted when the pause is triggered by `account`, and changed to `newPausedStatus`. - event Paused(address indexed account, uint256 newPausedStatus); - - /// @notice Emitted when the pause is lifted by `account`, and changed to `newPausedStatus`. - event Unpaused(address indexed account, uint256 newPausedStatus); - /// @notice modifier onlyPauser() { require(pauserRegistry.isPauser(msg.sender), "msg.sender is not permissioned as pauser"); diff --git a/test/mocks/SlasherMock.sol b/test/mocks/SlasherMock.sol index 91652df2..abf60d6a 100644 --- a/test/mocks/SlasherMock.sol +++ b/test/mocks/SlasherMock.sol @@ -57,28 +57,6 @@ contract SlasherMock is Initializable, OwnableUpgradeable, ISlasher, PausableMoc */ mapping(address => MiddlewareTimes[]) internal _operatorToMiddlewareTimes; - /// @notice Emitted when a middleware times is added to `operator`'s array. - event MiddlewareTimesAdded( - address operator, uint256 index, uint32 stalestUpdateBlock, uint32 latestServeUntilBlock - ); - - /// @notice Emitted when `operator` begins to allow `contractAddress` to slash them. - event OptedIntoSlashing(address indexed operator, address indexed contractAddress); - - /// @notice Emitted when `contractAddress` signals that it will no longer be able to slash `operator` after the `contractCanSlashOperatorUntilBlock`. - event SlashingAbilityRevoked( - address indexed operator, address indexed contractAddress, uint32 contractCanSlashOperatorUntilBlock - ); - - /** - * @notice Emitted when `slashingContract` 'freezes' the `slashedOperator`. - * @dev The `slashingContract` must have permission to slash the `slashedOperator`, i.e. `canSlash(slasherOperator, slashingContract)` must return 'true'. - */ - event OperatorFrozen(address indexed slashedOperator, address indexed slashingContract); - - /// @notice Emitted when `previouslySlashedAddress` is 'unfrozen', allowing them to again move deposited funds within EigenLayer. - event FrozenStatusReset(address indexed previouslySlashedAddress); - constructor(IStrategyManager _strategyManager, IDelegationManager _delegation) { strategyManager = _strategyManager; delegation = _delegation;