Skip to content

Commit

Permalink
Adapt scripts for Validium mode
Browse files Browse the repository at this point in the history
  • Loading branch information
ilitteri committed Dec 21, 2023
1 parent 63d5fea commit 0845a34
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion l1-contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ async function main() {
.option("--create2-salt <create2-salt>")
.option("--diamond-upgrade-init <version>")
.option("--only-verifier")
.option('--validium-mode')
.action(async (cmd) => {
const deployWallet = cmd.privateKey
? new Wallet(cmd.privateKey, provider)
Expand Down Expand Up @@ -81,7 +82,7 @@ async function main() {

await deployer.deployGovernance(create2Salt, { gasPrice, nonce });
await deployer.deployAllowList(create2Salt, { gasPrice, nonce: nonce + 1 });
await deployer.deployZkSyncContract(create2Salt, gasPrice, nonce + 2);
await deployer.deployZkSyncContract(create2Salt, gasPrice, nonce + 2, cmd.validiumMode);
await deployer.deployBridgeContracts(create2Salt, gasPrice); // Do not pass nonce, since it was increment after deploying zkSync contracts
await deployer.deployWethBridgeContracts(create2Salt, gasPrice);
await deployer.deployValidatorTimelock(create2Salt, { gasPrice });
Expand Down
21 changes: 19 additions & 2 deletions l1-contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,12 +244,25 @@ export class Deployer {
const contractAddress = await this.deployViaCreate2("ExecutorFacet", [], create2Salt, ethTxOptions);

if (this.verbose) {
console.log(`VALIDIUM_MODE=false`);
console.log(`CONTRACTS_EXECUTOR_FACET_ADDR=${contractAddress}`);
}

this.addresses.ZkSync.ExecutorFacet = contractAddress;
}

public async deployValidiumExecutorFacet(create2Salt: string, ethTxOptions: ethers.providers.TransactionRequest) {
ethTxOptions.gasLimit ??= 10_000_000;
const contractAddress = await this.deployViaCreate2('ValidiumExecutorFacet', [], create2Salt, ethTxOptions);

if (this.verbose) {
console.log(`VALIDIUM_MODE=true`);
console.log(`CONTRACTS_VALIDIUM_EXECUTOR_FACET_ADDR=${contractAddress}`);
}

this.addresses.ZkSync.ExecutorFacet = contractAddress;
}

public async deployGettersFacet(create2Salt: string, ethTxOptions: ethers.providers.TransactionRequest) {
ethTxOptions.gasLimit ??= 10_000_000;
const contractAddress = await this.deployViaCreate2("GettersFacet", [], create2Salt, ethTxOptions);
Expand Down Expand Up @@ -409,13 +422,17 @@ export class Deployer {
this.addresses.ZkSync.DiamondProxy = contractAddress;
}

public async deployZkSyncContract(create2Salt: string, gasPrice?: BigNumberish, nonce?) {
public async deployZkSyncContract(create2Salt: string, gasPrice?: BigNumberish, nonce?, validiumMode?: boolean) {
nonce = nonce ? parseInt(nonce) : await this.deployWallet.getTransactionCount();

const executorFacetPromise = validiumMode
? this.deployValidiumExecutorFacet(create2Salt, { gasPrice, nonce: nonce + 1 })
: this.deployExecutorFacet(create2Salt, { gasPrice, nonce: nonce + 1 });

// deploy zkSync contract
const independentZkSyncDeployPromises = [
this.deployMailboxFacet(create2Salt, { gasPrice, nonce }),
this.deployExecutorFacet(create2Salt, { gasPrice, nonce: nonce + 1 }),
executorFacetPromise,
this.deployAdminFacet(create2Salt, { gasPrice, nonce: nonce + 2 }),
this.deployGettersFacet(create2Salt, { gasPrice, nonce: nonce + 3 }),
this.deployDiamondInit(create2Salt, { gasPrice, nonce: nonce + 4 }),
Expand Down

0 comments on commit 0845a34

Please sign in to comment.