From ed7babc1cc16aebfaea549fed145184393801b6a Mon Sep 17 00:00:00 2001 From: Sam Goldman Date: Thu, 17 Nov 2022 02:43:18 -0500 Subject: [PATCH] fix(ct): fix out-of-gas bug for implementation contract deployments --- .changeset/mighty-geese-tan.md | 5 +++++ .../contracts/contracts/ChugSplashManager.sol | 16 ++++++++++++++++ packages/contracts/src/ifaces.ts | 2 +- packages/plugins/src/hardhat/deployments.ts | 2 +- 4 files changed, 23 insertions(+), 2 deletions(-) create mode 100644 .changeset/mighty-geese-tan.md diff --git a/.changeset/mighty-geese-tan.md b/.changeset/mighty-geese-tan.md new file mode 100644 index 000000000..5e8970eb7 --- /dev/null +++ b/.changeset/mighty-geese-tan.md @@ -0,0 +1,5 @@ +--- +'@chugsplash/contracts': patch +--- + +Fix bug where implementation contract deployments were failing due to out-of-gas diff --git a/packages/contracts/contracts/ChugSplashManager.sol b/packages/contracts/contracts/ChugSplashManager.sol index 69f14ef54..01820c7e0 100644 --- a/packages/contracts/contracts/ChugSplashManager.sol +++ b/packages/contracts/contracts/ChugSplashManager.sol @@ -789,11 +789,27 @@ contract ChugSplashManager is OwnableUpgradeable, ReentrancyGuardUpgradeable { * @param _code Creation bytecode of the implementation contract. */ function _deployImplementation(string memory _target, bytes memory _code) internal { + // Get the expected address of the implementation contract. + address expectedImplementation = Create2.compute( + address(this), + bytes32(0), + _code + ); + address implementation; assembly { implementation := create2(0x0, add(_code, 0x20), mload(_code), 0x0) } + // Could happen if insufficient gas is supplied to this transaction, should not + // happen otherwise. If there's a situation in which this could happen other than a + // standard OOG, then this would halt the entire contract. + // TODO: Make sure this cannot happen in any case other than OOG. + require( + expectedImplementation == implementation, + "ChugSplashManager: implementation was not deployed correctly" + ); + // Set the target to its newly deployed implementation. implementations[_target] = implementation; } diff --git a/packages/contracts/src/ifaces.ts b/packages/contracts/src/ifaces.ts index d9053fa68..3053ef48d 100644 --- a/packages/contracts/src/ifaces.ts +++ b/packages/contracts/src/ifaces.ts @@ -7,7 +7,7 @@ export const ProxyUpdaterArtifact = require('../artifacts/contracts/ProxyUpdater export const DefaultAdapterArtifact = require('../artifacts/contracts/adapters/DefaultAdapter.sol/DefaultAdapter.json') export const ProxyArtifact = require('../artifacts/contracts/libraries/Proxy.sol/Proxy.json') -export const buildInfo = require('../artifacts/build-info/b00e1a42c4580623826aa11edd72371a.json') +export const buildInfo = require('../artifacts/build-info/d5ced5690fbead1b00cfc48cc8c48668.json') export const ChugSplashRegistryABI = ChugSplashRegistryArtifact.abi export const ChugSplashBootLoaderABI = ChugSplashBootLoaderArtifact.abi diff --git a/packages/plugins/src/hardhat/deployments.ts b/packages/plugins/src/hardhat/deployments.ts index 2579893e1..0a94bea46 100644 --- a/packages/plugins/src/hardhat/deployments.ts +++ b/packages/plugins/src/hardhat/deployments.ts @@ -144,7 +144,7 @@ export const deployChugSplashConfig = async ( hre, parsedConfig ) - // Approve the deployment. If `remoteExecution is `true`, this also monitors the deployment + // Approve the deployment. If `remoteExecution` is `true`, this also monitors the deployment // until it is completed and generates the deployment artifacts. await chugsplashApproveTask( {