diff --git a/foundry.toml b/foundry.toml index 602df24..9ce667b 100644 --- a/foundry.toml +++ b/foundry.toml @@ -52,7 +52,7 @@ forge-std = "1.17.0" # a bump that changes `src/generated/` needs a new interface version. "@openzeppelin-contracts" = "5.7.0" rain-sol-codegen = "0.1.39" -rain-deploy = "0.1.43" +rain-deploy = "0.1.44" # rain-deploy imports it by path. rain-extrospection = "0.1.31" # rain-extrospection imports it by path. diff --git a/script/Build.sol b/script/Build.sol index 8ce5d76..519b241 100644 --- a/script/Build.sol +++ b/script/Build.sol @@ -7,8 +7,8 @@ import {BeaconProxy} from "@openzeppelin-contracts-5.7.0/proxy/beacon/BeaconProx import {RegistryBeaconProxy} from "./RegistryBeaconProxy.sol"; import {LibCodeGen} from "rain-sol-codegen-0.1.39/src/lib/LibCodeGen.sol"; import {LibFs} from "rain-sol-codegen-0.1.39/src/lib/LibFs.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployConfig} from "rain-deploy-0.1.43/src/lib/LibRainDeployConfig.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployConfig} from "rain-deploy-0.1.44/src/lib/LibRainDeployConfig.sol"; /// @title Build /// @notice Writes `src/generated/BeaconProxy.sol`: OpenZeppelin `BeaconProxy`'s diff --git a/soldeer.lock b/soldeer.lock index 14f63c2..8eaadf3 100644 --- a/soldeer.lock +++ b/soldeer.lock @@ -14,10 +14,10 @@ integrity = "fa706c8a7caf3426c90f75e6aafa3224b0a6c899b490800cf6944e4ec42f9344" [[dependencies]] name = "rain-deploy" -version = "0.1.43" -url = "https://soldeer-revisions.s3.amazonaws.com/rain-deploy/0_1_43_27-11-2026_16:25:33_rain.zip" -checksum = "6b3502113b36819382320351c569bc7dc76106b9dbb141f904e6e8f9f61b7c53" -integrity = "8bedc496af60801ae3c540b23d8b7b036df7145091215e8b2deee0674ba97b69" +version = "0.1.44" +url = "https://soldeer-revisions.s3.amazonaws.com/rain-deploy/0_1_44_30-11-2026_18:00:04_rain.zip" +checksum = "2d014abdc7c24f538b3fe681aca69bd90da02cc98f7f483eeaf0e8cef910a994" +integrity = "46a335fae8cf3ca9aa60cb3d7240426af770ce2c2abd7543991c98e6c8991379" [[dependencies]] name = "rain-extrospection" diff --git a/src/lib/LibCloneCandidates.sol b/src/lib/LibCloneCandidates.sol index 6a20b4c..9c49d30 100644 --- a/src/lib/LibCloneCandidates.sol +++ b/src/lib/LibCloneCandidates.sol @@ -2,9 +2,9 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.25; -import {DeployCandidate, DeployDeclaration} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeployCandidate, DeployDeclaration} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {CloneDeploy} from "./LibRainDeployClone.sol"; import {BeaconProxyDeploy} from "./LibRainDeployBeaconProxy.sol"; import {RegistryBeaconProxyDeploy} from "./LibRainDeployRegistryBeaconProxy.sol"; diff --git a/src/lib/LibICloneableFactoryV7.sol b/src/lib/LibICloneableFactoryV7.sol index 4c38cd0..ccf484f 100644 --- a/src/lib/LibICloneableFactoryV7.sol +++ b/src/lib/LibICloneableFactoryV7.sol @@ -8,7 +8,7 @@ import { } from "../interface/ICloneableFactoryV7.sol"; import {LibICloneableFactoryV5} from "./LibICloneableFactoryV5.sol"; import {REGISTRY_BEACON_PROXY_CREATION_CODE} from "../generated/RegistryBeaconProxy.sol"; -import {IConfigRegistryV5} from "rain-deploy-0.1.43/src/interface/IConfigRegistryV5.sol"; +import {IConfigRegistryV5} from "rain-deploy-0.1.44/src/interface/IConfigRegistryV5.sol"; /// @dev The value type hash a beacon binding must carry. bytes32 constant BEACON_BINDING_VALUE_TYPE_HASH = keccak256("address"); diff --git a/src/lib/LibRainDeployBeacon.sol b/src/lib/LibRainDeployBeacon.sol index 44cff59..dc29546 100644 --- a/src/lib/LibRainDeployBeacon.sol +++ b/src/lib/LibRainDeployBeacon.sol @@ -5,9 +5,9 @@ pragma solidity ^0.8.25; import {IBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/IBeacon.sol"; import {IERC5313} from "@openzeppelin-contracts-5.7.0/interfaces/IERC5313.sol"; import {Ownable2Step} from "@openzeppelin-contracts-5.7.0/access/Ownable2Step.sol"; -import {MIGRATION_HEAD_GENESIS, Prerequisite} from "rain-deploy-0.1.43/src/interface/IMigrationRegistryV5.sol"; -import {LibMigrationRegistry} from "rain-deploy-0.1.43/src/lib/LibMigrationRegistry.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {MIGRATION_HEAD_GENESIS, Prerequisite} from "rain-deploy-0.1.44/src/interface/IMigrationRegistryV5.sol"; +import {LibMigrationRegistry} from "rain-deploy-0.1.44/src/lib/LibMigrationRegistry.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; /// The declared suite a beacon points at, by key, and its owner. /// @param implementation The key of the released suite `implementation()` MUST return the address of. @@ -111,10 +111,15 @@ library LibRainDeployBeacon { /// `LibMigrationRegistry.UnexpectedMigrationRegistryCodeHash` when a transition is declared and the registry is /// not deployed, and `BeaconTransitionsOutOfOrder`. /// @param network The network's name, for the refusal. + /// @param chainId The beacon's network's chain id, for `checkTransitionMigrations`' refusals. /// @param beacon The beacon, resolved: `beacon` set, as `RainDeployVerifyBase.resolveBeacon` sets it. /// @return The state index, as `stateAt` takes it. - function appliedState(string memory network, DeployBeacon memory beacon) internal view returns (uint256) { - checkTransitionMigrations(block.chainid, beacon); + function appliedState(string memory network, uint256 chainId, DeployBeacon memory beacon) + internal + view + returns (uint256) + { + checkTransitionMigrations(chainId, beacon); uint256 state = 0; for (uint256 i = 0; i < beacon.transitions.length; i++) { Prerequisite memory migration = beacon.transitions[i].migration; diff --git a/src/lib/LibRainDeployBeaconDeclarationChecks.sol b/src/lib/LibRainDeployBeaconDeclarationChecks.sol index 32e6a1c..316973b 100644 --- a/src/lib/LibRainDeployBeaconDeclarationChecks.sol +++ b/src/lib/LibRainDeployBeaconDeclarationChecks.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.25; -import {DeployDeclaration} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDeclaration} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {LibRainDeployBeaconResolution} from "./LibRainDeployBeaconResolution.sol"; /// @param chainId The beacon's chain id. diff --git a/src/lib/LibRainDeployBeaconProxy.sol b/src/lib/LibRainDeployBeaconProxy.sol index d48eb2b..07231a0 100644 --- a/src/lib/LibRainDeployBeaconProxy.sol +++ b/src/lib/LibRainDeployBeaconProxy.sol @@ -10,7 +10,7 @@ import {ICloneableFactoryV6} from "../interface/deprecated/ICloneableFactoryV6.s import {BEACON_PROXY_CREATION_CODE} from "../generated/BeaconProxy.sol"; import {LibICloneableFactoryV5} from "./LibICloneableFactoryV5.sol"; -import {DeployDependency} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {CloneParams} from "./LibRainDeployClone.sol"; /// @dev The artifact path a beacon proxy suite carries. It names no compiled source here: see @@ -176,4 +176,11 @@ library LibRainDeployBeaconProxy { } return proxy; } + + /// `beaconProxyDeployStep` without the broadcast. + function beaconProxyDeployStepLocally(Vm, address, bytes memory paramsData) internal returns (address) { + CloneParams memory params = abi.decode(paramsData, (CloneParams)); + return ICloneableFactoryV6(params.factory) + .beaconProxyDeterministicOpenSalt(params.implementation, params.data, params.salt); + } } diff --git a/src/lib/LibRainDeployBeaconResolution.sol b/src/lib/LibRainDeployBeaconResolution.sol index 1f6b004..c1e21eb 100644 --- a/src/lib/LibRainDeployBeaconResolution.sol +++ b/src/lib/LibRainDeployBeaconResolution.sol @@ -8,10 +8,14 @@ import { DeployDeclaration, DeploySuite, DerivationSnapshotRevertFailed -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DerivedDeploy, NoDerivedDeployment} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyBase.sol"; -import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import { + DerivedDeploy, + NoDerivedDeployment, + NotDerivedOnChain +} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyBase.sol"; +import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {ChainBeacon, DeployBeacon, LibRainDeployBeacon} from "./LibRainDeployBeacon.sol"; import {LibRainDeployCloneMechanism} from "./LibRainDeployCloneMechanism.sol"; import { @@ -88,14 +92,15 @@ library LibRainDeployBeaconResolution { DeployBeacon memory beacon = resolved.beacon; // Deliberately rechecked by `checkBeacon`, which holds a beacon to its code hash on its own. if (bytes(beacon.beaconSuite).length != 0) { - checkSuiteOnNetwork(network, resolved.suite, resolved.derived, beacon.beacon); + checkSuiteOnNetwork(network, resolved.chainId, resolved.suite, resolved.derived, beacon.beacon); } - uint256 state = LibRainDeployBeacon.appliedState(network, beacon); + uint256 state = LibRainDeployBeacon.appliedState(network, resolved.chainId, beacon); LibRainDeployBeacon.checkBeacon( network, beacon, resolved.implementationAddresses[state], LibRainDeployBeacon.stateAt(beacon, state).owner ); checkSuiteOnNetwork( network, + resolved.chainId, resolved.implementations[state], resolved.implementationDerived[state], resolved.implementationAddresses[state] @@ -103,17 +108,19 @@ library LibRainDeployBeaconResolution { } /// @param network The selected fork's network. + /// @param chainId The chain id the suite was resolved on, whose derived code hash it is held to. /// @param suite The suite. /// @param derived Its derivation. /// @param deployedAddress Its address on the selected fork. function checkSuiteOnNetwork( string memory network, + uint256 chainId, DeploySuite memory suite, DerivedDeploy memory derived, address deployedAddress ) internal view { LibRainDeploy.checkDeclaredDependencies(network, suite.dependencies); - LibRainDeploy.checkDeployedCode(network, deployedAddress, derived.bytecodeHash); + LibRainDeploy.checkDeployedCode(network, deployedAddress, derivedCodeHash(derived, chainId)); } /// When a beacon is declared, `BeaconOnUncheckedNetwork` for any beacon off `d.networks` before resolving any; then, @@ -221,7 +228,7 @@ library LibRainDeployBeaconResolution { (resolved.suite, resolved.derived) = resolveReleased(d, index, beacon.beaconSuite); beacon.beacon = LibRainDeployDeclaration.mechanismOf(d, resolved.suite).deployedAddress(d, resolved.suite, chainId); - beacon.beaconCodeHash = resolved.derived.bytecodeHash; + beacon.beaconCodeHash = derivedCodeHash(resolved.derived, chainId); } else if (beacon.beacon == address(0) || beacon.beaconCodeHash == bytes32(0)) { revert BeaconUnnamed(chainId, beaconIndex); } @@ -296,7 +303,10 @@ library LibRainDeployBeaconResolution { revert NoDerivedDeployment(suite.suite); } DerivedDeploy memory derivedDeploy = DerivedDeploy({ - suite: suite.suite, deployedAddresses: deployedAddresses, bytecodeHash: deployedAddresses[deployed].codehash + suite: suite.suite, + chainIds: LibRainDeploy.networkChainIds(LibRainDeploy.declaredNetworkConfigs(suite.networks)), + deployedAddresses: deployedAddresses, + bytecodeHashes: codeHashes(deployedAddresses) }); if (!vm.revertToState(snapshotId)) { revert DerivationSnapshotRevertFailed(suite.suite, snapshotId); @@ -330,4 +340,21 @@ library LibRainDeployBeaconResolution { revert BeaconSeatedImplementation(resolved.chainId, beaconIndex, probe.implementation); } } + + function codeHashes(address[] memory addresses) internal view returns (bytes32[] memory) { + bytes32[] memory hashes = new bytes32[](addresses.length); + for (uint256 i = 0; i < addresses.length; i++) { + hashes[i] = addresses[i].codehash; + } + return hashes; + } + + function derivedCodeHash(DerivedDeploy memory derived, uint256 chainId) internal pure returns (bytes32) { + for (uint256 i = 0; i < derived.chainIds.length; i++) { + if (derived.chainIds[i] == chainId && derived.deployedAddresses[i] != address(0)) { + return derived.bytecodeHashes[i]; + } + } + revert NotDerivedOnChain(derived.suite, chainId); + } } diff --git a/src/lib/LibRainDeployClone.sol b/src/lib/LibRainDeployClone.sol index c585812..3425f8f 100644 --- a/src/lib/LibRainDeployClone.sol +++ b/src/lib/LibRainDeployClone.sol @@ -7,7 +7,7 @@ import {console2} from "forge-std-1.17.0/src/console2.sol"; import {ICloneableFactoryV6} from "../interface/deprecated/ICloneableFactoryV6.sol"; import {LibICloneableFactoryV5} from "./LibICloneableFactoryV5.sol"; -import {DeployDependency} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {ChainDeploy} from "./LibRainDeployExtendedNetworks.sol"; uint256 constant EIP1167_CREATION_CODE_PREFIX_LENGTH = 10; @@ -261,4 +261,12 @@ library LibRainDeployClone { vm.stopBroadcast(); return cloneDeployedAddr; } + + /// `cloneDeployStep` without the broadcast. + function cloneDeployStepLocally(Vm, address, bytes memory paramsData) internal returns (address) { + CloneParams memory params = abi.decode(paramsData, (CloneParams)); + return + ICloneableFactoryV6(params.factory) + .cloneDeterministicOpenSalt(params.implementation, params.data, params.salt); + } } diff --git a/src/lib/LibRainDeployCloneBuild.sol b/src/lib/LibRainDeployCloneBuild.sol index a6d2de4..91a52f2 100644 --- a/src/lib/LibRainDeployCloneBuild.sol +++ b/src/lib/LibRainDeployCloneBuild.sol @@ -4,7 +4,7 @@ pragma solidity ^0.8.25; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; import {RAIN_COPYRIGHT_TEXT, RAIN_SPDX_LICENSE_IDENTIFIER} from "rain-sol-codegen-0.1.39/src/lib/LibCodeGen.sol"; -import {DeployDeclaration} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDeclaration} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {ChainDeploy, LibRainDeployExtendedNetworks} from "./LibRainDeployExtendedNetworks.sol"; import {CloneLayerConfig, LibRainDeployCloneMechanism} from "./LibRainDeployCloneMechanism.sol"; diff --git a/src/lib/LibRainDeployCloneMechanism.sol b/src/lib/LibRainDeployCloneMechanism.sol index adceb8e..112e556 100644 --- a/src/lib/LibRainDeployCloneMechanism.sol +++ b/src/lib/LibRainDeployCloneMechanism.sol @@ -11,12 +11,12 @@ import { DeployDeclaration, DeployMechanismHandler, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {ChainDeploy, LibRainDeployExtendedNetworks} from "./LibRainDeployExtendedNetworks.sol"; import {ChainBeacon} from "./LibRainDeployBeacon.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import { CLONE_ARTIFACT_PATH, CLONE_UNANCHORABLE_REASON, @@ -171,6 +171,7 @@ library LibRainDeployCloneMechanism { recordedAddress: recordedAddress, deployStepData: deployStepData, deployStep: deployStep, + deployStepLocally: deployStepLocally, deployLocally: deployLocally, deployLocallyOnChain: deployLocallyOnChain, addUnrecordedNetworks: addUnrecordedNetworks, @@ -490,7 +491,7 @@ library LibRainDeployCloneMechanism { } /// @param suite A registry beacon proxy suite. - /// @return Its factory call, its factory, registry and beacon checked among its dependencies. + /// @return Its factory call, its factory and registry checked among its dependencies. function registryBeaconProxyParams(DeploySuite memory suite) internal pure @@ -499,7 +500,6 @@ library LibRainDeployCloneMechanism { RegistryBeaconProxyParams memory params = abi.decode(payload(suite), (RegistryBeaconProxyParams)); LibRainDeployClone.checkDependencyDeclared(params.factory, suite.dependencies); LibRainDeployClone.checkDependencyDeclared(params.registry, suite.dependencies); - LibRainDeployClone.checkDependencyDeclared(params.beacon, suite.dependencies); return params; } @@ -607,6 +607,21 @@ library LibRainDeployCloneMechanism { isBeaconProxy(suite) ? LibRainDeployBeaconProxy.beaconProxyDeployStep : LibRainDeployClone.cloneDeployStep; } + /// @param suite A clone or beacon proxy suite. + /// @return The local twin of its `deployStep`. + function deployStepLocally(DeployDeclaration memory, DeploySuite memory suite) + internal + pure + returns (function(Vm, address, bytes memory) internal returns (address)) + { + if (isRegistryBeaconProxy(suite)) { + return LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployStepLocally; + } + return isBeaconProxy(suite) + ? LibRainDeployBeaconProxy.beaconProxyDeployStepLocally + : LibRainDeployClone.cloneDeployStepLocally; + } + /// A per-network suite with an entry for every network in `chainIds` its candidate has and it lacks, each at the /// address the candidate's init data derives there. Any other suite, or one whose candidate is under another /// mechanism, is returned as it is. @@ -740,6 +755,17 @@ library LibRainDeployCloneMechanism { return false; } + /// For a consumer's `expectedBytecodeHash` override. + /// @param suite The suite. + /// @param chainId The chain id. + /// @return A registry beacon proxy's stored proxy code hash on `chainId`, else `suite.storedBytecodeHash`. + function expectedBytecodeHash(DeploySuite memory suite, uint256 chainId) internal pure returns (bytes32) { + if (!isRegistryBeaconProxy(suite)) { + return suite.storedBytecodeHash; + } + return LibRainDeployRegistryBeaconProxy.beaconOnNetwork(registryBeaconProxyParams(suite), chainId).proxyCodeHash; + } + /// @param suite A clone or beacon proxy suite. /// @param data The new payload. /// @return A deep copy of `suite` whose mechanism data wraps `data` under its tag; `suite` is not changed. @@ -758,7 +784,11 @@ library LibRainDeployCloneMechanism { function deployParams(Vm vm, DeploySuite memory suite, uint256 chainId, address expected) internal { if (isRegistryBeaconProxy(suite)) { checkRegistryBeaconProxyCreationCode(suite); - vm.etch(expected, suite.storedRuntimeCode); + vm.etch( + expected, + LibRainDeployRegistryBeaconProxy.beaconOnNetwork(registryBeaconProxyParams(suite), chainId) + .proxyRuntimeCode + ); return; } CloneParams memory params = cloneParamsOn(suite, chainId); @@ -893,10 +923,13 @@ library LibRainDeployCloneMechanism { registry: proxy.registry, authority: proxy.authority, beaconName: proxy.beaconName, - beacon: proxy.beacon, + beaconPerNetwork: proxy.beaconPerNetwork, data: proxy.data, - salt: proxy.salt + salt: proxy.salt, + implementation: proxy.implementation, + implementationRuntimeCode: proxy.implementationRuntimeCode }); + LibRainDeployRegistryBeaconProxy.checkProxyCode(params, proxy.runtimeCode); return DeployCandidate({ snapshot: DeploySuite({ suite: proxy.suite, diff --git a/src/lib/LibRainDeployCloneOnChainChecks.sol b/src/lib/LibRainDeployCloneOnChainChecks.sol index 668223b..465bb1c 100644 --- a/src/lib/LibRainDeployCloneOnChainChecks.sol +++ b/src/lib/LibRainDeployCloneOnChainChecks.sol @@ -10,9 +10,9 @@ import { DeployDeclaration, DeployMechanismHandler, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {ChainBeacon, LibRainDeployBeacon} from "./LibRainDeployBeacon.sol"; import { BEACON_PROXY_MECHANISM, @@ -155,7 +155,7 @@ library LibRainDeployCloneOnChainChecks { bytes32 id = LibRainDeployDeclaration.mechanismIdOf(suite); if (id == REGISTRY_BEACON_PROXY_MECHANISM) { LibRainDeployRegistryBeaconProxy.checkBeacon( - network, LibRainDeployCloneMechanism.registryBeaconProxyParams(suite) + network, chainId, LibRainDeployCloneMechanism.registryBeaconProxyParams(suite) ); return; } @@ -192,7 +192,11 @@ library LibRainDeployCloneOnChainChecks { { bytes32 id = LibRainDeployDeclaration.mechanismIdOf(suite); if (id == REGISTRY_BEACON_PROXY_MECHANISM) { - address beacon = LibRainDeployCloneMechanism.registryBeaconProxyParams(suite).beacon; + address beacon = + LibRainDeployRegistryBeaconProxy.beaconOnNetwork( + LibRainDeployCloneMechanism.registryBeaconProxyParams(suite), chainId + ) + .beacon; if (IERC5313(beacon).owner() == deployer) { revert RegistryBeaconOwnedByDeployKey(chainId, beacon); } diff --git a/src/lib/LibRainDeployCloneSnapshot.sol b/src/lib/LibRainDeployCloneSnapshot.sol index 568ef78..10372b4 100644 --- a/src/lib/LibRainDeployCloneSnapshot.sol +++ b/src/lib/LibRainDeployCloneSnapshot.sol @@ -5,14 +5,14 @@ pragma solidity ^0.8.25; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; import {LibCodeGen} from "rain-sol-codegen-0.1.39/src/lib/LibCodeGen.sol"; import {LibFs} from "rain-sol-codegen-0.1.39/src/lib/LibFs.sol"; -import {DeployDeclaration, DeploySuite, SnapshotFile} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeploySuiteIndex} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeployDeclaration, DeploySuite, SnapshotFile} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeploySuiteIndex} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import { FrozenSnapshotMechanismDataAmbiguous, FrozenSnapshotMechanismDataMissing, FrozenSnapshotUnreadable, LibRainDeploySnapshot -} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import {CloneNetworks} from "./LibRainDeployClone.sol"; import { BEACON_PROXY_MECHANISM, diff --git a/src/lib/LibRainDeployExtendedNetworks.sol b/src/lib/LibRainDeployExtendedNetworks.sol index ff59da1..cf7a8b8 100644 --- a/src/lib/LibRainDeployExtendedNetworks.sol +++ b/src/lib/LibRainDeployExtendedNetworks.sol @@ -8,7 +8,7 @@ import { RAIN_COPYRIGHT_TEXT, RAIN_SPDX_LICENSE_IDENTIFIER } from "rain-sol-codegen-0.1.39/src/lib/LibCodeGen.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; /// One network a suite deploys to with its own data, and therefore its own address. struct ChainDeploy { diff --git a/src/lib/LibRainDeployRegistryBeaconProxy.sol b/src/lib/LibRainDeployRegistryBeaconProxy.sol index f389a56..3eaa438 100644 --- a/src/lib/LibRainDeployRegistryBeaconProxy.sol +++ b/src/lib/LibRainDeployRegistryBeaconProxy.sol @@ -2,16 +2,17 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.25; -import {Vm} from "forge-std-1.17.0/src/Vm.sol"; +import {Vm, VmSafe} from "forge-std-1.17.0/src/Vm.sol"; import {console2} from "forge-std-1.17.0/src/console2.sol"; import {IERC5313} from "@openzeppelin-contracts-5.7.0/interfaces/IERC5313.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; import {ICloneableFactoryV7} from "../interface/ICloneableFactoryV7.sol"; import {LibICloneableFactoryV7} from "./LibICloneableFactoryV7.sol"; +import {LibICloneableFactoryV5} from "./LibICloneableFactoryV5.sol"; -import {DeployDependency} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {ConfigRegistry} from "rain-deploy-0.1.43/src/concrete/ConfigRegistry.sol"; -import {IConfigRegistryV5} from "rain-deploy-0.1.43/src/interface/IConfigRegistryV5.sol"; +import {DeployDependency} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {ConfigRegistry} from "rain-deploy-0.1.44/src/concrete/ConfigRegistry.sol"; +import {IConfigRegistryV5} from "rain-deploy-0.1.44/src/interface/IConfigRegistryV5.sol"; /// @dev The artifact path a registry beacon proxy suite carries. string constant REGISTRY_BEACON_PROXY_ARTIFACT_PATH = "rain-factory/RegistryBeaconProxy.sol:RegistryBeaconProxy"; @@ -21,6 +22,16 @@ string constant REGISTRY_BEACON_PROXY_UNANCHORABLE_REASON = "A RegistryBeaconPro "arguments. Its source is not compiled here, so there is no artifact to anchor it to; the beacon the binding " "resolves to, and each implementation it serves, are the anchored contracts."; +/// A registry beacon proxy's beacon, the beacon's expected code hash, and the proxy's expected runtime code and +/// code hash on one chain. +struct RegistryBeaconOnNetwork { + uint256 chainId; + address beacon; + bytes32 codeHash; + bytes32 proxyCodeHash; + bytes proxyRuntimeCode; +} + /// One contract a repo deploys as a registry beacon proxy. /// The address commits to the registry, authority and beacon name, not to the beacon they resolve to or the /// implementation that runs `initialize(data)`. Every beacon the binding resolves to while the proxy is @@ -32,14 +43,17 @@ struct RegistryBeaconProxyDeploy { address registry; address authority; bytes32 beaconName; - /// The beacon the binding MUST resolve to at broadcast. Not committed to by the address. - address beacon; + /// The beacon the binding MUST resolve to at broadcast on each chain. Not committed to by the address. + RegistryBeaconOnNetwork[] beaconPerNetwork; bytes data; bytes32 salt; - /// MUST include the factory, the registry and the beacon. + /// MUST include the factory and the registry. DeployDependency[] dependencies; /// The proxy's runtime code, generated into `src/generated/` and checked by `Git is clean`. bytes runtimeCode; + /// The implementation a beacon serves, so a local deploy runs the real `initialize(data)`. + address implementation; + bytes implementationRuntimeCode; } /// The factory call a registry beacon proxy suite's `mechanismData` carries. @@ -48,9 +62,11 @@ struct RegistryBeaconProxyParams { address registry; address authority; bytes32 beaconName; - address beacon; + RegistryBeaconOnNetwork[] beaconPerNetwork; bytes data; bytes32 salt; + address implementation; + bytes implementationRuntimeCode; } /// @title LibRainDeployRegistryBeaconProxy @@ -71,6 +87,35 @@ library LibRainDeployRegistryBeaconProxy { /// @param resolved The beacon the binding resolves to. error RegistryBeaconProxyBeaconMismatch(string network, address expected, address resolved); + /// Thrown when a suite names no beacon for a chain. + /// @param chainId The chain id. + error RegistryBeaconProxyNoBeaconOnNetwork(uint256 chainId); + + /// Thrown when a suite lists a chain more than once. + /// @param chainId The chain id. + error RegistryBeaconProxyBeaconListedTwice(uint256 chainId); + + /// Thrown when a chain's entry declares a zero proxy code hash or empty proxy runtime code. + /// @param chainId The chain id. + error RegistryBeaconProxyCodeNotDeclared(uint256 chainId); + + /// Thrown when a chain's proxy runtime code does not hash to its declared proxy code hash. + /// @param chainId The chain id. + /// @param declared The declared proxy code hash. + /// @param actual The hash of the declared proxy runtime code. + error RegistryBeaconProxyCodeHashIncoherent(uint256 chainId, bytes32 declared, bytes32 actual); + + /// Thrown when a suite's stored runtime code is no chain's declared proxy runtime code. + /// @param codeHash The hash of the stored runtime code. + error RegistryBeaconProxyRuntimeCodeOnNoNetwork(bytes32 codeHash); + + /// Thrown when the beacon on a network does not carry its declared code hash. + /// @param network The network. + /// @param beacon The beacon. + /// @param expected The declared code hash. + /// @param actual The beacon's code hash. + error RegistryBeaconProxyBeaconCodeHashMismatch(string network, address beacon, bytes32 expected, bytes32 actual); + /// Thrown when a registry beacon proxy deployed on the fork answers `owner()` with the deploy key. /// @param network The network. /// @param proxy The proxy. @@ -105,15 +150,36 @@ library LibRainDeployRegistryBeaconProxy { /// The proxy's runtime code, for a repo's `script/Build.sol` to generate into `src/generated/`. Etches a /// `ConfigRegistry` at `params.registry` binding `beaconName` under `authority` to an `UpgradeableBeacon` at - /// `params.beacon` serving `implementation`, deploys the creation code, then reverts the local state. + /// `chainId`'s beacon serving `implementation`, deploys the creation code, then reverts the local state. /// @param vm The Vm instance to etch with. /// @param params The proxy's factory call. + /// @param chainId The chain whose beacon to simulate. + /// @param implementation The implementation the beacon serves. + /// @param implementationCode The implementation's runtime code. + /// @return The proxy's runtime code. + function registryBeaconProxyRuntimeCodeOnNetwork( + Vm vm, + RegistryBeaconProxyParams memory params, + uint256 chainId, + address implementation, + bytes memory implementationCode + ) internal returns (bytes memory) { + // The entry's proxy code is what this generates, so it is not validated here. + return registryBeaconProxyRuntimeCode( + vm, params, params.beaconPerNetwork[entryIndex(params, chainId)].beacon, implementation, implementationCode + ); + } + + /// @param vm The Vm instance to etch with. + /// @param params The proxy's factory call. + /// @param beacon The beacon to simulate. /// @param implementation The implementation the beacon serves. /// @param implementationCode The implementation's runtime code. /// @return The proxy's runtime code. function registryBeaconProxyRuntimeCode( Vm vm, RegistryBeaconProxyParams memory params, + address beacon, address implementation, bytes memory implementationCode ) internal returns (bytes memory) { @@ -121,15 +187,13 @@ library LibRainDeployRegistryBeaconProxy { vm.etch(params.registry, address(new ConfigRegistry()).code); vm.etch(implementation, implementationCode); // slither-disable-next-line too-many-digits - vm.etch( - params.beacon, bytes.concat(type(UpgradeableBeacon).creationCode, abi.encode(implementation, params.beacon)) - ); + vm.etch(beacon, bytes.concat(type(UpgradeableBeacon).creationCode, abi.encode(implementation, beacon))); // slither-disable-next-line low-level-calls - (bool constructed, bytes memory beaconCode) = params.beacon.call(""); + (bool constructed, bytes memory beaconCode) = beacon.call(""); if (!constructed) { - revert RegistryBeaconProxyBeaconConstructionFailed(params.beacon, implementation); + revert RegistryBeaconProxyBeaconConstructionFailed(beacon, implementation); } - vm.etch(params.beacon, beaconCode); + vm.etch(beacon, beaconCode); uint256 moment = vm.getBlockTimestamp(); // slither-disable-next-line unused-return try IConfigRegistryV5(params.registry).getV5(params.authority, params.beaconName) returns ( @@ -142,7 +206,7 @@ library LibRainDeployRegistryBeaconProxy { vm.warp(moment + 1); vm.prank(params.authority); IConfigRegistryV5(params.registry) - .registerV5(params.authority, params.beaconName, "address", abi.encode(params.beacon), ""); + .registerV5(params.authority, params.beaconName, "address", abi.encode(beacon), ""); bytes memory creationCode = registryBeaconProxyCreationCode(params); address proxy; assembly ("memory-safe") { @@ -159,13 +223,82 @@ library LibRainDeployRegistryBeaconProxy { } /// Refuses `RegistryBeaconProxyBeaconMismatch` unless the binding on the current network resolves to the - /// declared beacon. + /// beacon declared on `chainId`. /// @param network The network. + /// @param chainId The network's chain id. /// @param params The proxy's factory call. - function checkBeacon(string memory network, RegistryBeaconProxyParams memory params) internal view { + function checkBeacon(string memory network, uint256 chainId, RegistryBeaconProxyParams memory params) + internal + view + { + RegistryBeaconOnNetwork memory onNetwork = beaconOnNetwork(params, chainId); address resolved = LibICloneableFactoryV7.resolveBeacon(params.registry, params.authority, params.beaconName); - if (resolved != params.beacon) { - revert RegistryBeaconProxyBeaconMismatch(network, params.beacon, resolved); + if (resolved != onNetwork.beacon) { + revert RegistryBeaconProxyBeaconMismatch(network, onNetwork.beacon, resolved); + } + if (onNetwork.beacon.codehash != onNetwork.codeHash) { + revert RegistryBeaconProxyBeaconCodeHashMismatch( + network, onNetwork.beacon, onNetwork.codeHash, onNetwork.beacon.codehash + ); + } + } + + /// @param params The proxy's factory call. + /// @param chainId The chain id. + /// @return The one entry of `beaconPerNetwork` for `chainId`, refusing `RegistryBeaconProxyNoBeaconOnNetwork` for + /// none, `RegistryBeaconProxyBeaconListedTwice` for several, `RegistryBeaconProxyCodeNotDeclared` for a zero hash + /// or empty code, and + /// `RegistryBeaconProxyCodeHashIncoherent` for code that does not hash to its hash. + function beaconOnNetwork(RegistryBeaconProxyParams memory params, uint256 chainId) + internal + pure + returns (RegistryBeaconOnNetwork memory) + { + RegistryBeaconOnNetwork memory onNetwork = params.beaconPerNetwork[entryIndex(params, chainId)]; + if (onNetwork.proxyCodeHash == bytes32(0) || onNetwork.proxyRuntimeCode.length == 0) { + revert RegistryBeaconProxyCodeNotDeclared(chainId); + } + bytes32 actual = keccak256(onNetwork.proxyRuntimeCode); + if (actual != onNetwork.proxyCodeHash) { + revert RegistryBeaconProxyCodeHashIncoherent(chainId, onNetwork.proxyCodeHash, actual); + } + return onNetwork; + } + + /// @param params The proxy's factory call. + /// @param chainId The chain id. + /// @return The index of the one entry of `beaconPerNetwork` for `chainId`, refusing + /// `RegistryBeaconProxyNoBeaconOnNetwork` for none and `RegistryBeaconProxyBeaconListedTwice` for several. + function entryIndex(RegistryBeaconProxyParams memory params, uint256 chainId) internal pure returns (uint256) { + uint256 found = type(uint256).max; + for (uint256 i = 0; i < params.beaconPerNetwork.length; i++) { + if (params.beaconPerNetwork[i].chainId == chainId) { + if (found != type(uint256).max) { + revert RegistryBeaconProxyBeaconListedTwice(chainId); + } + found = i; + } + } + if (found == type(uint256).max) { + revert RegistryBeaconProxyNoBeaconOnNetwork(chainId); + } + return found; + } + + /// Refuses unless every entry of `beaconPerNetwork` passes `beaconOnNetwork` and `runtimeCode` is one entry's + /// proxy runtime code. + /// @param params The proxy's factory call. + /// @param runtimeCode The suite's stored runtime code. + function checkProxyCode(RegistryBeaconProxyParams memory params, bytes memory runtimeCode) internal pure { + bytes32 codeHash = keccak256(runtimeCode); + bool onSomeNetwork = false; + for (uint256 i = 0; i < params.beaconPerNetwork.length; i++) { + if (beaconOnNetwork(params, params.beaconPerNetwork[i].chainId).proxyCodeHash == codeHash) { + onSomeNetwork = true; + } + } + if (!onSomeNetwork) { + revert RegistryBeaconProxyRuntimeCodeOnNoNetwork(codeHash); } } @@ -194,7 +327,7 @@ library LibRainDeployRegistryBeaconProxy { RegistryBeaconProxyParams memory params = abi.decode(paramsData, (RegistryBeaconProxyParams)); console2.log(" - Registry Beacon Proxy Factory:", params.factory); - checkBeacon(network, params); + checkBeacon(network, block.chainid, params); address expectedAddress = registryBeaconProxyDeployedAddress(params); address factoryPredictedAddress = ICloneableFactoryV7(params.factory) .predictRegistryBeaconProxyAddress( @@ -218,4 +351,34 @@ library LibRainDeployRegistryBeaconProxy { } return proxy; } + + /// `registryBeaconProxyDeployStep` without the broadcast: places the current chain id's beacon serving + /// `params.implementation` and that chain's proxy code, then runs `initialize(data)` as the factory. + function registryBeaconProxyDeployStepLocally(Vm vm, address, bytes memory paramsData) internal returns (address) { + RegistryBeaconProxyParams memory params = abi.decode(paramsData, (RegistryBeaconProxyParams)); + RegistryBeaconOnNetwork memory onNetwork = beaconOnNetwork(params, block.chainid); + address proxy = registryBeaconProxyDeployedAddress(params); + vm.etch(params.implementation, params.implementationRuntimeCode); + // slither-disable-next-line too-many-digits + vm.etch( + onNetwork.beacon, + bytes.concat(type(UpgradeableBeacon).creationCode, abi.encode(params.implementation, onNetwork.beacon)) + ); + // slither-disable-next-line low-level-calls + (bool constructed, bytes memory beaconCode) = onNetwork.beacon.call(""); + if (!constructed) { + revert RegistryBeaconProxyBeaconConstructionFailed(onNetwork.beacon, params.implementation); + } + vm.etch(onNetwork.beacon, beaconCode); + vm.etch(proxy, onNetwork.proxyRuntimeCode); + // Foundry rejects a single prank under the caller's active startPrank, so it is overridden then restored. + (VmSafe.CallerMode mode, address sender, address origin) = vm.readCallers(); + vm.startPrank(params.factory, origin); + LibICloneableFactoryV5.initializeChild(proxy, params.data); + vm.stopPrank(); + if (mode == VmSafe.CallerMode.RecurrentPrank) { + vm.startPrank(sender, origin); + } + return proxy; + } } diff --git a/test/abstract/BeaconVerifyFixture.sol b/test/abstract/BeaconVerifyFixture.sol index 461c205..24b8864 100644 --- a/test/abstract/BeaconVerifyFixture.sol +++ b/test/abstract/BeaconVerifyFixture.sol @@ -9,15 +9,15 @@ import { DeployDependency, DeploySuite, RainDeploySuitesBase -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifyBase} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyBase} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {BeaconState, BeaconTransition, ChainBeacon, DeployBeacon} from "../../src/lib/LibRainDeployBeacon.sol"; import {LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; -import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {Prerequisite} from "rain-deploy-0.1.43/src/interface/IMigrationRegistryV5.sol"; -import {MigrationRegistry} from "rain-deploy-0.1.43/src/concrete/MigrationRegistry.sol"; +import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {Prerequisite} from "rain-deploy-0.1.44/src/interface/IMigrationRegistryV5.sol"; +import {MigrationRegistry} from "rain-deploy-0.1.44/src/concrete/MigrationRegistry.sol"; import {MockDeployable} from "../concrete/MockDeployable.sol"; import {MockDeployableV2} from "../concrete/MockDeployableV2.sol"; import {LibBeaconTest} from "../lib/LibBeaconTest.sol"; diff --git a/test/abstract/ExampleCloneDeploys.sol b/test/abstract/ExampleCloneDeploys.sol index 3e05d52..a9611c1 100644 --- a/test/abstract/ExampleCloneDeploys.sol +++ b/test/abstract/ExampleCloneDeploys.sol @@ -7,12 +7,12 @@ import { DeployDeclaration, DeploySuite, RainDeploySuitesBase -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {LibCloneCandidates} from "../../src/lib/LibCloneCandidates.sol"; import {CLONE_ARTIFACT_PATH, CloneDeploy, LibRainDeployClone} from "../../src/lib/LibRainDeployClone.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {MockCloneFactory} from "../concrete/MockCloneFactory.sol"; import {MockCloneable} from "../concrete/MockCloneable.sol"; import {LibExternalDeployments} from "../lib/LibExternalDeployments.sol"; diff --git a/test/abstract/ExternalDeployBroadcast.sol b/test/abstract/ExternalDeployBroadcast.sol index b35f7e0..fa16a42 100644 --- a/test/abstract/ExternalDeployBroadcast.sol +++ b/test/abstract/ExternalDeployBroadcast.sol @@ -2,9 +2,9 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.25; -import {RainDeployBroadcast} from "rain-deploy-0.1.43/src/abstract/RainDeployBroadcast.sol"; +import {RainDeployBroadcast} from "rain-deploy-0.1.44/src/abstract/RainDeployBroadcast.sol"; import {ExternalDeploySuites} from "./ExternalDeploySuites.sol"; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {MockOriginOwned} from "../concrete/MockOriginOwned.sol"; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; diff --git a/test/abstract/ExternalDeploySuites.sol b/test/abstract/ExternalDeploySuites.sol index 6b765b9..374375f 100644 --- a/test/abstract/ExternalDeploySuites.sol +++ b/test/abstract/ExternalDeploySuites.sol @@ -8,9 +8,9 @@ import { DeploySuite, RainDeploySuitesBase, SnapshotFile -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; /// @title ExternalDeploySuites diff --git a/test/abstract/PerNetworkCloneBeaconVerifyChain.sol b/test/abstract/PerNetworkCloneBeaconVerifyChain.sol index 4c8f370..37956f5 100644 --- a/test/abstract/PerNetworkCloneBeaconVerifyChain.sol +++ b/test/abstract/PerNetworkCloneBeaconVerifyChain.sol @@ -6,11 +6,11 @@ import { DeployDeclaration, DeployDependency, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifyChain} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {BeaconState, ChainBeacon} from "../../src/lib/LibRainDeployBeacon.sol"; import {LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; import {LibCloneCandidates} from "../../src/lib/LibCloneCandidates.sol"; diff --git a/test/abstract/PerNetworkCloneDeploys.sol b/test/abstract/PerNetworkCloneDeploys.sol index dff0fef..7f4614e 100644 --- a/test/abstract/PerNetworkCloneDeploys.sol +++ b/test/abstract/PerNetworkCloneDeploys.sol @@ -3,8 +3,8 @@ pragma solidity ^0.8.25; import {LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {LibCloneCandidates} from "../../src/lib/LibCloneCandidates.sol"; import {LibExternalDeployments} from "../lib/LibExternalDeployments.sol"; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; @@ -12,7 +12,7 @@ import { DeployDeclaration, DeploySuite, RainDeploySuitesBase -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import { CLONE_ARTIFACT_PATH, CloneDeploy, @@ -21,7 +21,7 @@ import { LibRainDeployClone } from "../../src/lib/LibRainDeployClone.sol"; import {ChainDeploy} from "../../src/lib/LibRainDeployExtendedNetworks.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {exampleCloneDependencies, exampleCloneFactory, exampleCloneImplementation} from "./ExampleCloneDeploys.sol"; import { BYTECODE_HASH as PER_NETWORK_CLONE_BYTECODE_HASH, diff --git a/test/abstract/RainDeployVerifyChainBeaconPerNetworkCloneTestBase.sol b/test/abstract/RainDeployVerifyChainBeaconPerNetworkCloneTestBase.sol index 9a2987d..79ef49c 100644 --- a/test/abstract/RainDeployVerifyChainBeaconPerNetworkCloneTestBase.sol +++ b/test/abstract/RainDeployVerifyChainBeaconPerNetworkCloneTestBase.sol @@ -3,9 +3,9 @@ pragma solidity ^0.8.25; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {LibRainDeployBeaconResolution} from "../../src/lib/LibRainDeployBeaconResolution.sol"; import { PER_NETWORK_CLONE_ARBITRUM_ONE_CHAIN_ID, diff --git a/test/abstract/UpgradedPerNetworkCloneDeploys.sol b/test/abstract/UpgradedPerNetworkCloneDeploys.sol index f9966a1..5c7a6d8 100644 --- a/test/abstract/UpgradedPerNetworkCloneDeploys.sol +++ b/test/abstract/UpgradedPerNetworkCloneDeploys.sol @@ -2,11 +2,11 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.25; -import {DeployDeclaration, RainDeploySuitesBase} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeployDeclaration, RainDeploySuitesBase} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {LibCloneCandidates} from "../../src/lib/LibCloneCandidates.sol"; import {CloneDeploy, CloneParams, LibRainDeployClone} from "../../src/lib/LibRainDeployClone.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {MockCloneFactory} from "../concrete/MockCloneFactory.sol"; import {MockCloneableV2} from "../concrete/MockCloneableV2.sol"; import {perNetworkCloneInitData, perNetworkCloneLayers, perNetworkCloneReleased} from "./PerNetworkCloneDeploys.sol"; diff --git a/test/abstract/ZoltuDeployOrAdopt.sol b/test/abstract/ZoltuDeployOrAdopt.sol index 39d756d..5291e52 100644 --- a/test/abstract/ZoltuDeployOrAdopt.sol +++ b/test/abstract/ZoltuDeployOrAdopt.sol @@ -3,7 +3,7 @@ pragma solidity ^0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; /// @title ZoltuDeployOrAdopt /// @notice Puts a clone fixture's factory or implementation at its Zoltu address on a fork, for diff --git a/test/concrete/BeaconOwnerDeploy.sol b/test/concrete/BeaconOwnerDeploy.sol index 889efb0..3f5c067 100644 --- a/test/concrete/BeaconOwnerDeploy.sol +++ b/test/concrete/BeaconOwnerDeploy.sol @@ -6,9 +6,9 @@ import { DeployCandidate, DeployDeclaration, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {ChainBeacon, DeployBeacon} from "../../src/lib/LibRainDeployBeacon.sol"; import {LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; import {ExternalDeployBroadcast} from "../abstract/ExternalDeployBroadcast.sol"; diff --git a/test/concrete/BeaconProxyOnlyDeploySuites.sol b/test/concrete/BeaconProxyOnlyDeploySuites.sol index e3b507c..5da4db7 100644 --- a/test/concrete/BeaconProxyOnlyDeploySuites.sol +++ b/test/concrete/BeaconProxyOnlyDeploySuites.sol @@ -2,9 +2,9 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeployCandidate, DeployDeclaration} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {DeployCandidate, DeployDeclaration} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {BeaconProxyDeploy} from "../../src/lib/LibRainDeployBeaconProxy.sol"; import {LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; import {ExternalDeploySuites} from "../abstract/ExternalDeploySuites.sol"; diff --git a/test/concrete/CloneBuildScriptHarness.sol b/test/concrete/CloneBuildScriptHarness.sol index 4075626..c65fb05 100644 --- a/test/concrete/CloneBuildScriptHarness.sol +++ b/test/concrete/CloneBuildScriptHarness.sol @@ -2,12 +2,12 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {BuildScript, GeneratedContract} from "rain-deploy-0.1.43/src/abstract/BuildScript.sol"; -import {DeployDeclaration, DeploySuite, SnapshotFile} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {BuildScript, GeneratedContract} from "rain-deploy-0.1.44/src/abstract/BuildScript.sol"; +import {DeployDeclaration, DeploySuite, SnapshotFile} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {RAIN_COPYRIGHT_TEXT, RAIN_SPDX_LICENSE_IDENTIFIER} from "rain-sol-codegen-0.1.39/src/lib/LibCodeGen.sol"; import {LibRainDeployCloneBuild} from "../../src/lib/LibRainDeployCloneBuild.sol"; import {ExtendedNetworksDeclaration, LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; diff --git a/test/concrete/ExampleCloneDeploy.sol b/test/concrete/ExampleCloneDeploy.sol index 03b98d3..91ca1cc 100644 --- a/test/concrete/ExampleCloneDeploy.sol +++ b/test/concrete/ExampleCloneDeploy.sol @@ -4,8 +4,8 @@ pragma solidity =0.8.25; import {ExampleCloneDeploys} from "../abstract/ExampleCloneDeploys.sol"; import {ExternalDeployBroadcast} from "../abstract/ExternalDeployBroadcast.sol"; -import {DeployDeclaration, RainDeploySuitesBase} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeployDependency} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDeclaration, RainDeploySuitesBase} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDependency} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {LibExternalDeployments} from "../lib/LibExternalDeployments.sol"; /// @title ExampleCloneDeploy diff --git a/test/concrete/LocalForkVm.sol b/test/concrete/LocalForkVm.sol index 0e4b89c..e6cdd5c 100644 --- a/test/concrete/LocalForkVm.sol +++ b/test/concrete/LocalForkVm.sol @@ -3,7 +3,7 @@ pragma solidity =0.8.25; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; /// @title LocalForkVm /// @notice Forks each catalogue alias as the local EVM at its catalogue chain id, or at `sReportedChainId` once set, diff --git a/test/concrete/MixedCloneBeaconProxyDeploySuites.sol b/test/concrete/MixedCloneBeaconProxyDeploySuites.sol index 24d167e..79845ba 100644 --- a/test/concrete/MixedCloneBeaconProxyDeploySuites.sol +++ b/test/concrete/MixedCloneBeaconProxyDeploySuites.sol @@ -6,7 +6,7 @@ import { DeployCandidate, DeployDeclaration, RainDeploySuitesBase -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {BeaconProxyDeploy} from "../../src/lib/LibRainDeployBeaconProxy.sol"; import {LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; import {ExampleCloneDeploys, exampleCloneDeploys} from "../abstract/ExampleCloneDeploys.sol"; diff --git a/test/concrete/MockRegistryReadingCloneable.sol b/test/concrete/MockRegistryReadingCloneable.sol index 75f0ceb..d115a38 100644 --- a/test/concrete/MockRegistryReadingCloneable.sol +++ b/test/concrete/MockRegistryReadingCloneable.sol @@ -3,7 +3,7 @@ pragma solidity =0.8.25; import {ICloneableV2, ICLONEABLE_V2_SUCCESS} from "../../src/interface/ICloneableV2.sol"; -import {IConfigRegistryV5} from "rain-deploy-0.1.43/src/interface/IConfigRegistryV5.sol"; +import {IConfigRegistryV5} from "rain-deploy-0.1.44/src/interface/IConfigRegistryV5.sol"; /// @title MockRegistryReadingCloneable /// @notice A cloneable whose `initialize` keeps the value a registry binds to a name. diff --git a/test/concrete/OriginOwnedCloneDeploy.sol b/test/concrete/OriginOwnedCloneDeploy.sol index b22f39e..10de204 100644 --- a/test/concrete/OriginOwnedCloneDeploy.sol +++ b/test/concrete/OriginOwnedCloneDeploy.sol @@ -2,10 +2,10 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeployDeclaration} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {DeployDeclaration} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {CloneDeploy} from "../../src/lib/LibRainDeployClone.sol"; import {LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; import {ExternalDeployBroadcast} from "../abstract/ExternalDeployBroadcast.sol"; diff --git a/test/concrete/PerNetworkCloneBuildScriptHarness.sol b/test/concrete/PerNetworkCloneBuildScriptHarness.sol index 08ad9b4..56c90c2 100644 --- a/test/concrete/PerNetworkCloneBuildScriptHarness.sol +++ b/test/concrete/PerNetworkCloneBuildScriptHarness.sol @@ -2,12 +2,12 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {BuildScript, GeneratedContract} from "rain-deploy-0.1.43/src/abstract/BuildScript.sol"; -import {DeployDeclaration, DeploySuite, SnapshotFile} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployConfig} from "rain-deploy-0.1.43/src/lib/LibRainDeployConfig.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {BuildScript, GeneratedContract} from "rain-deploy-0.1.44/src/abstract/BuildScript.sol"; +import {DeployDeclaration, DeploySuite, SnapshotFile} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployConfig} from "rain-deploy-0.1.44/src/lib/LibRainDeployConfig.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {RAIN_COPYRIGHT_TEXT, RAIN_SPDX_LICENSE_IDENTIFIER} from "rain-sol-codegen-0.1.39/src/lib/LibCodeGen.sol"; import {LibRainDeployCloneBuild} from "../../src/lib/LibRainDeployCloneBuild.sol"; import {ExtendedNetworksDeclaration, LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; diff --git a/test/concrete/PerNetworkCloneDeploy.sol b/test/concrete/PerNetworkCloneDeploy.sol index 9f05b65..5ccf7d6 100644 --- a/test/concrete/PerNetworkCloneDeploy.sol +++ b/test/concrete/PerNetworkCloneDeploy.sol @@ -7,9 +7,9 @@ import { DeployDeclaration, DeploySuite, RainDeploySuitesBase -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {ChainDeploy, LibRainDeployExtendedNetworks} from "../../src/lib/LibRainDeployExtendedNetworks.sol"; import {ExtendedNetworksDeclaration, LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; import {ExternalDeployBroadcast} from "../abstract/ExternalDeployBroadcast.sol"; diff --git a/test/concrete/TwoReleasePerNetworkCloneBuildScriptHarness.sol b/test/concrete/TwoReleasePerNetworkCloneBuildScriptHarness.sol index a275058..0e892fb 100644 --- a/test/concrete/TwoReleasePerNetworkCloneBuildScriptHarness.sol +++ b/test/concrete/TwoReleasePerNetworkCloneBuildScriptHarness.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {ExtendedNetworksDeclaration} from "../../src/lib/LibRainDeployCloneMechanism.sol"; import {ChainDeploy} from "../../src/lib/LibRainDeployExtendedNetworks.sol"; import {PerNetworkCloneBuildScriptHarness} from "./PerNetworkCloneBuildScriptHarness.sol"; diff --git a/test/concrete/UpgradedPerNetworkCloneDeploy.sol b/test/concrete/UpgradedPerNetworkCloneDeploy.sol index da931e5..2f12cca 100644 --- a/test/concrete/UpgradedPerNetworkCloneDeploy.sol +++ b/test/concrete/UpgradedPerNetworkCloneDeploy.sol @@ -7,9 +7,9 @@ import { DeployDeclaration, DeploySuite, RainDeploySuitesBase -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {CloneDeploy} from "../../src/lib/LibRainDeployClone.sol"; import {ChainDeploy, LibRainDeployExtendedNetworks} from "../../src/lib/LibRainDeployExtendedNetworks.sol"; import {ExtendedNetworksDeclaration, LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; diff --git a/test/concrete/WideCandidatePerNetworkCloneDeploy.sol b/test/concrete/WideCandidatePerNetworkCloneDeploy.sol index 0fe13a5..13b89e3 100644 --- a/test/concrete/WideCandidatePerNetworkCloneDeploy.sol +++ b/test/concrete/WideCandidatePerNetworkCloneDeploy.sol @@ -2,10 +2,10 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeployCandidate, DeployDeclaration} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {DeployCandidate, DeployDeclaration} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {LibRainDeployCloneMechanism} from "../../src/lib/LibRainDeployCloneMechanism.sol"; import {exampleCloneDependencies} from "../abstract/ExampleCloneDeploys.sol"; import {ExternalDeployBroadcast} from "../abstract/ExternalDeployBroadcast.sol"; diff --git a/test/fixture-mechanism-change/lib/LibMockCloneableReleased.sol b/test/fixture-mechanism-change/lib/LibMockCloneableReleased.sol index 55572aa..a0849a0 100644 --- a/test/fixture-mechanism-change/lib/LibMockCloneableReleased.sol +++ b/test/fixture-mechanism-change/lib/LibMockCloneableReleased.sol @@ -4,8 +4,8 @@ pragma solidity ^0.8.25; // THIS FILE IS AUTOGENERATED BY THE BUILD SCRIPT. DO NOT EDIT BY HAND. -import {DeployDependency, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {DeployDependency, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {CLONE_MECHANISM} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {CLONE_PER_NETWORK_MECHANISM} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; diff --git a/test/lib/LibBeaconProxyTest.sol b/test/lib/LibBeaconProxyTest.sol index f028693..65b7df9 100644 --- a/test/lib/LibBeaconProxyTest.sol +++ b/test/lib/LibBeaconProxyTest.sol @@ -6,7 +6,7 @@ import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/Upgr import {LibRainDeployClone} from "../../src/lib/LibRainDeployClone.sol"; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; import {BeaconProxyDeploy, LibRainDeployBeaconProxy} from "../../src/lib/LibRainDeployBeaconProxy.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {MockBeaconProxyFactory} from "../concrete/MockBeaconProxyFactory.sol"; import {perNetworkCloneInitData} from "../abstract/PerNetworkCloneDeploys.sol"; diff --git a/test/lib/LibBeaconTest.sol b/test/lib/LibBeaconTest.sol index 04b94cc..4f4e874 100644 --- a/test/lib/LibBeaconTest.sol +++ b/test/lib/LibBeaconTest.sol @@ -4,12 +4,12 @@ pragma solidity ^0.8.25; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; -import {DeployDependency, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; -import {LibMigrationRegistry} from "rain-deploy-0.1.43/src/lib/LibMigrationRegistry.sol"; -import {LibMigrationRegistryDeploy} from "rain-deploy-0.1.43/src/lib/LibMigrationRegistryDeploy.sol"; -import {IMigrationRegistryV5, Prerequisite} from "rain-deploy-0.1.43/src/interface/IMigrationRegistryV5.sol"; +import {DeployDependency, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; +import {LibMigrationRegistry} from "rain-deploy-0.1.44/src/lib/LibMigrationRegistry.sol"; +import {LibMigrationRegistryDeploy} from "rain-deploy-0.1.44/src/lib/LibMigrationRegistryDeploy.sol"; +import {IMigrationRegistryV5, Prerequisite} from "rain-deploy-0.1.44/src/interface/IMigrationRegistryV5.sol"; /// @title LibBeaconTest /// @notice The fixtures and assertions the beacon tests share. diff --git a/test/lib/LibExternalDeployments.sol b/test/lib/LibExternalDeployments.sol index a2f7df7..bf80722 100644 --- a/test/lib/LibExternalDeployments.sol +++ b/test/lib/LibExternalDeployments.sol @@ -6,7 +6,7 @@ import { DeployDeclaration, DeployDependency, ExternalDeployment -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; /// @title LibExternalDeployments /// @notice Declares deployments outside a fixture's suites as its external deployments. diff --git a/test/lib/LibRegistryBeaconProxyTest.sol b/test/lib/LibRegistryBeaconProxyTest.sol index 0a935d7..699cd22 100644 --- a/test/lib/LibRegistryBeaconProxyTest.sol +++ b/test/lib/LibRegistryBeaconProxyTest.sol @@ -4,12 +4,13 @@ pragma solidity ^0.8.25; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; -import {ConfigRegistry} from "rain-deploy-0.1.43/src/concrete/ConfigRegistry.sol"; -import {IConfigRegistryV5} from "rain-deploy-0.1.43/src/interface/IConfigRegistryV5.sol"; -import {DeployDependency} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {ConfigRegistry} from "rain-deploy-0.1.44/src/concrete/ConfigRegistry.sol"; +import {IConfigRegistryV5} from "rain-deploy-0.1.44/src/interface/IConfigRegistryV5.sol"; +import {DeployDependency} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {TestCloneFactory} from "../../src/test/TestCloneFactory.sol"; import { LibRainDeployRegistryBeaconProxy, + RegistryBeaconOnNetwork, RegistryBeaconProxyDeploy, RegistryBeaconProxyParams } from "../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; @@ -31,7 +32,7 @@ library LibRegistryBeaconProxyTest { } /// A fresh `TestCloneFactory`, `ConfigRegistry` and `UpgradeableBeacon` serving `implementation`, the beacon - /// bound in the registry. + /// bound in the registry and listed for the current chain. /// @param vm The Vm instance to prank with. /// @param implementation The implementation the beacon serves. /// @param beaconOwner The beacon's owner. @@ -45,18 +46,100 @@ library LibRegistryBeaconProxyTest { address registry = address(new ConfigRegistry()); address beacon = address(new UpgradeableBeacon(implementation, beaconOwner)); bind(vm, registry, beacon); - return RegistryBeaconProxyParams({ + RegistryBeaconProxyParams memory params = RegistryBeaconProxyParams({ factory: address(new TestCloneFactory()), registry: registry, authority: AUTHORITY, beaconName: BEACON_NAME, - beacon: beacon, + beaconPerNetwork: new RegistryBeaconOnNetwork[](0), data: data, - salt: salt + salt: salt, + implementation: implementation, + implementationRuntimeCode: implementation.code }); + params.beaconPerNetwork = onlyOn(vm, params, block.chainid, beacon); + return params; } - /// `params` declared, its factory, registry and beacon its dependencies with the code they hold now. + /// `entry` with the runtime code `params`'s proxy has with the name bound to the entry's beacon, simulated with + /// that beacon serving `params.implementation`, and that code's hash. + /// @param vm The Vm instance to simulate with. + /// @param params The factory call. + /// @param entry The entry. + /// @return `entry` with its proxy code. + function withProxyCode(Vm vm, RegistryBeaconProxyParams memory params, RegistryBeaconOnNetwork memory entry) + internal + returns (RegistryBeaconOnNetwork memory) + { + bytes memory proxyRuntimeCode = LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCode( + vm, params, entry.beacon, params.implementation, params.implementationRuntimeCode + ); + return RegistryBeaconOnNetwork({ + chainId: entry.chainId, + beacon: entry.beacon, + codeHash: entry.codeHash, + proxyCodeHash: keccak256(proxyRuntimeCode), + proxyRuntimeCode: proxyRuntimeCode + }); + } + + /// @param vm The Vm instance to simulate with. + /// @param params The factory call. + /// @param chainId The chain id. + /// @param beacon The beacon. + /// @return `beacon` on `chainId`, at the hash of the code it holds now, with `params`'s proxy code there. + function onNetwork(Vm vm, RegistryBeaconProxyParams memory params, uint256 chainId, address beacon) + internal + returns (RegistryBeaconOnNetwork memory) + { + return withProxyCode( + vm, + params, + RegistryBeaconOnNetwork({ + chainId: chainId, + beacon: beacon, + codeHash: beacon.codehash, + proxyCodeHash: bytes32(0), + proxyRuntimeCode: "" + }) + ); + } + + /// @param vm The Vm instance to simulate with. + /// @param params The factory call. + /// @param chainId The chain id. + /// @param beacon The beacon. + /// @return `onNetwork(vm, params, chainId, beacon)` alone. + function onlyOn(Vm vm, RegistryBeaconProxyParams memory params, uint256 chainId, address beacon) + internal + returns (RegistryBeaconOnNetwork[] memory) + { + RegistryBeaconOnNetwork[] memory beaconPerNetwork = new RegistryBeaconOnNetwork[](1); + beaconPerNetwork[0] = onNetwork(vm, params, chainId, beacon); + return beaconPerNetwork; + } + + /// @param vm The Vm instance to simulate with. + /// @param params The factory call. + /// @param chainIds The chain ids. + /// @param beacon The beacon. + /// @return `params.beaconPerNetwork` then `onNetwork(vm, params, chainId, beacon)` for each of `chainIds`. + function alsoOn(Vm vm, RegistryBeaconProxyParams memory params, uint256[] memory chainIds, address beacon) + internal + returns (RegistryBeaconOnNetwork[] memory) + { + uint256 listed = params.beaconPerNetwork.length; + RegistryBeaconOnNetwork[] memory beaconPerNetwork = new RegistryBeaconOnNetwork[](listed + chainIds.length); + for (uint256 i = 0; i < listed; i++) { + beaconPerNetwork[i] = params.beaconPerNetwork[i]; + } + for (uint256 i = 0; i < chainIds.length; i++) { + beaconPerNetwork[listed + i] = onNetwork(vm, params, chainIds[i], beacon); + } + return beaconPerNetwork; + } + + /// `params` declared, its factory and registry its dependencies with the code they hold now. /// @param suite The suite key. /// @param params The factory call. /// @param runtimeCode The proxy's declared runtime code. @@ -66,33 +149,34 @@ library LibRegistryBeaconProxyTest { view returns (RegistryBeaconProxyDeploy memory) { - DeployDependency[] memory dependencies = new DeployDependency[](3); + DeployDependency[] memory dependencies = new DeployDependency[](2); dependencies[0] = DeployDependency({deployedAddress: params.factory, runtimeCode: params.factory.code}); dependencies[1] = DeployDependency({deployedAddress: params.registry, runtimeCode: params.registry.code}); - dependencies[2] = DeployDependency({deployedAddress: params.beacon, runtimeCode: params.beacon.code}); return RegistryBeaconProxyDeploy({ suite: suite, factory: params.factory, registry: params.registry, authority: params.authority, beaconName: params.beaconName, - beacon: params.beacon, + beaconPerNetwork: params.beaconPerNetwork, data: params.data, salt: params.salt, dependencies: dependencies, - runtimeCode: runtimeCode + runtimeCode: runtimeCode, + implementation: params.implementation, + implementationRuntimeCode: params.implementationRuntimeCode }); } - /// The generated runtime code of `params`'s proxy, its beacon serving the implementation the real beacon at - /// `params.beacon` serves. + /// The generated runtime code of `params`'s proxy on the chain of `params.beaconPerNetwork[0]`, its beacon + /// serving the implementation the real beacon there serves. /// @param vm The Vm instance to generate with. - /// @param params The factory call, a real beacon at its `beacon`. + /// @param params The factory call, a real beacon at its `beaconPerNetwork[0]`. /// @return The proxy's runtime code. function runtimeOf(Vm vm, RegistryBeaconProxyParams memory params) internal returns (bytes memory) { - address implementation = UpgradeableBeacon(params.beacon).implementation(); - return LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCode( - vm, params, implementation, implementation.code + address implementation = UpgradeableBeacon(params.beaconPerNetwork[0].beacon).implementation(); + return LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCodeOnNetwork( + vm, params, params.beaconPerNetwork[0].chainId, implementation, implementation.code ); } } diff --git a/test/lib/LibSuiteIndexPointers.sol b/test/lib/LibSuiteIndexPointers.sol index 1e05d2c..25ec303 100644 --- a/test/lib/LibSuiteIndexPointers.sol +++ b/test/lib/LibSuiteIndexPointers.sol @@ -2,8 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity ^0.8.25; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeploySuiteIndex} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeploySuiteIndex} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; /// @title LibSuiteIndexPointers /// @notice Where an index and its built arrays live in memory, to tell one index, and one build of it, from another. diff --git a/test/src/abstract/BuildScriptClone.t.sol b/test/src/abstract/BuildScriptClone.t.sol index 767516d..df8839f 100644 --- a/test/src/abstract/BuildScriptClone.t.sol +++ b/test/src/abstract/BuildScriptClone.t.sol @@ -3,7 +3,7 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import { LibCodeGen, RAIN_COPYRIGHT_TEXT, diff --git a/test/src/abstract/RainDeployBroadcastBeaconSeat.t.sol b/test/src/abstract/RainDeployBroadcastBeaconSeat.t.sol index f226ff8..91e2e55 100644 --- a/test/src/abstract/RainDeployBroadcastBeaconSeat.t.sol +++ b/test/src/abstract/RainDeployBroadcastBeaconSeat.t.sol @@ -4,9 +4,9 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {Prerequisite} from "rain-deploy-0.1.43/src/interface/IMigrationRegistryV5.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {Prerequisite} from "rain-deploy-0.1.44/src/interface/IMigrationRegistryV5.sol"; import {BeaconState, BeaconTransition, DeployBeacon} from "../../../src/lib/LibRainDeployBeacon.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {perNetworkCloneChainIds} from "../../abstract/PerNetworkCloneDeploys.sol"; diff --git a/test/src/abstract/RainDeployBroadcastClone.t.sol b/test/src/abstract/RainDeployBroadcastClone.t.sol index a723a7a..3d7a082 100644 --- a/test/src/abstract/RainDeployBroadcastClone.t.sol +++ b/test/src/abstract/RainDeployBroadcastClone.t.sol @@ -3,9 +3,9 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; -import {SuiteSeatsDeployKey} from "rain-deploy-0.1.43/src/abstract/RainDeployBroadcast.sol"; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {SuiteSeatsDeployKey} from "rain-deploy-0.1.44/src/abstract/RainDeployBroadcast.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import { CLONE_ARTIFACT_PATH, CloneNetworks, diff --git a/test/src/abstract/RainDeployBroadcastClonePerNetwork.t.sol b/test/src/abstract/RainDeployBroadcastClonePerNetwork.t.sol index 6aedd1c..35e6c76 100644 --- a/test/src/abstract/RainDeployBroadcastClonePerNetwork.t.sol +++ b/test/src/abstract/RainDeployBroadcastClonePerNetwork.t.sol @@ -2,8 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import { ExtendedNetworkAddressMismatch, ExtendedNetworkUnfrozen, diff --git a/test/src/abstract/RainDeployBroadcastSingleClone.t.sol b/test/src/abstract/RainDeployBroadcastSingleClone.t.sol index 1b889b6..52c78bc 100644 --- a/test/src/abstract/RainDeployBroadcastSingleClone.t.sol +++ b/test/src/abstract/RainDeployBroadcastSingleClone.t.sol @@ -2,8 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {ZoltuDeployOrAdopt} from "../../abstract/ZoltuDeployOrAdopt.sol"; import {ExampleCloneDeploy} from "../../concrete/ExampleCloneDeploy.sol"; import {MockCloneFactory} from "../../concrete/MockCloneFactory.sol"; diff --git a/test/src/abstract/RainDeployVerifyBaseBeacon.t.sol b/test/src/abstract/RainDeployVerifyBaseBeacon.t.sol index bfcea37..e93e252 100644 --- a/test/src/abstract/RainDeployVerifyBaseBeacon.t.sol +++ b/test/src/abstract/RainDeployVerifyBaseBeacon.t.sol @@ -19,9 +19,9 @@ import { LibRainDeployBeacon } from "../../../src/lib/LibRainDeployBeacon.sol"; import {LibRainDeployBeaconResolution} from "../../../src/lib/LibRainDeployBeaconResolution.sol"; -import {DeployDeclaration} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeployDeclaration} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {MockDeployable} from "../../concrete/MockDeployable.sol"; import {MockDeployableV2} from "../../concrete/MockDeployableV2.sol"; import {LibBeaconDeclarations} from "../../lib/LibBeaconDeclarations.sol"; diff --git a/test/src/abstract/RainDeployVerifyBaseBeaconChainSeated.t.sol b/test/src/abstract/RainDeployVerifyBaseBeaconChainSeated.t.sol index fae5d1f..f6acbf8 100644 --- a/test/src/abstract/RainDeployVerifyBaseBeaconChainSeated.t.sol +++ b/test/src/abstract/RainDeployVerifyBaseBeaconChainSeated.t.sol @@ -2,8 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {LibRainDeployBeaconDeclarationChecks} from "../../../src/lib/LibRainDeployBeaconDeclarationChecks.sol"; import {BeaconSeatedOwner} from "../../../src/lib/LibRainDeployCloneOnChainChecks.sol"; import {ChainBeacon} from "../../../src/lib/LibRainDeployBeacon.sol"; diff --git a/test/src/abstract/RainDeployVerifyBaseBeaconPerNetworkCloneSeated.t.sol b/test/src/abstract/RainDeployVerifyBaseBeaconPerNetworkCloneSeated.t.sol index 4b33707..5a2ae75 100644 --- a/test/src/abstract/RainDeployVerifyBaseBeaconPerNetworkCloneSeated.t.sol +++ b/test/src/abstract/RainDeployVerifyBaseBeaconPerNetworkCloneSeated.t.sol @@ -8,11 +8,11 @@ import { DeployDeclaration, DeployDependency, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {ChainBeacon} from "../../../src/lib/LibRainDeployBeacon.sol"; import {CLONE_ARTIFACT_PATH, CloneNetworks, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import {ChainDeploy} from "../../../src/lib/LibRainDeployExtendedNetworks.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {MockCloneFactory} from "../../concrete/MockCloneFactory.sol"; import {MockChainRefusingCloneable} from "../../concrete/MockChainRefusingCloneable.sol"; import {LibBeaconDeclarations} from "../../lib/LibBeaconDeclarations.sol"; diff --git a/test/src/abstract/RainDeployVerifyBaseBeaconRevertingRead.t.sol b/test/src/abstract/RainDeployVerifyBaseBeaconRevertingRead.t.sol index 44e025f..aba42dd 100644 --- a/test/src/abstract/RainDeployVerifyBaseBeaconRevertingRead.t.sol +++ b/test/src/abstract/RainDeployVerifyBaseBeaconRevertingRead.t.sol @@ -2,8 +2,8 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {LibRainDeployBeaconDeclarationChecks} from "../../../src/lib/LibRainDeployBeaconDeclarationChecks.sol"; import {ChainBeacon} from "../../../src/lib/LibRainDeployBeacon.sol"; import {MockDeployableV2} from "../../concrete/MockDeployableV2.sol"; diff --git a/test/src/abstract/RainDeployVerifyChainBeacon.t.sol b/test/src/abstract/RainDeployVerifyChainBeacon.t.sol index 7093f1f..3595687 100644 --- a/test/src/abstract/RainDeployVerifyChainBeacon.t.sol +++ b/test/src/abstract/RainDeployVerifyChainBeacon.t.sol @@ -4,12 +4,12 @@ pragma solidity =0.8.25; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DerivedDeploy} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyBase.sol"; -import {RainDeployVerifyChain} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {MIGRATION_HEAD_GENESIS, Prerequisite} from "rain-deploy-0.1.43/src/interface/IMigrationRegistryV5.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DerivedDeploy} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {MIGRATION_HEAD_GENESIS, Prerequisite} from "rain-deploy-0.1.44/src/interface/IMigrationRegistryV5.sol"; import { BeaconState, BeaconTransition, @@ -583,7 +583,7 @@ contract RainDeployVerifyChainBeaconTest is BeaconVerifyFixture, RainDeployVerif vm.expectCall(LibRainDeploy.ZOLTU_FACTORY, type(MockDeployableV2).creationCode, 1); vm.expectCall(LibRainDeploy.ZOLTU_FACTORY, type(MockDeployable).creationCode, 1); DerivedDeploy memory derived = this.externalDeriveUnlessResolved(other, arbitrum()); - assertEq(derived.bytecodeHash, keccak256(type(MockDeployable).runtimeCode)); + assertEq(derived.bytecodeHashes[0], keccak256(type(MockDeployable).runtimeCode)); } function testSuiteWithAResolvedKeyButOtherDependenciesIsDerivedAfresh() external { @@ -699,7 +699,7 @@ contract RainDeployVerifyChainBeaconTest is BeaconVerifyFixture, RainDeployVerif ); vm.expectCall(LibRainDeploy.ZOLTU_FACTORY, type(MockDeployable).creationCode, 1); DerivedDeploy memory derived = this.externalDeriveUnlessResolved(other, arbitrum()); - assertEq(derived.bytecodeHash, keccak256(type(MockDeployable).runtimeCode)); + assertEq(derived.bytecodeHashes[0], keccak256(type(MockDeployable).runtimeCode)); } function testImplementationSuiteMustHaveItsDerivedCodeOffline() external { diff --git a/test/src/abstract/RainDeployVerifyChainBeaconPerNetworkCloneUnrecorded.t.sol b/test/src/abstract/RainDeployVerifyChainBeaconPerNetworkCloneUnrecorded.t.sol index e8c714a..99eff5a 100644 --- a/test/src/abstract/RainDeployVerifyChainBeaconPerNetworkCloneUnrecorded.t.sol +++ b/test/src/abstract/RainDeployVerifyChainBeaconPerNetworkCloneUnrecorded.t.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +import {DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {ChainDeploy, LibRainDeployExtendedNetworks} from "../../../src/lib/LibRainDeployExtendedNetworks.sol"; import { PER_NETWORK_CLONE_POLYGON_CHAIN_ID, diff --git a/test/src/abstract/RainDeployVerifyChainBeaconProxy.t.sol b/test/src/abstract/RainDeployVerifyChainBeaconProxy.t.sol index 95a34f1..50ab8ca 100644 --- a/test/src/abstract/RainDeployVerifyChainBeaconProxy.t.sol +++ b/test/src/abstract/RainDeployVerifyChainBeaconProxy.t.sol @@ -8,9 +8,9 @@ import { } from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {BeaconProxyBeaconUndeclared} from "../../../src/lib/LibRainDeployCloneOnChainChecks.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import { PER_NETWORK_CLONE_ARBITRUM_ONE_CHAIN_ID, PER_NETWORK_CLONE_POLYGON_CHAIN_ID, diff --git a/test/src/abstract/RainDeployVerifyChainClone.t.sol b/test/src/abstract/RainDeployVerifyChainClone.t.sol index b3271ae..21da7e8 100644 --- a/test/src/abstract/RainDeployVerifyChainClone.t.sol +++ b/test/src/abstract/RainDeployVerifyChainClone.t.sol @@ -7,9 +7,9 @@ import { DeployDeclaration, DeploySuite, RainDeploySuitesBase -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifyChain} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {DeployDependency, LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {DeployDependency, LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {ExampleCloneDeploys} from "../../abstract/ExampleCloneDeploys.sol"; import {CloneParams} from "../../../src/lib/LibRainDeployClone.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; diff --git a/test/src/abstract/RainDeployVerifyChainCloneDependencies.t.sol b/test/src/abstract/RainDeployVerifyChainCloneDependencies.t.sol index 956b139..2e563c7 100644 --- a/test/src/abstract/RainDeployVerifyChainCloneDependencies.t.sol +++ b/test/src/abstract/RainDeployVerifyChainCloneDependencies.t.sol @@ -2,10 +2,10 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeployDeclaration, RainDeploySuitesBase} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifyChain} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeployDeclaration, RainDeploySuitesBase} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {LibCloneCandidates} from "../../../src/lib/LibCloneCandidates.sol"; import { PerNetworkCloneDeploys, diff --git a/test/src/abstract/RainDeployVerifyChainClonePerNetwork.t.sol b/test/src/abstract/RainDeployVerifyChainClonePerNetwork.t.sol index 1ea4e39..d9887c6 100644 --- a/test/src/abstract/RainDeployVerifyChainClonePerNetwork.t.sol +++ b/test/src/abstract/RainDeployVerifyChainClonePerNetwork.t.sol @@ -2,9 +2,9 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifyChain} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {PerNetworkCloneDeploys, etchPerNetworkCloneRelease} from "../../abstract/PerNetworkCloneDeploys.sol"; diff --git a/test/src/abstract/RainDeployVerifyChainClonePerNetworkExtended.t.sol b/test/src/abstract/RainDeployVerifyChainClonePerNetworkExtended.t.sol index 98e00f5..d91dec0 100644 --- a/test/src/abstract/RainDeployVerifyChainClonePerNetworkExtended.t.sol +++ b/test/src/abstract/RainDeployVerifyChainClonePerNetworkExtended.t.sol @@ -7,11 +7,11 @@ import { DeployDeclaration, DeploySuite, RainDeploySuitesBase -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifyChain} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {CloneDeploy} from "../../../src/lib/LibRainDeployClone.sol"; import {ChainDeploy, LibRainDeployExtendedNetworks} from "../../../src/lib/LibRainDeployExtendedNetworks.sol"; import { diff --git a/test/src/abstract/RainDeployVerifyChainClonePerNetworkSubset.t.sol b/test/src/abstract/RainDeployVerifyChainClonePerNetworkSubset.t.sol index 64a83dd..f5988c1 100644 --- a/test/src/abstract/RainDeployVerifyChainClonePerNetworkSubset.t.sol +++ b/test/src/abstract/RainDeployVerifyChainClonePerNetworkSubset.t.sol @@ -4,9 +4,9 @@ pragma solidity =0.8.25; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; import {ICloneableFactoryV4} from "../../../src/interface/deprecated/ICloneableFactoryV4.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifyChain} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {CloneNetworks} from "../../../src/lib/LibRainDeployClone.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import { diff --git a/test/src/abstract/RainDeployVerifyChainClonePerNetworkUndeclared.t.sol b/test/src/abstract/RainDeployVerifyChainClonePerNetworkUndeclared.t.sol index daffebc..0b031c6 100644 --- a/test/src/abstract/RainDeployVerifyChainClonePerNetworkUndeclared.t.sol +++ b/test/src/abstract/RainDeployVerifyChainClonePerNetworkUndeclared.t.sol @@ -6,10 +6,10 @@ import { DeployDeclaration, DeploySuite, RainDeploySuitesBase -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifyChain} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {LibCloneCandidates} from "../../../src/lib/LibCloneCandidates.sol"; import { NoPerNetworkCloneAdmin, diff --git a/test/src/abstract/RainDeployVerifyChainClonePerNetworkUnrecorded.t.sol b/test/src/abstract/RainDeployVerifyChainClonePerNetworkUnrecorded.t.sol index 53e9a17..234de53 100644 --- a/test/src/abstract/RainDeployVerifyChainClonePerNetworkUnrecorded.t.sol +++ b/test/src/abstract/RainDeployVerifyChainClonePerNetworkUnrecorded.t.sol @@ -3,10 +3,10 @@ pragma solidity =0.8.25; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {ICloneableFactoryV4} from "../../../src/interface/deprecated/ICloneableFactoryV4.sol"; -import {RainDeployVerifyChain, SuiteRequiredNowhere} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {RainDeployVerifyChain, SuiteRequiredNowhere} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {ExtendedNetworkUnfrozen, LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {CloneNetworks, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import { diff --git a/test/src/abstract/RainDeployVerifyChainClonePerNetworkUnrecordedUpgraded.t.sol b/test/src/abstract/RainDeployVerifyChainClonePerNetworkUnrecordedUpgraded.t.sol index 506337b..b4ac2ec 100644 --- a/test/src/abstract/RainDeployVerifyChainClonePerNetworkUnrecordedUpgraded.t.sol +++ b/test/src/abstract/RainDeployVerifyChainClonePerNetworkUnrecordedUpgraded.t.sol @@ -2,9 +2,9 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifyChain} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyChain.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {ExtendedNetworkUnfrozen, LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {CloneDeploy, CloneNetworks} from "../../../src/lib/LibRainDeployClone.sol"; import { diff --git a/test/src/abstract/RainDeployVerifyChainRegistryBeaconProxy.t.sol b/test/src/abstract/RainDeployVerifyChainRegistryBeaconProxy.t.sol index 4063744..d125c91 100644 --- a/test/src/abstract/RainDeployVerifyChainRegistryBeaconProxy.t.sol +++ b/test/src/abstract/RainDeployVerifyChainRegistryBeaconProxy.t.sol @@ -4,11 +4,12 @@ pragma solidity =0.8.25; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import { LibRainDeployRegistryBeaconProxy, + RegistryBeaconOnNetwork, RegistryBeaconProxyParams } from "../../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; import { @@ -28,7 +29,11 @@ import {LibExternalDeployments} from "../../lib/LibExternalDeployments.sol"; contract RainDeployVerifyChainRegistryBeaconProxyTest is PerNetworkCloneBeaconVerifyChain { string constant PROXY_SUITE = "registry-beacon-proxy@0_0_1"; - RegistryBeaconProxyParams internal sParams; + bytes internal sParamsData; + + function storedParams() internal view returns (RegistryBeaconProxyParams memory) { + return abi.decode(sParamsData, (RegistryBeaconProxyParams)); + } /// Puts the per-network clone release and the beacon at its Polygon clone on every fork, as /// `RainDeployVerifyChainBeaconProxyTest` does, plus a factory and a registry binding the beacon. @@ -45,18 +50,22 @@ contract RainDeployVerifyChainRegistryBeaconProxyTest is PerNetworkCloneBeaconVe vm.etch(addresses[i], release.storedRuntimeCode); vm.makePersistent(addresses[i]); } - sParams = LibRegistryBeaconProxyTest.live(vm, addresses[1], OWNER, hex"deadbeef", bytes32(uint256(5))); - sBeacon = sParams.beacon; - vm.makePersistent(sParams.factory); - vm.makePersistent(sParams.registry); + RegistryBeaconProxyParams memory params = + LibRegistryBeaconProxyTest.live(vm, addresses[1], OWNER, hex"deadbeef", bytes32(uint256(5))); + sBeacon = params.beaconPerNetwork[0].beacon; + params.beaconPerNetwork = + LibRegistryBeaconProxyTest.onlyOn(vm, params, PER_NETWORK_CLONE_POLYGON_CHAIN_ID, sBeacon); + sParamsData = abi.encode(params); + vm.makePersistent(params.factory); + vm.makePersistent(params.registry); vm.makePersistent(sBeacon); - sExternalDeployments.push(LibExternalDeployments.deployedNow(sParams.factory)); - sExternalDeployments.push(LibExternalDeployments.deployedNow(sParams.registry)); + sExternalDeployments.push(LibExternalDeployments.deployedNow(params.factory)); + sExternalDeployments.push(LibExternalDeployments.deployedNow(params.registry)); sExternalDeployments.push(LibExternalDeployments.deployedNow(sBeacon)); } function liveProxySuite() internal returns (DeploySuite memory) { - RegistryBeaconProxyParams memory params = sParams; + RegistryBeaconProxyParams memory params = storedParams(); DeploySuite memory suite = LibRainDeployCloneMechanism.registryBeaconProxyCandidate( LibRegistryBeaconProxyTest.declared(PROXY_SUITE, params, LibRegistryBeaconProxyTest.runtimeOf(vm, params)) @@ -80,17 +89,49 @@ contract RainDeployVerifyChainRegistryBeaconProxyTest is PerNetworkCloneBeaconVe ); } + /// The matrix on local forks over `suite` alone, required on Arbitrum One and Polygon. + function externalCheckOnEveryLocalFork(DeploySuite memory suite) external { + DeploySuite[] memory suites = new DeploySuite[](1); + suites[0] = suite; + DeployDeclaration memory d = declaration(); + suites[0].networks = d.networks; + checkDeployedOnNetworks( + d, Vm(address(new LocalForkVm())), LibRainDeploy.declaredNetworkConfigs(d.networks), suites + ); + } + function testRegistryBeaconProxyWhoseBindingResolvesToItsDeclaredBeaconPasses() external { this.externalCheckOnLocalForks(liveProxySuite()); } + function testRegistryBeaconProxyWithOneBeaconListedForEachChainPassesOnEach() external { + RegistryBeaconProxyParams memory params = storedParams(); + RegistryBeaconOnNetwork[] memory both = new RegistryBeaconOnNetwork[](2); + both[0] = LibRegistryBeaconProxyTest.onNetwork(vm, params, PER_NETWORK_CLONE_ARBITRUM_ONE_CHAIN_ID, sBeacon); + both[1] = LibRegistryBeaconProxyTest.onNetwork(vm, params, PER_NETWORK_CLONE_POLYGON_CHAIN_ID, sBeacon); + params.beaconPerNetwork = both; + sParamsData = abi.encode(params); + this.externalCheckOnEveryLocalFork(liveProxySuite()); + } + + function testRegistryBeaconProxyRequiredOnAChainItDoesNotListIsRefused() external { + DeploySuite memory suite = liveProxySuite(); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyNoBeaconOnNetwork.selector, + PER_NETWORK_CLONE_ARBITRUM_ONE_CHAIN_ID + ) + ); + this.externalCheckOnEveryLocalFork(suite); + } + function testRegistryBeaconProxyWhoseBindingResolvesToAnotherBeaconIsRefused() external { DeploySuite memory suite = liveProxySuite(); address other = address(new UpgradeableBeacon(perNetworkCloneReleaseAddress(PER_NETWORK_CLONE_POLYGON_CHAIN_ID), OWNER)); vm.makePersistent(other); vm.warp(block.timestamp + 1); - LibRegistryBeaconProxyTest.bind(vm, sParams.registry, other); + LibRegistryBeaconProxyTest.bind(vm, storedParams().registry, other); vm.expectRevert( abi.encodeWithSelector( LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconMismatch.selector, @@ -104,13 +145,14 @@ contract RainDeployVerifyChainRegistryBeaconProxyTest is PerNetworkCloneBeaconVe function testRegistryBeaconProxyWithAChangedFactoryIsRefusedNamingNetworkAndDependency() external { DeploySuite memory suite = liveProxySuite(); - bytes32 declared = sParams.factory.codehash; - vm.etch(sParams.factory, type(MockCloneFactory).runtimeCode); + address factory = storedParams().factory; + bytes32 declared = factory.codehash; + vm.etch(factory, type(MockCloneFactory).runtimeCode); vm.expectRevert( abi.encodeWithSelector( LibRainDeploy.DependencyChanged.selector, LibRainDeploy.POLYGON, - sParams.factory, + factory, declared, keccak256(type(MockCloneFactory).runtimeCode) ) diff --git a/test/src/abstract/RainDeployVerifyChainRegistryBeaconProxyBeaconPerNetwork.t.sol b/test/src/abstract/RainDeployVerifyChainRegistryBeaconProxyBeaconPerNetwork.t.sol new file mode 100644 index 0000000..664d795 --- /dev/null +++ b/test/src/abstract/RainDeployVerifyChainRegistryBeaconProxyBeaconPerNetwork.t.sol @@ -0,0 +1,319 @@ +// SPDX-License-Identifier: LicenseRef-DCL-1.0 +// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd +pragma solidity =0.8.25; + +import {Vm} from "forge-std-1.17.0/src/Vm.sol"; +import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; +import { + DeployCandidate, + DeployDeclaration, + DeployDependency, + DeploySuite +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifyChain} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyChain.sol"; +import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {ICloneableFactoryV7} from "../../../src/interface/ICloneableFactoryV7.sol"; +import { + LibRainDeployCloneMechanism, + REGISTRY_BEACON_PROXY_MECHANISM +} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; +import { + LibRainDeployRegistryBeaconProxy, + RegistryBeaconOnNetwork, + RegistryBeaconProxyParams +} from "../../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; +import {LocalForkVm} from "../../concrete/LocalForkVm.sol"; +import {MockCloneableV2} from "../../concrete/MockCloneableV2.sol"; +import {MockOwnable2StepBeacon} from "../../concrete/MockOwnable2StepBeacon.sol"; +import {LibRegistryBeaconProxyTest} from "../../lib/LibRegistryBeaconProxyTest.sol"; +import {LibExternalDeployments} from "../../lib/LibExternalDeployments.sol"; + +/// @title RainDeployVerifyChainRegistryBeaconProxyBeaconPerNetworkTest +/// @notice The chain matrix, on local forks, over one registry beacon proxy suite on Arbitrum One, Base and Polygon, +/// each chain binding the name to its own beacon. +contract RainDeployVerifyChainRegistryBeaconProxyBeaconPerNetworkTest is RainDeployVerifyChain { + string constant PROXY_SUITE = "registry-beacon-proxy@0_0_1"; + string constant PROXY_CANDIDATE = "registry-beacon-proxy"; + + bytes internal sParamsData; + bytes internal sCandidateData; + + function storedParams() internal view returns (RegistryBeaconProxyParams memory) { + return abi.decode(sParamsData, (RegistryBeaconProxyParams)); + } + + function networks() internal pure returns (string[] memory) { + string[] memory names = new string[](3); + names[0] = LibRainDeploy.ARBITRUM_ONE; + names[1] = LibRainDeploy.BASE; + names[2] = LibRainDeploy.POLYGON; + return names; + } + + function expectedBytecodeHash(DeployDeclaration memory, DeploySuite memory suite, uint256 chainId) + internal + pure + override + returns (bytes32) + { + return LibRainDeployCloneMechanism.expectedBytecodeHash(suite, chainId); + } + + function declaration() internal view override returns (DeployDeclaration memory) { + RegistryBeaconProxyParams memory params = storedParams(); + DeployDeclaration memory d; + LibRainDeployDeclaration.extend(d); + LibRainDeployDeclaration.setNetworks(d, networks()); + LibRainDeployCloneMechanism.extend(d); + DeployDependency[] memory externals = new DeployDependency[](2); + externals[0] = LibExternalDeployments.deployedNow(params.factory); + externals[1] = LibExternalDeployments.deployedNow(params.registry); + LibExternalDeployments.add(d, externals); + DeployCandidate[] memory candidates = new DeployCandidate[](1); + candidates[0] = abi.decode(sCandidateData, (DeployCandidate)); + LibRainDeployDeclaration.addCandidates(d, candidates); + return d; + } + + /// A factory and registry, and a beacon per network, each serving its own implementation: an `UpgradeableBeacon` + /// on Arbitrum One, a `MockOwnable2StepBeacon` on Base and an `UpgradeableBeacon` under another owner on Polygon. + function setUp() external { + RegistryBeaconProxyParams memory params = LibRegistryBeaconProxyTest.live( + vm, address(new MockCloneableV2()), address(this), hex"deadbeef", bytes32(uint256(5)) + ); + address[3] memory beacons = [ + params.beaconPerNetwork[0].beacon, + address(new MockOwnable2StepBeacon(address(new MockCloneableV2()), address(this))), + address(new UpgradeableBeacon(address(new MockCloneableV2()), address(0xB0B))) + ]; + SupportedNetwork[] memory configs = LibRainDeploy.declaredNetworkConfigs(networks()); + params.beaconPerNetwork = new RegistryBeaconOnNetwork[](3); + for (uint256 i = 0; i < 3; i++) { + params.beaconPerNetwork[i] = + LibRegistryBeaconProxyTest.onNetwork(vm, params, configs[i].chainId, beacons[i]); + } + sParamsData = abi.encode(params); + sCandidateData = abi.encode( + LibRainDeployCloneMechanism.registryBeaconProxyCandidate( + LibRegistryBeaconProxyTest.declared( + PROXY_CANDIDATE, params, LibRegistryBeaconProxyTest.runtimeOf(vm, params) + ) + ) + ); + } + + function proxySuite(RegistryBeaconProxyParams memory params) internal returns (DeploySuite memory) { + return LibRainDeployCloneMechanism.registryBeaconProxyCandidate( + LibRegistryBeaconProxyTest.declared(PROXY_SUITE, params, LibRegistryBeaconProxyTest.runtimeOf(vm, params)) + ) + .snapshot; + } + + function externalProxySuite(RegistryBeaconProxyParams memory params) external returns (DeploySuite memory) { + return proxySuite(params); + } + + /// Selects `network`'s chain id and binds the name to `beacon` there. + function bindOn(RegistryBeaconProxyParams memory params, SupportedNetwork memory network, address beacon) internal { + vm.chainId(network.chainId); + vm.warp(block.timestamp + 1); + LibRegistryBeaconProxyTest.bind(vm, params.registry, beacon); + } + + /// The matrix on local forks over `suite` alone, required on `network`. + function externalCheckOnLocalForks(DeploySuite memory suite, string memory network) external { + DeploySuite[] memory suites = new DeploySuite[](1); + suites[0] = suite; + string[] memory required = new string[](1); + required[0] = network; + suites[0].networks = required; + DeployDeclaration memory d = declaration(); + checkDeployedOnNetworks( + d, Vm(address(new LocalForkVm())), LibRainDeploy.declaredNetworkConfigs(d.networks), suites + ); + } + + /// On each chain, from the same state: the name bound to that chain's beacon, the proxy simulated locally on that + /// chain is the one the factory deploys there, at the suite's one address, and the matrix passes the suite there. + function testOneSuiteOnItsOwnBeaconOnEachOfThreeChainsPassesOnEach() external { + RegistryBeaconProxyParams memory params = storedParams(); + DeploySuite memory suite = proxySuite(params); + SupportedNetwork[] memory configs = LibRainDeploy.declaredNetworkConfigs(networks()); + uint256 state = vm.snapshotState(); + for (uint256 i = 0; i < configs.length; i++) { + RegistryBeaconOnNetwork memory onNetwork = params.beaconPerNetwork[i]; + bindOn(params, configs[i], onNetwork.beacon); + address implementation = UpgradeableBeacon(onNetwork.beacon).implementation(); + bytes memory simulated = LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCodeOnNetwork( + vm, params, configs[i].chainId, implementation, implementation.code + ); + address proxy = ICloneableFactoryV7(params.factory) + .registryBeaconProxy(params.registry, params.authority, params.beaconName, params.data, params.salt); + assertEq(proxy, suite.storedDeployedAddress, configs[i].name); + assertEq(proxy.code, simulated, configs[i].name); + assertEq(MockCloneableV2(proxy).sInitData(), params.data, configs[i].name); + bytes memory deployed = proxy.code; + // `LocalForkVm`'s forks are the local EVM the derivation initializes into, so no proxy storage there. + assertTrue(vm.revertToState(state)); + bindOn(params, configs[i], onNetwork.beacon); + vm.etch(proxy, deployed); + this.externalCheckOnLocalForks(suite, configs[i].name); + assertTrue(vm.revertToState(state)); + } + } + + /// The suite's one address on every chain, the address a suite listing only one of its beacons has. + function testOneSuiteOverThreeChainsHasOneAddress() external { + RegistryBeaconProxyParams memory params = storedParams(); + DeploySuite memory suite = proxySuite(params); + RegistryBeaconProxyParams memory one = storedParams(); + one.beaconPerNetwork = LibRegistryBeaconProxyTest.onlyOn(vm, one, 42161, params.beaconPerNetwork[0].beacon); + address expected = proxySuite(one).storedDeployedAddress; + assertEq(suite.storedDeployedAddress, expected); + SupportedNetwork[] memory configs = LibRainDeploy.declaredNetworkConfigs(networks()); + DeployDeclaration memory d = declaration(); + for (uint256 i = 0; i < configs.length; i++) { + assertEq(LibRainDeployCloneMechanism.deployedAddress(d, suite, configs[i].chainId), expected); + } + } + + /// Network `i`'s own proxy code etched at the suite's address on its chain, the name bound to `beacon` there. + function liveOn(RegistryBeaconProxyParams memory params, DeploySuite memory suite, uint256 i, address beacon) + internal + { + bindOn(params, LibRainDeploy.declaredNetworkConfigs(networks())[i], beacon); + vm.etch(suite.storedDeployedAddress, storedParams().beaconPerNetwork[i].proxyRuntimeCode); + } + + function testOneSuiteOverThreeChainsPassesOnEachChainHoldingItsOwnProxyCode() external { + RegistryBeaconProxyParams memory params = storedParams(); + DeploySuite memory suite = proxySuite(params); + string[] memory names = networks(); + uint256 state = vm.snapshotState(); + for (uint256 i = 0; i < names.length; i++) { + liveOn(params, suite, i, params.beaconPerNetwork[i].beacon); + this.externalCheckOnLocalForks(suite, names[i]); + assertTrue(vm.revertToState(state)); + } + } + + function testOneSuiteOverThreeChainsIsRefusedOnEachChainHoldingAnotherChainsProxyCode() external { + RegistryBeaconProxyParams memory params = storedParams(); + DeploySuite memory suite = proxySuite(params); + string[] memory names = networks(); + uint256 state = vm.snapshotState(); + for (uint256 i = 0; i < names.length; i++) { + for (uint256 j = 0; j < names.length; j++) { + if (i == j) { + continue; + } + liveOn(params, suite, i, params.beaconPerNetwork[i].beacon); + vm.etch(suite.storedDeployedAddress, params.beaconPerNetwork[j].proxyRuntimeCode); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeploy.CodeHashMismatchOnNetwork.selector, + names[i], + suite.storedDeployedAddress, + params.beaconPerNetwork[i].proxyCodeHash, + params.beaconPerNetwork[j].proxyCodeHash + ) + ); + this.externalCheckOnLocalForks(suite, names[i]); + assertTrue(vm.revertToState(state)); + } + } + } + + function testOneSuiteOverThreeChainsIsRefusedOnAChainBoundToAnotherChainsBeacon() external { + RegistryBeaconProxyParams memory params = storedParams(); + DeploySuite memory suite = proxySuite(params); + liveOn(params, suite, 1, params.beaconPerNetwork[2].beacon); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconMismatch.selector, + LibRainDeploy.BASE, + params.beaconPerNetwork[1].beacon, + params.beaconPerNetwork[2].beacon + ) + ); + this.externalCheckOnLocalForks(suite, LibRainDeploy.BASE); + } + + function testOneSuiteOverThreeChainsIsRefusedOnAChainWhoseBeaconCodeChanged() external { + RegistryBeaconProxyParams memory params = storedParams(); + DeploySuite memory suite = proxySuite(params); + address beacon = params.beaconPerNetwork[1].beacon; + liveOn(params, suite, 1, beacon); + vm.etch(beacon, type(UpgradeableBeacon).runtimeCode); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconCodeHashMismatch.selector, + LibRainDeploy.BASE, + beacon, + params.beaconPerNetwork[1].codeHash, + keccak256(type(UpgradeableBeacon).runtimeCode) + ) + ); + this.externalCheckOnLocalForks(suite, LibRainDeploy.BASE); + } + + function testOneSuiteOverThreeChainsIsRefusedOnAChainWhoseBeaconHasNoCode() external { + RegistryBeaconProxyParams memory params = storedParams(); + DeploySuite memory suite = proxySuite(params); + address beacon = params.beaconPerNetwork[2].beacon; + liveOn(params, suite, 2, beacon); + vm.etch(beacon, ""); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconCodeHashMismatch.selector, + LibRainDeploy.POLYGON, + beacon, + params.beaconPerNetwork[2].codeHash, + beacon.codehash + ) + ); + this.externalCheckOnLocalForks(suite, LibRainDeploy.POLYGON); + } + + function testOneSuiteOverThreeChainsIsRefusedOnAChainItDoesNotList() external { + RegistryBeaconProxyParams memory params = storedParams(); + RegistryBeaconOnNetwork[] memory two = new RegistryBeaconOnNetwork[](2); + two[0] = params.beaconPerNetwork[0]; + two[1] = params.beaconPerNetwork[2]; + params.beaconPerNetwork = two; + DeploySuite memory suite = proxySuite(params); + liveOn(params, suite, 1, storedParams().beaconPerNetwork[1].beacon); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyNoBeaconOnNetwork.selector, uint256(8453) + ) + ); + this.externalCheckOnLocalForks(suite, LibRainDeploy.BASE); + } + + function testOneSuiteOverThreeChainsIsRefusedOnAChainItListsTwice() external { + RegistryBeaconProxyParams memory params = storedParams(); + DeploySuite memory suite = proxySuite(params); + RegistryBeaconOnNetwork[] memory four = new RegistryBeaconOnNetwork[](4); + for (uint256 i = 0; i < 3; i++) { + four[i] = params.beaconPerNetwork[i]; + } + four[3] = params.beaconPerNetwork[1]; + params.beaconPerNetwork = four; + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconListedTwice.selector, uint256(8453) + ) + ); + this.externalProxySuite(params); + suite.mechanismData = abi.encode(REGISTRY_BEACON_PROXY_MECHANISM, abi.encode(params)); + liveOn(params, suite, 1, four[1].beacon); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconListedTwice.selector, uint256(8453) + ) + ); + this.externalCheckOnLocalForks(suite, LibRainDeploy.BASE); + } +} diff --git a/test/src/abstract/RainDeployVerifyDeclarationClone.t.sol b/test/src/abstract/RainDeployVerifyDeclarationClone.t.sol index cfc4b89..64e1686 100644 --- a/test/src/abstract/RainDeployVerifyDeclarationClone.t.sol +++ b/test/src/abstract/RainDeployVerifyDeclarationClone.t.sol @@ -7,13 +7,13 @@ import { DeployDeclaration, DeployDependency, ExternalDeployment -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import { RainDeployDeclarationChecks, UndeclaredDependency -} from "rain-deploy-0.1.43/src/abstract/RainDeployDeclarationChecks.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeployDeclarationChecks.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {CloneDeploy, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import { diff --git a/test/src/abstract/RainDeployVerifySnapshotBaseBeacon.t.sol b/test/src/abstract/RainDeployVerifySnapshotBaseBeacon.t.sol index 361d8d8..d08ad6e 100644 --- a/test/src/abstract/RainDeployVerifySnapshotBaseBeacon.t.sol +++ b/test/src/abstract/RainDeployVerifySnapshotBaseBeacon.t.sol @@ -14,8 +14,8 @@ import { DeployDeclaration, DeployDependency, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {RainDeployVerifySnapshotBase} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifySnapshotBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {RainDeployVerifySnapshotBase} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifySnapshotBase.sol"; import { BeaconState, BeaconTransition, @@ -24,12 +24,12 @@ import { LibRainDeployBeacon } from "../../../src/lib/LibRainDeployBeacon.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {LibBeaconDeclarations} from "../../lib/LibBeaconDeclarations.sol"; import {LibBeaconTest} from "../../lib/LibBeaconTest.sol"; -import {MIGRATION_HEAD_GENESIS, Prerequisite} from "rain-deploy-0.1.43/src/interface/IMigrationRegistryV5.sol"; +import {MIGRATION_HEAD_GENESIS, Prerequisite} from "rain-deploy-0.1.44/src/interface/IMigrationRegistryV5.sol"; import {MockDeployable} from "../../concrete/MockDeployable.sol"; contract RainDeployVerifySnapshotBaseBeaconTest is RainDeployVerifySnapshotBase { diff --git a/test/src/abstract/RainDeployVerifySnapshotBaseClone.t.sol b/test/src/abstract/RainDeployVerifySnapshotBaseClone.t.sol index de4c705..2b89bcc 100644 --- a/test/src/abstract/RainDeployVerifySnapshotBaseClone.t.sol +++ b/test/src/abstract/RainDeployVerifySnapshotBaseClone.t.sol @@ -2,14 +2,14 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import { FrozenSnapshotNotReleased, RainDeployVerifySnapshotBase -} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifySnapshotBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifySnapshotBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import { EXAMPLE_CLONE_RECORD_ROOT, ExampleCloneDeploys, diff --git a/test/src/abstract/RainDeployVerifySnapshotBaseClonePerNetwork.t.sol b/test/src/abstract/RainDeployVerifySnapshotBaseClonePerNetwork.t.sol index b52caa4..44c6e42 100644 --- a/test/src/abstract/RainDeployVerifySnapshotBaseClonePerNetwork.t.sol +++ b/test/src/abstract/RainDeployVerifySnapshotBaseClonePerNetwork.t.sol @@ -2,14 +2,14 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import { FrozenSnapshotNotReleased, FrozenSnapshotsOutnumberReleases, RainDeployVerifySnapshotBase, StoredAddressMismatch -} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifySnapshotBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifySnapshotBase.sol"; import {CloneNetworks} from "../../../src/lib/LibRainDeployClone.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {LibRainDeployCloneSnapshot} from "../../../src/lib/LibRainDeployCloneSnapshot.sol"; @@ -17,7 +17,7 @@ import { FrozenSnapshotAmbiguous, FrozenSnapshotUnreadable, LibRainDeploySnapshot -} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import { PER_NETWORK_CLONE_ARBITRUM_ONE_CHAIN_ID, PER_NETWORK_CLONE_POLYGON_CHAIN_ID, diff --git a/test/src/abstract/RainDeployVerifySnapshotBaseRegistryBeaconProxyBeaconPerNetwork.t.sol b/test/src/abstract/RainDeployVerifySnapshotBaseRegistryBeaconProxyBeaconPerNetwork.t.sol new file mode 100644 index 0000000..88255f8 --- /dev/null +++ b/test/src/abstract/RainDeployVerifySnapshotBaseRegistryBeaconProxyBeaconPerNetwork.t.sol @@ -0,0 +1,195 @@ +// SPDX-License-Identifier: LicenseRef-DCL-1.0 +// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd +pragma solidity =0.8.25; + +import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; +import { + DeployCandidate, + DeployDeclaration, + DeployDependency, + DeploySuite +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DerivedDeploy} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyBase.sol"; +import {RainDeployVerifySnapshotBase} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifySnapshotBase.sol"; +import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; +import { + LibRainDeployRegistryBeaconProxy, + RegistryBeaconOnNetwork, + RegistryBeaconProxyParams +} from "../../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; +import {MockCloneableV2} from "../../concrete/MockCloneableV2.sol"; +import {MockOwnable2StepBeacon} from "../../concrete/MockOwnable2StepBeacon.sol"; +import {LibRegistryBeaconProxyTest} from "../../lib/LibRegistryBeaconProxyTest.sol"; +import {LibExternalDeployments} from "../../lib/LibExternalDeployments.sol"; + +/// @title RainDeployVerifySnapshotBaseRegistryBeaconProxyBeaconPerNetworkTest +/// @notice The snapshot group's derivation and internal consistency over one registry beacon proxy suite on Arbitrum +/// One, Base and Polygon, each chain on its own beacon. +contract RainDeployVerifySnapshotBaseRegistryBeaconProxyBeaconPerNetworkTest is RainDeployVerifySnapshotBase { + string constant PROXY_SUITE = "registry-beacon-proxy@0_0_1"; + string constant PROXY_CANDIDATE = "registry-beacon-proxy"; + + bytes internal sParamsData; + bytes internal sCandidateData; + + function storedParams() internal view returns (RegistryBeaconProxyParams memory) { + return abi.decode(sParamsData, (RegistryBeaconProxyParams)); + } + + function networks() internal pure returns (string[] memory) { + string[] memory names = new string[](3); + names[0] = LibRainDeploy.ARBITRUM_ONE; + names[1] = LibRainDeploy.BASE; + names[2] = LibRainDeploy.POLYGON; + return names; + } + + function expectedBytecodeHash(DeployDeclaration memory, DeploySuite memory suite, uint256 chainId) + internal + pure + override + returns (bytes32) + { + return LibRainDeployCloneMechanism.expectedBytecodeHash(suite, chainId); + } + + function declaration() internal view override returns (DeployDeclaration memory) { + RegistryBeaconProxyParams memory params = storedParams(); + DeployDeclaration memory d; + LibRainDeployDeclaration.extend(d); + LibRainDeployDeclaration.setNetworks(d, networks()); + LibRainDeployCloneMechanism.extend(d); + DeployDependency[] memory externals = new DeployDependency[](2); + externals[0] = LibExternalDeployments.deployedNow(params.factory); + externals[1] = LibExternalDeployments.deployedNow(params.registry); + LibExternalDeployments.add(d, externals); + DeployCandidate[] memory candidates = new DeployCandidate[](1); + candidates[0] = abi.decode(sCandidateData, (DeployCandidate)); + LibRainDeployDeclaration.addCandidates(d, candidates); + return d; + } + + /// A factory and registry, and a beacon per network: an `UpgradeableBeacon` on Arbitrum One, a + /// `MockOwnable2StepBeacon` on Base and an `UpgradeableBeacon` under another owner on Polygon. + function setUp() external { + RegistryBeaconProxyParams memory params = LibRegistryBeaconProxyTest.live( + vm, address(new MockCloneableV2()), address(this), hex"deadbeef", bytes32(uint256(5)) + ); + address[3] memory beacons = [ + params.beaconPerNetwork[0].beacon, + address(new MockOwnable2StepBeacon(address(new MockCloneableV2()), address(this))), + address(new UpgradeableBeacon(address(new MockCloneableV2()), address(0xB0B))) + ]; + SupportedNetwork[] memory configs = LibRainDeploy.declaredNetworkConfigs(networks()); + params.beaconPerNetwork = new RegistryBeaconOnNetwork[](3); + for (uint256 i = 0; i < 3; i++) { + params.beaconPerNetwork[i] = + LibRegistryBeaconProxyTest.onNetwork(vm, params, configs[i].chainId, beacons[i]); + } + sParamsData = abi.encode(params); + DeployCandidate memory candidate = LibRainDeployCloneMechanism.registryBeaconProxyCandidate( + LibRegistryBeaconProxyTest.declared( + PROXY_CANDIDATE, params, LibRegistryBeaconProxyTest.runtimeOf(vm, params) + ) + ); + candidate.snapshot.networks = networks(); + sCandidateData = abi.encode(candidate); + } + + /// `params` declared over the three networks, its runtime code generated on the first listed chain. + function proxySuite(RegistryBeaconProxyParams memory params) internal returns (DeploySuite memory) { + DeploySuite memory suite = + LibRainDeployCloneMechanism.registryBeaconProxyCandidate( + LibRegistryBeaconProxyTest.declared(PROXY_SUITE, params, LibRegistryBeaconProxyTest.runtimeOf(vm, params)) + ) + .snapshot; + suite.networks = networks(); + return suite; + } + + /// `params`'s proxy code on `chainId`, its beacon there serving the implementation it serves now. + function codeOn(RegistryBeaconProxyParams memory params, uint256 chainId) internal returns (bytes memory) { + address implementation = UpgradeableBeacon( + LibRainDeployRegistryBeaconProxy.beaconOnNetwork(params, chainId).beacon + ).implementation(); + return LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCodeOnNetwork( + vm, params, chainId, implementation, implementation.code + ); + } + + function externalDeriveDeployment(DeploySuite memory suite) external returns (DerivedDeploy memory) { + return deriveDeployment(declaration(), LibRainDeployDeclaration.emptyIndex(), suite); + } + + function externalCheckInternallyConsistent(DeploySuite memory suite) external { + checkInternallyConsistent(declaration(), LibRainDeployDeclaration.emptyIndex(), suite); + } + + /// Each chain derives the one address and the code its own beacon gives the proxy, the three codes distinct. + function testDerivationGivesEachChainItsOwnBeaconsCode() external { + RegistryBeaconProxyParams memory params = storedParams(); + DeploySuite memory suite = proxySuite(params); + DerivedDeploy memory derived = this.externalDeriveDeployment(suite); + SupportedNetwork[] memory configs = LibRainDeploy.declaredNetworkConfigs(networks()); + assertEq(derived.chainIds.length, 3); + for (uint256 i = 0; i < 3; i++) { + assertEq(derived.chainIds[i], configs[i].chainId, configs[i].name); + assertEq(derived.deployedAddresses[i], suite.storedDeployedAddress, configs[i].name); + assertEq(derived.bytecodeHashes[i], keccak256(codeOn(params, configs[i].chainId)), configs[i].name); + } + assertNotEq(derived.bytecodeHashes[0], derived.bytecodeHashes[1]); + assertNotEq(derived.bytecodeHashes[1], derived.bytecodeHashes[2]); + assertNotEq(derived.bytecodeHashes[0], derived.bytecodeHashes[2]); + } + + /// One beacon listed for every chain derives the same code on each, the code the suite records. + function testDerivationWithOneBeaconListedPerChainGivesEachChainTheRecordedCode() external { + RegistryBeaconProxyParams memory params = storedParams(); + address beacon = params.beaconPerNetwork[0].beacon; + for (uint256 i = 0; i < 3; i++) { + params.beaconPerNetwork[i] = + LibRegistryBeaconProxyTest.onNetwork(vm, params, params.beaconPerNetwork[i].chainId, beacon); + } + DeploySuite memory suite = proxySuite(params); + DerivedDeploy memory derived = this.externalDeriveDeployment(suite); + for (uint256 i = 0; i < 3; i++) { + assertEq(derived.deployedAddresses[i], suite.storedDeployedAddress); + assertEq(derived.bytecodeHashes[i], suite.storedBytecodeHash); + } + } + + /// A suite listing one beacon for every chain is internally consistent, as a single-beacon suite always was. + function testOneBeaconListedPerChainIsInternallyConsistent() external { + RegistryBeaconProxyParams memory params = storedParams(); + address beacon = params.beaconPerNetwork[0].beacon; + for (uint256 i = 0; i < 3; i++) { + params.beaconPerNetwork[i] = + LibRegistryBeaconProxyTest.onNetwork(vm, params, params.beaconPerNetwork[i].chainId, beacon); + } + this.externalCheckInternallyConsistent(proxySuite(params)); + } + + /// A suite whose chains each have their own beacon is internally consistent: each chain's derived code is checked + /// against the code that chain's beacon gives the proxy, not against one chain's. + function testEachChainOnItsOwnBeaconIsInternallyConsistent() external { + this.externalCheckInternallyConsistent(proxySuite(storedParams())); + } + + /// A chain the suite's networks name but its beacon list does not is refused while deriving. + function testDerivationRefusesANetworkWithNoBeaconListed() external { + RegistryBeaconProxyParams memory params = storedParams(); + RegistryBeaconOnNetwork[] memory two = new RegistryBeaconOnNetwork[](2); + two[0] = params.beaconPerNetwork[0]; + two[1] = params.beaconPerNetwork[2]; + params.beaconPerNetwork = two; + DeploySuite memory suite = proxySuite(params); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyNoBeaconOnNetwork.selector, uint256(8453) + ) + ); + this.externalDeriveDeployment(suite); + } +} diff --git a/test/src/lib/LibCloneCandidates.t.sol b/test/src/lib/LibCloneCandidates.t.sol index f1dfca2..d09f203 100644 --- a/test/src/lib/LibCloneCandidates.t.sol +++ b/test/src/lib/LibCloneCandidates.t.sol @@ -7,8 +7,8 @@ import { DeployCandidate, DeployDeclaration, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {BeaconProxyDeploy} from "../../../src/lib/LibRainDeployBeaconProxy.sol"; import {CloneDeploy, CloneNetworks, CloneParams, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import { @@ -16,7 +16,7 @@ import { LibRainDeployCloneMechanism } from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {LibCloneCandidates, NoFactoryDeploys} from "../../../src/lib/LibCloneCandidates.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import { exampleCloneDeploys, exampleCloneFactory, diff --git a/test/src/lib/LibICloneableFactoryV7.registryBeaconProxy.t.sol b/test/src/lib/LibICloneableFactoryV7.registryBeaconProxy.t.sol index d02977e..a8ca827 100644 --- a/test/src/lib/LibICloneableFactoryV7.registryBeaconProxy.t.sol +++ b/test/src/lib/LibICloneableFactoryV7.registryBeaconProxy.t.sol @@ -14,7 +14,7 @@ import {TestCloneFactory} from "../../../src/test/TestCloneFactory.sol"; import {TestCloneable} from "../../../src/test/TestCloneable.sol"; import {RegistryBeaconProxy} from "../../../script/RegistryBeaconProxy.sol"; import {TestRegistryBeaconSource, TestNameNotRegistered} from "../../concrete/TestRegistryBeaconSource.sol"; -import {IConfigRegistryV5} from "rain-deploy-0.1.43/src/interface/IConfigRegistryV5.sol"; +import {IConfigRegistryV5} from "rain-deploy-0.1.44/src/interface/IConfigRegistryV5.sol"; /// @title LibICloneableFactoryV7RegistryBeaconProxyTest /// `registryBeaconProxy` through `TestCloneFactory`: the beacon comes from the diff --git a/test/src/lib/LibRainDeployBeacon.t.sol b/test/src/lib/LibRainDeployBeacon.t.sol index 25d6d76..1da25c9 100644 --- a/test/src/lib/LibRainDeployBeacon.t.sol +++ b/test/src/lib/LibRainDeployBeacon.t.sol @@ -10,15 +10,15 @@ import { DeployBeacon, LibRainDeployBeacon } from "../../../src/lib/LibRainDeployBeacon.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibMigrationRegistry} from "rain-deploy-0.1.43/src/lib/LibMigrationRegistry.sol"; -import {LibMigrationRegistryDeploy} from "rain-deploy-0.1.43/src/lib/LibMigrationRegistryDeploy.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibMigrationRegistry} from "rain-deploy-0.1.44/src/lib/LibMigrationRegistry.sol"; +import {LibMigrationRegistryDeploy} from "rain-deploy-0.1.44/src/lib/LibMigrationRegistryDeploy.sol"; import { IMigrationRegistryV5, MIGRATION_HEAD_GENESIS, Prerequisite -} from "rain-deploy-0.1.43/src/interface/IMigrationRegistryV5.sol"; -import {MigrationRegistry} from "rain-deploy-0.1.43/src/concrete/MigrationRegistry.sol"; +} from "rain-deploy-0.1.44/src/interface/IMigrationRegistryV5.sol"; +import {MigrationRegistry} from "rain-deploy-0.1.44/src/concrete/MigrationRegistry.sol"; import {MockDeployableV2} from "../../concrete/MockDeployableV2.sol"; import {MockOwnable2StepBeacon} from "../../concrete/MockOwnable2StepBeacon.sol"; import {MockFallbackBeacon} from "../../concrete/MockFallbackBeacon.sol"; @@ -130,7 +130,7 @@ contract LibRainDeployBeaconTest is Test { } function externalAppliedState(DeployBeacon memory beacon) external view returns (uint256) { - return LibRainDeployBeacon.appliedState(NETWORK, beacon); + return LibRainDeployBeacon.appliedState(NETWORK, block.chainid, beacon); } function externalCheckBeacon(DeployBeacon memory beacon, address implementation, address owner) external view { diff --git a/test/src/lib/LibRainDeployBeaconProxy.t.sol b/test/src/lib/LibRainDeployBeaconProxy.t.sol index d48681a..8d1427d 100644 --- a/test/src/lib/LibRainDeployBeaconProxy.t.sol +++ b/test/src/lib/LibRainDeployBeaconProxy.t.sol @@ -10,7 +10,7 @@ import { import {ICloneableFactoryV7} from "../../../src/interface/ICloneableFactoryV7.sol"; import {BEACON_PROXY_CREATION_CODE} from "../../../src/generated/BeaconProxy.sol"; import {DelegatedBeacon} from "../../../src/lib/LibICloneableFactoryV5.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {CloneParams} from "../../../src/lib/LibRainDeployClone.sol"; import {BEACON_PROXY_ARTIFACT_PATH, LibRainDeployBeaconProxy} from "../../../src/lib/LibRainDeployBeaconProxy.sol"; import {EXAMPLE_BEACON_PROXY_RUNTIME_CODE, LibBeaconProxyTest} from "../../lib/LibBeaconProxyTest.sol"; diff --git a/test/src/lib/LibRainDeployBeaconResolution.chainGatedPerNetworkClone.t.sol b/test/src/lib/LibRainDeployBeaconResolution.chainGatedPerNetworkClone.t.sol index 3f3c861..5d805b7 100644 --- a/test/src/lib/LibRainDeployBeaconResolution.chainGatedPerNetworkClone.t.sol +++ b/test/src/lib/LibRainDeployBeaconResolution.chainGatedPerNetworkClone.t.sol @@ -6,10 +6,10 @@ import { DeployDeclaration, DeployDependency, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DerivedDeploy, NoDerivedDeployment} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyBase.sol"; -import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DerivedDeploy, NoDerivedDeployment} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyBase.sol"; +import {LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {ChainBeacon} from "../../../src/lib/LibRainDeployBeacon.sol"; import {LibRainDeployBeaconResolution} from "../../../src/lib/LibRainDeployBeaconResolution.sol"; import {CLONE_ARTIFACT_PATH, CloneNetworks, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; @@ -124,7 +124,7 @@ contract LibRainDeployBeaconResolutionChainGatedPerNetworkCloneTest is BeaconVer assertEq(derived.deployedAddresses.length, 2); assertEq(derived.deployedAddresses[0], arbitrumClone); assertEq(derived.deployedAddresses[1], baseClone); - assertEq(derived.bytecodeHash, keccak256(suite.storedRuntimeCode)); + assertEq(derived.bytecodeHashes[0], keccak256(suite.storedRuntimeCode)); assertEq(block.chainid, chainId); assertEq(arbitrumClone.code.length, 0); assertEq(baseClone.code.length, 0); @@ -164,7 +164,7 @@ contract LibRainDeployBeaconResolutionChainGatedPerNetworkCloneTest is BeaconVer assertEq(derived.deployedAddresses.length, 2); assertEq(derived.deployedAddresses[0], address(0)); assertEq(derived.deployedAddresses[1], baseClone); - assertEq(derived.bytecodeHash, keccak256(suite.storedRuntimeCode)); + assertEq(derived.bytecodeHashes[1], keccak256(suite.storedRuntimeCode)); } function testDerivationRecordingNoCloneOnAnyOfItsNetworksIsRefused() external { diff --git a/test/src/lib/LibRainDeployBeaconResolution.sharedIndex.t.sol b/test/src/lib/LibRainDeployBeaconResolution.sharedIndex.t.sol index d022022..6afe107 100644 --- a/test/src/lib/LibRainDeployBeaconResolution.sharedIndex.t.sol +++ b/test/src/lib/LibRainDeployBeaconResolution.sharedIndex.t.sol @@ -3,13 +3,13 @@ pragma solidity =0.8.25; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {DeploySuiteIndex} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {DeploySuiteIndex} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import { LibRainDeployZoltuMechanism, ZOLTU_MECHANISM_ID -} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {ChainBeacon} from "../../../src/lib/LibRainDeployBeacon.sol"; import {LibRainDeployBeaconResolution, ResolvedBeacon} from "../../../src/lib/LibRainDeployBeaconResolution.sol"; import {LibBeaconDeclarations} from "../../lib/LibBeaconDeclarations.sol"; diff --git a/test/src/lib/LibRainDeployBeaconResolution.t.sol b/test/src/lib/LibRainDeployBeaconResolution.t.sol index 53889a2..d3b3130 100644 --- a/test/src/lib/LibRainDeployBeaconResolution.t.sol +++ b/test/src/lib/LibRainDeployBeaconResolution.t.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {ChainBeacon, DeployBeacon} from "../../../src/lib/LibRainDeployBeacon.sol"; import {BeaconDeclaredTwice} from "../../../src/lib/LibRainDeployBeaconDeclarationChecks.sol"; import {BeaconNamedTwice} from "../../../src/lib/LibRainDeployCloneOnChainChecks.sol"; diff --git a/test/src/lib/LibRainDeployBeaconResolution.unrevertableDerivation.t.sol b/test/src/lib/LibRainDeployBeaconResolution.unrevertableDerivation.t.sol index 52b4935..fffc4cc 100644 --- a/test/src/lib/LibRainDeployBeaconResolution.unrevertableDerivation.t.sol +++ b/test/src/lib/LibRainDeployBeaconResolution.unrevertableDerivation.t.sol @@ -2,10 +2,10 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeploySuite, DerivationSnapshotRevertFailed} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DerivedDeploy} from "rain-deploy-0.1.43/src/abstract/RainDeployVerifyBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeploySuite, DerivationSnapshotRevertFailed} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DerivedDeploy} from "rain-deploy-0.1.44/src/abstract/RainDeployVerifyBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {LibRainDeployBeaconResolution} from "../../../src/lib/LibRainDeployBeaconResolution.sol"; import {MockSnapshotDeletingCreation} from "../../concrete/MockSnapshotDeletingCreation.sol"; import {LibBeaconTest} from "../../lib/LibBeaconTest.sol"; diff --git a/test/src/lib/LibRainDeployClone.t.sol b/test/src/lib/LibRainDeployClone.t.sol index 8cd5e84..ac96869 100644 --- a/test/src/lib/LibRainDeployClone.t.sol +++ b/test/src/lib/LibRainDeployClone.t.sol @@ -9,7 +9,7 @@ import { } from "../../../src/lib/LibICloneableFactoryV5.sol"; import {ICloneableFactoryV4} from "../../../src/interface/deprecated/ICloneableFactoryV4.sol"; import {Vm, VmSafe} from "forge-std-1.17.0/src/Vm.sol"; -import {DeployDependency, LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency, LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import { CLONE_ARTIFACT_PATH, CloneParams, diff --git a/test/src/lib/LibRainDeployCloneMechanism.configRegistryRead.t.sol b/test/src/lib/LibRainDeployCloneMechanism.configRegistryRead.t.sol index 144376a..58b2e1f 100644 --- a/test/src/lib/LibRainDeployCloneMechanism.configRegistryRead.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanism.configRegistryRead.t.sol @@ -3,14 +3,14 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {IConfigRegistryV5} from "rain-deploy-0.1.43/src/interface/IConfigRegistryV5.sol"; -import {LibConfigRegistryDeploy} from "rain-deploy-0.1.43/src/lib/LibConfigRegistryDeploy.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {IConfigRegistryV5} from "rain-deploy-0.1.44/src/interface/IConfigRegistryV5.sol"; +import {LibConfigRegistryDeploy} from "rain-deploy-0.1.44/src/lib/LibConfigRegistryDeploy.sol"; import { RUNTIME_CODE as CONFIG_REGISTRY_RUNTIME_CODE -} from "rain-deploy-0.1.43/src/generated/candidate/ConfigRegistry.sol"; +} from "rain-deploy-0.1.44/src/generated/candidate/ConfigRegistry.sol"; import {CloneDeploy, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {MockCloneFactory} from "../../concrete/MockCloneFactory.sol"; diff --git a/test/src/lib/LibRainDeployCloneMechanism.dependencyClosure.t.sol b/test/src/lib/LibRainDeployCloneMechanism.dependencyClosure.t.sol index ce8f15c..7031c74 100644 --- a/test/src/lib/LibRainDeployCloneMechanism.dependencyClosure.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanism.dependencyClosure.t.sol @@ -9,10 +9,10 @@ import { DeployDependency, DeploySuite, ExternalDeployment -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {CloneDeploy, CloneParams, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import { diff --git a/test/src/lib/LibRainDeployCloneMechanism.deployLocally.t.sol b/test/src/lib/LibRainDeployCloneMechanism.deployLocally.t.sol index 28331d3..0a10644 100644 --- a/test/src/lib/LibRainDeployCloneMechanism.deployLocally.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanism.deployLocally.t.sol @@ -7,9 +7,9 @@ import { DeployDeclaration, DeployDependency, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {CLONE_ARTIFACT_PATH, CloneNetworks, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import { CLONE_PER_NETWORK_MECHANISM, diff --git a/test/src/lib/LibRainDeployCloneMechanism.deployStepLocally.t.sol b/test/src/lib/LibRainDeployCloneMechanism.deployStepLocally.t.sol new file mode 100644 index 0000000..254d3d5 --- /dev/null +++ b/test/src/lib/LibRainDeployCloneMechanism.deployStepLocally.t.sol @@ -0,0 +1,260 @@ +// SPDX-License-Identifier: LicenseRef-DCL-1.0 +// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd +pragma solidity =0.8.25; + +import {Test} from "forge-std-1.17.0/src/Test.sol"; +import {VmSafe} from "forge-std-1.17.0/src/Vm.sol"; +import {IERC5313} from "@openzeppelin-contracts-5.7.0/interfaces/IERC5313.sol"; +import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; +import { + DeployDeclaration, + DeployDependency, + DeployMechanismHandler, + DeploySuite +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {TestCloneFactory} from "../../../src/test/TestCloneFactory.sol"; +import {CloneDeploy} from "../../../src/lib/LibRainDeployClone.sol"; +import {BeaconProxyDeploy, LibRainDeployBeaconProxy} from "../../../src/lib/LibRainDeployBeaconProxy.sol"; +import { + LibRainDeployRegistryBeaconProxy, + RegistryBeaconProxyParams +} from "../../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; +import { + BEACON_PROXY_MECHANISM, + BEACON_PROXY_PER_NETWORK_MECHANISM, + CLONE_MECHANISM, + CLONE_PER_NETWORK_MECHANISM, + LibRainDeployCloneMechanism, + REGISTRY_BEACON_PROXY_MECHANISM +} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; +import {MockOriginOwnedCloneable} from "../../concrete/MockOriginOwnedCloneable.sol"; +import {LibRegistryBeaconProxyTest} from "../../lib/LibRegistryBeaconProxyTest.sol"; + +/// @title LibRainDeployCloneMechanismDeployStepLocallyTest +/// @notice Each mechanism's `deployStepLocally` under the deploy key as sender and origin, against its `deployStep`. +contract LibRainDeployCloneMechanismDeployStepLocallyTest is Test { + address constant DEPLOYER = address(0xD3910E8); + + bytes32 constant SALT = bytes32(uint256(7)); + + string constant SUITE = "deploy-step-locally"; + + bytes internal sData; + + function initDataOf(uint256) internal view returns (bytes memory) { + return sData; + } + + function declaration() internal view returns (DeployDeclaration memory) { + DeployDeclaration memory d; + LibRainDeployCloneMechanism.extend(d); + return d; + } + + function handlerOf(DeployDeclaration memory d, DeploySuite memory suite) + internal + pure + returns (DeployMechanismHandler memory) + { + return LibRainDeployDeclaration.mechanismById( + d, LibRainDeployCloneMechanism.mechanismTag(suite.mechanismData), suite.suite + ); + } + + function externalDeployStep(DeploySuite memory suite) external returns (address) { + DeployDeclaration memory d = declaration(); + DeployMechanismHandler memory h = handlerOf(d, suite); + return + h.deployStep(d, suite)(vm, LibRainDeploy.ARBITRUM_ONE, DEPLOYER, h.deployStepData(d, suite, block.chainid)); + } + + function expectedAddress(DeploySuite memory suite) internal view returns (address) { + DeployDeclaration memory d = declaration(); + return handlerOf(d, suite).deployedAddress(d, suite, block.chainid); + } + + function chainIds() internal view returns (uint256[] memory) { + uint256[] memory ids = new uint256[](2); + ids[0] = block.chainid; + ids[1] = 137; + return ids; + } + + function cloneDeploy(address implementation, bytes memory data, bool perNetwork) + internal + returns (CloneDeploy memory) + { + sData = data; + address factory = address(new TestCloneFactory()); + DeployDependency[] memory dependencies = new DeployDependency[](2); + dependencies[0] = DeployDependency({deployedAddress: factory, runtimeCode: factory.code}); + dependencies[1] = DeployDependency({deployedAddress: implementation, runtimeCode: implementation.code}); + return CloneDeploy({ + suite: SUITE, + factory: factory, + implementation: implementation, + data: perNetwork ? bytes("") : data, + initDataPerNetwork: perNetwork, + initData: initDataOf, + salt: SALT, + dependencies: dependencies + }); + } + + function cloneSuite(bytes memory data, bool perNetwork) internal returns (DeploySuite memory) { + return LibRainDeployCloneMechanism.cloneCandidate( + cloneDeploy(address(new MockOriginOwnedCloneable()), data, perNetwork), chainIds() + ) + .snapshot; + } + + function beaconProxySuite(bytes memory data, bool perNetwork) internal returns (DeploySuite memory) { + address implementation = address(new MockOriginOwnedCloneable()); + address beacon = address(new UpgradeableBeacon(implementation, address(this))); + CloneDeploy memory clone = cloneDeploy(beacon, data, perNetwork); + BeaconProxyDeploy memory proxy = BeaconProxyDeploy({ + suite: clone.suite, + factory: clone.factory, + beacon: beacon, + data: clone.data, + initDataPerNetwork: clone.initDataPerNetwork, + initData: clone.initData, + salt: clone.salt, + dependencies: clone.dependencies, + runtimeCode: LibRainDeployBeaconProxy.beaconProxyRuntimeCode( + vm, beacon, implementation, implementation.code + ) + }); + return LibRainDeployCloneMechanism.beaconProxyCandidate(proxy, chainIds()).snapshot; + } + + function registryBeaconProxySuite(bytes memory data) internal returns (DeploySuite memory) { + RegistryBeaconProxyParams memory params = + LibRegistryBeaconProxyTest.live(vm, address(new MockOriginOwnedCloneable()), address(this), data, SALT); + return LibRainDeployCloneMechanism.registryBeaconProxyCandidate( + LibRegistryBeaconProxyTest.declared(SUITE, params, LibRegistryBeaconProxyTest.runtimeOf(vm, params)) + ) + .snapshot; + } + + /// The real step's address, code and owner, its state reverted. + function broadcastStep(DeploySuite memory suite) internal returns (address, bytes memory, address) { + uint256 state = vm.snapshotState(); + address deployed = this.externalDeployStep(suite); + bytes memory code = deployed.code; + address seated = IERC5313(deployed).owner(); + assertTrue(vm.revertToState(state)); + return (deployed, code, seated); + } + + function localStep(DeploySuite memory suite) internal returns (address) { + DeployDeclaration memory d = declaration(); + DeployMechanismHandler memory h = handlerOf(d, suite); + bytes memory data = h.deployStepData(d, suite, block.chainid); + vm.startPrank(DEPLOYER, DEPLOYER); + address deployed = h.deployStepLocally(d, suite)(vm, DEPLOYER, data); + (VmSafe.CallerMode mode, address sender, address origin) = vm.readCallers(); + vm.stopPrank(); + assertEq(uint256(mode), uint256(VmSafe.CallerMode.RecurrentPrank)); + assertEq(sender, DEPLOYER); + assertEq(origin, DEPLOYER); + return deployed; + } + + function checkLocalStepMatchesBroadcastStep(DeploySuite memory suite, bytes32 id) internal returns (address) { + assertEq(LibRainDeployCloneMechanism.mechanismTag(suite.mechanismData), id); + (address deployed, bytes memory code, address seated) = broadcastStep(suite); + address local = localStep(suite); + assertEq(local, deployed); + assertEq(local.code, code); + assertEq(IERC5313(local).owner(), seated); + return local; + } + + function checkLocalStepSeatsTheDeployKeyTheBroadcastStepRefuses( + DeploySuite memory suite, + bytes32 id, + bytes4 refusal + ) internal { + assertEq(LibRainDeployCloneMechanism.mechanismTag(suite.mechanismData), id); + address expected = expectedAddress(suite); + vm.expectRevert(abi.encodeWithSelector(refusal, LibRainDeploy.ARBITRUM_ONE, expected)); + this.externalDeployStep(suite); + address local = localStep(suite); + assertEq(local, expected); + assertEq(IERC5313(local).owner(), DEPLOYER); + } + + function testCloneLocalStepMatchesTheBroadcastStep(address owner) external { + vm.assume(owner != address(0) && owner != DEPLOYER); + address local = checkLocalStepMatchesBroadcastStep(cloneSuite(abi.encode(owner), false), CLONE_MECHANISM); + assertEq(IERC5313(local).owner(), owner); + } + + function testClonePerNetworkLocalStepMatchesTheBroadcastStep(address owner) external { + vm.assume(owner != address(0) && owner != DEPLOYER); + address local = + checkLocalStepMatchesBroadcastStep(cloneSuite(abi.encode(owner), true), CLONE_PER_NETWORK_MECHANISM); + assertEq(IERC5313(local).owner(), owner); + } + + function testBeaconProxyLocalStepMatchesTheBroadcastStep(address owner) external { + vm.assume(owner != address(0) && owner != DEPLOYER); + address local = + checkLocalStepMatchesBroadcastStep(beaconProxySuite(abi.encode(owner), false), BEACON_PROXY_MECHANISM); + assertEq(IERC5313(local).owner(), owner); + } + + function testBeaconProxyPerNetworkLocalStepMatchesTheBroadcastStep(address owner) external { + vm.assume(owner != address(0) && owner != DEPLOYER); + address local = checkLocalStepMatchesBroadcastStep( + beaconProxySuite(abi.encode(owner), true), BEACON_PROXY_PER_NETWORK_MECHANISM + ); + assertEq(IERC5313(local).owner(), owner); + } + + function testRegistryBeaconProxyLocalStepMatchesTheBroadcastStep(address owner) external { + vm.assume(owner != address(0) && owner != DEPLOYER); + address local = checkLocalStepMatchesBroadcastStep( + registryBeaconProxySuite(abi.encode(owner)), REGISTRY_BEACON_PROXY_MECHANISM + ); + assertEq(IERC5313(local).owner(), owner); + } + + function testCloneLocalStepSeatsTheDeployKeyAsTheBroadcastStepDoes() external { + address local = checkLocalStepMatchesBroadcastStep(cloneSuite(abi.encode(address(0)), false), CLONE_MECHANISM); + assertEq(IERC5313(local).owner(), DEPLOYER); + } + + function testClonePerNetworkLocalStepSeatsTheDeployKeyAsTheBroadcastStepDoes() external { + address local = + checkLocalStepMatchesBroadcastStep(cloneSuite(abi.encode(address(0)), true), CLONE_PER_NETWORK_MECHANISM); + assertEq(IERC5313(local).owner(), DEPLOYER); + } + + function testBeaconProxyLocalStepSeatsTheDeployKeyTheBroadcastStepRefuses() external { + checkLocalStepSeatsTheDeployKeyTheBroadcastStepRefuses( + beaconProxySuite(abi.encode(address(0)), false), + BEACON_PROXY_MECHANISM, + LibRainDeployBeaconProxy.BeaconProxySeatsDeployKey.selector + ); + } + + function testBeaconProxyPerNetworkLocalStepSeatsTheDeployKeyTheBroadcastStepRefuses() external { + checkLocalStepSeatsTheDeployKeyTheBroadcastStepRefuses( + beaconProxySuite(abi.encode(address(0)), true), + BEACON_PROXY_PER_NETWORK_MECHANISM, + LibRainDeployBeaconProxy.BeaconProxySeatsDeployKey.selector + ); + } + + function testRegistryBeaconProxyLocalStepSeatsTheDeployKeyTheBroadcastStepRefuses() external { + checkLocalStepSeatsTheDeployKeyTheBroadcastStepRefuses( + registryBeaconProxySuite(abi.encode(address(0))), + REGISTRY_BEACON_PROXY_MECHANISM, + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxySeatsDeployKey.selector + ); + } +} diff --git a/test/src/lib/LibRainDeployCloneMechanism.handlers.t.sol b/test/src/lib/LibRainDeployCloneMechanism.handlers.t.sol index a81f126..5e81b2d 100644 --- a/test/src/lib/LibRainDeployCloneMechanism.handlers.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanism.handlers.t.sol @@ -3,8 +3,8 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; -import {DeployDeclaration} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {DeployDeclaration} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import { BEACON_PROXY_MECHANISM, BEACON_PROXY_PER_NETWORK_MECHANISM, diff --git a/test/src/lib/LibRainDeployCloneMechanism.recordedAddress.t.sol b/test/src/lib/LibRainDeployCloneMechanism.recordedAddress.t.sol index c13dc07..9f319e3 100644 --- a/test/src/lib/LibRainDeployCloneMechanism.recordedAddress.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanism.recordedAddress.t.sol @@ -7,7 +7,7 @@ import { DeployDeclaration, DeploySuite, UnrecordedOnNetwork -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import { BEACON_PROXY_PER_NETWORK_MECHANISM, LibRainDeployCloneMechanism diff --git a/test/src/lib/LibRainDeployCloneMechanism.t.sol b/test/src/lib/LibRainDeployCloneMechanism.t.sol index 437d4ce..0db3ca4 100644 --- a/test/src/lib/LibRainDeployCloneMechanism.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanism.t.sol @@ -11,14 +11,14 @@ import { DeploySuite, MechanismUnclaimed, UnexpectedMechanismData -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeployDependency, LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDependency, LibRainDeploy, SupportedNetwork} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import { LibRainDeployZoltuMechanism, ZOLTU_MECHANISM_ID -} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import { CLONE_ARTIFACT_PATH, CLONE_UNANCHORABLE_REASON, diff --git a/test/src/lib/LibRainDeployCloneMechanismBeaconProxy.t.sol b/test/src/lib/LibRainDeployCloneMechanismBeaconProxy.t.sol index ef25151..c5ed29c 100644 --- a/test/src/lib/LibRainDeployCloneMechanismBeaconProxy.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanismBeaconProxy.t.sol @@ -9,10 +9,10 @@ import { DeployCandidate, DeployDeclaration, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import { CLONE_ARTIFACT_PATH, CloneNetworks, diff --git a/test/src/lib/LibRainDeployCloneMechanismBroadcast.t.sol b/test/src/lib/LibRainDeployCloneMechanismBroadcast.t.sol index 680dd27..c5425a1 100644 --- a/test/src/lib/LibRainDeployCloneMechanismBroadcast.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanismBroadcast.t.sol @@ -2,7 +2,7 @@ // SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd pragma solidity =0.8.25; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import { CLONE_ARTIFACT_PATH, CloneNetworks, @@ -21,11 +21,11 @@ import { DeploySuite, UnexpectedMechanismData, UnrecordedOnNetwork -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import { LibRainDeployZoltuMechanism, ZOLTU_MECHANISM_ID -} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {LibRainDeployBeaconProxy} from "../../../src/lib/LibRainDeployBeaconProxy.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; import {MockBeaconProxyFactory} from "../../concrete/MockBeaconProxyFactory.sol"; diff --git a/test/src/lib/LibRainDeployCloneMechanismCandidates.t.sol b/test/src/lib/LibRainDeployCloneMechanismCandidates.t.sol index 02d8efb..0bf95d9 100644 --- a/test/src/lib/LibRainDeployCloneMechanismCandidates.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanismCandidates.t.sol @@ -7,7 +7,7 @@ import { DeployCandidate, DeployDeclaration, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {BEACON_PROXY_ARTIFACT_PATH} from "../../../src/lib/LibRainDeployBeaconProxy.sol"; import {CLONE_ARTIFACT_PATH, CloneDeploy} from "../../../src/lib/LibRainDeployClone.sol"; import {BEACON_PROXY_MECHANISM, LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; diff --git a/test/src/lib/LibRainDeployCloneMechanismRegistryBeaconProxy.t.sol b/test/src/lib/LibRainDeployCloneMechanismRegistryBeaconProxy.t.sol index 1ba93a1..6910f8f 100644 --- a/test/src/lib/LibRainDeployCloneMechanismRegistryBeaconProxy.t.sol +++ b/test/src/lib/LibRainDeployCloneMechanismRegistryBeaconProxy.t.sol @@ -5,10 +5,11 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; import {Vm} from "forge-std-1.17.0/src/Vm.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; -import {DeployCandidate, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {DeployCandidate, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {ICloneableFactoryV7} from "../../../src/interface/ICloneableFactoryV7.sol"; +import {ICLONEABLE_V2_SUCCESS} from "../../../src/interface/ICloneableV2.sol"; import {CloneParams, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import {LibRainDeployBeaconProxy} from "../../../src/lib/LibRainDeployBeaconProxy.sol"; import {ChainDeploy} from "../../../src/lib/LibRainDeployExtendedNetworks.sol"; @@ -16,6 +17,7 @@ import { LibRainDeployRegistryBeaconProxy, REGISTRY_BEACON_PROXY_ARTIFACT_PATH, REGISTRY_BEACON_PROXY_UNANCHORABLE_REASON, + RegistryBeaconOnNetwork, RegistryBeaconProxyDeploy, RegistryBeaconProxyParams } from "../../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; @@ -52,13 +54,15 @@ contract LibRainDeployCloneMechanismRegistryBeaconProxyTest is Test { sDeploy = new ExampleCloneDeploy(); } - /// `LibRegistryBeaconProxyTest.live`, its factory, registry and beacon declared external deployments of `sDeploy`. + /// `LibRegistryBeaconProxyTest.live`, its beacon also listed on each per-network clone chain, its factory and + /// registry declared external deployments of `sDeploy`. function liveParams() internal returns (RegistryBeaconProxyParams memory) { RegistryBeaconProxyParams memory params = LibRegistryBeaconProxyTest.live(vm, address(new MockCloneableV2()), address(this), TEST_DATA, TEST_SALT); + params.beaconPerNetwork = + LibRegistryBeaconProxyTest.alsoOn(vm, params, perNetworkCloneChainIds(), params.beaconPerNetwork[0].beacon); sDeploy.addExternalDeployment(LibExternalDeployments.deployedNow(params.factory)); sDeploy.addExternalDeployment(LibExternalDeployments.deployedNow(params.registry)); - sDeploy.addExternalDeployment(LibExternalDeployments.deployedNow(params.beacon)); return params; } @@ -84,18 +88,39 @@ contract LibRainDeployCloneMechanismRegistryBeaconProxyTest is Test { return LibRainDeployCloneMechanism.appendExtendedNetworks(suite, extended); } - function testRegistryBeaconProxyCandidateDerivesEveryFieldFromTheDeclaration(RegistryBeaconProxyDeploy memory proxy) - external - pure - { + /// `proxy` with a coherent per-chain code record: at least one entry, distinct chain ids, each entry's non-empty + /// code under its hash, and the stored runtime code entry `pick`'s. + function coherent(RegistryBeaconProxyDeploy memory proxy, uint256 pick) internal pure { + if (proxy.beaconPerNetwork.length == 0) { + proxy.beaconPerNetwork = new RegistryBeaconOnNetwork[](1); + } + for (uint256 i = 0; i < proxy.beaconPerNetwork.length; i++) { + RegistryBeaconOnNetwork memory entry = proxy.beaconPerNetwork[i]; + entry.chainId = uint256(keccak256(abi.encode(i, entry.chainId))); + if (entry.proxyRuntimeCode.length == 0) { + entry.proxyRuntimeCode = abi.encodePacked(i); + } + entry.proxyCodeHash = keccak256(entry.proxyRuntimeCode); + } + proxy.runtimeCode = proxy.beaconPerNetwork[pick % proxy.beaconPerNetwork.length].proxyRuntimeCode; + } + + function testRegistryBeaconProxyCandidateDerivesEveryFieldFromTheDeclaration( + RegistryBeaconProxyDeploy memory proxy, + address beacon, + uint256 pick + ) external pure { + coherent(proxy, pick); RegistryBeaconProxyParams memory params = RegistryBeaconProxyParams({ factory: proxy.factory, registry: proxy.registry, authority: proxy.authority, beaconName: proxy.beaconName, - beacon: proxy.beacon, + beaconPerNetwork: proxy.beaconPerNetwork, data: proxy.data, - salt: proxy.salt + salt: proxy.salt, + implementation: proxy.implementation, + implementationRuntimeCode: proxy.implementationRuntimeCode }); DeployCandidate memory candidate = LibRainDeployCloneMechanism.registryBeaconProxyCandidate(proxy); DeploySuite memory snapshot = candidate.snapshot; @@ -116,7 +141,7 @@ contract LibRainDeployCloneMechanismRegistryBeaconProxyTest is Test { assertNotEq( snapshot.storedDeployedAddress, LibRainDeployBeaconProxy.beaconProxyDeployedAddress( - CloneParams({factory: proxy.factory, implementation: proxy.beacon, data: proxy.data, salt: proxy.salt}) + CloneParams({factory: proxy.factory, implementation: beacon, data: proxy.data, salt: proxy.salt}) ) ); } @@ -202,15 +227,22 @@ contract LibRainDeployCloneMechanismRegistryBeaconProxyTest is Test { assertEq(suite.storedDeployedAddress.code, suite.storedRuntimeCode); } - function testRegistryBeaconProxyLocalDeployEtchesItsStoredRuntimeCodeWithoutCallingFactoryOrRegistry(bytes memory runtimeCode) + /// The local step initializes the proxy, so the recorded code answers `initialize` with success before `tail`. + function testRegistryBeaconProxyLocalDeployEtchesItsStoredRuntimeCodeWithoutCallingFactoryOrRegistry(bytes memory tail) external { - vm.assume(runtimeCode.length > 0); - vm.assume(runtimeCode[0] != 0xef); + bytes memory runtimeCode = bytes.concat(hex"7f", ICLONEABLE_V2_SUCCESS, hex"60005260206000f3", tail); RegistryBeaconProxyParams memory params = liveParams(); - DeploySuite memory suite = suiteOf(params); - suite.storedRuntimeCode = runtimeCode; - suite.storedBytecodeHash = keccak256(runtimeCode); + for (uint256 i = 0; i < params.beaconPerNetwork.length; i++) { + params.beaconPerNetwork[i].proxyRuntimeCode = runtimeCode; + params.beaconPerNetwork[i].proxyCodeHash = keccak256(runtimeCode); + } + DeploySuite memory suite = + LibRainDeployCloneMechanism.registryBeaconProxyCandidate( + LibRegistryBeaconProxyTest.declared(SUITE, params, runtimeCode) + ) + .snapshot; + suite.networks = perNetworkCloneNetworks(); suite.dependencies[0].runtimeCode = hex"fe"; suite.dependencies[1].runtimeCode = hex"fe"; @@ -268,8 +300,9 @@ contract LibRainDeployCloneMechanismRegistryBeaconProxyTest is Test { function testRegistryBeaconProxyCreationCodeOfAnotherMechanismIsRefused() external { RegistryBeaconProxyParams memory params = liveParams(); DeploySuite memory suite = suiteOf(params); - expectCreationCodeRefused(suite, LibRainDeployBeaconProxy.beaconProxyCreationCode(params.beacon)); - expectCreationCodeRefused(suite, LibRainDeployClone.cloneCreationCode(params.beacon)); + address beacon = params.beaconPerNetwork[0].beacon; + expectCreationCodeRefused(suite, LibRainDeployBeaconProxy.beaconProxyCreationCode(beacon)); + expectCreationCodeRefused(suite, LibRainDeployClone.cloneCreationCode(beacon)); expectCreationCodeRefused(suite, ""); } @@ -305,7 +338,7 @@ contract LibRainDeployCloneMechanismRegistryBeaconProxyTest is Test { abi.encodeWithSelector( LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconMismatch.selector, LibRainDeploy.ARBITRUM_ONE, - params.beacon, + params.beaconPerNetwork[0].beacon, otherBeacon ) ); @@ -325,11 +358,11 @@ contract LibRainDeployCloneMechanismRegistryBeaconProxyTest is Test { function testRegistryBeaconProxySuiteMissingADependencyIsRefused() external { RegistryBeaconProxyParams memory params = liveParams(); DeploySuite memory declared = suiteOf(params); - address[3] memory required = [params.factory, params.registry, params.beacon]; + address[2] memory required = [params.factory, params.registry]; for (uint256 missing = 0; missing < required.length; missing++) { DeploySuite memory suite = abi.decode(abi.encode(declared), (DeploySuite)); - DeployDependency[] memory kept = new DeployDependency[](2); + DeployDependency[] memory kept = new DeployDependency[](1); uint256 k = 0; for (uint256 i = 0; i < declared.dependencies.length; i++) { if (declared.dependencies[i].deployedAddress != required[missing]) { @@ -337,7 +370,7 @@ contract LibRainDeployCloneMechanismRegistryBeaconProxyTest is Test { k++; } } - assertEq(k, 2); + assertEq(k, 1); suite.dependencies = kept; bytes memory refusal = diff --git a/test/src/lib/LibRainDeployCloneOnChainChecks.declarationPerNetwork.t.sol b/test/src/lib/LibRainDeployCloneOnChainChecks.declarationPerNetwork.t.sol index eec6d84..f7645b7 100644 --- a/test/src/lib/LibRainDeployCloneOnChainChecks.declarationPerNetwork.t.sol +++ b/test/src/lib/LibRainDeployCloneOnChainChecks.declarationPerNetwork.t.sol @@ -3,7 +3,7 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; -import {DeployDeclaration} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +import {DeployDeclaration} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import { ChainDeploy, ExtendedNetworksUnrecorded, diff --git a/test/src/lib/LibRainDeployCloneOnChainChecks.probeBeacon.t.sol b/test/src/lib/LibRainDeployCloneOnChainChecks.probeBeacon.t.sol index e148ab0..7ef043b 100644 --- a/test/src/lib/LibRainDeployCloneOnChainChecks.probeBeacon.t.sol +++ b/test/src/lib/LibRainDeployCloneOnChainChecks.probeBeacon.t.sol @@ -3,9 +3,9 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployZoltuMechanism} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import { BeaconProbe, diff --git a/test/src/lib/LibRainDeployCloneOnChainChecks.registryBeaconProxy.t.sol b/test/src/lib/LibRainDeployCloneOnChainChecks.registryBeaconProxy.t.sol index c1e11e7..a1d07e9 100644 --- a/test/src/lib/LibRainDeployCloneOnChainChecks.registryBeaconProxy.t.sol +++ b/test/src/lib/LibRainDeployCloneOnChainChecks.registryBeaconProxy.t.sol @@ -4,8 +4,8 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; import {LibRainDeployCloneOnChainChecks} from "../../../src/lib/LibRainDeployCloneOnChainChecks.sol"; import { @@ -31,6 +31,7 @@ contract LibRainDeployCloneOnChainChecksRegistryBeaconProxyTest is Test { } function liveSuite() internal returns (RegistryBeaconProxyParams memory, DeploySuite memory) { + vm.chainId(ARBITRUM_ONE_CHAIN_ID); RegistryBeaconProxyParams memory params = LibRegistryBeaconProxyTest.live( vm, address(new MockCloneableV2()), address(this), hex"deadbeef", bytes32(uint256(5)) ); @@ -58,7 +59,7 @@ contract LibRainDeployCloneOnChainChecksRegistryBeaconProxyTest is Test { abi.encodeWithSelector( LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconMismatch.selector, LibRainDeploy.ARBITRUM_ONE, - params.beacon, + params.beaconPerNetwork[0].beacon, bound ) ); diff --git a/test/src/lib/LibRainDeployCloneOnChainChecks.released.t.sol b/test/src/lib/LibRainDeployCloneOnChainChecks.released.t.sol index 20ffa10..5107564 100644 --- a/test/src/lib/LibRainDeployCloneOnChainChecks.released.t.sol +++ b/test/src/lib/LibRainDeployCloneOnChainChecks.released.t.sol @@ -7,8 +7,8 @@ import { DeployCandidate, DeployDeclaration, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import {CloneNetworks} from "../../../src/lib/LibRainDeployClone.sol"; import {ChainDeploy, LibRainDeployExtendedNetworks} from "../../../src/lib/LibRainDeployExtendedNetworks.sol"; import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; diff --git a/test/src/lib/LibRainDeployCloneOnChainChecks.t.sol b/test/src/lib/LibRainDeployCloneOnChainChecks.t.sol index 43ac7bb..26b3a0c 100644 --- a/test/src/lib/LibRainDeployCloneOnChainChecks.t.sol +++ b/test/src/lib/LibRainDeployCloneOnChainChecks.t.sol @@ -3,8 +3,8 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; -import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {Prerequisite} from "rain-deploy-0.1.43/src/interface/IMigrationRegistryV5.sol"; +import {DeployDeclaration, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {Prerequisite} from "rain-deploy-0.1.44/src/interface/IMigrationRegistryV5.sol"; import {BeaconState, BeaconTransition, ChainBeacon, DeployBeacon} from "../../../src/lib/LibRainDeployBeacon.sol"; import { BEACON_PROXY_MECHANISM, @@ -17,7 +17,12 @@ import { LibRainDeployCloneOnChainChecks, RegistryBeaconOwnedByDeployKey } from "../../../src/lib/LibRainDeployCloneOnChainChecks.sol"; -import {RegistryBeaconProxyParams} from "../../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; +import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; +import { + LibRainDeployRegistryBeaconProxy, + RegistryBeaconOnNetwork, + RegistryBeaconProxyParams +} from "../../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; import {LibRegistryBeaconProxyTest} from "../../lib/LibRegistryBeaconProxyTest.sol"; import {MockCloneableV2} from "../../concrete/MockCloneableV2.sol"; @@ -90,6 +95,7 @@ contract LibRainDeployCloneOnChainChecksBroadcastSeatTest is Test { LibRegistryBeaconProxyTest.live( vm, address(new MockCloneableV2()), beaconOwner, hex"deadbeef", bytes32(uint256(5)) ); + params.beaconPerNetwork[0].chainId = 42161; DeploySuite memory suite = LibRainDeployCloneMechanism.registryBeaconProxyCandidate( LibRegistryBeaconProxyTest.declared( @@ -120,7 +126,9 @@ contract LibRainDeployCloneOnChainChecksBroadcastSeatTest is Test { function testBroadcastSeatRefusesARegistryBeaconProxyWhoseDeclaredBeaconTheDeployKeyOwns() external { (RegistryBeaconProxyParams memory params, DeploySuite memory suite) = registrySuite(DEPLOYER); - vm.expectRevert(abi.encodeWithSelector(RegistryBeaconOwnedByDeployKey.selector, 42161, params.beacon)); + vm.expectRevert( + abi.encodeWithSelector(RegistryBeaconOwnedByDeployKey.selector, 42161, params.beaconPerNetwork[0].beacon) + ); this.checkRegistryBroadcastSeat(suite, OWNER); } @@ -128,4 +136,83 @@ contract LibRainDeployCloneOnChainChecksBroadcastSeatTest is Test { (, DeploySuite memory suite) = registrySuite(OWNER); this.checkRegistryBroadcastSeat(suite, DEPLOYER); } + + function checkRegistryBroadcastSeatOn(DeploySuite memory suite, uint256 chainId) external view { + LibRainDeployCloneOnChainChecks.checkBroadcastSeat(declaration(OWNER, OWNER), suite, chainId, DEPLOYER); + } + + /// `owners[i]` owns the beacon on `chainIds[i]`, each its own beacon. + function registrySuiteOver(uint256[] memory chainIds, address[] memory owners) + internal + returns (RegistryBeaconProxyParams memory, DeploySuite memory) + { + RegistryBeaconProxyParams memory params = LibRegistryBeaconProxyTest.live( + vm, address(new MockCloneableV2()), owners[0], hex"deadbeef", bytes32(uint256(5)) + ); + address first = params.beaconPerNetwork[0].beacon; + params.beaconPerNetwork = new RegistryBeaconOnNetwork[](chainIds.length); + for (uint256 i = 0; i < chainIds.length; i++) { + address onChain = i == 0 ? first : address(new UpgradeableBeacon(address(new MockCloneableV2()), owners[i])); + params.beaconPerNetwork[i] = LibRegistryBeaconProxyTest.onNetwork(vm, params, chainIds[i], onChain); + } + DeploySuite memory suite = + LibRainDeployCloneMechanism.registryBeaconProxyCandidate( + LibRegistryBeaconProxyTest.declared( + "registry-beacon-proxy@0_0_1", params, LibRegistryBeaconProxyTest.runtimeOf(vm, params) + ) + ) + .snapshot; + return (params, suite); + } + + /// Three chains, each on its own beacon, the deploy key owning only Base's: refused on Base naming Base's beacon, + /// passed on the others, refused on a chain the suite does not list. + function testBroadcastSeatReadsEachChainsOwnRegistryBeacon() external { + uint256[] memory chainIds = new uint256[](3); + chainIds[0] = 42161; + chainIds[1] = 8453; + chainIds[2] = 137; + address[] memory owners = new address[](3); + owners[0] = OWNER; + owners[1] = DEPLOYER; + owners[2] = NEW_OWNER; + (RegistryBeaconProxyParams memory params, DeploySuite memory suite) = registrySuiteOver(chainIds, owners); + + this.checkRegistryBroadcastSeatOn(suite, 42161); + this.checkRegistryBroadcastSeatOn(suite, 137); + vm.expectRevert( + abi.encodeWithSelector(RegistryBeaconOwnedByDeployKey.selector, 8453, params.beaconPerNetwork[1].beacon) + ); + this.checkRegistryBroadcastSeatOn(suite, 8453); + vm.expectRevert( + abi.encodeWithSelector(LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyNoBeaconOnNetwork.selector, 1) + ); + this.checkRegistryBroadcastSeatOn(suite, 1); + } + + /// One beacon listed for each of two chains is read on each. + function testBroadcastSeatReadsOneRegistryBeaconListedPerChain() external { + (RegistryBeaconProxyParams memory params,) = registrySuite(DEPLOYER); + address shared = params.beaconPerNetwork[0].beacon; + RegistryBeaconOnNetwork[] memory both = new RegistryBeaconOnNetwork[](2); + both[0] = LibRegistryBeaconProxyTest.onNetwork(vm, params, 42161, shared); + both[1] = LibRegistryBeaconProxyTest.onNetwork(vm, params, 8453, shared); + params.beaconPerNetwork = both; + DeploySuite memory suite = + LibRainDeployCloneMechanism.registryBeaconProxyCandidate( + LibRegistryBeaconProxyTest.declared( + "registry-beacon-proxy@0_0_1", params, LibRegistryBeaconProxyTest.runtimeOf(vm, params) + ) + ) + .snapshot; + for (uint256 i = 0; i < both.length; i++) { + vm.expectRevert(abi.encodeWithSelector(RegistryBeaconOwnedByDeployKey.selector, both[i].chainId, shared)); + this.checkRegistryBroadcastSeatOn(suite, both[i].chainId); + } + vm.prank(DEPLOYER); + UpgradeableBeacon(shared).transferOwnership(OWNER); + for (uint256 i = 0; i < both.length; i++) { + this.checkRegistryBroadcastSeatOn(suite, both[i].chainId); + } + } } diff --git a/test/src/lib/LibRainDeployClonePerNetwork.t.sol b/test/src/lib/LibRainDeployClonePerNetwork.t.sol index 981ec5f..2210a53 100644 --- a/test/src/lib/LibRainDeployClonePerNetwork.t.sol +++ b/test/src/lib/LibRainDeployClonePerNetwork.t.sol @@ -3,7 +3,7 @@ pragma solidity =0.8.25; import {Test} from "forge-std-1.17.0/src/Test.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {CloneNetworks, CloneParams, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import {ChainDeploy} from "../../../src/lib/LibRainDeployExtendedNetworks.sol"; import { diff --git a/test/src/lib/LibRainDeployCloneSnapshot.beaconProxy.t.sol b/test/src/lib/LibRainDeployCloneSnapshot.beaconProxy.t.sol index 67d3415..7935065 100644 --- a/test/src/lib/LibRainDeployCloneSnapshot.beaconProxy.t.sol +++ b/test/src/lib/LibRainDeployCloneSnapshot.beaconProxy.t.sol @@ -10,15 +10,15 @@ import { MechanismUnclaimed, RainDeploySuitesBase, SnapshotFile -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {RAIN_COPYRIGHT_TEXT, RAIN_SPDX_LICENSE_IDENTIFIER} from "rain-sol-codegen-0.1.39/src/lib/LibCodeGen.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import { FrozenSnapshotMechanismDataAmbiguous, FrozenSnapshotMechanismDataMissing, FrozenSnapshotUnreadable, LibRainDeploySnapshot -} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import {LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import {BEACON_PROXY_ARTIFACT_PATH, BeaconProxyDeploy} from "../../../src/lib/LibRainDeployBeaconProxy.sol"; import { @@ -33,7 +33,7 @@ import { FrozenSnapshotBeaconProxyMechanismDataMissing, LibRainDeployCloneSnapshot } from "../../../src/lib/LibRainDeployCloneSnapshot.sol"; -import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; +import {DeployDependency, LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; import {MockBeaconProxyFactory} from "../../concrete/MockBeaconProxyFactory.sol"; import {MockCloneableV2} from "../../concrete/MockCloneableV2.sol"; import {exampleCloneImplementation} from "../../abstract/ExampleCloneDeploys.sol"; diff --git a/test/src/lib/LibRainDeployCloneSnapshot.registryBeaconProxy.t.sol b/test/src/lib/LibRainDeployCloneSnapshot.registryBeaconProxy.t.sol index c0cb0ec..43613f0 100644 --- a/test/src/lib/LibRainDeployCloneSnapshot.registryBeaconProxy.t.sol +++ b/test/src/lib/LibRainDeployCloneSnapshot.registryBeaconProxy.t.sol @@ -9,14 +9,14 @@ import { DeploySuite, RainDeploySuitesBase, SnapshotFile -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {RAIN_COPYRIGHT_TEXT, RAIN_SPDX_LICENSE_IDENTIFIER} from "rain-sol-codegen-0.1.39/src/lib/LibCodeGen.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; import { FrozenSnapshotMechanismDataAmbiguous, FrozenSnapshotUnreadable, LibRainDeploySnapshot -} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import { LibRainDeployRegistryBeaconProxy, REGISTRY_BEACON_PROXY_ARTIFACT_PATH, @@ -33,7 +33,7 @@ import { } from "../../../src/lib/LibRainDeployCloneSnapshot.sol"; import {LibRegistryBeaconProxyTest} from "../../lib/LibRegistryBeaconProxyTest.sol"; import {MockCloneableV2} from "../../concrete/MockCloneableV2.sol"; -import {perNetworkCloneLayers} from "../../abstract/PerNetworkCloneDeploys.sol"; +import {perNetworkCloneChainIds, perNetworkCloneLayers} from "../../abstract/PerNetworkCloneDeploys.sol"; import {LibExternalDeployments} from "../../lib/LibExternalDeployments.sol"; /// @title LibRainDeployCloneSnapshotRegistryBeaconProxyTest @@ -224,9 +224,10 @@ contract LibRainDeployCloneSnapshotRegistryBeaconProxyTest is Test, RainDeploySu RegistryBeaconProxyParams memory params = LibRegistryBeaconProxyTest.live( vm, address(new MockCloneableV2()), address(this), hex"deadbeef", bytes32(uint256(7)) ); + params.beaconPerNetwork = + LibRegistryBeaconProxyTest.alsoOn(vm, params, perNetworkCloneChainIds(), params.beaconPerNetwork[0].beacon); sExternalDeployments.push(LibExternalDeployments.deployedNow(params.factory)); sExternalDeployments.push(LibExternalDeployments.deployedNow(params.registry)); - sExternalDeployments.push(LibExternalDeployments.deployedNow(params.beacon)); DeploySuite memory suite = LibRainDeployCloneMechanism.registryBeaconProxyCandidate( LibRegistryBeaconProxyTest.declared( diff --git a/test/src/lib/LibRainDeployCloneSnapshot.t.sol b/test/src/lib/LibRainDeployCloneSnapshot.t.sol index 15c8eb5..7ed6f54 100644 --- a/test/src/lib/LibRainDeployCloneSnapshot.t.sol +++ b/test/src/lib/LibRainDeployCloneSnapshot.t.sol @@ -9,15 +9,15 @@ import { DeploySuite, RainDeploySuitesBase, SnapshotFile -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; import {RAIN_COPYRIGHT_TEXT, RAIN_SPDX_LICENSE_IDENTIFIER} from "rain-sol-codegen-0.1.39/src/lib/LibCodeGen.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {DeploySuiteIndex, LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import { FrozenSnapshotMechanismDataMissing, LibRainDeploySnapshot -} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import {CLONE_ARTIFACT_PATH, CloneNetworks, LibRainDeployClone} from "../../../src/lib/LibRainDeployClone.sol"; import { CLONE_PER_NETWORK_MECHANISM, diff --git a/test/src/lib/LibRainDeployExtendedNetworks.t.sol b/test/src/lib/LibRainDeployExtendedNetworks.t.sol index 7b24f09..d903041 100644 --- a/test/src/lib/LibRainDeployExtendedNetworks.t.sol +++ b/test/src/lib/LibRainDeployExtendedNetworks.t.sol @@ -15,7 +15,7 @@ import { ExtendedNetworksUnrecorded, LibRainDeployExtendedNetworks } from "../../../src/lib/LibRainDeployExtendedNetworks.sol"; -import {InvalidRecordRoot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +import {InvalidRecordRoot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import {LibExtendedNetworksFixture} from "../../lib/LibExtendedNetworksFixture.sol"; /// @title LibRainDeployExtendedNetworksTest diff --git a/test/src/lib/LibRainDeployRegistryBeaconProxy.proxyCodeRecord.t.sol b/test/src/lib/LibRainDeployRegistryBeaconProxy.proxyCodeRecord.t.sol new file mode 100644 index 0000000..7418aea --- /dev/null +++ b/test/src/lib/LibRainDeployRegistryBeaconProxy.proxyCodeRecord.t.sol @@ -0,0 +1,205 @@ +// SPDX-License-Identifier: LicenseRef-DCL-1.0 +// SPDX-FileCopyrightText: Copyright (c) 2020 Rain Open Source Software Ltd +pragma solidity =0.8.25; + +import {Test} from "forge-std-1.17.0/src/Test.sol"; +import {DeployCandidate, DeploySuite} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeployCloneMechanism} from "../../../src/lib/LibRainDeployCloneMechanism.sol"; +import { + LibRainDeployRegistryBeaconProxy, + RegistryBeaconOnNetwork, + RegistryBeaconProxyDeploy, + RegistryBeaconProxyParams +} from "../../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; +import {LibRegistryBeaconProxyTest} from "../../lib/LibRegistryBeaconProxyTest.sol"; +import {MockCloneableV2} from "../../concrete/MockCloneableV2.sol"; + +/// @title LibRainDeployRegistryBeaconProxyProxyCodeRecordTest +/// @notice One chain's undeclared or incoherent proxy code is refused wherever a registry beacon proxy suite is read. +contract LibRainDeployRegistryBeaconProxyProxyCodeRecordTest is Test { + string constant SUITE = "registry-beacon-proxy"; + + bytes internal sParamsData; + + /// Arbitrum One, Base and Polygon, each on its own beacon with the proxy code that beacon gives. + function setUp() external { + RegistryBeaconProxyParams memory params = RegistryBeaconProxyParams({ + factory: address(0xFAC7), + registry: address(0x12E6), + authority: LibRegistryBeaconProxyTest.AUTHORITY, + beaconName: LibRegistryBeaconProxyTest.BEACON_NAME, + beaconPerNetwork: new RegistryBeaconOnNetwork[](3), + data: hex"deadbeef", + salt: bytes32(uint256(5)), + implementation: address(new MockCloneableV2()), + implementationRuntimeCode: "" + }); + params.implementationRuntimeCode = params.implementation.code; + uint256[3] memory chainIds = [uint256(42161), 8453, 137]; + address[3] memory beacons = [address(0xBEAC1), address(0xBEAC2), address(0xBEAC3)]; + for (uint256 i = 0; i < 3; i++) { + params.beaconPerNetwork[i] = LibRegistryBeaconProxyTest.withProxyCode( + vm, + params, + RegistryBeaconOnNetwork({ + chainId: chainIds[i], + beacon: beacons[i], + codeHash: keccak256(abi.encode(chainIds[i])), + proxyCodeHash: bytes32(0), + proxyRuntimeCode: "" + }) + ); + } + sParamsData = abi.encode(params); + } + + function threeChains() internal view returns (RegistryBeaconProxyParams memory) { + return abi.decode(sParamsData, (RegistryBeaconProxyParams)); + } + + function goodSuite() internal view returns (DeploySuite memory) { + RegistryBeaconProxyParams memory params = threeChains(); + return externalCandidate( + LibRegistryBeaconProxyTest.declared(SUITE, params, params.beaconPerNetwork[0].proxyRuntimeCode) + ) + .snapshot; + } + + function externalBeaconOnNetwork(RegistryBeaconProxyParams memory params, uint256 chainId) + external + pure + returns (RegistryBeaconOnNetwork memory) + { + return LibRainDeployRegistryBeaconProxy.beaconOnNetwork(params, chainId); + } + + function externalCheckProxyCode(RegistryBeaconProxyParams memory params, bytes memory runtimeCode) external pure { + LibRainDeployRegistryBeaconProxy.checkProxyCode(params, runtimeCode); + } + + function externalCandidate(RegistryBeaconProxyDeploy memory proxy) public pure returns (DeployCandidate memory) { + return LibRainDeployCloneMechanism.registryBeaconProxyCandidate(proxy); + } + + function externalExpectedBytecodeHash(DeploySuite memory suite, uint256 chainId) external pure returns (bytes32) { + return LibRainDeployCloneMechanism.expectedBytecodeHash(suite, chainId); + } + + function externalDeployParams(DeploySuite memory suite, uint256 chainId, address expected) external { + LibRainDeployCloneMechanism.deployParams(vm, suite, chainId, expected); + } + + function externalDeployStepLocally(bytes memory paramsData) external returns (address) { + return LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployStepLocally(vm, address(this), paramsData); + } + + function externalCheckBeacon(string memory network, RegistryBeaconProxyParams memory params) external view { + LibRainDeployRegistryBeaconProxy.checkBeacon(network, block.chainid, params); + } + + /// The stored runtime code is another chain's good code, so only entry `k` can be refused. + function expectRefusedEverywhere(RegistryBeaconProxyParams memory spoiled, uint256 k, bytes memory refusal) + internal + { + uint256 chainId = spoiled.beaconPerNetwork[k].chainId; + bytes memory otherCode = threeChains().beaconPerNetwork[(k + 1) % 3].proxyRuntimeCode; + DeploySuite memory suite = LibRainDeployCloneMechanism.withPayload(goodSuite(), abi.encode(spoiled)); + vm.chainId(chainId); + + vm.expectRevert(refusal); + this.externalBeaconOnNetwork(spoiled, chainId); + + vm.expectRevert(refusal); + this.externalCheckProxyCode(spoiled, otherCode); + + vm.expectRevert(refusal); + this.externalCandidate(LibRegistryBeaconProxyTest.declared(SUITE, spoiled, otherCode)); + + vm.expectRevert(refusal); + this.externalExpectedBytecodeHash(suite, chainId); + + vm.expectRevert(refusal); + this.externalDeployParams(suite, chainId, suite.storedDeployedAddress); + + vm.expectRevert(refusal); + this.externalDeployStepLocally(abi.encode(spoiled)); + + vm.expectRevert(refusal); + this.externalCheckBeacon("spoiled", spoiled); + } + + function testAZeroProxyCodeHashOnOneChainIsRefusedEverywhere(uint8 at) external { + uint256 k = at % 3; + RegistryBeaconProxyParams memory spoiled = threeChains(); + spoiled.beaconPerNetwork[k].proxyCodeHash = bytes32(0); + expectRefusedEverywhere( + spoiled, + k, + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyCodeNotDeclared.selector, + spoiled.beaconPerNetwork[k].chainId + ) + ); + } + + function testEmptyProxyRuntimeCodeOnOneChainIsRefusedEverywhere(uint8 at) external { + uint256 k = at % 3; + RegistryBeaconProxyParams memory spoiled = threeChains(); + spoiled.beaconPerNetwork[k].proxyRuntimeCode = ""; + expectRefusedEverywhere( + spoiled, + k, + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyCodeNotDeclared.selector, + spoiled.beaconPerNetwork[k].chainId + ) + ); + } + + function testProxyRuntimeCodeNotHashingToItsHashOnOneChainIsRefusedEverywhere( + uint8 at, + bytes32 declared, + bytes memory code + ) external { + vm.assume(declared != bytes32(0) && code.length > 0 && keccak256(code) != declared); + uint256 k = at % 3; + RegistryBeaconProxyParams memory spoiled = threeChains(); + spoiled.beaconPerNetwork[k].proxyCodeHash = declared; + spoiled.beaconPerNetwork[k].proxyRuntimeCode = code; + expectRefusedEverywhere( + spoiled, + k, + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyCodeHashIncoherent.selector, + spoiled.beaconPerNetwork[k].chainId, + declared, + keccak256(code) + ) + ); + } + + function testStoredRuntimeCodeThatIsNoChainsProxyCodeIsRefused(bytes memory runtimeCode) external { + RegistryBeaconProxyParams memory params = threeChains(); + for (uint256 i = 0; i < 3; i++) { + vm.assume(keccak256(runtimeCode) != params.beaconPerNetwork[i].proxyCodeHash); + } + bytes memory refusal = abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyRuntimeCodeOnNoNetwork.selector, keccak256(runtimeCode) + ); + vm.expectRevert(refusal); + this.externalCheckProxyCode(params, runtimeCode); + vm.expectRevert(refusal); + this.externalCandidate(LibRegistryBeaconProxyTest.declared(SUITE, params, runtimeCode)); + } + + function testStoredRuntimeCodeThatIsAnyChainsProxyCodeIsAccepted() external view { + RegistryBeaconProxyParams memory params = threeChains(); + for (uint256 i = 0; i < 3; i++) { + bytes memory runtimeCode = params.beaconPerNetwork[i].proxyRuntimeCode; + this.externalCheckProxyCode(params, runtimeCode); + DeploySuite memory suite = + this.externalCandidate(LibRegistryBeaconProxyTest.declared(SUITE, params, runtimeCode)).snapshot; + assertEq(suite.storedRuntimeCode, runtimeCode); + } + } +} diff --git a/test/src/lib/LibRainDeployRegistryBeaconProxy.t.sol b/test/src/lib/LibRainDeployRegistryBeaconProxy.t.sol index 0607f9d..2aa4d91 100644 --- a/test/src/lib/LibRainDeployRegistryBeaconProxy.t.sol +++ b/test/src/lib/LibRainDeployRegistryBeaconProxy.t.sol @@ -6,14 +6,15 @@ import {Test} from "forge-std-1.17.0/src/Test.sol"; import {UpgradeableBeacon} from "@openzeppelin-contracts-5.7.0/proxy/beacon/UpgradeableBeacon.sol"; import {ICloneableFactoryV7} from "../../../src/interface/ICloneableFactoryV7.sol"; import {REGISTRY_BEACON_PROXY_CREATION_CODE} from "../../../src/generated/RegistryBeaconProxy.sol"; -import {DelegatedBeacon} from "../../../src/lib/LibICloneableFactoryV5.sol"; +import {DelegatedBeacon, ZeroBeaconCodeSize} from "../../../src/lib/LibICloneableFactoryV5.sol"; import {BeaconBindingTypeMismatch} from "../../../src/lib/LibICloneableFactoryV7.sol"; import {TestCloneFactory} from "../../../src/test/TestCloneFactory.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {IConfigRegistryV5} from "rain-deploy-0.1.43/src/interface/IConfigRegistryV5.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {IConfigRegistryV5} from "rain-deploy-0.1.44/src/interface/IConfigRegistryV5.sol"; import { LibRainDeployRegistryBeaconProxy, REGISTRY_BEACON_PROXY_ARTIFACT_PATH, + RegistryBeaconOnNetwork, RegistryBeaconProxyParams } from "../../../src/lib/LibRainDeployRegistryBeaconProxy.sol"; import {RegistryBeaconProxy} from "../../../script/RegistryBeaconProxy.sol"; @@ -23,6 +24,7 @@ import {MockDirtyOwnerCloneable} from "../../concrete/MockDirtyOwnerCloneable.so import {MockLongOwnerCloneable} from "../../concrete/MockLongOwnerCloneable.sol"; import {MockMisansweringOwnerCloneable} from "../../concrete/MockMisansweringOwnerCloneable.sol"; import {MockOriginOwnedCloneable} from "../../concrete/MockOriginOwnedCloneable.sol"; +import {MockOwnable2StepBeacon} from "../../concrete/MockOwnable2StepBeacon.sol"; /// @title LibRainDeployRegistryBeaconProxyTest /// @notice `LibRainDeployRegistryBeaconProxy`'s derivations, generator and deploy step, against a real @@ -34,6 +36,8 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { address constant DEPLOYER = address(0xD3910E8); + address constant UNLIVED_BEACON = address(0xBEAC0); + function externalDeployStep(string memory network, address deployer, bytes memory paramsData) external returns (address) @@ -43,16 +47,36 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { function externalRuntimeCode( RegistryBeaconProxyParams memory params, + address beacon, address implementation, bytes memory implementationCode ) external returns (bytes memory) { return LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCode( - vm, params, implementation, implementationCode + vm, params, beacon, implementation, implementationCode + ); + } + + function externalRuntimeCodeOnNetwork( + RegistryBeaconProxyParams memory params, + uint256 chainId, + address implementation, + bytes memory implementationCode + ) external returns (bytes memory) { + return LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCodeOnNetwork( + vm, params, chainId, implementation, implementationCode ); } function externalCheckBeacon(string memory network, RegistryBeaconProxyParams memory params) external view { - LibRainDeployRegistryBeaconProxy.checkBeacon(network, params); + LibRainDeployRegistryBeaconProxy.checkBeacon(network, block.chainid, params); + } + + function externalBeaconOnNetwork(RegistryBeaconProxyParams memory params, uint256 chainId) + external + pure + returns (RegistryBeaconOnNetwork memory) + { + return LibRainDeployRegistryBeaconProxy.beaconOnNetwork(params, chainId); } function liveParams(address implementation, bytes memory data) internal returns (RegistryBeaconProxyParams memory) { @@ -65,21 +89,67 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { registry: address(0x12E6), authority: LibRegistryBeaconProxyTest.AUTHORITY, beaconName: LibRegistryBeaconProxyTest.BEACON_NAME, - beacon: address(0xBEAC0), + beaconPerNetwork: new RegistryBeaconOnNetwork[](0), data: TEST_DATA, - salt: TEST_SALT + salt: TEST_SALT, + implementation: address(0), + implementationRuntimeCode: "" }); } + /// Three chains, each on its own beacon at its own address and code hash. + function threeChains() internal pure returns (RegistryBeaconOnNetwork[] memory) { + RegistryBeaconOnNetwork[] memory beaconPerNetwork = new RegistryBeaconOnNetwork[](3); + beaconPerNetwork[0] = RegistryBeaconOnNetwork({ + chainId: 42161, + beacon: address(0xBEAC1), + codeHash: keccak256("arbitrum"), + proxyCodeHash: bytes32(0), + proxyRuntimeCode: "" + }); + beaconPerNetwork[1] = RegistryBeaconOnNetwork({ + chainId: 8453, + beacon: address(0xBEAC2), + codeHash: keccak256("base"), + proxyCodeHash: bytes32(0), + proxyRuntimeCode: "" + }); + beaconPerNetwork[2] = RegistryBeaconOnNetwork({ + chainId: 137, + beacon: address(0xBEAC3), + codeHash: keccak256("polygon"), + proxyCodeHash: bytes32(0), + proxyRuntimeCode: "" + }); + return beaconPerNetwork; + } + + /// `unlivedParams` over `threeChains`, each entry carrying the proxy code its beacon gives, the beacons serving a + /// `MockCloneableV2`. + function unlivedThreeChains() internal returns (RegistryBeaconProxyParams memory) { + RegistryBeaconProxyParams memory params = unlivedParams(); + MockCloneableV2 implementation = new MockCloneableV2(); + params.implementation = address(implementation); + params.implementationRuntimeCode = address(implementation).code; + params.beaconPerNetwork = threeChains(); + for (uint256 i = 0; i < params.beaconPerNetwork.length; i++) { + params.beaconPerNetwork[i] = + LibRegistryBeaconProxyTest.withProxyCode(vm, params, params.beaconPerNetwork[i]); + } + return params; + } + function copy(RegistryBeaconProxyParams memory params) internal pure returns (RegistryBeaconProxyParams memory) { return RegistryBeaconProxyParams({ factory: params.factory, registry: params.registry, authority: params.authority, beaconName: params.beaconName, - beacon: params.beacon, + beaconPerNetwork: params.beaconPerNetwork, data: params.data, - salt: params.salt + salt: params.salt, + implementation: params.implementation, + implementationRuntimeCode: params.implementationRuntimeCode }); } @@ -128,7 +198,7 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { ); } - function testRegistryBeaconProxyAddressMovesWithEveryCommittedInputButNotTheBeacon( + function testRegistryBeaconProxyAddressMovesWithEveryCommittedInput( RegistryBeaconProxyParams memory params, uint160 delta, bytes32 other @@ -159,11 +229,20 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { moved = copy(params); moved.data = abi.encodePacked(params.data, hex"00"); assertNotEq(LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(moved), base, "data"); - moved = copy(params); - unchecked { - moved.beacon = address(uint160(params.beacon) + delta); - } - assertEq(LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(moved), base, "beacon"); + } + + function testRegistryBeaconProxyAddressIsTheSameWhateverTheBeaconPerNetwork( + RegistryBeaconProxyParams memory params, + RegistryBeaconOnNetwork[] memory other + ) external pure { + address base = LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(params); + RegistryBeaconProxyParams memory moved = copy(params); + moved.beaconPerNetwork = other; + assertEq(LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(moved), base, "other list"); + moved.beaconPerNetwork = threeChains(); + assertEq(LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(moved), base, "three chains"); + moved.beaconPerNetwork = new RegistryBeaconOnNetwork[](0); + assertEq(LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(moved), base, "empty list"); } function testRegistryBeaconProxyArtifactPathResolvesToNothing() external view { @@ -194,13 +273,16 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { registry: registryAt, authority: LibRegistryBeaconProxyTest.AUTHORITY, beaconName: LibRegistryBeaconProxyTest.BEACON_NAME, - beacon: beaconAt, + beaconPerNetwork: new RegistryBeaconOnNetwork[](0), data: data, - salt: salt + salt: salt, + implementation: address(implementation), + implementationRuntimeCode: address(implementation).code }); + params.beaconPerNetwork = LibRegistryBeaconProxyTest.onlyOn(vm, params, block.chainid, beaconAt); - bytes memory generated = LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCode( - vm, params, address(implementation), address(implementation).code + bytes memory generated = LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCodeOnNetwork( + vm, params, block.chainid, address(implementation), address(implementation).code ); assertEq(registryAt.code.length, 0, "registry left behind"); assertEq(beaconAt.code.length, 0, "beacon left behind"); @@ -220,55 +302,72 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { function testRegistryBeaconProxyRuntimeCodeCommitsToTheBeacon(uint160 delta) external { vm.assume(delta != 0); - RegistryBeaconProxyParams memory params = RegistryBeaconProxyParams({ - factory: address(0xFAC7), - registry: address(0x12E6), - authority: LibRegistryBeaconProxyTest.AUTHORITY, - beaconName: LibRegistryBeaconProxyTest.BEACON_NAME, - beacon: address(0xBEAC0), - data: TEST_DATA, - salt: TEST_SALT - }); + RegistryBeaconProxyParams memory params = unlivedParams(); MockCloneableV2 implementation = new MockCloneableV2(); bytes memory base = LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCode( - vm, params, address(implementation), address(implementation).code + vm, params, UNLIVED_BEACON, address(implementation), address(implementation).code ); - RegistryBeaconProxyParams memory moved = copy(params); + address moved; unchecked { - moved.beacon = address(uint160(params.beacon) + delta); + moved = address(uint160(UNLIVED_BEACON) + delta); } vm.assume( - uint160(moved.beacon) > 0xffff && moved.beacon != params.registry && moved.beacon != address(implementation) - && moved.beacon.code.length == 0 + uint160(moved) > 0xffff && moved != params.registry && moved != address(implementation) + && moved.code.length == 0 ); - assumeNotForgeAddress(moved.beacon); + assumeNotForgeAddress(moved); assertNotEq( LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCode( - vm, moved, address(implementation), address(implementation).code + vm, params, moved, address(implementation), address(implementation).code ), base ); } + function testRegistryBeaconProxyRuntimeCodeOnNetworkSimulatesEachChainsOwnBeacon() external { + RegistryBeaconProxyParams memory params = unlivedParams(); + params.beaconPerNetwork = threeChains(); + MockCloneableV2 implementation = new MockCloneableV2(); + for (uint256 i = 0; i < params.beaconPerNetwork.length; i++) { + assertEq( + this.externalRuntimeCodeOnNetwork( + params, params.beaconPerNetwork[i].chainId, address(implementation), address(implementation).code + ), + this.externalRuntimeCode( + params, params.beaconPerNetwork[i].beacon, address(implementation), address(implementation).code + ) + ); + } + assertNotEq( + this.externalRuntimeCodeOnNetwork(params, 42161, address(implementation), address(implementation).code), + this.externalRuntimeCodeOnNetwork(params, 8453, address(implementation), address(implementation).code) + ); + } + + function testRegistryBeaconProxyRuntimeCodeOnNetworkRefusesAChainNotListed(uint256 chainId) external { + RegistryBeaconProxyParams memory params = unlivedParams(); + params.beaconPerNetwork = threeChains(); + vm.assume(chainId != 42161 && chainId != 8453 && chainId != 137); + MockCloneableV2 implementation = new MockCloneableV2(); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyNoBeaconOnNetwork.selector, chainId + ) + ); + this.externalRuntimeCodeOnNetwork(params, chainId, address(implementation), address(implementation).code); + } + function testRegistryBeaconProxyRuntimeCodeRefusesAnImplementationWithoutCode() external { - RegistryBeaconProxyParams memory params = RegistryBeaconProxyParams({ - factory: address(0xFAC7), - registry: address(0x12E6), - authority: LibRegistryBeaconProxyTest.AUTHORITY, - beaconName: LibRegistryBeaconProxyTest.BEACON_NAME, - beacon: address(0xBEAC0), - data: TEST_DATA, - salt: TEST_SALT - }); + RegistryBeaconProxyParams memory params = unlivedParams(); address implementation = address(0x1A9E); vm.expectRevert( abi.encodeWithSelector( LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconConstructionFailed.selector, - params.beacon, + UNLIVED_BEACON, implementation ) ); - this.externalRuntimeCode(params, implementation, ""); + this.externalRuntimeCode(params, UNLIVED_BEACON, implementation, ""); } function testRegistryBeaconProxyRuntimeCodeOutlastsABindingAfterTheClock(uint32 ahead) external { @@ -277,7 +376,7 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { bytes memory expected = LibRegistryBeaconProxyTest.runtimeOf(vm, params); uint256 moment = block.timestamp; vm.warp(moment + ahead); - LibRegistryBeaconProxyTest.bind(vm, params.registry, params.beacon); + LibRegistryBeaconProxyTest.bind(vm, params.registry, params.beaconPerNetwork[0].beacon); vm.warp(moment); assertEq(LibRegistryBeaconProxyTest.runtimeOf(vm, params), expected); assertEq(block.timestamp, moment, "clock left moved"); @@ -287,12 +386,12 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { RegistryBeaconProxyParams memory params = unlivedParams(); MockCloneableV2 deployed = new MockCloneableV2(); bytes memory expected = LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCode( - vm, params, address(deployed), address(deployed).code + vm, params, UNLIVED_BEACON, address(deployed), address(deployed).code ); address implementation = address(0x1A9E); assertEq( LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCode( - vm, params, implementation, address(deployed).code + vm, params, UNLIVED_BEACON, implementation, address(deployed).code ), expected ); @@ -303,7 +402,7 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { RegistryBeaconProxyParams memory params = unlivedParams(); MockCloneableV2 implementation = new MockCloneableV2(); vm.mockCall( - params.beacon, + UNLIVED_BEACON, abi.encodeWithSelector(UpgradeableBeacon.implementation.selector), abi.encode(address(0x1A9E)) ); @@ -315,7 +414,7 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { params.beaconName ) ); - this.externalRuntimeCode(params, address(implementation), address(implementation).code); + this.externalRuntimeCode(params, UNLIVED_BEACON, address(implementation), address(implementation).code); } function testCheckBeaconAcceptsTheBoundBeacon() external { @@ -325,9 +424,9 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { function testCheckBeaconRefusesAnotherBeacon(address declared) external { RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); - vm.assume(declared != params.beacon); - address bound = params.beacon; - params.beacon = declared; + address bound = params.beaconPerNetwork[0].beacon; + vm.assume(declared != bound); + params.beaconPerNetwork[0].beacon = declared; vm.expectRevert( abi.encodeWithSelector( LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconMismatch.selector, @@ -339,6 +438,225 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { this.externalCheckBeacon(LibRainDeploy.ARBITRUM_ONE, params); } + function testBeaconOnNetworkAnswersEachChainsOwnEntry() external { + RegistryBeaconProxyParams memory params = unlivedThreeChains(); + for (uint256 i = 0; i < params.beaconPerNetwork.length; i++) { + assertEq( + abi.encode(this.externalBeaconOnNetwork(params, params.beaconPerNetwork[i].chainId)), + abi.encode(params.beaconPerNetwork[i]) + ); + } + } + + function testBeaconOnNetworkRefusesAChainNotListed(uint256 chainId) external { + RegistryBeaconProxyParams memory params = unlivedParams(); + params.beaconPerNetwork = threeChains(); + vm.assume(chainId != 42161 && chainId != 8453 && chainId != 137); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyNoBeaconOnNetwork.selector, chainId + ) + ); + this.externalBeaconOnNetwork(params, chainId); + } + + function testBeaconOnNetworkRefusesAnEmptyList(uint256 chainId) external { + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyNoBeaconOnNetwork.selector, chainId + ) + ); + this.externalBeaconOnNetwork(unlivedParams(), chainId); + } + + /// A chain listed twice is refused whether the entries agree or not, and wherever the second one sits. + function testBeaconOnNetworkRefusesAChainListedTwice(uint8 duplicated, uint8 at, bool same) external { + RegistryBeaconOnNetwork[] memory three = threeChains(); + RegistryBeaconOnNetwork memory twice = three[duplicated % 3]; + if (!same) { + twice = RegistryBeaconOnNetwork({ + chainId: twice.chainId, + beacon: address(0xBEAC4), + codeHash: keccak256("other"), + proxyCodeHash: bytes32(0), + proxyRuntimeCode: "" + }); + } + RegistryBeaconOnNetwork[] memory four = new RegistryBeaconOnNetwork[](4); + uint256 insertAt = at % 4; + uint256 k = 0; + for (uint256 i = 0; i < 4; i++) { + four[i] = i == insertAt ? twice : three[k++]; + } + RegistryBeaconProxyParams memory params = unlivedParams(); + params.beaconPerNetwork = four; + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconListedTwice.selector, twice.chainId + ) + ); + this.externalBeaconOnNetwork(params, twice.chainId); + } + + /// Three chains, each binding the name to its own live beacon: on each the check passes, and refuses a binding to + /// another chain's beacon naming the one this chain declares. + function testCheckBeaconReadsTheCurrentChainsBeacon() external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + uint256[3] memory chainIds = [uint256(42161), 8453, 137]; + address[3] memory beacons = [ + address(new UpgradeableBeacon(address(new MockCloneableV2()), address(this))), + address(new MockOwnable2StepBeacon(address(new MockCloneableV2()), address(this))), + address(new UpgradeableBeacon(address(new MockCloneableV2()), address(0xB0B))) + ]; + params.beaconPerNetwork = new RegistryBeaconOnNetwork[](3); + for (uint256 i = 0; i < 3; i++) { + params.beaconPerNetwork[i] = LibRegistryBeaconProxyTest.onNetwork(vm, params, chainIds[i], beacons[i]); + } + for (uint256 i = 0; i < 3; i++) { + vm.chainId(chainIds[i]); + vm.warp(block.timestamp + 1); + LibRegistryBeaconProxyTest.bind(vm, params.registry, beacons[i]); + this.externalCheckBeacon(LibRainDeploy.ARBITRUM_ONE, params); + + address other = beacons[(i + 1) % 3]; + vm.warp(block.timestamp + 1); + LibRegistryBeaconProxyTest.bind(vm, params.registry, other); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconMismatch.selector, + LibRainDeploy.ARBITRUM_ONE, + beacons[i], + other + ) + ); + this.externalCheckBeacon(LibRainDeploy.ARBITRUM_ONE, params); + } + } + + function testCheckBeaconRefusesAChainNotListed(uint64 chainId) external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + vm.assume(chainId != 0 && chainId != block.chainid); + vm.chainId(chainId); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyNoBeaconOnNetwork.selector, chainId + ) + ); + this.externalCheckBeacon(LibRainDeploy.ARBITRUM_ONE, params); + } + + function testCheckBeaconRefusesTheCurrentChainListedTwice() external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + RegistryBeaconOnNetwork[] memory twice = new RegistryBeaconOnNetwork[](2); + twice[0] = params.beaconPerNetwork[0]; + twice[1] = params.beaconPerNetwork[0]; + params.beaconPerNetwork = twice; + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconListedTwice.selector, block.chainid + ) + ); + this.externalCheckBeacon(LibRainDeploy.ARBITRUM_ONE, params); + } + + function testCheckBeaconRefusesACodeHashMismatch(bytes32 declared) external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + address beacon = params.beaconPerNetwork[0].beacon; + vm.assume(declared != beacon.codehash); + params.beaconPerNetwork[0].codeHash = declared; + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconCodeHashMismatch.selector, + LibRainDeploy.ARBITRUM_ONE, + beacon, + declared, + beacon.codehash + ) + ); + this.externalCheckBeacon(LibRainDeploy.ARBITRUM_ONE, params); + } + + function testCheckBeaconRefusesABeaconWhoseCodeChanged() external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + address beacon = params.beaconPerNetwork[0].beacon; + bytes32 declared = beacon.codehash; + vm.etch(beacon, type(MockOwnable2StepBeacon).runtimeCode); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconCodeHashMismatch.selector, + LibRainDeploy.ARBITRUM_ONE, + beacon, + declared, + keccak256(type(MockOwnable2StepBeacon).runtimeCode) + ) + ); + this.externalCheckBeacon(LibRainDeploy.ARBITRUM_ONE, params); + } + + function testCheckBeaconRefusesABoundBeaconWithoutCode() external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + address beacon = params.beaconPerNetwork[0].beacon; + bytes32 declared = beacon.codehash; + vm.etch(beacon, ""); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconCodeHashMismatch.selector, + LibRainDeploy.ARBITRUM_ONE, + beacon, + declared, + beacon.codehash + ) + ); + this.externalCheckBeacon(LibRainDeploy.ARBITRUM_ONE, params); + } + + /// A beacon without code is refused even when it is declared at the code hash it has. + function testRegistryBeaconProxyDeployStepRefusesABeaconWithoutCodeDeclaredAtItsHash(address codeless) external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + assumeNotForgeAddress(codeless); + vm.assume(codeless.code.length == 0 && uint160(codeless) > 0xffff); + vm.warp(block.timestamp + 1); + LibRegistryBeaconProxyTest.bind(vm, params.registry, codeless); + params.beaconPerNetwork = LibRegistryBeaconProxyTest.onlyOn(vm, params, block.chainid, codeless); + address expected = LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(params); + vm.expectRevert(abi.encodeWithSelector(ZeroBeaconCodeSize.selector)); + this.externalDeployStep(LibRainDeploy.ARBITRUM_ONE, DEPLOYER, abi.encode(params)); + assertEq(expected.code.length, 0); + } + + function testRegistryBeaconProxyDeployStepRefusesACodeHashMismatch(bytes32 declared) external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + address beacon = params.beaconPerNetwork[0].beacon; + vm.assume(declared != beacon.codehash); + params.beaconPerNetwork[0].codeHash = declared; + address expected = LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(params); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconCodeHashMismatch.selector, + LibRainDeploy.ARBITRUM_ONE, + beacon, + declared, + beacon.codehash + ) + ); + this.externalDeployStep(LibRainDeploy.ARBITRUM_ONE, DEPLOYER, abi.encode(params)); + assertEq(expected.code.length, 0); + } + + function testRegistryBeaconProxyDeployStepRefusesAChainNotListed(uint64 chainId) external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + vm.assume(chainId != 0 && chainId != block.chainid); + vm.chainId(chainId); + address expected = LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(params); + vm.expectRevert( + abi.encodeWithSelector( + LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyNoBeaconOnNetwork.selector, chainId + ) + ); + this.externalDeployStep(LibRainDeploy.ARBITRUM_ONE, DEPLOYER, abi.encode(params)); + assertEq(expected.code.length, 0); + } + function testRegistryBeaconProxyDeployStepDeploysTheDerivedAddress() external { RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); address deployed = this.externalDeployStep(LibRainDeploy.ARBITRUM_ONE, DEPLOYER, abi.encode(params)); @@ -347,6 +665,55 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { assertEq(MockCloneableV2(deployed).sInitData(), TEST_DATA); } + function testRegistryBeaconProxyDeployStepWithOneBeaconListedPerChainDeploysOneProxyOnEach() external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + address beacon = params.beaconPerNetwork[0].beacon; + uint256[3] memory chainIds = [uint256(42161), 8453, 137]; + params.beaconPerNetwork = new RegistryBeaconOnNetwork[](3); + for (uint256 i = 0; i < 3; i++) { + params.beaconPerNetwork[i] = LibRegistryBeaconProxyTest.onNetwork(vm, params, chainIds[i], beacon); + } + bytes memory expectedCode = LibRegistryBeaconProxyTest.runtimeOf(vm, params); + address expected = LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(params); + uint256 state = vm.snapshotState(); + for (uint256 i = 0; i < 3; i++) { + vm.chainId(chainIds[i]); + address deployed = this.externalDeployStep(LibRainDeploy.ARBITRUM_ONE, DEPLOYER, abi.encode(params)); + assertEq(deployed, expected); + assertEq(deployed.code, expectedCode); + assertTrue(vm.revertToState(state)); + } + } + + function testRegistryBeaconProxyDeployStepDeploysEachChainsOwnBeaconAtOneAddress() external { + RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); + uint256[3] memory chainIds = [uint256(42161), 8453, 137]; + address[3] memory beacons = [ + params.beaconPerNetwork[0].beacon, + address(new MockOwnable2StepBeacon(address(new MockCloneableV2()), address(this))), + address(new UpgradeableBeacon(address(new MockCloneableV2()), address(0xB0B))) + ]; + params.beaconPerNetwork = new RegistryBeaconOnNetwork[](3); + for (uint256 i = 0; i < 3; i++) { + params.beaconPerNetwork[i] = LibRegistryBeaconProxyTest.onNetwork(vm, params, chainIds[i], beacons[i]); + } + address expected = LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(params); + uint256 state = vm.snapshotState(); + for (uint256 i = 0; i < 3; i++) { + vm.chainId(chainIds[i]); + vm.warp(block.timestamp + 1); + LibRegistryBeaconProxyTest.bind(vm, params.registry, beacons[i]); + address implementation = UpgradeableBeacon(beacons[i]).implementation(); + bytes memory simulated = LibRainDeployRegistryBeaconProxy.registryBeaconProxyRuntimeCodeOnNetwork( + vm, params, chainIds[i], implementation, implementation.code + ); + address deployed = this.externalDeployStep(LibRainDeploy.ARBITRUM_ONE, DEPLOYER, abi.encode(params)); + assertEq(deployed, expected); + assertEq(deployed.code, simulated); + assertTrue(vm.revertToState(state)); + } + } + function testRegistryBeaconProxyDeployStepReturnsWhereTheFactoryDeployed() external { RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); address elsewhere = @@ -399,7 +766,7 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { abi.encodeWithSelector( LibRainDeployRegistryBeaconProxy.RegistryBeaconProxyBeaconMismatch.selector, LibRainDeploy.ARBITRUM_ONE, - params.beacon, + params.beaconPerNetwork[0].beacon, bound ) ); @@ -412,7 +779,9 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { vm.warp(block.timestamp + 1); vm.prank(params.authority); IConfigRegistryV5(params.registry) - .registerV5(params.authority, params.beaconName, "uint256", abi.encode(params.beacon), ""); + .registerV5( + params.authority, params.beaconName, "uint256", abi.encode(params.beaconPerNetwork[0].beacon), "" + ); address expected = LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(params); vm.expectRevert( abi.encodeWithSelector( @@ -427,9 +796,12 @@ contract LibRainDeployRegistryBeaconProxyTest is Test { assertEq(expected.code.length, 0); } + /// Refused even when declared at the code hash the delegation gives it. function testRegistryBeaconProxyDeployStepRefusesADelegatedBeacon(address delegate) external { RegistryBeaconProxyParams memory params = liveParams(address(new MockCloneableV2()), TEST_DATA); - vm.etch(params.beacon, abi.encodePacked(hex"ef0100", delegate)); + address beacon = params.beaconPerNetwork[0].beacon; + vm.etch(beacon, abi.encodePacked(hex"ef0100", delegate)); + params.beaconPerNetwork[0].codeHash = beacon.codehash; address expected = LibRainDeployRegistryBeaconProxy.registryBeaconProxyDeployedAddress(params); vm.expectRevert(abi.encodeWithSelector(DelegatedBeacon.selector)); this.externalDeployStep(LibRainDeploy.ARBITRUM_ONE, DEPLOYER, abi.encode(params)); diff --git a/test/src/lib/LibRainDeploySnapshotRecordedMechanismClone.t.sol b/test/src/lib/LibRainDeploySnapshotRecordedMechanismClone.t.sol index 30c3200..5e0811d 100644 --- a/test/src/lib/LibRainDeploySnapshotRecordedMechanismClone.t.sol +++ b/test/src/lib/LibRainDeploySnapshotRecordedMechanismClone.t.sol @@ -8,14 +8,14 @@ import { DeployDependency, DeployMechanismHandler, DeploySuite -} from "rain-deploy-0.1.43/src/abstract/RainDeploySuitesBase.sol"; -import {LibRainDeploy} from "rain-deploy-0.1.43/src/lib/LibRainDeploy.sol"; -import {LibRainDeployDeclaration} from "rain-deploy-0.1.43/src/lib/LibRainDeployDeclaration.sol"; -import {LibRainDeploySnapshot} from "rain-deploy-0.1.43/src/lib/LibRainDeploySnapshot.sol"; +} from "rain-deploy-0.1.44/src/abstract/RainDeploySuitesBase.sol"; +import {LibRainDeploy} from "rain-deploy-0.1.44/src/lib/LibRainDeploy.sol"; +import {LibRainDeployDeclaration} from "rain-deploy-0.1.44/src/lib/LibRainDeployDeclaration.sol"; +import {LibRainDeploySnapshot} from "rain-deploy-0.1.44/src/lib/LibRainDeploySnapshot.sol"; import { LibRainDeployZoltuMechanism, ZOLTU_MECHANISM_ID -} from "rain-deploy-0.1.43/src/lib/LibRainDeployZoltuMechanism.sol"; +} from "rain-deploy-0.1.44/src/lib/LibRainDeployZoltuMechanism.sol"; import {CLONE_ARTIFACT_PATH} from "../../../src/lib/LibRainDeployClone.sol"; import { CLONE_MECHANISM,