diff --git a/contracts/script/GenerateAlloc.s.sol b/contracts/script/GenerateAlloc.s.sol index 95a1ebf1..855ae54a 100644 --- a/contracts/script/GenerateAlloc.s.sol +++ b/contracts/script/GenerateAlloc.s.sol @@ -144,12 +144,15 @@ contract GenerateAlloc is Script { function setStaking() internal { address impl = Predeploys.getImplAddress(Predeploys.Staking); - address tmp = address(new IPTokenStaking( - 1 gwei, // stakingRounding - 1000, // defaultCommissionRate, 10% - 5000, // defaultMaxCommissionRate, 50% - 500 // defaultMaxCommissionChangeRate, 5% - )); + address tmp = address( + new IPTokenStaking( + 1 gwei, // stakingRounding + 1000, // defaultCommissionRate, 10% + 5000, // defaultMaxCommissionRate, 50% + 500 // defaultMaxCommissionChangeRate, 5% + ) + ); + console2.log("tpm", tmp); vm.etch(impl, tmp.code); diff --git a/contracts/script/TestPrecompileUpgrades.s.sol b/contracts/script/TestPrecompileUpgrades.s.sol index 76228602..18021355 100644 --- a/contracts/script/TestPrecompileUpgrades.s.sol +++ b/contracts/script/TestPrecompileUpgrades.s.sol @@ -16,7 +16,7 @@ import { EIP1967Helper } from "./utils/EIP1967Helper.sol"; import { Predeploys } from "../src/libraries/Predeploys.sol"; abstract contract MockNewFeatures { - function foo() external pure returns(string memory) { + function foo() external pure returns (string memory) { return "bar"; } } @@ -27,17 +27,16 @@ contract IPTokenStakingV2 is IPTokenStaking, MockNewFeatures { uint32 defaultCommissionRate, uint32 defaultMaxCommissionRate, uint32 defaultMaxCommissionChangeRate - ) IPTokenStaking(stakingRounding, defaultCommissionRate, defaultMaxCommissionRate, defaultMaxCommissionChangeRate) { - - } + ) + IPTokenStaking(stakingRounding, defaultCommissionRate, defaultMaxCommissionRate, defaultMaxCommissionChangeRate) + {} } contract IPTokenSlashingV2 is IPTokenSlashing, MockNewFeatures { constructor(address ipTokenStaking) IPTokenSlashing(ipTokenStaking) {} } -contract UpgradeEntrypointV2 is UpgradeEntrypoint, MockNewFeatures { -} +contract UpgradeEntrypointV2 is UpgradeEntrypoint, MockNewFeatures {} /** * @title TestPrecompileUpgrades @@ -60,22 +59,18 @@ contract TestPrecompileUpgrades is Script { vm.startBroadcast(upgradeKey); // ---- Staking - address newImpl = address(new IPTokenStakingV2( - 1 gwei, // stakingRounding - 1000, // defaultCommissionRate, 10% - 5000, // defaultMaxCommissionRate, 50% - 500 // defaultMaxCommissionChangeRate, 5% - )); - ProxyAdmin proxyAdmin = ProxyAdmin( - EIP1967Helper.getAdmin(Predeploys.Staking) + address newImpl = address( + new IPTokenStakingV2( + 1 gwei, // stakingRounding + 1000, // defaultCommissionRate, 10% + 5000, // defaultMaxCommissionRate, 50% + 500 // defaultMaxCommissionChangeRate, 5% + ) ); + ProxyAdmin proxyAdmin = ProxyAdmin(EIP1967Helper.getAdmin(Predeploys.Staking)); console2.log("staking proxy admin", address(proxyAdmin)); console2.log("staking proxy admin owner", proxyAdmin.owner()); - proxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(Predeploys.Staking), - newImpl, - "" - ); + proxyAdmin.upgradeAndCall(ITransparentUpgradeableProxy(Predeploys.Staking), newImpl, ""); if (EIP1967Helper.getImplementation(Predeploys.Staking) != newImpl) { revert("Staking not upgraded"); } @@ -84,19 +79,11 @@ contract TestPrecompileUpgrades is Script { } // ---- Slashing - newImpl = address(new IPTokenSlashingV2( - Predeploys.Staking - )); - proxyAdmin = ProxyAdmin( - EIP1967Helper.getAdmin(Predeploys.Slashing) - ); + newImpl = address(new IPTokenSlashingV2(Predeploys.Staking)); + proxyAdmin = ProxyAdmin(EIP1967Helper.getAdmin(Predeploys.Slashing)); console2.log("slashing proxy admin", address(proxyAdmin)); console2.log("slashing proxy admin owner", proxyAdmin.owner()); - proxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(Predeploys.Slashing), - newImpl, - "" - ); + proxyAdmin.upgradeAndCall(ITransparentUpgradeableProxy(Predeploys.Slashing), newImpl, ""); if (EIP1967Helper.getImplementation(Predeploys.Slashing) != newImpl) { revert("Slashing not upgraded"); } @@ -106,17 +93,11 @@ contract TestPrecompileUpgrades is Script { // ---- Upgrades newImpl = address(new UpgradeEntrypointV2()); - proxyAdmin = ProxyAdmin( - EIP1967Helper.getAdmin(Predeploys.Upgrades) - ); + proxyAdmin = ProxyAdmin(EIP1967Helper.getAdmin(Predeploys.Upgrades)); console2.log("upgrades proxy admin", address(proxyAdmin)); console2.log("upgrades proxy admin owner", proxyAdmin.owner()); - proxyAdmin.upgradeAndCall( - ITransparentUpgradeableProxy(Predeploys.Upgrades), - newImpl, - "" - ); + proxyAdmin.upgradeAndCall(ITransparentUpgradeableProxy(Predeploys.Upgrades), newImpl, ""); if (keccak256(abi.encode(UpgradeEntrypointV2(Predeploys.Upgrades).foo())) != keccak256(abi.encode("bar"))) { revert("Upgraded to wrong iface"); } diff --git a/contracts/test/script/DeployCore.t.sol b/contracts/test/script/DeployCore.t.sol index 285fa7c3..86597b98 100644 --- a/contracts/test/script/DeployCore.t.sol +++ b/contracts/test/script/DeployCore.t.sol @@ -1,30 +1,27 @@ -// // SPDX-License-Identifier: BUSL-1.1 -// pragma solidity ^0.8.23; +// SPDX-License-Identifier: BUSL-1.1 +pragma solidity ^0.8.23; // /* solhint-disable no-console */ // /* solhint-disable max-line-length */ -// /// NOTE: pragma allowlist-secret must be inline (same line as the pubkey hex string) to avoid false positive -// /// flag "Hex High Entropy String" in CI run detect-secrets +/// NOTE: pragma allowlist-secret must be inline (same line as the pubkey hex string) to avoid false positive +/// flag "Hex High Entropy String" in CI run detect-secrets -// import { Test } from "forge-std/Test.sol"; +import { Test } from "forge-std/Test.sol"; // import { DeployCore } from "../../script/DeployCore.s.sol"; -// contract DeployCoreTest is Test { -// DeployCore private deployCore; - -// function setUp() public { -// deployCore = new DeployCore(); -// } - -// function testDeployDeployCore_run() public { -// // Network shall not deploy the IPTokenStaking contract if IPTOKENSTAKING_DEPLOYER_KEY not set. -// vm.chainId(1513); -// // solhint-disable -// vm.expectRevert('vm.envUint: environment variable "IPTOKENSTAKING_DEPLOYER_KEY" not found'); -// deployCore.run(); - -// // Network shall deploy the IPTokenStaking contract. -// vm.setEnv("IPTOKENSTAKING_DEPLOYER_KEY", "0x123456789abcdef"); -// deployCore.run(); -// } -// } +contract DeployCoreTest is Test { + // DeployCore private deployCore; + // function setUp() public { + // deployCore = new DeployCore(); + // } + // function testDeployDeployCore_run() public { + // // Network shall not deploy the IPTokenStaking contract if IPTOKENSTAKING_DEPLOYER_KEY not set. + // vm.chainId(1513); + // // solhint-disable + // vm.expectRevert('vm.envUint: environment variable "IPTOKENSTAKING_DEPLOYER_KEY" not found'); + // deployCore.run(); + // // Network shall deploy the IPTokenStaking contract. + // vm.setEnv("IPTOKENSTAKING_DEPLOYER_KEY", "0x123456789abcdef"); + // deployCore.run(); + // } +} diff --git a/contracts/test/upgrade/UpgradeEntryPoint.t.sol b/contracts/test/upgrade/UpgradeEntryPoint.t.sol index 1cd2a7f6..8e6081f8 100644 --- a/contracts/test/upgrade/UpgradeEntryPoint.t.sol +++ b/contracts/test/upgrade/UpgradeEntryPoint.t.sol @@ -5,13 +5,11 @@ pragma solidity ^0.8.23; /// NOTE: pragma allowlist-secret must be inline (same line as the pubkey hex string) to avoid false positive /// flag "Hex High Entropy String" in CI run detect-secrets -import { UpgradeEntrypoint, IUpgradeEntrypoint } from "../../src/protocol/UpgradeEntrypoint.sol"; -import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; +import { IUpgradeEntrypoint } from "../../src/protocol/UpgradeEntrypoint.sol"; import { Test } from "../utils/Test.sol"; contract UpgradeEntrypointTest is Test { - function testUpgradeEntrypoint_planUpgrade() public { // Network shall allow the protocol owner to submit an upgrade plan. string memory name = "upgrade"; diff --git a/contracts/test/utils/Test.sol b/contracts/test/utils/Test.sol index 28446b72..fd3639e5 100644 --- a/contracts/test/utils/Test.sol +++ b/contracts/test/utils/Test.sol @@ -3,9 +3,7 @@ pragma solidity ^0.8.23; /* solhint-disable no-console */ /* solhint-disable max-line-length */ -import { console2 } from "forge-std/console2.sol"; import { Test as ForgeTest } from "forge-std/Test.sol"; -import { TransparentUpgradeableProxy } from "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol"; import { IPTokenStaking } from "../../src/protocol/IPTokenStaking.sol"; import { IPTokenSlashing } from "../../src/protocol/IPTokenSlashing.sol"; @@ -22,7 +20,7 @@ contract Test is ForgeTest { IPTokenSlashing internal ipTokenSlashing; UpgradeEntrypoint internal upgradeEntrypoint; - function setUp() virtual public { + function setUp() public virtual { GenerateAlloc initializer = new GenerateAlloc(); initializer.disableStateDump(); // Faster tests. Don't call to verify JSON output initializer.setAdminAddresses(upgradeAdmin, admin);