Commit ce665207 authored by Mark Tyneway's avatar Mark Tyneway

contracts-bedrock: fixup standard bridge

parent 91772bb8
This diff is collapsed.
This diff is collapsed.
......@@ -198,17 +198,17 @@ L1StandardBridge_DepositERC20_TestFail:test_depositERC20_notEoa_reverts() (gas:
L1StandardBridge_DepositETHTo_Test:test_depositETHTo_succeeds() (gas: 514657)
L1StandardBridge_DepositETH_Test:test_depositETH_succeeds() (gas: 501874)
L1StandardBridge_DepositETH_TestFail:test_depositETH_notEoa_reverts() (gas: 40759)
L1StandardBridge_FinalizeBridgeETH_Test:test_finalizeBridgeETH_succeeds() (gas: 54082)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_incorrectValue_reverts() (gas: 36531)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_sendToMessenger_reverts() (gas: 36718)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_sendToSelf_reverts() (gas: 36603)
L1StandardBridge_FinalizeERC20Withdrawal_Test:test_finalizeERC20Withdrawal_succeeds() (gas: 498115)
L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notMessenger_reverts() (gas: 33432)
L1StandardBridge_FinalizeBridgeETH_Test:test_finalizeBridgeETH_succeeds() (gas: 54085)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_incorrectValue_reverts() (gas: 36534)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_sendToMessenger_reverts() (gas: 36721)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_sendToSelf_reverts() (gas: 36606)
L1StandardBridge_FinalizeERC20Withdrawal_Test:test_finalizeERC20Withdrawal_succeeds() (gas: 498117)
L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notMessenger_reverts() (gas: 33435)
L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notOtherBridge_reverts() (gas: 34084)
L1StandardBridge_FinalizeETHWithdrawal_Test:test_finalizeETHWithdrawal_succeeds() (gas: 64602)
L1StandardBridge_Getter_Test:test_getters_succeeds() (gas: 28352)
L1StandardBridge_FinalizeETHWithdrawal_Test:test_finalizeETHWithdrawal_succeeds() (gas: 64605)
L1StandardBridge_Getter_Test:test_getters_succeeds() (gas: 28372)
L1StandardBridge_Initialize_Test:test_initialize_fix_succeeds() (gas: 5258)
L1StandardBridge_Initialize_Test:test_initialize_succeeds() (gas: 24175)
L1StandardBridge_Initialize_Test:test_initialize_succeeds() (gas: 24178)
L1StandardBridge_Receive_Test:test_receive_succeeds() (gas: 615010)
L2CrossDomainMessenger_Test:test_messageVersion_succeeds() (gas: 8477)
L2CrossDomainMessenger_Test:test_relayMessage_retry_succeeds() (gas: 163815)
......@@ -273,13 +273,13 @@ L2StandardBridge_BridgeERC20_Test:test_bridgeLegacyERC20_succeeds() (gas: 395741
L2StandardBridge_BridgeERC20_Test:test_withdrawLegacyERC20_succeeds() (gas: 396103)
L2StandardBridge_BridgeERC20_Test:test_withdraw_notEOA_reverts() (gas: 251807)
L2StandardBridge_BridgeERC20_Test:test_withdraw_withdrawingERC20_succeeds() (gas: 387750)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_incorrectValue_reverts() (gas: 26112)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_sendToMessenger_reverts() (gas: 26380)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_sendToSelf_reverts() (gas: 26139)
L2StandardBridge_Bridge_Test:test_finalizeDeposit_depositingERC20_succeeds() (gas: 96071)
L2StandardBridge_Bridge_Test:test_finalizeDeposit_depositingETH_succeeds() (gas: 94925)
L2StandardBridge_FinalizeBridgeETH_Test:test_finalizeBridgeETH_succeeds() (gas: 45508)
L2StandardBridge_Test:test_initialize_succeeds() (gas: 26296)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_incorrectValue_reverts() (gas: 26126)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_sendToMessenger_reverts() (gas: 26394)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_sendToSelf_reverts() (gas: 26153)
L2StandardBridge_Bridge_Test:test_finalizeDeposit_depositingERC20_succeeds() (gas: 96085)
L2StandardBridge_Bridge_Test:test_finalizeDeposit_depositingETH_succeeds() (gas: 94939)
L2StandardBridge_FinalizeBridgeETH_Test:test_finalizeBridgeETH_succeeds() (gas: 45522)
L2StandardBridge_Test:test_initialize_succeeds() (gas: 26310)
L2StandardBridge_Test:test_receive_succeeds() (gas: 176756)
L2StandardBridge_Test:test_withdraw_ether_succeeds() (gas: 142997)
L2StandardBridge_Test:test_withdraw_insufficientValue_reverts() (gas: 16552)
......
......@@ -38,7 +38,7 @@
| spacer_0_2_20 | address | 0 | 2 | 20 | src/L1/L1StandardBridge.sol:L1StandardBridge |
| spacer_1_0_20 | address | 1 | 0 | 20 | src/L1/L1StandardBridge.sol:L1StandardBridge |
| deposits | mapping(address => mapping(address => uint256)) | 2 | 0 | 32 | src/L1/L1StandardBridge.sol:L1StandardBridge |
| _MESSENGER | contract CrossDomainMessenger | 3 | 0 | 20 | src/L1/L1StandardBridge.sol:L1StandardBridge |
| MESSENGER | contract CrossDomainMessenger | 3 | 0 | 20 | src/L1/L1StandardBridge.sol:L1StandardBridge |
| __gap | uint256[46] | 4 | 0 | 1472 | src/L1/L1StandardBridge.sol:L1StandardBridge |
=======================
......@@ -156,7 +156,7 @@
| spacer_0_2_20 | address | 0 | 2 | 20 | src/L2/L2StandardBridge.sol:L2StandardBridge |
| spacer_1_0_20 | address | 1 | 0 | 20 | src/L2/L2StandardBridge.sol:L2StandardBridge |
| deposits | mapping(address => mapping(address => uint256)) | 2 | 0 | 32 | src/L2/L2StandardBridge.sol:L2StandardBridge |
| _MESSENGER | contract CrossDomainMessenger | 3 | 0 | 20 | src/L2/L2StandardBridge.sol:L2StandardBridge |
| MESSENGER | contract CrossDomainMessenger | 3 | 0 | 20 | src/L2/L2StandardBridge.sol:L2StandardBridge |
| __gap | uint256[46] | 4 | 0 | 1472 | src/L2/L2StandardBridge.sol:L2StandardBridge |
=======================
......
......@@ -232,7 +232,7 @@ contract L1StandardBridge is StandardBridge, Semver {
/// @notice Retrieves the access of the corresponding L2 bridge contract.
/// @return Address of the corresponding L2 bridge contract.
function l2TokenBridge() external view returns (address) {
return address(_OTHER_BRIDGE);
return address(OTHER_BRIDGE);
}
/// @notice Internal function for initiating an ETH deposit.
......
......@@ -145,7 +145,7 @@ contract L2StandardBridge is StandardBridge, Semver {
/// @notice Retrieves the access of the corresponding L1 bridge contract.
/// @return Address of the corresponding L1 bridge contract.
function l1TokenBridge() external view returns (address) {
return address(_OTHER_BRIDGE);
return address(OTHER_BRIDGE);
}
/// @custom:legacy
......
......@@ -22,8 +22,10 @@ abstract contract StandardBridge is Initializable {
/// @notice The L2 gas limit set when eth is depoisited using the receive() function.
uint32 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 200_000;
/// @notice Corresponding bridge on the other domain.
StandardBridge internal immutable _OTHER_BRIDGE;
/// @notice Corresponding bridge on the other domain. This public getter is deprecated
/// and will be removed in the future. Please use `otherBridge` instead.
/// @custom:legacy
StandardBridge public immutable OTHER_BRIDGE;
/// @custom:legacy
/// @custom:spacer messenger
......@@ -38,8 +40,11 @@ abstract contract StandardBridge is Initializable {
/// @notice Mapping that stores deposits for a given pair of local and remote tokens.
mapping(address => mapping(address => uint256)) public deposits;
/// @notice Messenger contract on this domain.
CrossDomainMessenger internal _MESSENGER;
/// @notice Messenger contract on this domain. This public getter is deprecated
/// and will be removed in the future. Please use `messenger` instead.
/// @custom:legacy
/// @custom:network-specific
CrossDomainMessenger public MESSENGER;
/// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades.
/// A gap size of 46 was chosen here, so that the first slot used in a child contract
......@@ -116,8 +121,8 @@ abstract contract StandardBridge is Initializable {
/// @notice Ensures that the caller is a cross-chain message from the other bridge.
modifier onlyOtherBridge() {
require(
msg.sender == address(_MESSENGER) &&
_MESSENGER.xDomainMessageSender() == address(_OTHER_BRIDGE),
msg.sender == address(MESSENGER) &&
MESSENGER.xDomainMessageSender() == address(OTHER_BRIDGE),
"StandardBridge: function can only be called from the other bridge"
);
_;
......@@ -125,14 +130,14 @@ abstract contract StandardBridge is Initializable {
/// @param _otherBridge Address of the other StandardBridge contract.
constructor(StandardBridge _otherBridge) {
_OTHER_BRIDGE = _otherBridge;
OTHER_BRIDGE = _otherBridge;
}
/// @notice Initializer.
/// @param _messenger Address of CrossDomainMessenger on this network.
// solhint-disable-next-line func-name-mixedcase
function __StandardBridge_init(CrossDomainMessenger _messenger) internal onlyInitializing {
_MESSENGER = _messenger;
MESSENGER = _messenger;
}
/// @notice Allows EOAs to bridge ETH by sending directly to the bridge.
......@@ -142,24 +147,12 @@ abstract contract StandardBridge is Initializable {
/// @notice Getter for messenger contract.
/// @return Messenger contract on this domain.
function messenger() external view returns (CrossDomainMessenger) {
return _MESSENGER;
}
/// @notice Legacy getter for messenger contract.
/// @custom:legacy
function MESSENGER() external view returns (CrossDomainMessenger) {
return _MESSENGER;
return MESSENGER;
}
/// @notice Getter for the remote domain bridge contract.
function otherBridge() external view returns (StandardBridge) {
return _OTHER_BRIDGE;
}
/// @notice Legacy getter for the remote domain bridge contract.
/// @custom:legacy
function OTHER_BRIDGE() external view returns (StandardBridge) {
return _OTHER_BRIDGE;
return OTHER_BRIDGE;
}
/// @notice Sends ETH to the sender's address on the other chain.
......@@ -267,7 +260,7 @@ abstract contract StandardBridge is Initializable {
) public payable onlyOtherBridge {
require(msg.value == _amount, "StandardBridge: amount sent does not match amount required");
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");
// Emit the correct events. By default this will be _amount, but child
// contracts may override this function in order to emit legacy events as well.
......@@ -336,8 +329,8 @@ abstract contract StandardBridge is Initializable {
// contracts may override this function in order to emit legacy events as well.
_emitETHBridgeInitiated(_from, _to, _amount, _extraData);
_MESSENGER.sendMessage{ value: _amount }(
address(_OTHER_BRIDGE),
MESSENGER.sendMessage{ value: _amount }(
address(OTHER_BRIDGE),
abi.encodeWithSelector(
this.finalizeBridgeETH.selector,
_from,
......@@ -383,8 +376,8 @@ abstract contract StandardBridge is Initializable {
// contracts may override this function in order to emit legacy events as well.
_emitERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
_MESSENGER.sendMessage(
address(_OTHER_BRIDGE),
MESSENGER.sendMessage(
address(OTHER_BRIDGE),
abi.encodeWithSelector(
this.finalizeBridgeERC20.selector,
// Because this call will be executed on the remote chain, we reverse the order of
......
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