Skip to content

Commit

Permalink
fix(ct): fix out-of-gas bug for implementation contract deployments
Browse files Browse the repository at this point in the history
  • Loading branch information
sam-goldman committed Nov 17, 2022
1 parent 2557846 commit ed7babc
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/mighty-geese-tan.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@chugsplash/contracts': patch
---

Fix bug where implementation contract deployments were failing due to out-of-gas
16 changes: 16 additions & 0 deletions packages/contracts/contracts/ChugSplashManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/contracts/src/ifaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/plugins/src/hardhat/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand Down

0 comments on commit ed7babc

Please sign in to comment.