Skip to content

Commit

Permalink
Remove oz storage checks from GHA (#10)
Browse files Browse the repository at this point in the history
* remove oz foundry lib from gha build

* remove duplicated gha code, remove forge install oz upgrade lib

* use test deploy proxy helper to unblock
  • Loading branch information
Ramarti authored Mar 21, 2024
1 parent d826433 commit bf49b64
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 24 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ jobs:
- name: Run Forge build
run: |
forge --version
forge install OpenZeppelin/openzeppelin-foundry-upgrades --no-git
forge build --force --sizes --skip test --skip script
forge build
id: build

- name: Run Forge tests
Expand All @@ -65,9 +63,6 @@ jobs:
- name: Run solhint
run: npx solhint contracts/**/*.sol

- name: Run solhint
run: npx solhint contracts/*.sol

# - name: Gas Difference
# run:
# forge snapshot --gas-report --diff --desc
Expand Down
9 changes: 6 additions & 3 deletions script/foundry/deployment/Main.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import { ERC20 } from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import { console2 } from "forge-std/console2.sol";
import { Script } from "forge-std/Script.sol";
import { stdJson } from "forge-std/StdJson.sol";
import { Upgrades } from "openzeppelin-foundry-upgrades/Upgrades.sol";
// TODO: fix the install of this plugin for safer deployments
// import { Upgrades } from "openzeppelin-foundry-upgrades/Upgrades.sol";
import { TestProxyHelper } from "test/foundry/utils/TestProxyHelper.sol";

// contracts
import { AccessController } from "contracts/AccessController.sol";
Expand Down Expand Up @@ -205,9 +207,10 @@ contract Main is Script, BroadcastManager, JsonDeploymentHandler {

contractKey = "LicenseRegistry";
_predeploy(contractKey);
address impl = address(new LicenseRegistry());
licenseRegistry = LicenseRegistry(
Upgrades.deployUUPSProxy(
"LicenseRegistry.sol",
TestProxyHelper.deployUUPSProxy(
impl,
abi.encodeCall(
LicenseRegistry.initialize, (
address(governance),
Expand Down
8 changes: 2 additions & 6 deletions test/foundry/mocks/registry/MockLicenseRegistryV2.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,18 @@
pragma solidity 0.8.23;

import { LicenseRegistry } from "contracts/registries/LicenseRegistry.sol";
import { ILicensingModule } from "contracts/interfaces/modules/licensing/ILicensingModule.sol";
import { IDisputeModule } from "contracts/interfaces/modules/dispute/IDisputeModule.sol";
import { Licensing } from "contracts/lib/Licensing.sol";

/// @custom:oz-upgrades-from LicenseRegistry
contract MockLicenseRegistryV2 is LicenseRegistry {

// New storage
/// @custom:storage-location erc7201:story-protocol.MockLicenseRegistryV2
struct MockLicenseRegistryV2Storage {
string foo;
}

// keccak256(abi.encode(uint256(keccak256("story-protocol.MockLicenseRegistryV2")) - 1)) & ~bytes32(uint256(0xff));
bytes32 private constant MockLicenseRegistryV2StorageLocation = 0x6e5bb326ebeeee96c5ce55286f71e5aa42dda8a70ba2a20389e489f13b57b300;
bytes32 private constant MockLicenseRegistryV2StorageLocation =
0x6e5bb326ebeeee96c5ce55286f71e5aa42dda8a70ba2a20389e489f13b57b300;

function setFoo(string memory _foo) external {
_getMockLicenseRegistryV2Storage().foo = _foo;
Expand All @@ -32,5 +29,4 @@ contract MockLicenseRegistryV2 is LicenseRegistry {
$.slot := MockLicenseRegistryV2StorageLocation
}
}

}
10 changes: 3 additions & 7 deletions test/foundry/utils/DeployHelper.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pragma solidity 0.8.23;
// external
import { console2 } from "forge-std/console2.sol"; // console to indicate mock deployment calls.
import { ERC6551Registry } from "erc6551/ERC6551Registry.sol";
import { TestProxyHelper } from "./TestProxyHelper.sol";

// contracts
import { AccessController } from "../../../contracts/AccessController.sol";
Expand Down Expand Up @@ -43,6 +42,8 @@ import { MockLicenseRegistry } from "../mocks/registry/MockLicenseRegistry.sol";
import { MockModuleRegistry } from "../mocks/registry/MockModuleRegistry.sol";
import { MockERC20 } from "../mocks/token/MockERC20.sol";
import { MockERC721 } from "../mocks/token/MockERC721.sol";
import { TestProxyHelper } from "./TestProxyHelper.sol";


contract DeployHelper {
// TODO: three options, auto/mock/real in deploy condition, so that we don't need to manually
Expand Down Expand Up @@ -257,12 +258,7 @@ contract DeployHelper {
licenseRegistry = LicenseRegistry(
TestProxyHelper.deployUUPSProxy(
newIml,
abi.encodeCall(
LicenseRegistry.initialize, (
address(getGovernance()),
"deploy helper"
)
)
abi.encodeCall(LicenseRegistry.initialize, (address(getGovernance()), "deploy helper"))
)
);
console2.log("DeployHelper: Using REAL LicenseRegistry");
Expand Down
5 changes: 2 additions & 3 deletions test/foundry/utils/TestProxyHelper.sol
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
pragma solidity ^0.8.23;
import { ERC1967Proxy } from "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol";

library TestProxyHelper {

/// Deploys a new UUPS proxy with the provided implementation and data
/// @dev WARNING: DO NOT USE IN PRODUCTION, this doesn't check for storage layout compatibility
/// @param impl address of the implementation contract
Expand All @@ -12,4 +11,4 @@ library TestProxyHelper {
ERC1967Proxy proxy = new ERC1967Proxy(impl, data);
return address(proxy);
}
}
}

0 comments on commit bf49b64

Please sign in to comment.