Skip to content

Commit

Permalink
Update packages, refactor scripts, update foundry
Browse files Browse the repository at this point in the history
  • Loading branch information
bxmmm1 committed Nov 14, 2023
1 parent 1da8c4e commit b9d7ff9
Show file tree
Hide file tree
Showing 21 changed files with 263 additions and 149 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ jobs:

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly-ca67d15f4abd46394b324c50e21e66f306a1162d

- name: Install deps
run: forge install
Expand Down
4 changes: 2 additions & 2 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/eigenlayer-contracts
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts
Submodule openzeppelin-contracts updated 76 files
+6 −0 .changeset/dull-ghosts-sip.md
+5 −0 .changeset/eleven-planets-relax.md
+5 −0 .changeset/grumpy-poets-rush.md
+6 −0 .changeset/purple-squids-attend.md
+5 −0 .changeset/thirty-drinks-happen.md
+8 −1 .github/workflows/checks.yml
+33 −8 CHANGELOG.md
+2 −2 certora/Makefile
+36 −0 certora/harnesses/AccessManagedHarness.sol
+116 −0 certora/harnesses/AccessManagerHarness.sol
+14 −0 certora/harnesses/NoncesHarness.sol
+24 −0 certora/specs.json
+34 −0 certora/specs/AccessManaged.spec
+826 −0 certora/specs/AccessManager.spec
+92 −0 certora/specs/Nonces.spec
+5 −0 certora/specs/helpers/helpers.spec
+5 −0 certora/specs/methods/IAccessManaged.spec
+33 −0 certora/specs/methods/IAccessManager.spec
+6 −0 contracts/access/Ownable2Step.sol
+2 −2 contracts/access/manager/AccessManager.sol
+1 −1 contracts/mocks/AuthorityMock.sol
+25 −0 contracts/mocks/docs/access-control/AccessControlERC20MintBase.sol
+24 −0 contracts/mocks/docs/access-control/AccessControlERC20MintMissing.sol
+23 −0 contracts/mocks/docs/access-control/AccessControlERC20MintOnlyRole.sol
+16 −0 contracts/mocks/docs/access-control/AccessManagedERC20MintBase.sol
+1 −1 contracts/mocks/docs/access-control/MyContractOwnable.sol
+0 −0 contracts/mocks/token/ERC20VotesTimestampMock.sol
+3 −2 contracts/proxy/transparent/TransparentUpgradeableProxy.sol
+1 −2 contracts/token/ERC1155/IERC1155.sol
+8 −8 contracts/token/ERC20/extensions/ERC4626.sol
+97 −0 docs/modules/ROOT/images/access-control-multiple.svg
+47 −0 docs/modules/ROOT/images/access-manager-functions.svg
+99 −0 docs/modules/ROOT/images/access-manager.svg
+158 −74 docs/modules/ROOT/pages/access-control.adoc
+31 −15 docs/modules/ROOT/pages/utilities.adoc
+4 −3 hardhat.config.js
+30 −8 hardhat/env-artifacts.js
+26 −10 hardhat/env-contract.js
+1,160 −205 package-lock.json
+6 −3 package.json
+1 −1 requirements.txt
+413 −447 test/access/AccessControl.behavior.js
+12 −5 test/access/AccessControl.test.js
+42 −35 test/access/Ownable.test.js
+53 −38 test/access/Ownable2Step.test.js
+17 −13 test/access/extensions/AccessControlDefaultAdminRules.test.js
+13 −6 test/access/extensions/AccessControlEnumerable.test.js
+76 −73 test/access/manager/AccessManaged.test.js
+87 −599 test/access/manager/AccessManager.behavior.js
+454 −0 test/access/manager/AccessManager.predicate.js
+1,000 −1,211 test/access/manager/AccessManager.test.js
+49 −39 test/access/manager/AuthorityUtils.test.js
+15 −33 test/finance/VestingWallet.behavior.js
+44 −34 test/finance/VestingWallet.test.js
+201 −81 test/governance/extensions/GovernorTimelockAccess.test.js
+2 −2 test/governance/extensions/GovernorTimelockCompound.test.js
+37 −19 test/helpers/access-manager.js
+2 −2 test/helpers/account.js
+3 −7 test/helpers/chainid.js
+9 −4 test/helpers/constants.js
+0 −22 test/helpers/create.js
+2 −0 test/helpers/customError.js
+13 −20 test/helpers/eip712.js
+8 −9 test/helpers/erc1967.js
+2 −2 test/helpers/methods.js
+28 −0 test/helpers/namespaced-storage.js
+18 −6 test/helpers/time.js
+2 −2 test/proxy/Clones.test.js
+2 −2 test/proxy/transparent/ProxyAdmin.test.js
+2 −3 test/proxy/transparent/TransparentUpgradeableProxy.behaviour.js
+40 −0 test/sanity.test.js
+1 −1 test/token/common/ERC2981.behavior.js
+27 −7 test/utils/Create2.test.js
+10 −17 test/utils/cryptography/EIP712.test.js
+109 −143 test/utils/cryptography/MerkleProof.test.js
+28 −23 test/utils/introspection/SupportsInterface.behavior.js
2 changes: 1 addition & 1 deletion lib/openzeppelin-contracts-upgradeable
Submodule openzeppelin-contracts-upgradeable updated 77 files
+6 −0 .changeset/dull-ghosts-sip.md
+5 −0 .changeset/eleven-planets-relax.md
+5 −0 .changeset/grumpy-poets-rush.md
+6 −0 .changeset/purple-squids-attend.md
+5 −0 .changeset/thirty-drinks-happen.md
+8 −1 .github/workflows/checks.yml
+1 −1 .gitmodules
+33 −8 CHANGELOG.md
+2 −2 certora/Makefile
+36 −0 certora/harnesses/AccessManagedHarness.sol
+116 −0 certora/harnesses/AccessManagerHarness.sol
+14 −0 certora/harnesses/NoncesHarness.sol
+24 −0 certora/specs.json
+34 −0 certora/specs/AccessManaged.spec
+826 −0 certora/specs/AccessManager.spec
+92 −0 certora/specs/Nonces.spec
+5 −0 certora/specs/helpers/helpers.spec
+5 −0 certora/specs/methods/IAccessManaged.spec
+33 −0 certora/specs/methods/IAccessManager.spec
+6 −0 contracts/access/Ownable2StepUpgradeable.sol
+2 −2 contracts/access/manager/AccessManagerUpgradeable.sol
+3 −3 contracts/mocks/AuthorityMockUpgradeable.sol
+51 −23 contracts/mocks/WithInit.sol
+31 −0 contracts/mocks/docs/access-control/AccessControlERC20MintBaseUpgradeable.sol
+30 −0 contracts/mocks/docs/access-control/AccessControlERC20MintMissingUpgradeable.sol
+29 −0 contracts/mocks/docs/access-control/AccessControlERC20MintOnlyRoleUpgradeable.sol
+22 −0 contracts/mocks/docs/access-control/AccessManagedERC20MintBaseUpgradeable.sol
+2 −2 contracts/mocks/docs/access-control/MyContractOwnableUpgradeable.sol
+0 −0 contracts/mocks/token/ERC20VotesTimestampMockUpgradeable.sol
+8 −8 contracts/token/ERC20/extensions/ERC4626Upgradeable.sol
+97 −0 docs/modules/ROOT/images/access-control-multiple.svg
+47 −0 docs/modules/ROOT/images/access-manager-functions.svg
+99 −0 docs/modules/ROOT/images/access-manager.svg
+158 −74 docs/modules/ROOT/pages/access-control.adoc
+31 −15 docs/modules/ROOT/pages/utilities.adoc
+4 −3 hardhat.config.js
+30 −8 hardhat/env-artifacts.js
+26 −10 hardhat/env-contract.js
+1 −1 lib/openzeppelin-contracts
+1,160 −205 package-lock.json
+6 −3 package.json
+1 −1 requirements.txt
+413 −447 test/access/AccessControl.behavior.js
+12 −5 test/access/AccessControl.test.js
+42 −35 test/access/Ownable.test.js
+53 −38 test/access/Ownable2Step.test.js
+17 −13 test/access/extensions/AccessControlDefaultAdminRules.test.js
+13 −6 test/access/extensions/AccessControlEnumerable.test.js
+76 −73 test/access/manager/AccessManaged.test.js
+87 −599 test/access/manager/AccessManager.behavior.js
+454 −0 test/access/manager/AccessManager.predicate.js
+1,000 −1,211 test/access/manager/AccessManager.test.js
+49 −39 test/access/manager/AuthorityUtils.test.js
+15 −33 test/finance/VestingWallet.behavior.js
+44 −34 test/finance/VestingWallet.test.js
+201 −81 test/governance/extensions/GovernorTimelockAccess.test.js
+2 −2 test/governance/extensions/GovernorTimelockCompound.test.js
+37 −19 test/helpers/access-manager.js
+2 −2 test/helpers/account.js
+3 −7 test/helpers/chainid.js
+9 −4 test/helpers/constants.js
+0 −22 test/helpers/create.js
+2 −0 test/helpers/customError.js
+13 −20 test/helpers/eip712.js
+8 −9 test/helpers/erc1967.js
+2 −2 test/helpers/methods.js
+28 −0 test/helpers/namespaced-storage.js
+18 −6 test/helpers/time.js
+2 −2 test/proxy/Clones.test.js
+2 −2 test/proxy/transparent/ProxyAdmin.test.js
+2 −3 test/proxy/transparent/TransparentUpgradeableProxy.behaviour.js
+40 −0 test/sanity.test.js
+1 −1 test/token/common/ERC2981.behavior.js
+27 −7 test/utils/Create2.test.js
+10 −17 test/utils/cryptography/EIP712.test.js
+109 −143 test/utils/cryptography/MerkleProof.test.js
+28 −23 test/utils/introspection/SupportsInterface.behavior.js
2 changes: 1 addition & 1 deletion lib/safe-contracts
2 changes: 1 addition & 1 deletion lib/solady
Submodule solady updated 80 files
+815 −648 .gas-snapshot
+15 −10 .github/workflows/ci-all-via-ir.yml
+2 −1 .github/workflows/ci-woke.yml
+61 −29 .github/workflows/ci.yml
+17 −7 README.md
+ audits/cantina-solady-report.pdf
+1 −23 foundry.toml
+66 −0 js/solady.d.ts
+15 −3 js/solady.js
+6 −0 js/solady.test.js
+3 −2 package.json
+9 −33 src/Milady.sol
+104 −0 src/accounts/ERC1271.sol
+386 −0 src/accounts/ERC4337.sol
+71 −0 src/accounts/ERC4337Factory.sol
+321 −0 src/accounts/ERC6551.sol
+72 −0 src/accounts/ERC6551Proxy.sol
+33 −0 src/accounts/Receiver.sol
+59 −21 src/auth/Ownable.sol
+1 −1 src/auth/OwnableRoles.sol
+39 −48 src/tokens/ERC1155.sol
+63 −92 src/tokens/ERC20.sol
+556 −0 src/tokens/ERC6909.sol
+25 −24 src/tokens/ERC721.sol
+2 −4 src/tokens/WETH.sol
+9 −4 src/utils/CREATE3.sol
+15 −0 src/utils/Clone.sol
+137 −87 src/utils/DynamicBufferLib.sol
+93 −53 src/utils/ECDSA.sol
+53 −26 src/utils/EIP712.sol
+20 −40 src/utils/ERC1967Factory.sol
+7 −2 src/utils/ERC1967FactoryConstants.sol
+365 −230 src/utils/FixedPointMathLib.sol
+815 −0 src/utils/JSONParserLib.sol
+52 −41 src/utils/LibBit.sol
+6 −10 src/utils/LibBitmap.sol
+322 −78 src/utils/LibClone.sol
+4 −4 src/utils/LibPRNG.sol
+2 −0 src/utils/LibRLP.sol
+77 −24 src/utils/LibString.sol
+1 −1 src/utils/LibZip.sol
+21 −7 src/utils/MerkleProofLib.sol
+5 −5 src/utils/Multicallable.sol
+24 −14 src/utils/SSTORE2.sol
+122 −151 src/utils/SafeTransferLib.sol
+255 −98 src/utils/SignatureCheckerLib.sol
+148 −0 src/utils/UUPSUpgradeable.sol
+10 −10 test/DateTimeLib.t.sol
+249 −41 test/DynamicBufferLib.t.sol
+6 −8 test/ECDSA.t.sol
+51 −3 test/EIP712.t.sol
+0 −52 test/ERC20.t.sol
+555 −0 test/ERC4337.t.sol
+75 −0 test/ERC4337Factory.t.sol
+415 −0 test/ERC6551.t.sol
+490 −0 test/ERC6909.t.sol
+481 −8 test/FixedPointMathLib.t.sol
+788 −0 test/JSONParserLib.t.sol
+76 −0 test/LibBit.t.sol
+116 −39 test/LibClone.t.sol
+1 −1 test/LibPRNG.t.sol
+54 −13 test/LibString.t.sol
+9 −1 test/LibZip.t.sol
+43 −0 test/Receiver.t.sol
+28 −0 test/SSTORE2.t.sol
+36 −0 test/SafeTransferLib.t.sol
+19 −0 test/SignatureCheckerLib.t.sol
+84 −0 test/UUPSUpgradeable.t.sol
+2 −2 test/utils/TestPlus.sol
+43 −0 test/utils/mocks/MockEIP712Dynamic.sol
+6 −18 test/utils/mocks/MockERC20.sol
+50 −0 test/utils/mocks/MockERC4337.sol
+55 −0 test/utils/mocks/MockERC6551.sol
+115 −0 test/utils/mocks/MockERC6551Registry.sol
+111 −0 test/utils/mocks/MockERC6909.sol
+34 −0 test/utils/mocks/MockEntryPoint.sol
+2 −2 test/utils/mocks/MockOwnable.sol
+2 −2 test/utils/mocks/MockOwnableRoles.sol
+8 −0 test/utils/mocks/MockReceiver.sol
+46 −0 test/utils/mocks/MockUUPSImplementation.sol
23 changes: 23 additions & 0 deletions script/DeployEverything.s.sol
Original file line number Diff line number Diff line change
@@ -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;
}
}
14 changes: 12 additions & 2 deletions script/1_DeployGuardians.s.sol → script/DeployGuardians.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()));
Expand Down Expand Up @@ -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)
Expand Down
50 changes: 35 additions & 15 deletions script/DeployPuffer.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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());
Expand Down Expand Up @@ -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) {
Expand Down
32 changes: 32 additions & 0 deletions script/DeploymentStructs.sol
Original file line number Diff line number Diff line change
@@ -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
}
Loading

0 comments on commit b9d7ff9

Please sign in to comment.