From 3e709b4de3e3fc8b3730c9db2195f503491e55fe Mon Sep 17 00:00:00 2001 From: elenadimitrova Date: Fri, 4 Jun 2021 17:42:33 +0300 Subject: [PATCH] Remove AddressManager from the L1 standard bridge --- .../bridge/tokens/OVM_L1StandardBridge.sol | 21 ++-------- .../assets/OVM_L1StandardBridge.spec.ts | 40 ------------------- 2 files changed, 3 insertions(+), 58 deletions(-) diff --git a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1StandardBridge.sol b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1StandardBridge.sol index c9f6df4ebd4b..ba8b9e9e94e3 100644 --- a/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1StandardBridge.sol +++ b/packages/contracts/contracts/optimistic-ethereum/OVM/bridge/tokens/OVM_L1StandardBridge.sol @@ -10,8 +10,6 @@ import { iOVM_L2ERC20Bridge } from "../../../iOVM/bridge/tokens/iOVM_L2ERC20Brid import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; /* Library Imports */ -import { Lib_AddressResolver } from "../../../libraries/resolver/Lib_AddressResolver.sol"; -import { Lib_AddressManager } from "../../../libraries/resolver/Lib_AddressManager.sol"; import { OVM_CrossDomainEnabled } from "../../../libraries/bridge/OVM_CrossDomainEnabled.sol"; import { Lib_PredeployAddresses } from "../../../libraries/constants/Lib_PredeployAddresses.sol"; import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol"; @@ -25,7 +23,7 @@ import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; * Compiler used: solc * Runtime target: EVM */ -contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled, Lib_AddressResolver { +contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled { using SafeMath for uint; using SafeERC20 for IERC20; @@ -53,7 +51,6 @@ contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled, // This contract lives behind a proxy, so the constructor parameters will go unused. constructor() OVM_CrossDomainEnabled(address(0)) - Lib_AddressResolver(address(0)) {} /****************** @@ -73,12 +70,10 @@ contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled, ) public { - require(libAddressManager == Lib_AddressManager(0), "Contract has already been initialized."); - libAddressManager = Lib_AddressManager(_libAddressManager); + require(messenger == address(0), "Contract has already been initialized."); messenger = _l1messenger; l2TokenBridge = _l2TokenBridge; ovmEth = _ovmEth; - messenger = resolve("Proxy__OVM_L1CrossDomainMessenger"); } /************** @@ -316,20 +311,10 @@ contract OVM_L1StandardBridge is iOVM_L1StandardBridge, OVM_CrossDomainEnabled, * Temporary - Migrating ETH * *****************************/ - /** - * @dev Migrates entire ETH balance to another gateway. - * @param _to Gateway Proxy address to migrate ETH to. - */ - function migrateEth(address payable _to) external { - address owner = Lib_AddressManager(libAddressManager).owner(); - require(msg.sender == owner, "Only the owner can migrate ETH"); - uint256 balance = address(this).balance; - OVM_L1StandardBridge(_to).donateETH{value:balance}(); - } - /** * @dev Adds ETH balance to the account. This is meant to allow for ETH * to be migrated from an old gateway to a new gateway. + * NOTE: This is left for one upgrade only so we are able to receive the migrated ETH from the old contract */ function donateETH() external payable {} } diff --git a/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1StandardBridge.spec.ts b/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1StandardBridge.spec.ts index 803410855d2c..179da924d38e 100644 --- a/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1StandardBridge.spec.ts +++ b/packages/contracts/test/contracts/OVM/bridge/assets/OVM_L1StandardBridge.spec.ts @@ -279,46 +279,6 @@ describe('OVM_L1StandardBridge', () => { }) }) - describe('migrating ETH', () => { - const migrateAmount = 1_000 - - let New_OVM_L1StandardBridge: Contract - beforeEach(async () => { - await OVM_L1StandardBridge.donateETH({ value: migrateAmount }) - const bridgeBalance = await ethers.provider.getBalance( - OVM_L1StandardBridge.address - ) - expect(bridgeBalance).to.equal(migrateAmount) - - // Setup a new bridge to migrate to - New_OVM_L1StandardBridge = await ( - await ethers.getContractFactory('OVM_L1StandardBridge') - ).deploy() - await New_OVM_L1StandardBridge.initialize( - AddressManager.address, - Mock__OVM_L1CrossDomainMessenger.address, - DUMMY_L2_BRIDGE_ADDRESS, - Mock__OVM_ETH.address - ) - }) - - it('should successfully migrate ETH to new bridge', async () => { - await OVM_L1StandardBridge.migrateEth(New_OVM_L1StandardBridge.address) - const newBridgeBalance = await ethers.provider.getBalance( - New_OVM_L1StandardBridge.address - ) - expect(newBridgeBalance).to.equal(migrateAmount) - }) - - it('should not allow migrating ETH from non-owner', async () => { - await expect( - OVM_L1StandardBridge.connect(bob).migrateEth( - New_OVM_L1StandardBridge.address - ) - ).to.be.revertedWith('Only the owner can migrate ETH') - }) - }) - describe('ERC20 deposits', () => { const INITIAL_DEPOSITER_BALANCE = 100_000 let depositer: string