-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #72 from matter-labs/sb-merge-grc-2-sls
Merge grc 2 into sync-layer-stable
- Loading branch information
Showing
90 changed files
with
676 additions
and
480 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,11 @@ | ||
// SPDX-License-Identifier: MIT | ||
|
||
pragma solidity 0.8.24; | ||
|
||
import {IVectorx} from "./IVectorx.sol"; | ||
|
||
contract DummyVectorX is IVectorx { | ||
function rangeStartBlocks(bytes32 rangeHash) external view returns (uint32 startBlock) { | ||
function rangeStartBlocks(bytes32) external view returns (uint32 startBlock) { | ||
return 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,14 +7,13 @@ import {IAssetRouterBase} from "./IAssetRouterBase.sol"; | |
import {AssetRouterBase} from "./AssetRouterBase.sol"; | ||
|
||
import {IL2NativeTokenVault} from "../ntv/IL2NativeTokenVault.sol"; | ||
import {INativeTokenVault} from "../ntv/INativeTokenVault.sol"; | ||
import {IL2SharedBridgeLegacy} from "../interfaces/IL2SharedBridgeLegacy.sol"; | ||
import {IAssetHandler} from "../interfaces/IAssetHandler.sol"; | ||
import {IBridgedStandardToken} from "../interfaces/IBridgedStandardToken.sol"; | ||
import {IL1ERC20Bridge} from "../interfaces/IL1ERC20Bridge.sol"; | ||
|
||
import {IBridgehub} from "../../bridgehub/IBridgehub.sol"; | ||
import {AddressAliasHelper} from "../../vendor/AddressAliasHelper.sol"; | ||
import {ReentrancyGuard} from "../../common/ReentrancyGuard.sol"; | ||
|
||
import {L2_NATIVE_TOKEN_VAULT_ADDR, L2_BRIDGEHUB_ADDR} from "../../common/L2ContractAddresses.sol"; | ||
import {L2ContractHelper} from "../../common/libraries/L2ContractHelper.sol"; | ||
|
@@ -25,7 +24,7 @@ import {TokenNotLegacy, EmptyAddress, InvalidCaller, AmountMustBeGreaterThanZero | |
/// @custom:security-contact [email protected] | ||
/// @notice The "default" bridge implementation for the ERC20 tokens. Note, that it does not | ||
/// support any custom token logic, i.e. rebase tokens' functionality is not supported. | ||
contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | ||
contract L2AssetRouter is AssetRouterBase, IL2AssetRouter, ReentrancyGuard { | ||
/// @dev The address of the L2 legacy shared bridge. | ||
address public immutable L2_LEGACY_SHARED_BRIDGE; | ||
|
||
|
@@ -49,8 +48,8 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
} | ||
|
||
/// @notice Checks that the message sender is the L1 Asset Router. | ||
modifier onlyAssetRouterCounterpartOrSelf(uint256 _originChainId) { | ||
if (_originChainId == L1_CHAIN_ID) { | ||
modifier onlyAssetRouterCounterpartOrSelf(uint256 _chainId) { | ||
if (_chainId == L1_CHAIN_ID) { | ||
// Only the L1 Asset Router counterpart can initiate and finalize the deposit. | ||
if ((AddressAliasHelper.undoL1ToL2Alias(msg.sender) != L1_ASSET_ROUTER) && (msg.sender != address(this))) { | ||
revert InvalidCaller(msg.sender); | ||
|
@@ -86,7 +85,7 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
address _legacySharedBridge, | ||
bytes32 _baseTokenAssetId, | ||
address _aliasedOwner | ||
) AssetRouterBase(_l1ChainId, _eraChainId, IBridgehub(L2_BRIDGEHUB_ADDR)) { | ||
) AssetRouterBase(_l1ChainId, _eraChainId, IBridgehub(L2_BRIDGEHUB_ADDR)) reentrancyGuardInitializer { | ||
L2_LEGACY_SHARED_BRIDGE = _legacySharedBridge; | ||
if (_l1AssetRouter == address(0)) { | ||
revert EmptyAddress(); | ||
|
@@ -133,7 +132,13 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
uint256, | ||
bytes32 _assetId, | ||
bytes calldata _transferData | ||
) public payable override(AssetRouterBase, IAssetRouterBase) onlyAssetRouterCounterpartOrSelf(L1_CHAIN_ID) { | ||
) | ||
public | ||
payable | ||
override(AssetRouterBase, IAssetRouterBase) | ||
onlyAssetRouterCounterpartOrSelf(L1_CHAIN_ID) | ||
nonReentrant | ||
{ | ||
if (_assetId == BASE_TOKEN_ASSET_ID) { | ||
revert AssetIdNotSupported(BASE_TOKEN_ASSET_ID); | ||
} | ||
|
@@ -148,7 +153,7 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
/// that rely on it must be upgradeable. | ||
/// @param _assetId The asset id of the withdrawn asset | ||
/// @param _assetData The data that is passed to the asset handler contract | ||
function withdraw(bytes32 _assetId, bytes memory _assetData) public override returns (bytes32) { | ||
function withdraw(bytes32 _assetId, bytes memory _assetData) public override nonReentrant returns (bytes32) { | ||
return _withdrawSender(_assetId, _assetData, msg.sender, true); | ||
} | ||
|
||
|
@@ -195,6 +200,7 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
if (l1Token == address(0)) { | ||
revert AssetIdNotSupported(_assetId); | ||
} | ||
// slither-disable-next-line unused-return | ||
(uint256 amount, address l1Receiver, ) = DataEncoding.decodeBridgeBurnData(_assetData); | ||
message = _getSharedBridgeWithdrawMessage(l1Receiver, l1Token, amount); | ||
txHash = IL2SharedBridgeLegacy(L2_LEGACY_SHARED_BRIDGE).sendMessageToL1(message); | ||
|
@@ -286,7 +292,7 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
/// @param _l1Receiver The account address that should receive funds on L1 | ||
/// @param _l2Token The L2 token address which is withdrawn | ||
/// @param _amount The total amount of tokens to be withdrawn | ||
function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external { | ||
function withdraw(address _l1Receiver, address _l2Token, uint256 _amount) external nonReentrant { | ||
if (_amount == 0) { | ||
revert AmountMustBeGreaterThanZero(); | ||
} | ||
|
@@ -304,7 +310,7 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
address _l2Token, | ||
uint256 _amount, | ||
address _sender | ||
) external onlyLegacyBridge { | ||
) external onlyLegacyBridge nonReentrant { | ||
_withdrawLegacy(_l1Receiver, _l2Token, _amount, _sender); | ||
} | ||
|
||
|
@@ -331,7 +337,7 @@ contract L2AssetRouter is AssetRouterBase, IL2AssetRouter { | |
return address(0); | ||
} | ||
|
||
return IBridgedStandardToken(_l2Token).l1Address(); | ||
return IBridgedStandardToken(_l2Token).originToken(); | ||
} | ||
|
||
/// @notice Legacy function used for backward compatibility to return L2 wrapped token | ||
|
Oops, something went wrong.