Skip to content

Commit

Permalink
Merge branch 'dev' into dvush-new-sc
Browse files Browse the repository at this point in the history
  • Loading branch information
dvush committed Dec 3, 2020
2 parents 32f80eb + 6fc4f94 commit a459c3e
Show file tree
Hide file tree
Showing 182 changed files with 6,653 additions and 1,947 deletions.
2 changes: 1 addition & 1 deletion .githooks/pre-commit
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
RED='\033[0;31m'
NC='\033[0m' # No Color

# Check that `rustfmt` rules are not violated.
# Check that Rust formatting rules are not violated.
if ! cargo fmt -- --check; then
echo -e "${RED}Commit error!${NC}"
echo "Please format the code via 'cargo fmt', cannot commit unformatted code"
Expand Down
14 changes: 14 additions & 0 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/sh
#
# Pre-push hook verifying that inappropriate code will not be pushed.

# Colors for the terminal output
RED='\033[0;31m'
NC='\033[0m' # No Color

# Check that prettier formatting rules are not violated.
if ! zk fmt --check; then
echo -e "${RED}Commit error!${NC}"
echo "Please format the code via 'zk fmt', cannot push unformatted code"
exit 1
fi
4 changes: 3 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ on:

jobs:
ci-all:
runs-on: self-hosted
# We currently have two self-hosted runners, one of which is marked "DEV-CI" and other one is marder "MAIN".
# "MAIN" is the current CI runner, "DEV-CI" is currently used to experiment with CI optimizing.
runs-on: [self-hosted, MAIN]

steps:
- uses: actions/checkout@v2
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/promote-stage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ on:

jobs:
build-images:
runs-on: self-hosted
# We currently have two self-hosted runners, one of which is marked "DEV-CI" and other one is marder "MAIN".
# "MAIN" is the current CI runner, "DEV-CI" is currently used to experiment with CI optimizing.
runs-on: [self-hosted, MAIN]

steps:
- uses: actions/checkout@v2
Expand Down
7 changes: 4 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

### Contracts v4 and protocol (24.11.2020)

- Timestamp is added to the block commitment. Rollup block timestamp validity is checked when block is committed onchain.
- Offchain ChangePubKey can be performed for smart contract wallets that can be deployed with CREATE2 when pubkey hash is encoded in the CREATE2 salt parameter.
- Timestamp is added to the block commitment. Rollup block timestamp validity is checked when block is committed
onchain.
- Offchain ChangePubKey can be performed for smart contract wallets that can be deployed with CREATE2 when pubkey hash
is encoded in the CREATE2 salt parameter.
- Governance contract can pause token deposits.
- ChangePubKey message signature is changed.
- Onchain operation processing changed on the contract.
- Recursive block verifier added.
- Onchain rollup block commitment changed, multiple blocks can be committed, verified at once.


### Contracts v3 and protocol (4.09.2020)

- Change pubkey operation requires fee for processing.
Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion contracts/contracts/ZkSync.sol
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,10 @@ contract ZkSync is UpgradeableMaster, Storage, Config, Events, ReentrancyGuard {
++currentTotalBlocksProofed;

uint256 mask = (~uint256(0)) >> 3;
require(_proof.commitments[_commitmentIdxs[i]] & mask == uint256(_committedBlocks[i].commitment) & mask, "pbl3"); // incorrect block commitment in proof
require(
_proof.commitments[_commitmentIdxs[i]] & mask == uint256(_committedBlocks[i].commitment) & mask,
"pbl3"
); // incorrect block commitment in proof
}

bool success =
Expand Down
16 changes: 8 additions & 8 deletions contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ import '@nomiclabs/hardhat-waffle';
import '@nomiclabs/hardhat-solpp';
import 'hardhat-typechain';
import 'hardhat-contract-sizer';
import "@nomiclabs/hardhat-etherscan";
import '@nomiclabs/hardhat-etherscan';

const prodConfig = {
// UPGRADE_NOTICE_PERIOD: 0,
MAX_AMOUNT_OF_REGISTERED_TOKENS: 127,
// PRIORITY_EXPIRATION: 101,
DUMMY_VERIFIER: false
}
};
const testnetConfig = {
UPGRADE_NOTICE_PERIOD: 0,
MAX_AMOUNT_OF_REGISTERED_TOKENS: 127,
// PRIORITY_EXPIRATION: 101,
DUMMY_VERIFIER: false
}
};
const testConfig = {
UPGRADE_NOTICE_PERIOD: 0,
MAX_AMOUNT_OF_REGISTERED_TOKENS: 5,
PRIORITY_EXPIRATION: 101,
DUMMY_VERIFIER: true
}
};

const localConfig = Object.assign({}, prodConfig);
localConfig.DUMMY_VERIFIER = process.env.DUMMY_VERIFIER ? true : localConfig.DUMMY_VERIFIER;
Expand All @@ -30,8 +30,8 @@ const contractDefs = {
rinkeby: testnetConfig,
ropsten: testnetConfig,
mainnet: prodConfig,
test: testConfig,
localhost: localConfig,
test: testConfig,
localhost: localConfig
};

export default {
Expand All @@ -51,10 +51,10 @@ export default {
sources: './contracts'
},
solpp: {
defs: process.env.ETH_NETWORK ? contractDefs[process.env.ETH_NETWORK] : contractDefs["test"],
defs: process.env.ETH_NETWORK ? contractDefs[process.env.ETH_NETWORK] : contractDefs['test']
},
networks: {
env : {
env: {
url: process.env.WEB3_URL
}
},
Expand Down
7 changes: 6 additions & 1 deletion contracts/scripts/add-erc20-token.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import { ArgumentParser } from 'argparse';
import { BigNumber, Wallet, ethers } from 'ethers';
import { Deployer } from '../src.ts/deploy';
import * as fs from 'fs';
import * as path from 'path';

const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
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' }));

async function main() {
const parser = new ArgumentParser({
Expand All @@ -17,9 +21,10 @@ async function main() {
const args = parser.parseArgs(process.argv.slice(2));

const deployer = new Deployer({ deployWallet: ethers.Wallet.createRandom() });

const governorWallet = args.deployerPrivateKey
? new Wallet(args.deployerPrivateKey, provider)
: Wallet.fromMnemonic(process.env.MNEMONIC, "m/44'/60'/0'/0/1").connect(provider);
: Wallet.fromMnemonic(ethTestConfig.MNEMONIC, "m/44'/60'/0'/0/1").connect(provider);

console.log('Adding new ERC20 token to network: ', args.tokenAddress);

Expand Down
13 changes: 7 additions & 6 deletions contracts/scripts/deploy-eip1271.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,27 @@ import { deployContract } from 'ethereum-waffle';
import * as fs from 'fs';
import * as path from 'path';

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

(async () => {
try {
if (!['test', 'localhost'].includes(process.env.ETH_NETWORK)) {
console.error('This deploy script is only for localhost-test network');
process.exit(1);
}

const testConfigPath = path.join(process.env.ZKSYNC_HOME, `etc/test_config/constant/eip1271.json`);
const testConfig = JSON.parse(fs.readFileSync(testConfigPath, { encoding: 'utf-8' }));

const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
provider.pollingInterval = 10;

const deployWallet = ethers.Wallet.fromMnemonic(process.env.TEST_MNEMONIC, "m/44'/60'/0'/0/0").connect(
const deployWallet = ethers.Wallet.fromMnemonic(ethTestConfig.test_mnemonic, "m/44'/60'/0'/0/0").connect(
provider
);
const smartWallet = await deployContract(
deployWallet,
readContractCode('AccountMock'),
[testConfig.owner_address],
readContractCode('dev-contracts/AccountMock'),
[EIP1271TestConfig.owner_address],
{
gasLimit: 5000000
}
Expand Down
11 changes: 9 additions & 2 deletions contracts/scripts/deploy-erc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,14 @@ import { deployContract } from 'ethereum-waffle';
import { ethers, Wallet } from 'ethers';
import { readContractCode } from '../src.ts/deploy';
import { parseEther } from 'ethers/lib/utils';
import * as fs from 'fs';
import * as path from 'path';

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 provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
const wallet = Wallet.fromMnemonic(process.env.MNEMONIC, "m/44'/60'/0'/0/1").connect(provider);
const wallet = Wallet.fromMnemonic(ethTestConfig.mnemonic, "m/44'/60'/0'/0/1").connect(provider);

type Token = {
address: string | null;
Expand All @@ -24,7 +29,9 @@ async function deployToken(token: Token): Promise<Token> {

await erc20.mint(wallet.address, parseEther('3000000000'));
for (let i = 0; i < 10; ++i) {
const testWallet = Wallet.fromMnemonic(process.env.TEST_MNEMONIC, "m/44'/60'/0'/0/" + i).connect(provider);
const testWallet = Wallet.fromMnemonic(ethTestConfig.test_mnemonic as string, "m/44'/60'/0'/0/" + i).connect(
provider
);
await erc20.mint(testWallet.address, parseEther('3000000000'));
}
token.address = erc20.address;
Expand Down
9 changes: 7 additions & 2 deletions contracts/scripts/deploy-testkit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ import { ethers, Wallet } from 'ethers';
import { Deployer, readContractCode, readTestContracts, readProductionContracts } from '../src.ts/deploy';
import { deployContract } from 'ethereum-waffle';
import { ArgumentParser } from 'argparse';
import * as fs from 'fs';
import * as path from 'path';

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' }));

(async () => {
const parser = new ArgumentParser({
Expand All @@ -26,7 +31,7 @@ import { ArgumentParser } from 'argparse';
const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
provider.pollingInterval = 10;

const deployWallet = ethers.Wallet.fromMnemonic(process.env.TEST_MNEMONIC, "m/44'/60'/0'/0/0").connect(provider);
const deployWallet = ethers.Wallet.fromMnemonic(ethTestConfig.test_mnemonic, "m/44'/60'/0'/0/0").connect(provider);
// todo: should be decided when building
const contracts = readProductionContracts();
const deployer = new Deployer({ deployWallet, contracts, verbose: true });
Expand All @@ -48,7 +53,7 @@ import { ArgumentParser } from 'argparse';
}

for (let i = 0; i < 10; ++i) {
const testWallet = Wallet.fromMnemonic(process.env.TEST_MNEMONIC, "m/44'/60'/0'/0/" + i).connect(provider);
const testWallet = Wallet.fromMnemonic(ethTestConfig.test_mnemonic, "m/44'/60'/0'/0/" + i).connect(provider);
await (await erc20.mint(testWallet.address, '0x4B3B4CA85A86C47A098A224000000000')).wait();
}
})();
10 changes: 9 additions & 1 deletion contracts/scripts/deploy-testnet-token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,14 @@ import { ethers, Wallet } from 'ethers';
import { readContractCode } from '../src.ts/deploy';
import { encodeConstructorArgs, publishSourceCodeToEtherscan } from '../src.ts/publish-utils';
import * as fs from 'fs';
import * as path from 'path';
import { ArgumentParser } from 'argparse';

const mainnetTokens = require(`${process.env.ZKSYNC_HOME}/etc/tokens/mainnet`);

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' }));

(async () => {
const parser = new ArgumentParser({
version: '0.1.0',
Expand All @@ -18,10 +22,14 @@ const mainnetTokens = require(`${process.env.ZKSYNC_HOME}/etc/tokens/mainnet`);
action: 'storeTrue',
help: 'Only publish code for deployed tokens'
});
parser.addArgument('--deployerPrivateKey', { required: false, help: 'Wallet used to deploy contracts' });
const args = parser.parseArgs(process.argv.slice(2));

const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
const wallet = Wallet.fromMnemonic(process.env.MNEMONIC, "m/44'/60'/0'/0/1").connect(provider);
const wallet = args.deployerPrivateKey
? new Wallet(args.deployerPrivateKey, provider)
: Wallet.fromMnemonic(ethTestConfig.mnemonic, "m/44'/60'/0'/0/1").connect(provider);

const contractCode = readContractCode('TestnetERC20Token');

if (process.env.ETH_NETWORK === 'mainnet') {
Expand Down
14 changes: 9 additions & 5 deletions contracts/scripts/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,12 @@ import { ArgumentParser } from 'argparse';
import { ethers, Wallet } from 'ethers';
import { Deployer } from '../src.ts/deploy';
import { formatUnits, parseUnits } from 'ethers/lib/utils';
import * as fs from 'fs';
import * as path from 'path';

const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
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' }));

(async () => {
const parser = new ArgumentParser({
Expand All @@ -25,7 +29,7 @@ const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);

const wallet = args.deployerPrivateKey
? new Wallet(args.deployerPrivateKey, provider)
: Wallet.fromMnemonic(process.env.MNEMONIC, "m/44'/60'/0'/0/1").connect(provider);
: Wallet.fromMnemonic(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 Expand Up @@ -55,8 +59,8 @@ const provider = new ethers.providers.JsonRpcProvider(process.env.WEB3_URL);
if (args.contract === 'Governance' || args.contract == null) {
await deployer.deployGovernanceTarget({ gasPrice, nonce: args.nonce });
}
//
// if (args.contract === 'Proxies' || args.contract == null) {
// await deployer.deployProxiesAndGatekeeper({ gasPrice, nonce: args.nonce });
// }

if (args.contract === 'Proxies' || args.contract == null) {
await deployer.deployProxiesAndGatekeeper({ gasPrice, nonce: args.nonce });
}
})();
Loading

0 comments on commit a459c3e

Please sign in to comment.