-
Notifications
You must be signed in to change notification settings - Fork 694
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ethereum: Implement shutdown for all 3 contracts (fixes #1937)
These are stripped down versions of the original contracts that can be dropped in place via an upgrade to disable core functionality. Governance features are still enabled, which means it's possible to upgrade back to a working implementation.
- Loading branch information
Showing
14 changed files
with
171 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// contracts/Shutdown.sol | ||
// SPDX-License-Identifier: Apache 2 | ||
|
||
pragma solidity ^0.8.0; | ||
pragma experimental ABIEncoderV2; | ||
|
||
import "./Governance.sol"; | ||
|
||
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol"; | ||
|
||
/** | ||
* @title Shutdown | ||
* @notice This contract implements a stripped-down version of the Wormhole core | ||
* messaging protocol that is a drop-in replacement for Wormhole's | ||
* implementation contract, effectively disabling all non-governance | ||
* functionality. | ||
* In particular, outgoing messages are disabled, but the contract | ||
* remains upgradeable through governance. | ||
*/ | ||
contract Shutdown is Governance { | ||
|
||
function initialize() public { | ||
address implementation = ERC1967Upgrade._getImplementation(); | ||
setInitialized(implementation); | ||
|
||
// this function needs to be exposed for an upgrade to pass | ||
// NOTE: leave this function empty! It specifically does not have an | ||
// 'initializer' modifier, to allow this contract to be upgraded to | ||
// multiple times. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// contracts/BridgeShutdown.sol | ||
// SPDX-License-Identifier: Apache 2 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "./BridgeGovernance.sol"; | ||
|
||
import "@openzeppelin/contracts/security/ReentrancyGuard.sol"; | ||
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol"; | ||
|
||
/** | ||
* @title BridgeShutdown | ||
* @notice This contract implements a stripped-down version of the token bridge | ||
* asset transfer protocol that is a drop-in replacement for the Bridge | ||
* implementation contract, effectively disabling all non-governance | ||
* functionality. | ||
* In particular, sending and receiving assets is disabled, but the | ||
* contract remains upgradeable through governance. | ||
* @dev Technically the ReentrancyGuard is not used in this contract, | ||
* but it adds a storage variable, so as a matter of principle, we | ||
* inherit that here too in order keep the storage layout identical to | ||
* the actual implementation contract (which does use the reentrancy | ||
* guard). | ||
*/ | ||
contract BridgeShutdown is BridgeGovernance, ReentrancyGuard { | ||
|
||
function initialize() public { | ||
address implementation = ERC1967Upgrade._getImplementation(); | ||
setInitialized(implementation); | ||
|
||
// this function needs to be exposed for an upgrade to pass | ||
// NOTE: leave this function empty! It specifically does not have an | ||
// 'initializer' modifier, to allow this contract to be upgraded to | ||
// multiple times. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// contracts/NFTBridgeShutdown.sol | ||
// SPDX-License-Identifier: Apache 2 | ||
|
||
pragma solidity ^0.8.0; | ||
|
||
import "./NFTBridgeGovernance.sol"; | ||
|
||
import "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol"; | ||
|
||
/** | ||
* @title BridgeShutdown | ||
* @notice This contract implements a stripped-down version of the NFT bridge | ||
* asset transfer protocol that is a drop-in replacement for the | ||
* NFTBridge implementation contract, effectively disabling all | ||
* non-governance functionality. | ||
* In particular, sending and receiving assets is disabled, but the | ||
* contract remains upgradeable through governance. | ||
*/ | ||
contract NFTBridgeShutdown is NFTBridgeGovernance { | ||
|
||
function initialize() public { | ||
address implementation = ERC1967Upgrade._getImplementation(); | ||
setInitialized(implementation); | ||
|
||
// this function needs to be exposed for an upgrade to pass | ||
// NOTE: leave this function empty! It specifically does not have an | ||
// 'initializer' modifier, to allow this contract to be upgraded to | ||
// multiple times. | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const Shutdown = artifacts.require("Shutdown"); | ||
module.exports = async function(callback) { | ||
try { | ||
const contract = (await Shutdown.new()); | ||
console.log('tx: ' + contract.transactionHash); | ||
console.log('Shutdown address: ' + contract.address); | ||
callback(); | ||
} catch (e) { | ||
callback(e); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const Shutdown = artifacts.require("NFTBridgeShutdown"); | ||
module.exports = async function(callback) { | ||
try { | ||
const contract = (await Shutdown.new()); | ||
console.log('tx: ' + contract.transactionHash); | ||
console.log('NFTBridgeShutdown address: ' + contract.address); | ||
callback(); | ||
} catch (e) { | ||
callback(e); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
const Shutdown = artifacts.require("BridgeShutdown"); | ||
module.exports = async function(callback) { | ||
try { | ||
const contract = (await Shutdown.new()); | ||
console.log('tx: ' + contract.transactionHash); | ||
console.log('Bridge address: ' + contract.address); | ||
callback(); | ||
} catch (e) { | ||
callback(e); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters