Skip to content

Commit

Permalink
Introduce rest zk improvements from 2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
popzxc committed Nov 26, 2021
1 parent 342c2af commit b0ea3cb
Show file tree
Hide file tree
Showing 12 changed files with 171 additions and 86 deletions.
6 changes: 3 additions & 3 deletions contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ async function main() {
const wallet = args.deployerPrivateKey
? new Wallet(args.deployerPrivateKey, provider)
: Wallet.fromMnemonic(
process.env.MNEMONIC ? process.env.MNEMONIC : ethTestConfig.mnemonic,
"m/44'/60'/0'/0/1"
).connect(provider);
process.env.MNEMONIC ? process.env.MNEMONIC : ethTestConfig.mnemonic,
"m/44'/60'/0'/0/1"
).connect(provider);

const gasPrice = args.gasPrice ? parseUnits(args.gasPrice, 'gwei') : await provider.getGasPrice();
console.log(`Using gas price: ${formatUnits(gasPrice, 'gwei')} gwei`);
Expand Down
6 changes: 3 additions & 3 deletions contracts/scripts/upgrade-testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ async function main() {
const wallet = args.deployerPrivateKey
? new Wallet(args.deployerPrivateKey, provider)
: Wallet.fromMnemonic(
process.env.MNEMONIC ? process.env.MNEMONIC : ethTestConfig.mnemonic,
"m/44'/60'/0'/0/1"
).connect(provider);
process.env.MNEMONIC ? process.env.MNEMONIC : ethTestConfig.mnemonic,
"m/44'/60'/0'/0/1"
).connect(provider);

const gasPrice = args.gasPrice ? parseUnits(args.gasPrice, 'gwei') : await provider.getGasPrice();
console.info(`Using gas price: ${formatUnits(gasPrice, 'gwei')} gwei`);
Expand Down
20 changes: 19 additions & 1 deletion contracts/scripts/utils.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,30 @@
import { ethers } from 'ethers';
import { ParamType } from '@ethersproject/abi';
import * as chalk from 'chalk';

const warning = chalk.bold.yellow;

export function web3Url() {
return process.env.ETH_CLIENT_WEB3_URL.split(',')[0] as string;
}

export function web3Provider() {
return new ethers.providers.JsonRpcProvider(web3Url());
const provider = new ethers.providers.JsonRpcProvider(web3Url());

// Check that `CHAIN_ETH_NETWORK` variable is set. If not, it's most likely because
// the variable was renamed. As this affects the time to deploy contracts in localhost
// scenario, it surely deserves a warning.
const network = process.env.CHAIN_ETH_NETWORK;
if (!network) {
console.log(warning('Network variable is not set. Check if contracts/scripts/utils.ts is correct'));
}

// Short polling interval for local network
if (network === 'localhost') {
provider.pollingInterval = 100;
}

return provider;
}

export function storedBlockInfoParam(): ParamType {
Expand Down
8 changes: 2 additions & 6 deletions contracts/src.ts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@ import { deployContract } from 'ethereum-waffle';
import { ethers, Signer, providers } from 'ethers';
import { formatEther, Interface } from 'ethers/lib/utils';
import * as fs from 'fs';
import {
encodeConstructorArgs,
encodeProxyContstuctorArgs,
publishSourceCodeToEtherscan
} from './publish-utils';
import { encodeConstructorArgs, encodeProxyContstuctorArgs, publishSourceCodeToEtherscan } from './publish-utils';
import {
Governance,
GovernanceFactory,
Expand Down Expand Up @@ -219,7 +215,7 @@ export class Deployer {
this.addresses.Verifier = parsedLog.args.verifier;
this.addresses.UpgradeGatekeeper = parsedLog.args.gatekeeper;
}
} catch (_) { }
} catch (_) {}
}
const txHash = deployFactoryTx.transactionHash;
const gasUsed = deployFactoryTx.gasUsed;
Expand Down
1 change: 0 additions & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ This section provides an overview on folders / sub-projects that exist in this r
- `/etc`: Configration files.
- `/env`: `.env` files that contain environment variables for different configuration of zkSync Server / Prover.
- `/js`: Configuration files for JavaScript applications (such as Explorer).
- `/tesseracts`: Configuration for `tesseracts` minimalistic blockchain explorer (used for development).
- `/tokens`: Configuration of supported Ethereum ERC-20 tokens.
- `/infrastructure`: Application that aren't naturally a part of zkSync core, but are related to it.
- `/explorer`: A blockchain explorer for zkSync network.
Expand Down
58 changes: 0 additions & 58 deletions etc/tesseracts/tesseracts.toml

This file was deleted.

6 changes: 6 additions & 0 deletions infrastructure/zk/src/contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ export async function build() {
}

export async function publish() {
// Spawning a new script is expensive, so if we know that publishing is disabled, it's better to not launch
// it at all (even though `publish-sources` checks the network as well).
if (process.env.CHAIN_ETH_NETWORK == 'localhost') {
console.log('Skip contract publish on localhost');
return;
}
await utils.spawn('yarn contracts publish-sources');
}

Expand Down
5 changes: 5 additions & 0 deletions infrastructure/zk/src/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ export async function load() {
process.env.ENV_DIR = envDir;
dotenv.config({ path: envFile });
load_docker();

// This suppresses the warning that looks like: "Warning: Accessing non-existent property 'INVALID_ALT_NUMBER'...".
// This warning is spawned from the `antlr4`, which is a dep of old `solidity-parser` library.
// Old version of `solidity-parser` is still videly used, and currently we can't get rid of it fully.
process.env.NODE_OPTIONS = '--no-warnings';
}

// replaces an env variable in current .env file
Expand Down
8 changes: 4 additions & 4 deletions infrastructure/zk/src/fmt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ export const command = new Command('fmt')
await prettier(extension, cmd.check);
}
} else {
for (const ext of EXTENSIONS) {
await prettier(ext, cmd.check);
}
await rustfmt(cmd.check);
// Run all the checks in parallel.
const promises = EXTENSIONS.map((ext) => prettier(ext, cmd.check));
promises.push(rustfmt(cmd.check));
await Promise.all(promises);
}
});

Expand Down
4 changes: 1 addition & 3 deletions infrastructure/zk/src/run/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,7 @@ export async function tokenInfo(address: string) {
// installs all dependencies and builds our js packages
export async function yarn() {
await utils.spawn('yarn');
await utils.spawn('yarn crypto build');
await utils.spawn('yarn reading-tool build');
await utils.spawn('yarn zksync prepublish');
await utils.spawn('yarn init-build');
}

export async function deployTestkit(genesisRoot: string, prodContracts: boolean = false) {
Expand Down
11 changes: 8 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@
]
},
"scripts": {
"build:zksync-sdk": "yarn zksync prepublish",
"build:crypto": "yarn crypto build",
"build:reading-tool": "yarn reading-tool build",
"zksync": "yarn workspace zksync",
"crypto": "yarn workspace zksync-crypto",
"contracts": "yarn workspace franklin-contracts",
Expand All @@ -34,7 +37,8 @@
"explorer": "yarn workspace sync-explorer",
"zk": "yarn workspace zk",
"reading-tool": "yarn workspace reading-tool",
"api-docs": "yarn workspace api-docs"
"api-docs": "yarn workspace api-docs",
"init-build": "yarn npm-run-all --parallel build:*"
},
"devDependencies": {
"@typescript-eslint/eslint-plugin": "^4.10.0",
Expand All @@ -46,6 +50,7 @@
"markdownlint-cli": "^0.24.0",
"prettier": "^2.2.1",
"prettier-plugin-solidity": "^1.0.0-alpha.60",
"solhint": "^3.3.2"
"solhint": "^3.3.2",
"npm-run-all": "^4.1.5"
}
}
}
Loading

0 comments on commit b0ea3cb

Please sign in to comment.