Skip to content

Commit

Permalink
Merge branch 'dev' into vladyslav-bochok-zks-241-move-all-commands-fr…
Browse files Browse the repository at this point in the history
…om-tok-cli-to-zk
  • Loading branch information
vladbochok authored Jan 12, 2021
2 parents 326e68d + ab2a411 commit 8376713
Show file tree
Hide file tree
Showing 97 changed files with 1,255 additions and 497 deletions.
7 changes: 7 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
./volumes/**/*
node_modules
**/node_modules/**
build/
dist/
volumes/
.tslintrc.js
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ jobs:
run: |
# lint non-rust code
zk fmt --check
yarn lint:md
yarn lint:sol
zk lint --check
zk dummy-prover ensure-disabled
cargo fmt --all -- --check
zk f cargo clippy --tests --benches -- -D warnings
Expand Down
3 changes: 0 additions & 3 deletions .solhint.json

This file was deleted.

9 changes: 0 additions & 9 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"core/bin/key_generator",
"core/bin/server",
"core/bin/prover",
"core/bin/gen_token_add_contract",
"core/bin/parse_pub_data",

# Server micro-services
Expand Down
23 changes: 23 additions & 0 deletions changelog/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

All notable changes to the core components will be documented in this file.

## Unreleased

### Changed

- `gen_token_add_contract` crate is rewritten in ts.

### Added

- `closest_greater_or_eq_packable_fee_amount` and `closest_greater_or_eq_packable_token_amount` functions.
`test_float_conversions` test was expanded.

### Fixed

- Bug with `to_float` function. Now, it really rounds to the closest less or equal float number.
- Wrong index type used in the database causing some queries to take too much time.

## Prior to 2020-12-23

### Added
Expand All @@ -20,3 +36,10 @@ All notable changes to the core components will be documented in this file.
### Fixed

- Bug with delay between receiving a job and starting sending heartbeats.

## Unreleased

### Changed

- Metrics were added to some functions from lib/storage.
- `get_tx_by_hash` function was simplified.
19 changes: 17 additions & 2 deletions changelog/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,22 @@ components, the logs will have the following format:

## Unreleased

### Added

- (`fee-seller`): reserve fee accumulator address.

### Changed

- (`explorer`) was refactored and optimized.

### Fixed

- (`fee-seller`): the logic of amount to withdraw/transfer through ZkSync network.
- Link to status page was added to explorer.
- (`explorer`): account and token ids, verified and committed nonces.
- (`zk`): `lint` command.

### Changed

- `explorer` was refactored and optimized.
- `tok_cli` was removed and all commands from it have been moved to `zk`.
- (`explorer`): optimized by caching.
- (`tok_cli`): was removed and all commands from it have been moved to `zk`.
6 changes: 6 additions & 0 deletions changelog/js-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ All notable changes to `zksync.js` will be documented in this file.

- `updateTokenSet` function that updates the `tokenSet` stored in the `Provider`.
- `newMockProvider` and `DummyTransport`. Tests for the library.
- `closestGreaterOrEqPackableTransactionAmount` and `closestGreaterOrEqPackableTransactionFee` functions. Tests for
them.

### Fixed

- Bug with `integerToFloat` function. Now, it really rounds to the closest less or equal float number.

## Prior to 2020-12-10

Expand Down
1 change: 1 addition & 0 deletions changelog/rust-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ All notable changes to `zksync_rs` will be documented in this file.
### Added

- Additional unit tests.
- Exporting `closest_greater_or_eq_packable_fee_amount` and `closest_greater_or_eq_packable_token_amount` functions.

### Changed

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ pragma solidity ^0.5.0;
contract TokenDeployInit {
function getTokens() internal pure returns (address[] memory) {
address[] memory tokens = new address[]({{ token_len }});
{{~ #each tokens }}
{{#each tokens}}
tokens[{{@index}}] = {{ this.address }};
{{~ /each }}
{{/each}}
return tokens;
}
}
6 changes: 4 additions & 2 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
"@types/chai": "^4.2.14",
"@types/mocha": "^8.0.3",
"argparse": "^1.0.10",
"axios": "^0.21.0",
"axios": "^0.21.1",
"chai": "^4.2.0",
"chalk": "^4.1.0",
"ethereum-waffle": "^3.1.2",
"ethereumjs-abi": "^0.6.8",
"ethers": "^5.0.19",
"ethjs": "^0.4.0",
"fs": "^0.0.1-security",
"handlebars": "^4.7.6",
"mocha": "^8.2.0",
"openzeppelin-solidity": "^2.3.0",
"path": "^0.12.7",
Expand All @@ -41,6 +42,7 @@
"token-info": "ts-node scripts/token-info.ts",
"deploy-testkit": "ts-node scripts/deploy-testkit.ts",
"publish-sources": "ts-node scripts/publish.ts",
"deploy-testnet-erc20": "ts-node scripts/deploy-testnet-token.ts"
"deploy-testnet-erc20": "ts-node scripts/deploy-testnet-token.ts",
"gen-token-add-contract": "ts-node scripts/gen-token-add-contract.ts"
}
}
24 changes: 24 additions & 0 deletions contracts/scripts/gen-token-add-contract.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import * as fs from 'fs';
import * as path from 'path';
import * as Handlebars from 'handlebars';

const network = process.env.ETH_NETWORK as string;
const ZKSYNC_HOME = process.env.ZKSYNC_HOME as string;
if (!network) {
throw new Error('ETH_NETWORK is not set');
}
if (!ZKSYNC_HOME) {
throw new Error('ZKSYNC_HOME is not set');
}

const pathToTokenList = path.join(ZKSYNC_HOME, `etc/tokens/${network}.json`);
const tokenList = JSON.parse(fs.readFileSync(pathToTokenList, { encoding: 'utf-8' }));
const pathToExample = path.join(ZKSYNC_HOME, `contracts/contract-templates/TokenInitTemplate.template`);
const template = Handlebars.compile(fs.readFileSync(pathToExample, { encoding: 'utf-8' }));
const templateParams = {
token_len: tokenList.length,
tokens: tokenList
};
const contract = template(templateParams);
const outputPath = path.join(ZKSYNC_HOME, `contracts/contracts/TokenInit.sol`);
fs.writeFileSync(outputPath, contract, { encoding: 'utf-8' });
4 changes: 2 additions & 2 deletions contracts/test/unit_tests/bytes_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { BigNumber } = require('ethers');
const { expect } = require('chai');
const { provider, wallet, deployTestContract, getCallRevertReason } = require('./common');
const { deployTestContract, getCallRevertReason } = require('./common');

describe('Bytes unit tests', function() {
describe('Bytes unit tests', function () {
this.timeout(50000);

let bytesTestContract;
Expand Down
7 changes: 4 additions & 3 deletions contracts/test/unit_tests/common.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const ethers = require('ethers');
const { expect, use } = require('chai');
const { defaultAccounts, solidity, deployContract, MockProvider } = require('ethereum-waffle');
const { use } = require('chai');
const { solidity, deployContract, MockProvider } = require('ethereum-waffle');

const IERC20_INTERFACE = require('openzeppelin-solidity/build/contracts/IERC20');
const { rawEncode } = require('ethereumjs-abi');
const DEFAULT_REVERT_REASON = 'VM did not revert';

// For: geth

Expand Down Expand Up @@ -46,7 +47,7 @@ async function deployProxyContract(wallet, proxyCode, contractCode, initArgs, in
}

async function getCallRevertReason(f) {
let revertReason = 'VM did not revert';
let revertReason = DEFAULT_REVERT_REASON;
let result;
try {
result = await f();
Expand Down
5 changes: 4 additions & 1 deletion contracts/test/unit_tests/governance_test.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
const { expect } = require('chai');
const { wallet, deployProxyContract, getCallRevertReason } = require('./common');

describe('Governance unit tests', function() {
describe('Governance unit tests', function () {
this.timeout(50000);

let testContract;
before(async () => {
let governanceAddressDeployed;
// The `governanceAddressDeployed` is indeed never used
// but it is worth assigning it for clarity.
// eslint-disable-next-line no-unused-vars
[testContract, governanceAddressDeployed] = await deployProxyContract(
wallet,
require('../../build/Proxy'),
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/unit_tests/operations_test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { expect } = require('chai');
const { provider, wallet, deployTestContract, getCallRevertReason } = require('./common');
const { deployTestContract } = require('./common');

describe('Operations unit tests', function() {
describe('Operations unit tests', function () {
this.timeout(50000);

let testContract;
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/unit_tests/ownable_test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const { expect } = require('chai');
const { deployContract } = require('ethereum-waffle');
const { wallet1, wallet2, deployTestContract, getCallRevertReason } = require('./common');
const { wallet1, wallet2, getCallRevertReason } = require('./common');

describe('Ownable unit tests', function() {
describe('Ownable unit tests', function () {
this.timeout(50000);

let testContract;
Expand Down
2 changes: 1 addition & 1 deletion contracts/test/unit_tests/proxy_test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const { expect } = require('chai');
const { deployContract } = require('ethereum-waffle');
const { wallet, wallet1, wallet2, deployTestContract, getCallRevertReason } = require('./common');
const { wallet, wallet2, deployTestContract, getCallRevertReason } = require('./common');

import { Contract, constants } from 'ethers';

Expand Down
8 changes: 5 additions & 3 deletions contracts/test/unit_tests/specific_tokens_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@ import { ETHProxy } from 'zksync';
import { Address, TokenAddress } from 'zksync/build/types';
import { Deployer, readContractCode, readTestContracts } from '../../src.ts/deploy';

const { simpleEncode } = require('ethereumjs-abi');
const { expect } = require('chai');
const { deployContract } = require('ethereum-waffle');
const { wallet, exitWallet, deployTestContract, getCallRevertReason, IERC20_INTERFACE } = require('./common');
import * as zksync from 'zksync';
const { wallet, exitWallet, getCallRevertReason, IERC20_INTERFACE, DEFAULT_REVERT_REASON } = require('./common');

async function onchainTokenBalanceOfContract(
ethWallet: ethers.Wallet,
Expand Down Expand Up @@ -104,7 +102,9 @@ describe('zkSync process tokens which have no return value in `transfer` and `tr
async () => await zksyncContract.depositERC20(tokenContract.address, depositAmount, wallet.address)
);
const balanceAfter = await tokenContract.balanceOf(wallet.address);

expect(balanceBefore).eq(balanceAfter);
expect(revertReason).to.not.equal(DEFAULT_REVERT_REASON);
});

it('Withdraw ERC20 success', async () => {
Expand Down Expand Up @@ -144,7 +144,9 @@ describe('zkSync process tokens which have no return value in `transfer` and `tr
async () => await performWithdraw(wallet, tokenContract.address, tokenId, withdrawAmount.add(1))
);
const onchainBalAfter = await onchainBalance(wallet, tokenContract.address);

expect(onchainBalAfter).eq(onchainBalBefore);
expect(revertReason).to.not.eq(DEFAULT_REVERT_REASON);
});

it('Complete pending withdawals', async () => {
Expand Down
4 changes: 2 additions & 2 deletions contracts/test/unit_tests/upgradeGatekeeper_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { constants } from 'ethers';

const { expect } = require('chai');
const { deployContract } = require('ethereum-waffle');
const { provider, wallet, wallet1, wallet2, deployTestContract, getCallRevertReason } = require('./common');
const { provider, wallet, wallet2, deployTestContract, getCallRevertReason } = require('./common');

const { performance } = require('perf_hooks');

// some random constants for checking write and read from storage
const bytes = [133, 174, 97, 255];

import { Contract, ethers } from 'ethers';
import { Contract } from 'ethers';

const TX_OPTIONS = {
gasLimit: 900000
Expand Down
Loading

0 comments on commit 8376713

Please sign in to comment.