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
ce665207
Commit
ce665207
authored
Aug 07, 2023
by
Mark Tyneway
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
contracts-bedrock: fixup standard bridge
parent
91772bb8
Changes
9
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
46 additions
and
53 deletions
+46
-53
l1standardbridge.go
op-bindings/bindings/l1standardbridge.go
+1
-1
l1standardbridge_more.go
op-bindings/bindings/l1standardbridge_more.go
+2
-2
l2standardbridge.go
op-bindings/bindings/l2standardbridge.go
+1
-1
l2standardbridge_more.go
op-bindings/bindings/l2standardbridge_more.go
+2
-2
.gas-snapshot
packages/contracts-bedrock/.gas-snapshot
+16
-16
.storage-layout
packages/contracts-bedrock/.storage-layout
+2
-2
L1StandardBridge.sol
packages/contracts-bedrock/src/L1/L1StandardBridge.sol
+1
-1
L2StandardBridge.sol
packages/contracts-bedrock/src/L2/L2StandardBridge.sol
+1
-1
StandardBridge.sol
packages/contracts-bedrock/src/universal/StandardBridge.sol
+20
-27
No files found.
op-bindings/bindings/l1standardbridge.go
View file @
ce665207
This diff is collapsed.
Click to expand it.
op-bindings/bindings/l1standardbridge_more.go
View file @
ce665207
This diff is collapsed.
Click to expand it.
op-bindings/bindings/l2standardbridge.go
View file @
ce665207
This diff is collapsed.
Click to expand it.
op-bindings/bindings/l2standardbridge_more.go
View file @
ce665207
This diff is collapsed.
Click to expand it.
packages/contracts-bedrock/.gas-snapshot
View file @
ce665207
...
...
@@ -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: 5408
2
)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_incorrectValue_reverts() (gas: 3653
1
)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_sendToMessenger_reverts() (gas: 367
18
)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_sendToSelf_reverts() (gas: 3660
3
)
L1StandardBridge_FinalizeERC20Withdrawal_Test:test_finalizeERC20Withdrawal_succeeds() (gas: 49811
5
)
L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notMessenger_reverts() (gas: 3343
2
)
L1StandardBridge_FinalizeBridgeETH_Test:test_finalizeBridgeETH_succeeds() (gas: 5408
5
)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_incorrectValue_reverts() (gas: 3653
4
)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_sendToMessenger_reverts() (gas: 367
21
)
L1StandardBridge_FinalizeBridgeETH_TestFail:test_finalizeBridgeETH_sendToSelf_reverts() (gas: 3660
6
)
L1StandardBridge_FinalizeERC20Withdrawal_Test:test_finalizeERC20Withdrawal_succeeds() (gas: 49811
7
)
L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notMessenger_reverts() (gas: 3343
5
)
L1StandardBridge_FinalizeERC20Withdrawal_TestFail:test_finalizeERC20Withdrawal_notOtherBridge_reverts() (gas: 34084)
L1StandardBridge_FinalizeETHWithdrawal_Test:test_finalizeETHWithdrawal_succeeds() (gas: 6460
2
)
L1StandardBridge_Getter_Test:test_getters_succeeds() (gas: 283
5
2)
L1StandardBridge_FinalizeETHWithdrawal_Test:test_finalizeETHWithdrawal_succeeds() (gas: 6460
5
)
L1StandardBridge_Getter_Test:test_getters_succeeds() (gas: 283
7
2)
L1StandardBridge_Initialize_Test:test_initialize_fix_succeeds() (gas: 5258)
L1StandardBridge_Initialize_Test:test_initialize_succeeds() (gas: 2417
5
)
L1StandardBridge_Initialize_Test:test_initialize_succeeds() (gas: 2417
8
)
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: 261
12
)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_sendToMessenger_reverts() (gas: 263
80
)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_sendToSelf_reverts() (gas: 261
39
)
L2StandardBridge_Bridge_Test:test_finalizeDeposit_depositingERC20_succeeds() (gas: 960
71
)
L2StandardBridge_Bridge_Test:test_finalizeDeposit_depositingETH_succeeds() (gas: 949
25
)
L2StandardBridge_FinalizeBridgeETH_Test:test_finalizeBridgeETH_succeeds() (gas: 455
08
)
L2StandardBridge_Test:test_initialize_succeeds() (gas: 26
296
)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_incorrectValue_reverts() (gas: 261
26
)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_sendToMessenger_reverts() (gas: 263
94
)
L2StandardBridge_Bridge_Test:test_finalizeBridgeETH_sendToSelf_reverts() (gas: 261
53
)
L2StandardBridge_Bridge_Test:test_finalizeDeposit_depositingERC20_succeeds() (gas: 960
85
)
L2StandardBridge_Bridge_Test:test_finalizeDeposit_depositingETH_succeeds() (gas: 949
39
)
L2StandardBridge_FinalizeBridgeETH_Test:test_finalizeBridgeETH_succeeds() (gas: 455
22
)
L2StandardBridge_Test:test_initialize_succeeds() (gas: 26
310
)
L2StandardBridge_Test:test_receive_succeeds() (gas: 176756)
L2StandardBridge_Test:test_withdraw_ether_succeeds() (gas: 142997)
L2StandardBridge_Test:test_withdraw_insufficientValue_reverts() (gas: 16552)
...
...
packages/contracts-bedrock/.storage-layout
View file @
ce665207
...
...
@@ -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 |
=======================
...
...
packages/contracts-bedrock/src/L1/L1StandardBridge.sol
View file @
ce665207
...
...
@@ -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.
...
...
packages/contracts-bedrock/src/L2/L2StandardBridge.sol
View file @
ce665207
...
...
@@ -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
...
...
packages/contracts-bedrock/src/universal/StandardBridge.sol
View file @
ce665207
...
...
@@ -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
...
...
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