Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
juan518munoz committed Jan 31, 2024
1 parent 974f7ee commit 199aa65
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion l1-contracts/contracts/bridge/L1ERC20Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,18 @@ contract L1ERC20Bridge is IL1Bridge, IL1BridgeLegacy, ReentrancyGuard {
uint256 _deployBridgeProxyFee,
uint256 _amount
) external payable reentrancyGuardInitializer {
bool nativeErc20 = _amount != 0;

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(_amount == _deployBridgeImplementationFee + _deployBridgeProxyFee, "fee");
if (nativeErc20) {
require(_amount == _deployBridgeImplementationFee + _deployBridgeProxyFee, "fee");
} else {
require(msg.value == _deployBridgeImplementationFee + _deployBridgeProxyFee, "fee");
}
l2TokenProxyBytecodeHash = L2ContractHelper.hashL2Bytecode(_factoryDeps[2]);
l2TokenBeacon = _l2TokenBeacon;

Expand Down
10 changes: 7 additions & 3 deletions l1-contracts/scripts/initialize-bridges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ async function main() {
.option("--gas-price <gas-price>")
.option("--nonce <nonce>")
.option("--erc20-bridge <erc20-bridge>")
.option("--native-erc20")
.action(async (cmd) => {
const deployWallet = cmd.privateKey
? new Wallet(cmd.privateKey, provider)
Expand All @@ -70,6 +71,10 @@ async function main() {
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

// check if native erc20 is enabled
const nativeErc20impl = cmd.nativeErc20 ? true : false;
console.log(`Using native erc20: ${nativeErc20impl}`);

const gasPrice = cmd.gasPrice ? parseUnits(cmd.gasPrice, "gwei") : await provider.getGasPrice();
console.log(`Using gas price: ${formatUnits(gasPrice, "gwei")} gwei`);

Expand Down Expand Up @@ -152,7 +157,7 @@ async function main() {
zkSync.requestL2Transaction(
ethers.constants.AddressZero,
0,
requiredValueToPublishBytecodes,
nativeErc20impl ? requiredValueToPublishBytecodes : 0,
"0x",
priorityTxMaxGasLimit,
SYSTEM_CONFIG.requiredL2GasPricePerPubdata,
Expand All @@ -166,15 +171,14 @@ async function main() {
l2GovernorAddress,
requiredValueToInitializeBridge,
requiredValueToInitializeBridge,
requiredValueToInitializeBridge.mul(2),
nativeErc20impl ? requiredValueToInitializeBridge.mul(2) : 0,
{
gasPrice,
nonce: nonce + 1,
value: requiredValueToInitializeBridge.mul(2),
}
),
];

const txs = await Promise.all(independentInitialization);
for (const tx of txs) {
console.log(`Transaction sent with hash ${tx.hash} and nonce ${tx.nonce}. Waiting for receipt...`);
Expand Down

0 comments on commit 199aa65

Please sign in to comment.