Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
nebula
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
exchain
nebula
Commits
9269e224
Unverified
Commit
9269e224
authored
Jun 17, 2022
by
Maurelian
Committed by
GitHub
Jun 17, 2022
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #2765 from ethereum-optimism/m/oz-med-on-develop
parents
35757456
36592435
Changes
10
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
227 additions
and
177 deletions
+227
-177
three-pants-punch.md
.changeset/three-pants-punch.md
+9
-0
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+32
-30
L1StandardBridge.sol
packages/contracts-bedrock/contracts/L1/L1StandardBridge.sol
+68
-60
OptimismPortal.sol
packages/contracts-bedrock/contracts/L1/OptimismPortal.sol
+1
-1
L2StandardBridge.sol
packages/contracts-bedrock/contracts/L2/L2StandardBridge.sol
+42
-42
L1CrossDomainMessenger.t.sol
...racts-bedrock/contracts/test/L1CrossDomainMessenger.t.sol
+15
-0
L1StandardBridge.t.sol
...s/contracts-bedrock/contracts/test/L1StandardBridge.t.sol
+0
-9
L2StandardBridge.t.sol
...s/contracts-bedrock/contracts/test/L2StandardBridge.t.sol
+17
-2
CrossDomainMessenger.sol
...acts-bedrock/contracts/universal/CrossDomainMessenger.sol
+7
-0
StandardBridge.sol
.../contracts-bedrock/contracts/universal/StandardBridge.sol
+36
-33
No files found.
.changeset/three-pants-punch.md
0 → 100644
View file @
9269e224
---
'
@eth-optimism/contracts-bedrock'
:
patch
---
Fixes to medium severity OZ findings
-
Disallow reentrant withdrawals
-
remove donateEth
-
Correct ordering of
\_
from and
\_
to arguments on refunds of failed deposits
packages/contracts-bedrock/.gas-snapshot
View file @
9269e224
...
...
@@ -23,39 +23,40 @@ L1BlockTest:test_updateValues() (gas: 28215)
L1BlockNumberTest:test_fallback() (gas: 18773)
L1BlockNumberTest:test_getL1BlockNumber() (gas: 10589)
L1BlockNumberTest:test_receive() (gas: 25436)
L1CrossDomainMessenger_Test:testCannot_L1MessengerPause() (gas: 10909)
L1CrossDomainMessenger_Test:test_L1MessengerMessageVersion() (gas: 8366)
L1CrossDomainMessenger_Test:test_L1MessengerPause() (gas: 31882)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageSucceeds() (gas: 61239)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageToSystemContract() (gas: 44859)
L1CrossDomainMessenger_Test:test_L1MessengerRelayShouldRevertIfPaused() (gas: 41631)
L1CrossDomainMessenger_Test:test_L1MessengerSendMessage() (gas: 172148)
L1CrossDomainMessenger_Test:test_L1MessengerTwiceSendMessage() (gas: 1254131)
L1CrossDomainMessenger_Test:test_L1MessengerXDomainSenderReverts() (gas: 10566)
L1CrossDomainMessenger_Test:test_L1MessengerxDomainMessageSenderResets() (gas: 58535)
L1StandardBridge_Test:test_depositERC20() (gas: 452873)
L1StandardBridge_Test:test_depositERC20To() (gas: 454650)
L1StandardBridge_Test:test_depositETH() (gas: 247054)
L1StandardBridge_Test:test_depositETHTo() (gas: 204938)
L1StandardBridge_Test:test_donateETH() (gas: 17545)
L1StandardBridge_Test:test_finalizeERC20Withdrawal() (gas: 438824)
L1CrossDomainMessenger_Test:testCannot_L1MessengerPause() (gas: 10844)
L1CrossDomainMessenger_Test:testCannot_L1MessengerUnpause() (gas: 10858)
L1CrossDomainMessenger_Test:test_L1MessengerMessageVersion() (gas: 8388)
L1CrossDomainMessenger_Test:test_L1MessengerPause() (gas: 31860)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageSucceeds() (gas: 61261)
L1CrossDomainMessenger_Test:test_L1MessengerRelayMessageToSystemContract() (gas: 44881)
L1CrossDomainMessenger_Test:test_L1MessengerRelayShouldRevertIfPaused() (gas: 41587)
L1CrossDomainMessenger_Test:test_L1MessengerSendMessage() (gas: 172193)
L1CrossDomainMessenger_Test:test_L1MessengerTwiceSendMessage() (gas: 1254199)
L1CrossDomainMessenger_Test:test_L1MessengerUnpause() (gas: 23804)
L1CrossDomainMessenger_Test:test_L1MessengerXDomainSenderReverts() (gas: 10599)
L1CrossDomainMessenger_Test:test_L1MessengerxDomainMessageSenderResets() (gas: 58579)
L1StandardBridge_Test:test_depositERC20() (gas: 452856)
L1StandardBridge_Test:test_depositERC20To() (gas: 454632)
L1StandardBridge_Test:test_depositETH() (gas: 247077)
L1StandardBridge_Test:test_depositETHTo() (gas: 204961)
L1StandardBridge_Test:test_finalizeERC20Withdrawal() (gas: 438752)
L1StandardBridge_Test:test_finalizeETHWithdrawal() (gas: 48005)
L1StandardBridge_Test:test_initialize() (gas: 14885)
L1StandardBridge_Test:test_onlyEOADepositERC20() (gas: 12085)
L1StandardBridge_Test:test_onlyEOADepositETH() (gas: 30637)
L1StandardBridge_Test:test_onlyL2BridgeFinalizeERC20Withdrawal() (gas: 23565)
L1StandardBridge_Test:test_onlyPortalFinalizeERC20Withdrawal() (gas: 22919)
L1StandardBridge_Test:test_receive() (gas: 391
794
)
L1StandardBridge_Test:test_receive() (gas: 391
817
)
L2CrossDomainMessenger_Test:testCannot_L2MessengerPause() (gas: 10843)
L2CrossDomainMessenger_Test:test_L2MessengerMessageVersion() (gas: 8410)
L2CrossDomainMessenger_Test:test_L2MessengerPause() (gas: 31837)
L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageSucceeds() (gas: 57538)
L2CrossDomainMessenger_Test:test_L2MessengerRelayMessageToSystemContract() (gas: 24567)
L2CrossDomainMessenger_Test:test_L2MessengerRelayShouldRevertIfPaused() (gas: 41599)
L2CrossDomainMessenger_Test:test_L2MessengerSendMessage() (gas: 1196
59
)
L2CrossDomainMessenger_Test:test_L2MessengerTwiceSendMessage() (gas: 133
096
)
L2CrossDomainMessenger_Test:test_L2MessengerXDomainSenderReverts() (gas: 105
88
)
L2CrossDomainMessenger_Test:test_L2MessengerxDomainMessageSenderResets() (gas: 548
59
)
L2CrossDomainMessenger_Test:test_L2MessengerSendMessage() (gas: 1196
82
)
L2CrossDomainMessenger_Test:test_L2MessengerTwiceSendMessage() (gas: 133
142
)
L2CrossDomainMessenger_Test:test_L2MessengerXDomainSenderReverts() (gas: 105
99
)
L2CrossDomainMessenger_Test:test_L2MessengerxDomainMessageSenderResets() (gas: 548
81
)
L2OutputOracleTest:testCannot_appendEmptyOutput() (gas: 18442)
L2OutputOracleTest:testCannot_appendFutureTimetamp() (gas: 20072)
L2OutputOracleTest:testCannot_appendOnWrongFork() (gas: 20710)
...
...
@@ -71,14 +72,15 @@ L2OutputOracleTest:test_deleteL2Output() (gas: 66081)
L2OutputOracleTest:test_getL2Output() (gas: 76274)
L2OutputOracleTest:test_latestBlockNumber() (gas: 70075)
L2OutputOracleTest:test_nextBlockNumber() (gas: 9279)
L2StandardBridge_Test:test_cannotWithdrawEthWithoutSendingIt() (gas: 21578)
L2StandardBridge_Test:test_finalizeDeposit() (gas: 93165)
L2StandardBridge_Test:test_finalizeDeposit_failsToCompleteOutboundTransfer() (gas: 140106)
L2StandardBridge_Test:test_initialize() (gas: 14834)
L2StandardBridge_Test:test_receive() (gas: 136459)
L2StandardBridge_Test:test_withdraw() (gas: 352724)
L2StandardBridge_Test:test_withdrawTo() (gas: 353480)
L2StandardBridge_Test:test_withdraw_onlyEOA() (gas: 251952)
L2StandardBridge_Test:test_ERC20BridgeFailed_whenLocalTokenIsBridge() (gas: 133097)
L2StandardBridge_Test:test_cannotWithdrawEthWithoutSendingIt() (gas: 21611)
L2StandardBridge_Test:test_finalizeDeposit() (gas: 93100)
L2StandardBridge_Test:test_finalizeDeposit_failsToCompleteOutboundTransfer() (gas: 140129)
L2StandardBridge_Test:test_initialize() (gas: 14856)
L2StandardBridge_Test:test_receive() (gas: 136415)
L2StandardBridge_Test:test_withdraw() (gas: 352760)
L2StandardBridge_Test:test_withdrawTo() (gas: 353481)
L2StandardBridge_Test:test_withdraw_onlyEOA() (gas: 251970)
L2ToL1MessagePasserTest:test_burn() (gas: 112046)
L2ToL1MessagePasserTest:test_initiateWithdrawal_fromContract() (gas: 67890)
L2ToL1MessagePasserTest:test_initiateWithdrawal_fromEOA() (gas: 74851)
...
...
@@ -164,4 +166,4 @@ SequencerFeeVault_Test:test_constructor() (gas: 7611)
SequencerFeeVault_Test:test_minWithdrawalAmount() (gas: 5429)
SequencerFeeVault_Test:test_receive() (gas: 17280)
SequencerFeeVault_Test:test_revertWithdraw() (gas: 9266)
SequencerFeeVault_Test:test_withdraw() (gas: 14730
0
)
SequencerFeeVault_Test:test_withdraw() (gas: 14730
1
)
packages/contracts-bedrock/contracts/L1/L1StandardBridge.sol
View file @
9269e224
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/contracts/L1/OptimismPortal.sol
View file @
9269e224
...
...
@@ -165,7 +165,7 @@ contract OptimismPortal is ResourceMetering {
WithdrawalVerifier.OutputRootProof calldata _outputRootProof,
bytes calldata _withdrawalProof
) external payable {
// Prevent
reentrancy
.
// Prevent
nested withdrawals within withdrawals
.
require(
l2Sender == DEFAULT_L2_SENDER,
"OptimismPortal: can only trigger one withdrawal per transaction"
...
...
packages/contracts-bedrock/contracts/L2/L2StandardBridge.sol
View file @
9269e224
...
...
@@ -22,12 +22,12 @@ contract L2StandardBridge is StandardBridge {
* @custom:legacy
* @notice Emitted whenever a withdrawal from L2 to L1 is initiated.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the withdrawer.
* @param _to Address of the recipient on L1.
* @param _amount Amount of the ERC20 withdrawn.
* @param _
data
Extra data attached to the withdrawal.
* @param _l1Token
Address of the token on L1.
* @param _l2Token
Address of the corresponding token on L2.
* @param _from
Address of the withdrawer.
* @param _to
Address of the recipient on L1.
* @param _amount
Amount of the ERC20 withdrawn.
* @param _
extraData
Extra data attached to the withdrawal.
*/
event WithdrawalInitiated(
address indexed _l1Token,
...
...
@@ -35,19 +35,19 @@ contract L2StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _
d
ata
bytes _
extraD
ata
);
/**
* @custom:legacy
* @notice Emitted whenever an ERC20 deposit is finalized.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _
data
Extra data attached to the deposit.
* @param _l1Token
Address of the token on L1.
* @param _l2Token
Address of the corresponding token on L2.
* @param _from
Address of the depositor.
* @param _to
Address of the recipient on L2.
* @param _amount
Amount of the ERC20 deposited.
* @param _
extraData
Extra data attached to the deposit.
*/
event DepositFinalized(
address indexed _l1Token,
...
...
@@ -55,19 +55,19 @@ contract L2StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _
d
ata
bytes _
extraD
ata
);
/**
* @custom:legacy
* @notice Emitted whenever a deposit fails.
*
* @param _l1Token Address of the token on L1.
* @param _l2Token Address of the corresponding token on L2.
* @param _from Address of the depositor.
* @param _to Address of the recipient on L2.
* @param _amount Amount of the ERC20 deposited.
* @param _
data
Extra data attached to the deposit.
* @param _l1Token
Address of the token on L1.
* @param _l2Token
Address of the corresponding token on L2.
* @param _from
Address of the depositor.
* @param _to
Address of the recipient on L2.
* @param _amount
Amount of the ERC20 deposited.
* @param _
extraData
Extra data attached to the deposit.
*/
event DepositFailed(
address indexed _l1Token,
...
...
@@ -75,7 +75,7 @@ contract L2StandardBridge is StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _
d
ata
bytes _
extraD
ata
);
/**
...
...
@@ -94,15 +94,15 @@ contract L2StandardBridge is StandardBridge {
* @param _l2Token Address of the L2 token to withdraw.
* @param _amount Amount of the L2 token to withdraw.
* @param _minGasLimit Minimum gas limit to use for the transaction.
* @param _
data
Extra data attached to the withdrawal.
* @param _
extraData
Extra data attached to the withdrawal.
*/
function withdraw(
address _l2Token,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) external payable virtual onlyEOA {
_initiateWithdrawal(_l2Token, msg.sender, msg.sender, _amount, _minGasLimit, _
d
ata);
_initiateWithdrawal(_l2Token, msg.sender, msg.sender, _amount, _minGasLimit, _
extraD
ata);
}
/**
...
...
@@ -117,28 +117,28 @@ contract L2StandardBridge is StandardBridge {
* @param _to Recipient account on L1.
* @param _amount Amount of the L2 token to withdraw.
* @param _minGasLimit Minimum gas limit to use for the transaction.
* @param _
data
Extra data attached to the withdrawal.
* @param _
extraData
Extra data attached to the withdrawal.
*/
function withdrawTo(
address _l2Token,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) external payable virtual {
_initiateWithdrawal(_l2Token, msg.sender, _to, _amount, _minGasLimit, _
d
ata);
_initiateWithdrawal(_l2Token, msg.sender, _to, _amount, _minGasLimit, _
extraD
ata);
}
/**
* @custom:legacy
* @notice Finalizes a deposit from L1 to L2.
*
* @param _l1Token Address of the L1 token to deposit.
* @param _l2Token Address of the corresponding L2 token.
* @param _from Address of the depositor.
* @param _to Address of the recipient.
* @param _amount Amount of the tokens being deposited.
* @param _
data
Extra data attached to the deposit.
* @param _l1Token
Address of the L1 token to deposit.
* @param _l2Token
Address of the corresponding L2 token.
* @param _from
Address of the depositor.
* @param _to
Address of the recipient.
* @param _amount
Amount of the tokens being deposited.
* @param _
extraData
Extra data attached to the deposit.
*/
function finalizeDeposit(
address _l1Token,
...
...
@@ -146,14 +146,14 @@ contract L2StandardBridge is StandardBridge {
address _from,
address _to,
uint256 _amount,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) external payable virtual {
if (_l1Token == address(0) && _l2Token == Lib_PredeployAddresses.OVM_ETH) {
finalizeBridgeETH(_from, _to, _amount, _
d
ata);
finalizeBridgeETH(_from, _to, _amount, _
extraD
ata);
} else {
finalizeBridgeERC20(_l2Token, _l1Token, _from, _to, _amount, _
d
ata);
finalizeBridgeERC20(_l2Token, _l1Token, _from, _to, _amount, _
extraD
ata);
}
emit DepositFinalized(_l1Token, _l2Token, _from, _to, _amount, _
d
ata);
emit DepositFinalized(_l1Token, _l2Token, _from, _to, _amount, _
extraD
ata);
}
/**
...
...
@@ -165,7 +165,7 @@ contract L2StandardBridge is StandardBridge {
* @param _to Recipient account on L1.
* @param _amount Amount of the L2 token to withdraw.
* @param _minGasLimit Minimum gas limit to use for the transaction.
* @param _
data
Extra data attached to the withdrawal.
* @param _
extraData
Extra data attached to the withdrawal.
*/
function _initiateWithdrawal(
address _l2Token,
...
...
@@ -173,15 +173,15 @@ contract L2StandardBridge is StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) internal {
address l1Token = OptimismMintableERC20(_l2Token).l1Token();
if (_l2Token == Lib_PredeployAddresses.OVM_ETH) {
require(msg.value == _amount, "ETH withdrawals must include sufficient ETH value.");
_initiateBridgeETH(_from, _to, _amount, _minGasLimit, _
d
ata);
_initiateBridgeETH(_from, _to, _amount, _minGasLimit, _
extraD
ata);
} else {
_initiateBridgeERC20(_l2Token, l1Token, _from, _to, _amount, _minGasLimit, _
d
ata);
_initiateBridgeERC20(_l2Token, l1Token, _from, _to, _amount, _minGasLimit, _
extraD
ata);
}
emit WithdrawalInitiated(l1Token, _l2Token, _from, _to, _amount, _
d
ata);
emit WithdrawalInitiated(l1Token, _l2Token, _from, _to, _amount, _
extraD
ata);
}
}
packages/contracts-bedrock/contracts/test/L1CrossDomainMessenger.t.sol
View file @
9269e224
...
...
@@ -42,6 +42,21 @@ contract L1CrossDomainMessenger_Test is Messenger_Initializer {
L1Messenger.pause();
}
// unpause: should unpause the contract when called by the current owner
function test_L1MessengerUnpause() external {
L1Messenger.pause();
assert(L1Messenger.paused());
L1Messenger.unpause();
assert(!L1Messenger.paused());
}
// unpause: should not unpause the contract when called by account other than the owner
function testCannot_L1MessengerUnpause() external {
vm.expectRevert("Ownable: caller is not the owner");
vm.prank(address(0xABBA));
L1Messenger.unpause();
}
// the version is encoded in the nonce
function test_L1MessengerMessageVersion() external {
assertEq(
...
...
packages/contracts-bedrock/contracts/test/L1StandardBridge.t.sol
View file @
9269e224
...
...
@@ -390,13 +390,4 @@ contract L1StandardBridge_Test is Bridge_Initializer {
hex""
);
}
// donateETH
// - can send ETH to the contract
function test_donateETH() external {
assertEq(address(L1Bridge).balance, 0);
vm.prank(alice);
L1Bridge.donateETH{ value: 1000 }();
assertEq(address(L1Bridge).balance, 1000);
}
}
packages/contracts-bedrock/contracts/test/L2StandardBridge.t.sol
View file @
9269e224
...
...
@@ -146,13 +146,12 @@ contract L2StandardBridge_Test is Bridge_Initializer {
// - invalid deposit calls Withdrawer.initiateWithdrawal
function test_finalizeDeposit_failsToCompleteOutboundTransfer() external {
// TODO: events and calls
address invalidL2Token = address(0x1234);
vm.mockCall(
address(L2Bridge.messenger()),
abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector),
abi.encode(address(L2Bridge.otherBridge()))
);
address invalidL2Token = address(0x1234);
vm.prank(address(L2Messenger));
vm.expectEmit(true, true, true, true);
emit ERC20BridgeInitiated(
...
...
@@ -181,5 +180,21 @@ contract L2StandardBridge_Test is Bridge_Initializer {
hex""
);
}
// finalizeBridgeERC20
// - fails when the local token's address equals bridge address
function test_ERC20BridgeFailed_whenLocalTokenIsBridge() external {
vm.mockCall(
address(L2Bridge.messenger()),
abi.encodeWithSelector(CrossDomainMessenger.xDomainMessageSender.selector),
abi.encode(address(L2Bridge.otherBridge()))
);
// fails when the local token's address equals bridge address
vm.expectEmit(true, true, true, true);
emit ERC20BridgeFailed(address(L2Bridge), address(L1Token), alice, bob, 100, hex"");
vm.prank(address(L2Messenger));
L2Bridge.finalizeDeposit(address(L1Token), address(L2Bridge), alice, bob, 100, hex"");
}
}
packages/contracts-bedrock/contracts/universal/CrossDomainMessenger.sol
View file @
9269e224
...
...
@@ -101,6 +101,13 @@ abstract contract CrossDomainMessenger is
_pause();
}
/**
* Unpause relaying.
*/
function unpause() external onlyOwner {
_unpause();
}
/**
* Retrieves the address of the x-domain message sender. Will throw an error
* if the sender is not currently set (equal to the default sender).
...
...
packages/contracts-bedrock/contracts/universal/StandardBridge.sol
View file @
9269e224
...
...
@@ -31,14 +31,14 @@ abstract contract StandardBridge {
address indexed _from,
address indexed _to,
uint256 _amount,
bytes _
d
ata
bytes _
extraD
ata
);
event ETHBridgeFinalized(
address indexed _from,
address indexed _to,
uint256 _amount,
bytes _
d
ata
bytes _
extraD
ata
);
event ERC20BridgeInitiated(
...
...
@@ -47,7 +47,7 @@ abstract contract StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _
d
ata
bytes _
extraD
ata
);
event ERC20BridgeFinalized(
...
...
@@ -56,7 +56,7 @@ abstract contract StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _
d
ata
bytes _
extraD
ata
);
event ERC20BridgeFailed(
...
...
@@ -65,7 +65,7 @@ abstract contract StandardBridge {
address indexed _from,
address _to,
uint256 _amount,
bytes _
d
ata
bytes _
extraD
ata
);
/*************
...
...
@@ -128,11 +128,6 @@ abstract contract StandardBridge {
* Public Functions *
********************/
/**
* @notice Send ETH to this contract. This is used during upgrades
*/
function donateETH() external payable {}
/**
* @notice EOAs can simply send ETH to this contract to have it be deposited
* to L2 through the standard bridge.
...
...
@@ -144,8 +139,8 @@ abstract contract StandardBridge {
/**
* @notice Send ETH to the message sender on the remote domain
*/
function bridgeETH(uint32 _minGasLimit, bytes calldata _
d
ata) public payable onlyEOA {
_initiateBridgeETH(msg.sender, msg.sender, msg.value, _minGasLimit, _
d
ata);
function bridgeETH(uint32 _minGasLimit, bytes calldata _
extraD
ata) public payable onlyEOA {
_initiateBridgeETH(msg.sender, msg.sender, msg.value, _minGasLimit, _
extraD
ata);
}
/**
...
...
@@ -155,9 +150,9 @@ abstract contract StandardBridge {
function bridgeETHTo(
address _to,
uint32 _minGasLimit,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) public payable {
_initiateBridgeETH(msg.sender, _to, msg.value, _minGasLimit, _
d
ata);
_initiateBridgeETH(msg.sender, _to, msg.value, _minGasLimit, _
extraD
ata);
}
/**
...
...
@@ -168,7 +163,7 @@ abstract contract StandardBridge {
address _remoteToken,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) public virtual onlyEOA {
_initiateBridgeERC20(
_localToken,
...
...
@@ -177,7 +172,7 @@ abstract contract StandardBridge {
msg.sender,
_amount,
_minGasLimit,
_
d
ata
_
extraD
ata
);
}
...
...
@@ -190,7 +185,7 @@ abstract contract StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) public virtual {
_initiateBridgeERC20(
_localToken,
...
...
@@ -199,7 +194,7 @@ abstract contract StandardBridge {
_to,
_amount,
_minGasLimit,
_
d
ata
_
extraD
ata
);
}
...
...
@@ -210,12 +205,12 @@ abstract contract StandardBridge {
address _from,
address _to,
uint256 _amount,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) public payable onlyOtherBridge {
require(msg.value == _amount, "Amount sent does not match amount required.");
require(_to != address(this), "Cannot send to self.");
emit ETHBridgeFinalized(_from, _to, _amount, _
d
ata);
emit ETHBridgeFinalized(_from, _to, _amount, _
extraD
ata);
(bool success, ) = _to.call{ value: _amount }(new bytes(0));
require(success, "ETH transfer failed.");
}
...
...
@@ -229,23 +224,25 @@ abstract contract StandardBridge {
address _from,
address _to,
uint256 _amount,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) public onlyOtherBridge {
try this.completeOutboundTransfer(_localToken, _remoteToken, _to, _amount) {
emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _
d
ata);
emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _
extraD
ata);
} catch {
// Something went wrong during the bridging process, return to sender.
// Can happen if a bridge UI specifies the wrong L2 token.
// We reverse both the local and remote token addresses, as well as the to and from
// addresses. This will preserve the accuracy of accounting based on emitted events.
_initiateBridgeERC20Unchecked(
_localToken,
_remoteToken,
_from,
_to,
_from,
_amount,
0, // _minGasLimit, 0 is fine here
_
d
ata
_
extraD
ata
);
emit ERC20BridgeFailed(_localToken, _remoteToken, _from, _to, _amount, _
d
ata);
emit ERC20BridgeFailed(_localToken, _remoteToken, _from, _to, _amount, _
extraD
ata);
}
}
...
...
@@ -296,13 +293,19 @@ abstract contract StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes memory _
d
ata
bytes memory _
extraD
ata
) internal {
emit ETHBridgeInitiated(_from, _to, _amount, _
d
ata);
emit ETHBridgeInitiated(_from, _to, _amount, _
extraD
ata);
messenger.sendMessage{ value: _amount }(
address(otherBridge),
abi.encodeWithSelector(this.finalizeBridgeETH.selector, _from, _to, _amount, _data),
abi.encodeWithSelector(
this.finalizeBridgeETH.selector,
_from,
_to,
_amount,
_extraData
),
_minGasLimit
);
}
...
...
@@ -317,7 +320,7 @@ abstract contract StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) internal {
// Make sure external function calls can't be used to trigger calls to
// completeOutboundTransfer. We only make external (write) calls to _localToken.
...
...
@@ -343,7 +346,7 @@ abstract contract StandardBridge {
_to,
_amount,
_minGasLimit,
_
d
ata
_
extraD
ata
);
}
...
...
@@ -357,7 +360,7 @@ abstract contract StandardBridge {
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _
d
ata
bytes calldata _
extraD
ata
) internal {
messenger.sendMessage(
address(otherBridge),
...
...
@@ -371,12 +374,12 @@ abstract contract StandardBridge {
_from,
_to,
_amount,
_
d
ata
_
extraD
ata
),
_minGasLimit
);
emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _
d
ata);
emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _
extraD
ata);
}
/**
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment