Commit 32e59853 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: standard bridge pausable withdrawals

parent 65821936
...@@ -234,6 +234,7 @@ abstract contract StandardBridge is Initializable { ...@@ -234,6 +234,7 @@ abstract contract StandardBridge is Initializable {
payable payable
onlyOtherBridge onlyOtherBridge
{ {
require(paused() == false, "StandardBridge: paused");
require(msg.value == _amount, "StandardBridge: amount sent does not match amount required"); require(msg.value == _amount, "StandardBridge: amount sent does not match amount required");
require(_to != address(this), "StandardBridge: cannot send to self"); require(_to != address(this), "StandardBridge: cannot send to self");
require(_to != address(MESSENGER), "StandardBridge: cannot send to messenger"); require(_to != address(MESSENGER), "StandardBridge: cannot send to messenger");
...@@ -267,6 +268,7 @@ abstract contract StandardBridge is Initializable { ...@@ -267,6 +268,7 @@ abstract contract StandardBridge is Initializable {
public public
onlyOtherBridge onlyOtherBridge
{ {
require(paused() == false, "StandardBridge: paused");
if (_isOptimismMintableERC20(_localToken)) { if (_isOptimismMintableERC20(_localToken)) {
require( require(
_isCorrectTokenPair(_localToken, _remoteToken), _isCorrectTokenPair(_localToken, _remoteToken),
...@@ -301,7 +303,6 @@ abstract contract StandardBridge is Initializable { ...@@ -301,7 +303,6 @@ abstract contract StandardBridge is Initializable {
) )
internal internal
{ {
require(paused() == false, "StandardBridge: paused");
require(msg.value == _amount, "StandardBridge: bridging ETH must include sufficient ETH value"); require(msg.value == _amount, "StandardBridge: bridging ETH must include sufficient ETH value");
// Emit the correct events. By default this will be _amount, but child // Emit the correct events. By default this will be _amount, but child
...@@ -335,8 +336,6 @@ abstract contract StandardBridge is Initializable { ...@@ -335,8 +336,6 @@ abstract contract StandardBridge is Initializable {
) )
internal internal
{ {
require(paused() == false, "StandardBridge: paused");
if (_isOptimismMintableERC20(_localToken)) { if (_isOptimismMintableERC20(_localToken)) {
require( require(
_isCorrectTokenPair(_localToken, _remoteToken), _isCorrectTokenPair(_localToken, _remoteToken),
......
...@@ -71,85 +71,60 @@ contract L1StandardBridge_Pause_TestFail is Bridge_Initializer { ...@@ -71,85 +71,60 @@ contract L1StandardBridge_Pause_TestFail is Bridge_Initializer {
vm.prank(superchainConfig.guardian()); vm.prank(superchainConfig.guardian());
superchainConfig.pause("identifier"); superchainConfig.pause("identifier");
assertTrue(l1StandardBridge.paused()); assertTrue(l1StandardBridge.paused());
}
function test_pause_bridgeETH_reverts() external { vm.deal(address(l1StandardBridge.messenger()), 1 ether);
vm.expectRevert("StandardBridge: paused");
vm.prank(alice, alice);
l1StandardBridge.bridgeETH({ _minGasLimit: 0, _extraData: hex"" });
}
function test_pause_bridgeETHTo_reverts() external { vm.mockCall(
vm.expectRevert("StandardBridge: paused"); address(l1StandardBridge.messenger()),
vm.prank(alice, alice); abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector),
l1StandardBridge.bridgeETHTo({ _to: address(1), _minGasLimit: 0, _extraData: hex"" }); abi.encode(address(l1StandardBridge.otherBridge()))
} );
function test_pause_depositETH_reverts() external {
vm.expectRevert("StandardBridge: paused");
vm.prank(alice, alice);
l1StandardBridge.depositETH({ _minGasLimit: 0, _extraData: hex"" });
}
function test_pause_depositETHTo_reverts() external {
vm.expectRevert("StandardBridge: paused");
vm.prank(alice, alice);
l1StandardBridge.depositETHTo({ _to: address(1), _minGasLimit: 0, _extraData: hex"" });
}
function test_pause_fallback_reverts() external {
vm.expectRevert("StandardBridge: paused");
vm.prank(alice, alice);
(bool success,) = address(l1StandardBridge).call{ value: 1 ether }(hex"");
assertTrue(success);
} }
function test_pause_bridgeERC20_reverts() external { function test_pause_finalizeBridgeETH_reverts() external {
vm.prank(address(l1StandardBridge.messenger()));
vm.expectRevert("StandardBridge: paused"); vm.expectRevert("StandardBridge: paused");
vm.prank(alice, alice); l1StandardBridge.finalizeBridgeETH{ value: 100 }({
l1StandardBridge.bridgeERC20({ _from: address(2),
_localToken: address(1), _to: address(3),
_remoteToken: address(2), _amount: 100,
_amount: 0,
_minGasLimit: 0,
_extraData: hex"" _extraData: hex""
}); });
} }
function test_pause_bridgeERC20To_reverts() external { function test_pause_finalizeETHWithdrawal_reverts() external {
vm.prank(address(l1StandardBridge.messenger()));
vm.expectRevert("StandardBridge: paused"); vm.expectRevert("StandardBridge: paused");
vm.prank(alice, alice); l1StandardBridge.finalizeETHWithdrawal{ value: 100 }({
l1StandardBridge.bridgeERC20To({ _from: address(2),
_localToken: address(1),
_remoteToken: address(2),
_to: address(3), _to: address(3),
_amount: 0, _amount: 100,
_minGasLimit: 0,
_extraData: hex"" _extraData: hex""
}); });
} }
function test_pause_depositERC20_reverts() external { function test_pause_finalizeERC20Withdrawal_reverts() external {
vm.prank(address(l1StandardBridge.messenger()));
vm.expectRevert("StandardBridge: paused"); vm.expectRevert("StandardBridge: paused");
vm.prank(alice, alice); l1StandardBridge.finalizeERC20Withdrawal({
l1StandardBridge.depositERC20({ _l1Token: address(0),
_l1Token: address(1), _l2Token: address(0),
_l2Token: address(2), _from: address(0),
_to: address(0),
_amount: 0, _amount: 0,
_minGasLimit: 0,
_extraData: hex"" _extraData: hex""
}); });
} }
function test_pause_depositERC20To_reverts() external { function test_pause_finalizeBridgeERC20_reverts() external {
vm.prank(address(l1StandardBridge.messenger()));
vm.expectRevert("StandardBridge: paused"); vm.expectRevert("StandardBridge: paused");
vm.prank(alice, alice); l1StandardBridge.finalizeBridgeERC20({
l1StandardBridge.depositERC20To({ _localToken: address(0),
_l1Token: address(1), _remoteToken: address(0),
_l2Token: address(2), _from: address(0),
_to: address(3), _to: address(0),
_amount: 0, _amount: 0,
_minGasLimit: 0,
_extraData: hex"" _extraData: hex""
}); });
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment