Skip to content

Commit

Permalink
started updating deploy scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
kelemeno committed Feb 2, 2024
1 parent 3893d12 commit d2f1150
Show file tree
Hide file tree
Showing 21 changed files with 354 additions and 37 deletions.
4 changes: 0 additions & 4 deletions l1-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,6 @@
"deploy-testkit": "ts-node scripts/deploy-testkit.ts",
"verify": "hardhat run --network env scripts/verify.ts",
"read-variable": "ts-node scripts/read-variable.ts",
"erc20-deploy-on-chain": "ts-node scripts/erc20-deploy-on-chain.ts",
"erc20-finish-deployment-on-chain": "ts-node scripts/erc20-finish-deployment-on-chain.ts",
"weth-deploy-on-chain": "ts-node scripts/weth-deploy-on-chain.ts",
"weth-finish-deployment-on-chain": "ts-node scripts/weth-finish-deployment-on-chain.ts",
"initialize-erc20-bridge": "ts-node scripts/initialize-erc20-bridge.ts",
"initialize-weth-bridge": "ts-node scripts/initialize-weth-bridge.ts",
"initialize-governance-chain": "ts-node scripts/initialize-governance-chain.ts",
Expand Down
8 changes: 6 additions & 2 deletions l1-contracts/scripts/initialize-l2-weth-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ async function getL1TxInfo(
gasPrice: ethers.BigNumber
) {
const bridgehub = deployer.bridgehubContract(ethers.Wallet.createRandom().connect(provider));
const l1Calldata = bridgehub.interface.encodeFunctionData("requestL2Transaction", [
const l1GasPriceConverted = await bridgehub.provider.getGasPrice();
const l1Calldata = bridgehub.interface.encodeFunctionData("requestL2TransactionDirect", [
{
chainId,
l2Contract: to,
Expand All @@ -55,6 +56,7 @@ async function getL1TxInfo(
l2Calldata,
l2GasLimit: DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,
l2GasPerPubdataByteLimit: SYSTEM_CONFIG.requiredL2GasPricePerPubdata,
l1GasPriceConverted: l1GasPriceConverted,
factoryDeps: [], // It is assumed that the target has already been deployed
refundRecipient,
},
Expand Down Expand Up @@ -171,8 +173,9 @@ async function main() {
SYSTEM_CONFIG.requiredL2GasPricePerPubdata
);
const calldata = getL2Calldata(l2WethBridgeAddress, l1WethTokenAddress, l2WethTokenImplAddress);
const l1GasPriceConverted = await bridgehub.provider.getGasPrice();

const tx = await bridgehub.requestL2Transaction(
const tx = await bridgehub.requestL2TransactionDirect(
{
chainId,
l2Contract: l2WethTokenProxyAddress,
Expand All @@ -181,6 +184,7 @@ async function main() {
l2Calldata: calldata,
l2GasLimit: DEPLOY_L2_BRIDGE_COUNTERPART_GAS_LIMIT,
l2GasPerPubdataByteLimit: SYSTEM_CONFIG.requiredL2GasPricePerPubdata,
l1GasPriceConverted: l1GasPriceConverted,
factoryDeps: [],
refundRecipient: deployWallet.address,
},
Expand Down
8 changes: 5 additions & 3 deletions l1-contracts/src.ts/erc20-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,15 @@ export async function initializeErc20Bridge(

const l1GovernorAddress = deployer.addresses.Governance;

const l1WethAddress = process.env.CONTRACTS_L1_WETH_ADDR!; //kl todo is this right?
// Governor should always be smart contract (except for unit tests)
const l2GovernorAddress = applyL1ToL2Alias(l1GovernorAddress);
// const l2GovernorAddress = applyL1ToL2Alias(l1GovernorAddress);

const l2TokenProxyBytecodeHash = ethers.utils.keccak256(L2_STANDARD_ERC20_PROXY_BYTECODE);
// const l2TokenProxyBytecodeHash = ethers.utils.keccak256(L2_STANDARD_ERC20_PROXY_BYTECODE);

const tx1 = await erc20Bridge.initialize();
const tx2 = await erc20Bridge.initializeV2(

Check failure on line 42 in l1-contracts/src.ts/erc20-initialize.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎····l1WethAddress,⏎····l1GovernorAddress,⏎····{·nonce:·nonce·+·1,·gasPrice·}⏎··` with `l1WethAddress,·l1GovernorAddress,·{·nonce:·nonce·+·1,·gasPrice·}`

Check failure on line 42 in l1-contracts/src.ts/erc20-initialize.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎····l1WethAddress,⏎····l1GovernorAddress,⏎····{·nonce:·nonce·+·1,·gasPrice·}⏎··` with `l1WethAddress,·l1GovernorAddress,·{·nonce:·nonce·+·1,·gasPrice·}`

Check failure on line 42 in l1-contracts/src.ts/erc20-initialize.ts

View workflow job for this annotation

GitHub Actions / lint

Replace `⏎····l1WethAddress,⏎····l1GovernorAddress,⏎····{·nonce:·nonce·+·1,·gasPrice·}⏎··` with `l1WethAddress,·l1GovernorAddress,·{·nonce:·nonce·+·1,·gasPrice·}`
l1WethAddress,
l1GovernorAddress,
{ nonce: nonce + 1, gasPrice }
);
Expand Down Expand Up @@ -118,7 +120,7 @@ export async function startErc20BridgeInitOnChain(
}
nonce = await deployWallet.getTransactionCount();
const l1GasPriceConverted = await bridgehub.provider.getGasPrice();
const tx1 = await bridgehub.requestL2Transaction(
const tx1 = await bridgehub.requestL2TransactionDirect(
{
chainId,
l2Contract: ethers.constants.AddressZero,
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/src.ts/weth-initialize.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ export async function startWethBridgeInitOnChain(
nonce = await deployWallet.getTransactionCount();
const l1GasPriceConverted = await bridgehub.provider.getGasPrice();

const tx1 = await bridgehub.requestL2Transaction(
const tx1 = await bridgehub.requestL2TransactionDirect(
{
chainId,
l2Contract: ethers.constants.AddressZero,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ contract RequestL2TransactionTest is BridgehubMailboxTest {

vm.expectRevert(revertMessage);
vm.startPrank(msgSender);
bridgehub.requestL2Transaction{value: msgValue}(
bridgehub.requestL2TransactionDirect{value: msgValue}(
chainId,
contractL2,
l2Value,
Expand Down Expand Up @@ -120,7 +120,7 @@ contract RequestL2TransactionTest is BridgehubMailboxTest {
);

vm.startPrank(msgSender);
bytes32 canonicalTxHash = bridgehub.requestL2Transaction{value: msgValue}(
bytes32 canonicalTxHash = bridgehub.requestL2TransactionDirect{value: msgValue}(
chainId,
contractL2,
l2Value,
Expand Down
34 changes: 17 additions & 17 deletions l1-contracts/test/test_config/constant/hardhat.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,96 +3,96 @@
"name": "DAI",
"symbol": "DAI",
"decimals": 18,
"address": "0x58E1Ae315c130302Ec6E48A9d8E69E8dEa690537"
"address": "0xE19793ef023Baa5d7747462E5CdaDef53E1A8389"
},
{
"name": "wBTC",
"symbol": "wBTC",
"decimals": 8,
"address": "0xFAC80988B9d5320261150A4B4ec119FB1C133580"
"address": "0xd4c434B61DC397065F92ef4CB09E1C93AC7A499E"
},
{
"name": "BAT",
"symbol": "BAT",
"decimals": 18,
"address": "0x9F5d1DA449A6c22CCCCE139acD98adD82797fEec"
"address": "0x31C5299977128159005736Ad18E91bF26961c7B4"
},
{
"name": "GNT",
"symbol": "GNT",
"decimals": 18,
"address": "0x275E5aa56a705c8726eE35B3DC6530DE0a0e5f6c"
"address": "0x5Fe5b78D6276cd0656d94e94e4d83310D8c5A639"
},
{
"name": "MLTT",
"symbol": "MLTT",
"decimals": 18,
"address": "0x18d8b7878Ee8D1cf3c32b177e0B0EC2379084B11"
"address": "0xb88DaBd4401898e614D9D3Ba83efdC3d437809Ee"
},
{
"name": "DAIK",
"symbol": "DAIK",
"decimals": 18,
"address": "0xe4B41b2c8e3831cbEdC8b3D82047fA30B6B22946"
"address": "0xF4d5D83386397278e9ADC349064a42FE1711baeb"
},
{
"name": "wBTCK",
"symbol": "wBTCK",
"decimals": 8,
"address": "0xe8c976ce9F855825e52015bd1E88Fc84Da1946d2"
"address": "0x75a41E462a87C17eba028d88d8e60135E971D4Fb"
},
{
"name": "BATK",
"symbol": "BATS",
"decimals": 18,
"address": "0xd012f213dDD34858A1357e30B4c491dbFCba8Ee3"
"address": "0x32a928B22c559b6D06cfbF864F84F1f119DBa3AF"
},
{
"name": "GNTK",
"symbol": "GNTS",
"decimals": 18,
"address": "0x8fbdf8cEAf04E3cc9ac53C90b344c0c2489a0645"
"address": "0x053Ea9b57a6CABD2EC65a9Aec8C744610B179E5F"
},
{
"name": "MLTTK",
"symbol": "MLTTS",
"decimals": 18,
"address": "0x91D6cBBb7006A3fC6686d65375A067624b8D405A"
"address": "0xd2FC55ab4Bab2f65224BFD6A2f858f2c18092eb5"
},
{
"name": "DAIL",
"symbol": "DAIL",
"decimals": 18,
"address": "0xEbD3994f1a9d85458bD2a40Fc6927C4048291067"
"address": "0xbbDA1f322f7183720Eeb921A74ebF38F62B7a890"
},
{
"name": "wBTCL",
"symbol": "wBTCP",
"decimals": 8,
"address": "0x194475D0de71858B134e2084fa627B5A7d04334c"
"address": "0xfFAF7791658fcB600bdfBDE52833A37050152003"
},
{
"name": "BATL",
"symbol": "BATW",
"decimals": 18,
"address": "0xfB6306147E50e7042E74eA6Cc3db38a8489F8D78"
"address": "0xC4835f7E82d39C4Ce084dBc885F7abC038ccd37a"
},
{
"name": "GNTL",
"symbol": "GNTW",
"decimals": 18,
"address": "0xA50C21DE8a2d575F915E5f8D6D5ec8eF2935D58e"
"address": "0x6400594D841c2c2F2268a1cF7e0d5826527701a8"
},
{
"name": "MLTTL",
"symbol": "MLTTW",
"decimals": 18,
"address": "0xCBaDEF24FA67dB5a56fD84c72b22797A125C3132"
"address": "0xd03A3110eC48d5A5159ed152C6C33a6BE97AECEe"
},
{
"name": "Wrapped Ether",
"symbol": "WETH",
"decimals": 18,
"address": "0x80C92D6E8d4015660506Cf4F4503eBF3bc073190"
"address": "0x59f450Fb56C968B4DC4E4F2f3f3c49BCfb52cB12"
}
]
]
2 changes: 1 addition & 1 deletion l1-contracts/test/unit_tests/custom_base_token.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function create2DeployFromL1(
);
const l1GasPriceConverted = await bridgehub.provider.getGasPrice();

await bridgehub.requestL2Transaction(
await bridgehub.requestL2TransactionDirect(
{
chainId,
l2Contract: DEPLOYER_SYSTEM_CONTRACT_ADDRESS,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export async function create2DeployFromL1(
);
const l1GasPriceConverted = await bridgehub.provider.getGasPrice();

await bridgehub.requestL2Transaction(
await bridgehub.requestL2TransactionDirect(
{
chainId,
l2Contract: DEPLOYER_SYSTEM_CONTRACT_ADDRESS,
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/test/unit_tests/l1_weth_bridge_test.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export async function create2DeployFromL1(
);
const l1GasPriceConverted = await bridgehub.provider.getGasPrice();

await bridgehub.requestL2Transaction(
await bridgehub.requestL2TransactionDirect(
{
chainId,
l2Contract: DEPLOYER_SYSTEM_CONTRACT_ADDRESS,
Expand Down
2 changes: 1 addition & 1 deletion l1-contracts/test/unit_tests/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ export async function requestExecute(
}
const l1GasPriceConverted = await bridgehub.provider.getGasPrice();

return await bridgehub.requestL2Transaction(
return await bridgehub.requestL2TransactionDirect(
{
chainId,
l2Contract: to,
Expand Down
8 changes: 7 additions & 1 deletion l2-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@
"test": "hardhat test",
"verify": "hardhat run src/verify.ts",
"deploy-testnet-paymaster": "ts-node src/deployTestnetPaymaster.ts",
"deploy-testnet-paymaster-from-l1": "ts-node src/deployTestnetPaymasteFromL1.ts",
"deploy-force-deploy-upgrader": "ts-node src/deployForceDeployUpgrader.ts",
"deploy-force-deploy-upgrader-from-l1": "ts-node src/deployForceDeployUpgraderFromL1.ts",
"publish-bridge-preimages": "ts-node src/publish-bridge-preimages.ts",
"deploy-l2-weth": "ts-node src/deployL2Weth.ts",
"upgrade-bridge-contracts": "ts-node src/upgradeBridgeImpl.ts"
"upgrade-bridge-contracts": "ts-node src/upgradeBridgeImpl.ts",
"erc20-deploy-on-chain": "ts-node scripts/erc20-deploy-on-chain.ts",
"weth-deploy-on-chain": "ts-node scripts/weth-deploy-on-chain.ts",
"erc20-deploy-on-chain-from-l1": "ts-node scripts/erc20-deploy-on-chain-from-l1.ts",
"weth-deploy-on-chain-from-l1": "ts-node scripts/weth-deploy-on-chain-from-l1.ts"
},
"dependencies": {
"dotenv": "^16.0.3"
Expand Down
67 changes: 67 additions & 0 deletions l2-contracts/src/deploy-force-deploy-upgrader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
import { Command } from "commander";
import { ethers, Wallet } from "ethers";
import { computeL2Create2Address, create2DeployFromL1, getNumberFromEnv } from "./utils";
import { web3Provider } from "../../l1-contracts/scripts/utils";
import * as fs from "fs";
import * as path from "path";
import * as hre from "hardhat";

const provider = web3Provider();
const testConfigPath = path.join(process.env.ZKSYNC_HOME as string, "etc/test_config/constant");
const ethTestConfig = JSON.parse(fs.readFileSync(`${testConfigPath}/eth.json`, { encoding: "utf-8" }));

const priorityTxMaxGasLimit = getNumberFromEnv("CONTRACTS_PRIORITY_TX_MAX_GAS_LIMIT");

// Script to deploy the force deploy upgrader contract and output its address.
// Note, that this script expects that the L2 contracts have been compiled PRIOR
// to running this script.
async function main() {
const program = new Command();

program
.version("0.1.0")
.name("deploy-force-deploy-upgrader")
.option("--chain-id <chain-id>")
.description("Deploys the force deploy upgrader contract to L2");

program.option("--private-key <private-key>").action(async (cmd) => {
const chainId: string = cmd.chainId ? cmd.chainId : process.env.CHAIN_ETH_ZKSYNC_NETWORK_ID;
const deployWallet = cmd.privateKey
? new Wallet(cmd.privateKey, provider)
: Wallet.fromMnemonic(
process.env.MNEMONIC ? process.env.MNEMONIC : ethTestConfig.mnemonic,
"m/44'/60'/0'/0/1"
).connect(provider);
console.log(`Using deployer wallet: ${deployWallet.address}`);

const forceDeployUpgraderBytecode = hre.artifacts.readArtifactSync("ForceDeployUpgrader").bytecode;
const create2Salt = ethers.constants.HashZero;
const forceDeployUpgraderAddress = computeL2Create2Address(
deployWallet,
forceDeployUpgraderBytecode,
"0x",
create2Salt
);

// TODO: request from API how many L2 gas needs for the transaction.
await create2DeployFromL1(
chainId,
deployWallet,
forceDeployUpgraderBytecode,
"0x",
create2Salt,
priorityTxMaxGasLimit
);

console.log(`CONTRACTS_L2_DEFAULT_UPGRADE_ADDR=${forceDeployUpgraderAddress}`);
});

await program.parseAsync(process.argv);
}

main()
.then(() => process.exit(0))
.catch((err) => {
console.error("Error:", err);
process.exit(1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const priorityTxMaxGasLimit = getNumberFromEnv("CONTRACTS_PRIORITY_TX_MAX_GAS_LI
async function main() {
const program = new Command();

program.version("0.1.0").name("deploy-testnet-paymaster").description("Deploys the testnet paymaster to L2");
program.version("0.1.0").name("deploy-testnet-paymaster-from-l1").description("Deploys the testnet paymaster to L2");

program
.option("--private-key <private-key>")
Expand Down
Loading

0 comments on commit d2f1150

Please sign in to comment.