Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions ethereum/contracts/bridge/L1ERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,15 @@ contract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, AllowListed, ReentrancyGua
address _l2TokenBeacon,
address _governor,
uint256 _deployBridgeImplementationFee,
uint256 _deployBridgeProxyFee
uint256 _deployBridgeProxyFee,
uint256 _amount
) external payable reentrancyGuardInitializer {
require(_l2TokenBeacon != address(0), "nf");
require(_governor != address(0), "nh");
// We are expecting to see the exact three bytecodes that are needed to initialize the bridge
require(_factoryDeps.length == 3, "mk");
// The caller miscalculated deploy transactions fees
require(msg.value == _deployBridgeImplementationFee + _deployBridgeProxyFee, "fee");
require(_amount == _deployBridgeImplementationFee + _deployBridgeProxyFee, "fee");
l2TokenProxyBytecodeHash = L2ContractHelper.hashL2Bytecode(_factoryDeps[2]);
l2TokenBeacon = _l2TokenBeacon;

Expand All @@ -105,7 +106,8 @@ contract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, AllowListed, ReentrancyGua
_deployBridgeImplementationFee,
l2BridgeImplementationBytecodeHash,
"", // Empty constructor data
_factoryDeps // All factory deps are needed for L2 bridge
_factoryDeps, // All factory deps are needed for L2 bridge
_amount
);

// Prepare the proxy constructor data
Expand All @@ -126,7 +128,8 @@ contract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, AllowListed, ReentrancyGua
l2BridgeProxyBytecodeHash,
l2BridgeProxyConstructorData,
// No factory deps are needed for L2 bridge proxy, because it is already passed in previous step
new bytes[](0)
new bytes[](0),
_amount
);
}

Expand Down
11 changes: 7 additions & 4 deletions ethereum/contracts/bridge/L1WethBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -83,13 +83,14 @@ contract L1WethBridge is IL1Bridge, AllowListed, ReentrancyGuard {
address _l2WethAddress,
address _governor,
uint256 _deployBridgeImplementationFee,
uint256 _deployBridgeProxyFee
uint256 _deployBridgeProxyFee,
uint256 _amount
) external payable reentrancyGuardInitializer {
require(_l2WethAddress != address(0), "L2 WETH address cannot be zero");
require(_governor != address(0), "Governor address cannot be zero");
require(_factoryDeps.length == 2, "Invalid factory deps length provided");
require(
msg.value == _deployBridgeImplementationFee + _deployBridgeProxyFee,
_amount == _deployBridgeImplementationFee + _deployBridgeProxyFee,
"Miscalculated deploy transactions fees"
);

Expand All @@ -104,7 +105,8 @@ contract L1WethBridge is IL1Bridge, AllowListed, ReentrancyGuard {
_deployBridgeImplementationFee,
l2WethBridgeImplementationBytecodeHash,
"", // Empty constructor data
_factoryDeps // All factory deps are needed for L2 bridge
_factoryDeps, // All factory deps are needed for L2 bridge
_amount
);

// Prepare the proxy constructor data
Expand All @@ -129,7 +131,8 @@ contract L1WethBridge is IL1Bridge, AllowListed, ReentrancyGuard {
l2WethBridgeProxyBytecodeHash,
l2WethBridgeProxyConstructorData,
// No factory deps are needed for L2 bridge proxy, because it is already passed in the previous step
new bytes[](0)
new bytes[](0),
_amount
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ library BridgeInitializationHelper {
uint256 _deployTransactionFee,
bytes32 _bytecodeHash,
bytes memory _constructorData,
bytes[] memory _factoryDeps
bytes[] memory _factoryDeps,
uint256 _amount
) internal returns (address deployedAddress) {
bytes memory deployCalldata = abi.encodeCall(
IL2ContractDeployer.create2,
Expand All @@ -41,7 +42,7 @@ library BridgeInitializationHelper {
_zkSync.requestL2Transaction{value: _deployTransactionFee}(
L2_DEPLOYER_SYSTEM_CONTRACT_ADDR,
0,
0,
_amount,
deployCalldata,
DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,
REQUIRED_L2_GAS_PRICE_PER_PUBDATA,
Expand Down
3 changes: 2 additions & 1 deletion ethereum/scripts/initialize-bridges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ async function main() {
zkSync.requestL2Transaction(
ethers.constants.AddressZero,
0,
0,
requiredValueToPublishBytecodes,
"0x",
priorityTxMaxGasLimit,
REQUIRED_L2_GAS_PRICE_PER_PUBDATA,
Expand All @@ -161,6 +161,7 @@ async function main() {
l2GovernorAddress,
requiredValueToInitializeBridge,
requiredValueToInitializeBridge,
requiredValueToInitializeBridge.mul(2),
{
gasPrice,
nonce: nonce + 1,
Expand Down
1 change: 1 addition & 0 deletions ethereum/scripts/initialize-weth-bridges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ async function main() {
l2GovernorAddress,
requiredValueToInitializeBridge,
requiredValueToInitializeBridge,
requiredValueToInitializeBridge.mul(2),
{
gasPrice,
value: requiredValueToInitializeBridge.mul(2),
Expand Down