Skip to content

Commit 3a45065

Browse files
committed
Updated mirror.
Used 23b50e60676325e140b0576c38e2e1816956a521
1 parent 6391c0d commit 3a45065

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+2805
-460
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# zkSync Era: Smart Contracts
22

3-
[![Logo](eraLogo.png)](https://zksync.io/)
3+
[![Logo](eraLogo.svg)](https://zksync.io/)
44

55
zkSync Era is a layer 2 rollup that uses zero-knowledge proofs to scale Ethereum without compromising on security or
66
decentralization. Since it's EVM compatible (Solidity/Vyper), 99% of Ethereum projects can redeploy without refactoring
@@ -27,7 +27,7 @@ See [LICENSE-MIT](LICENSE-MIT) for details.
2727
- [GitHub](https://github.com/matter-labs)
2828
- [Twitter](https://twitter.com/zksync)
2929
- [Twitter for Devs](https://twitter.com/zkSyncDevs)
30-
- [Discord](https://join.zksync.dev)
30+
- [Discord](https://discord.gg/px2ar7w)
3131

3232
## Disclaimer
3333

docs/Overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ Thus:
276276
### Deposit Limitation
277277

278278
The amount of deposit can be limited. This limitation is applied on an account level and is not time-based. In other
279-
words, each account can not deposit more than the cap defined. The tokens and the cap can be set through governance
279+
words, each account cannot deposit more than the cap defined. The tokens and the cap can be set through governance
280280
transactions. Moreover, there is an allow listing mechanism as well (only some allow listed accounts can call some
281281
specific functions). So, the combination of deposit limitation and allow listing leads to limiting the deposit of the
282282
allow listed account to be less than the defined cap.

eraLogo.png

-77.2 KB
Binary file not shown.

eraLogo.svg

Lines changed: 13 additions & 0 deletions
Loading

ethereum/contracts/bridge/L1ERC20Bridge.sol

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,40 +13,38 @@ import "./interfaces/IL2ERC20Bridge.sol";
1313
import "./libraries/BridgeInitializationHelper.sol";
1414

1515
import "../zksync/interfaces/IZkSync.sol";
16-
import "../common/interfaces/IL2ContractDeployer.sol";
1716
import "../common/interfaces/IAllowList.sol";
1817
import "../common/AllowListed.sol";
1918
import "../common/libraries/UnsafeBytes.sol";
2019
import "../common/libraries/L2ContractHelper.sol";
21-
import "../common/L2ContractAddresses.sol";
2220
import "../common/ReentrancyGuard.sol";
2321
import "../vendor/AddressAliasHelper.sol";
2422

2523
/// @author Matter Labs
26-
/// @notice Smart contract that allows depositing ERC20 tokens from Ethereum to zkSync v2.0
24+
/// @notice Smart contract that allows depositing ERC20 tokens from Ethereum to zkSync Era
2725
/// @dev It is standard implementation of ERC20 Bridge that can be used as a reference
2826
/// for any other custom token bridges.
2927
contract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, AllowListed, ReentrancyGuard {
3028
using SafeERC20 for IERC20;
3129

3230
/// @dev The smart contract that manages the list with permission to call contract functions
33-
IAllowList immutable allowList;
31+
IAllowList internal immutable allowList;
3432

3533
/// @dev zkSync smart contract that is used to operate with L2 via asynchronous L2 <-> L1 communication
36-
IZkSync immutable zkSync;
34+
IZkSync internal immutable zkSync;
3735

3836
/// @dev A mapping L2 block number => message number => flag
3937
/// @dev Used to indicate that zkSync L2 -> L1 message was already processed
4038
mapping(uint256 => mapping(uint256 => bool)) public isWithdrawalFinalized;
4139

4240
/// @dev A mapping account => L1 token address => L2 deposit transaction hash => amount
4341
/// @dev Used for saving the number of deposited funds, to claim them in case the deposit transaction will fail
44-
mapping(address => mapping(address => mapping(bytes32 => uint256))) depositAmount;
42+
mapping(address => mapping(address => mapping(bytes32 => uint256))) internal depositAmount;
4543

4644
/// @dev The address of deployed L2 bridge counterpart
4745
address public l2Bridge;
4846

49-
/// @dev The address of the factory that deploys proxy for L2 tokens
47+
/// @dev The address that acts as a beacon for L2 tokens
5048
address public l2TokenBeacon;
5149

5250
/// @dev The bytecode hash of the L2 token contract
@@ -78,6 +76,8 @@ contract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, AllowListed, ReentrancyGua
7876
/// @notice At the time of the function call, it is not yet deployed in L2, but knowledge of its address
7977
/// @notice is necessary for determining L2 token address by L1 address, see `l2TokenAddress(address)` function
8078
/// @param _governor Address which can change L2 token implementation and upgrade the bridge
79+
/// @param _deployBridgeImplementationFee How much of the sent value should be allocated to deploying the L2 bridge implementation
80+
/// @param _deployBridgeProxyFee How much of the sent value should be allocated to deploying the L2 bridge proxy
8181
function initialize(
8282
bytes[] calldata _factoryDeps,
8383
address _l2TokenBeacon,
@@ -136,7 +136,7 @@ contract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, AllowListed, ReentrancyGua
136136
/// @param _l2TxGasLimit The L2 gas limit to be used in the corresponding L2 transaction
137137
/// @param _l2TxGasPerPubdataByte The gasPerPubdataByteLimit to be used in the corresponding L2 transaction
138138
/// @return l2TxHash The L2 transaction hash of deposit finalization
139-
/// NOTE: the function doesn't use `nonreentrant` and `senderCanCallFunction` modifiers, because the inner method do.
139+
/// NOTE: the function doesn't use `nonreentrant` and `senderCanCallFunction` modifiers, because the inner method does.
140140
function deposit(
141141
address _l2Receiver,
142142
address _l1Token,
@@ -154,8 +154,16 @@ contract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, AllowListed, ReentrancyGua
154154
/// @param _amount The total amount of tokens to be bridged
155155
/// @param _l2TxGasLimit The L2 gas limit to be used in the corresponding L2 transaction
156156
/// @param _l2TxGasPerPubdataByte The gasPerPubdataByteLimit to be used in the corresponding L2 transaction
157-
/// @param _refundRecipient The address on L2 that will receive the refund for the transaction. If the transaction fails,
158-
/// it will also be the address to receive `_l2Value`. If zero, the refund will be sent to the sender of the transaction.
157+
/// @param _refundRecipient The address on L2 that will receive the refund for the transaction.
158+
/// @dev If the L2 deposit finalization transaction fails, the `_refundRecipient` will receive the `_l2Value`.
159+
/// Please note, the contract may change the refund recipient's address to eliminate sending funds to addresses out of control.
160+
/// - If `_refundRecipient` is a contract on L1, the refund will be sent to the aliased `_refundRecipient`.
161+
/// - If `_refundRecipient` is set to `address(0)` and the sender has NO deployed bytecode on L1, the refund will be sent to the `msg.sender` address.
162+
/// - If `_refundRecipient` is set to `address(0)` and the sender has deployed bytecode on L1, the refund will be sent to the aliased `msg.sender` address.
163+
/// @dev The address aliasing of L1 contracts as refund recipient on L2 is necessary to guarantee that the funds are controllable through the Mailbox,
164+
/// since the Mailbox applies address aliasing to the from address for the L2 tx if the L1 msg.sender is a contract.
165+
/// Without address aliasing for L1 contracts as refund recipients they would not be able to make proper L2 tx requests
166+
/// through the Mailbox to use or withdraw the funds from L2, and the funds would be lost.
159167
/// @return l2TxHash The L2 transaction hash of deposit finalization
160168
function deposit(
161169
address _l2Receiver,
@@ -174,7 +182,7 @@ contract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, AllowListed, ReentrancyGua
174182
bytes memory l2TxCalldata = _getDepositL2Calldata(msg.sender, _l2Receiver, _l1Token, amount);
175183
// If the refund recipient is not specified, the refund will be sent to the sender of the transaction.
176184
// Otherwise, the refund will be sent to the specified address.
177-
// Please note, if the recipient is a contract (the only exception is a contracting contract, but it is shooting in the leg).
185+
// If the recipient is a contract on L1, the address alias will be applied.
178186
address refundRecipient = _refundRecipient;
179187
if (_refundRecipient == address(0)) {
180188
refundRecipient = msg.sender != tx.origin ? AddressAliasHelper.applyL1ToL2Alias(msg.sender) : msg.sender;

0 commit comments

Comments
 (0)