Skip to content

Commit

Permalink
Fix after merge
Browse files Browse the repository at this point in the history
Signed-off-by: deniallugo <[email protected]>
  • Loading branch information
Deniallugo committed Jun 28, 2021
1 parent bf1766f commit 5af42fe
Show file tree
Hide file tree
Showing 186 changed files with 11,962 additions and 8,431 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@ jobs:
ci_run zk db basic-setup
ci_run zk run yarn
- name: liquidity-token
run: docker-compose -f docker-compose-runner.yml restart dev-liquidity-token-watcher
- name: restart dev-liquidity-token-watcher and dev-ticker
run: docker-compose -f docker-compose-runner.yml restart dev-liquidity-token-watcher dev-ticker

- name: contracts-unit-tests
run: ci_run zk test contracts
Expand Down Expand Up @@ -102,8 +102,8 @@ jobs:
ci_run zk dummy-prover enable --no-redeploy
ci_run zk init
- name: liquidity-token
run: docker-compose -f docker-compose-runner.yml restart dev-liquidity-token-watcher
- name: restart dev-liquidity-token-watcher and dev-ticker
run: docker-compose -f docker-compose-runner.yml restart dev-liquidity-token-watcher dev-ticker

- name: run-services
run: |
Expand All @@ -116,7 +116,9 @@ jobs:
run: ci_run zk test i server

- name: integration-api
run: ci_run zk test i api
run: |
ci_run zk test i api
ci_run zk test i api-docs
- name: integration-zcli
run: ci_run zk test i zcli
Expand Down
23 changes: 23 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ members = [
"core/lib/contracts",
"core/lib/api_client",
"core/lib/notifier",
"core/lib/api_types",
"core/lib/balancer",

# Test infrastructure
Expand Down
9 changes: 9 additions & 0 deletions bin/api_docs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash

if [ -z "$1" ]; then
cd $ZKSYNC_HOME
yarn && yarn api-docs build
else
# can't start this with yarn since it has quirks with `--` as an argument
node -- $ZKSYNC_HOME/infrastructure/api-docs/build/index.js "$@"
fi
8 changes: 8 additions & 0 deletions changelog/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ All notable changes to the core components will be documented in this file.

### Removed

- (`api_server`): REST API v1.0.

### Changed

- (`loadtest`): `zksync_fee` has been moved to `[main_wallet]` section from the `[network]` section.
Expand All @@ -16,6 +18,7 @@ All notable changes to the core components will be documented in this file.
- (`api_server`): Make `submit_txs_batch` send only one signature request.
- Fast withdrawals now can trigger aggregated block execution.
- Replaced `anyhow` errors with typed errors in `lib/state`, `lib/crypto` and `lib/types`.
- (`fee-ticker`): Batch fee now includes `zkp_fee` and `gas_fee`.

### Added

Expand All @@ -30,6 +33,11 @@ All notable changes to the core components will be documented in this file.
- (`api_server`): Support for accounts that don't have to pay fees (e.g. network service accounts) was added.
- Added `BlockMetadata` structure and corresponding table to track block data that is not related to protocol.
- (`block_revert`): CLI that calls `revertBlocks` smart contract function and updates the database respectively.
- (`api_server`): Added REST API v0.2.
- (`api_client`): Client for REST API v0.2.
- (`api_types`): Crate for storing types that are used in API.
- Added hashes for batches and additional hashes for priority operations.
- Added `ForcedExit` fee type to REST API v0.2 and JSON RPC API.

### Fixed

Expand Down
3 changes: 2 additions & 1 deletion changelog/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ components, the logs will have the following format:

### Added

- (`api-docs`): tool for generating and testing API documentation. Docs are generated from a bunch of .apib files where
API endpoints and their inputs/outputs are defined.
- (`token_list_manager`): CLI for updating to new version of a previously saved list of trusted tokens.

- (`loadnext`): Crate, a new implementation of the loadtest for zkSync.

### Fixed
Expand Down
10 changes: 10 additions & 0 deletions changelog/js-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,19 @@ All notable changes to `zksync.js` will be documented in this file.
- Methods for working with NFTs. You can read more [here](https://zksync.io/dev/nfts.html).
- Methods for working with atomic swaps/limit orders. You can read more [here](https://zksync.io/dev/swaps.html).

- `RestProvider` class, that is used for queriing REST API v0.2.
- `SyncProvider` interface: common interface for API v0.2 `RestProvider` and JSON RPC `Provider`.
- Types for REST API v0.2.

### Changed

- `zksync-crypto` to support atomic swaps/limit orders functionality.
- Changed type of `provider` field in `Wallet` class from `Provider` to `SyncProvider`.
- `ForcedExit` fee type is used for `ForcedExit` transactions instead of `Withdraw` fee type.

### Deprecated

### Fixed

## Version 0.10.9 (13.04.2021)

Expand Down
3 changes: 2 additions & 1 deletion contracts/scripts/upgrade-testnet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ async function main() {
});
parser.addArgument('--initArgs', {
required: false,
help: 'Upgrade function parameters comma-separated, RLP serialized in hex (Governance,Verifier,ZkSync): 0xaa..aa,0xbb..bb,0xcc..c or zero by default.',
help:
'Upgrade function parameters comma-separated, RLP serialized in hex (Governance,Verifier,ZkSync): 0xaa..aa,0xbb..bb,0xcc..c or zero by default.',
defaultValue: '0x,0x,0x'
});
parser.addArgument('--cancelPreviousUpgrade', {
Expand Down
1 change: 1 addition & 0 deletions core/bin/data_restore/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ fn create_deposit(from: Address, to: Address, amount: u32) -> ExecutedOperations
deadline_block: 0,
eth_hash: H256::zero(),
eth_block: 0,
eth_block_index: None,
};
let executed_deposit_op = ExecutedPriorityOp {
priority_op: priority_operation,
Expand Down
1 change: 1 addition & 0 deletions core/bin/data_restore/src/tree_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,7 @@ impl TreeState {
deadline_block: 0,
eth_hash: H256::zero(),
eth_block: 0,
eth_block_index: None,
},
block_index,
created_at: chrono::Utc::now(),
Expand Down
1 change: 1 addition & 0 deletions core/bin/zksync_api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ zksync_contracts = { path = "../../lib/contracts", version = "1.0" }
zksync_eth_client = { path = "../../lib/eth_client", version = "1.0" }
zksync_eth_signer = { path = "../../lib/eth_signer", version = "1.0" }
zksync_api_client = { path = "../../lib/api_client", version = "0.1" }
zksync_api_types = { path = "../../lib/api_types", version = "1.0" }
zksync_prometheus_exporter = { path = "../../lib/prometheus_exporter", version = "1.0" }
zksync_balancer = { path = "../../lib/balancer", version = "1.0" }
zksync_gateway_watcher = { path = "../../lib/gateway_watcher", version = "1.0" }
Expand Down
40 changes: 21 additions & 19 deletions core/bin/zksync_api/benches/criterion/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,41 +2,43 @@ use criterion::{criterion_group, criterion_main, Criterion};
use ethabi::Address;
use reqwest::{blocking::Client, StatusCode};

use zksync_api_client::rest::v1::{IncomingTxBatchForFee, IncomingTxForFee};
use zksync_types::{TokenLike, TxFeeTypes};
use zksync_api_types::v02::fee::{
ApiTxFeeTypes, BatchFeeRequest, TxFeeRequest, TxInBatchFeeRequest,
};
use zksync_types::{TokenId, TokenLike};

fn generate_transactions(number: usize) -> IncomingTxBatchForFee {
let mut tx_types = vec![];
let mut addresses = vec![];
fn generate_transactions(number: usize) -> BatchFeeRequest {
let mut transactions = Vec::new();
for _ in 0..number {
tx_types.push(TxFeeTypes::Withdraw);
addresses.push(Address::random());
transactions.push(TxInBatchFeeRequest {
tx_type: ApiTxFeeTypes::Withdraw,
address: Address::random(),
});
}
IncomingTxBatchForFee {
tx_types,
addresses,
token_like: TokenLike::Symbol("wBTC".to_string()),
BatchFeeRequest {
transactions,
token_like: TokenLike::Id(TokenId(2)), // id of wBTC on localhost
}
}

fn get_txs_batch_fee(client: Client, url: String, transaction: IncomingTxBatchForFee) {
fn get_txs_batch_fee(client: Client, url: String, batch_fee_request: BatchFeeRequest) {
let res = client
.post(format!("{}/api/v1/transactions/fee/batch", url).as_str())
.json(&transaction)
.post(format!("{}/api/v0.2/fee/batch", url).as_str())
.json(&batch_fee_request)
.send()
.unwrap();
assert_eq!(res.status(), StatusCode::OK)
}

fn get_txs_fee(client: Client, url: String) {
let transaction = IncomingTxForFee {
tx_type: TxFeeTypes::Withdraw,
let transaction = TxFeeRequest {
tx_type: ApiTxFeeTypes::Withdraw,
address: Address::random(),
token_like: TokenLike::Symbol("wBTC".to_string()),
token_like: TokenLike::Id(TokenId(2)), // id of wBTC on localhost
};

let res = client
.post(format!("{}/api/v1/transactions/fee", url).as_str())
.post(format!("{}/api/v0.2/fee", url).as_str())
.json(&transaction)
.send()
.unwrap();
Expand All @@ -47,7 +49,7 @@ fn bench_fee(c: &mut Criterion) {
let url = std::env::var("API_REST_URL").unwrap();
let client = reqwest::blocking::Client::new();
let transaction = generate_transactions(100);
c.bench_function("get_txs_batch_fee_new_version", |b| {
c.bench_function("get_txs_batch_fee", |b| {
b.iter(|| get_txs_batch_fee(client.clone(), url.clone(), transaction.clone()))
});
c.bench_function("get_txs_fee", |b| {
Expand Down
1 change: 1 addition & 0 deletions core/bin/zksync_api/src/api_server/event_notify/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ impl NotifierState {
.account_schema()
.last_committed_state_for_account(id)
.await?
.1
}
ActionType::VERIFY => {
storage
Expand Down
13 changes: 1 addition & 12 deletions core/bin/zksync_api/src/api_server/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// External uses

// Workspace uses
use zksync_types::{tx::TxHash, H256};
use zksync_types::H256;
use zksync_utils::remove_prefix;

// Local uses
Expand All @@ -20,14 +20,3 @@ pub fn try_parse_hash(query: &str) -> Result<H256, hex::FromHexError> {

Ok(H256::from_slice(&slice))
}

pub fn try_parse_tx_hash(query: &str) -> Result<TxHash, hex::FromHexError> {
const HASH_SIZE: usize = 32; // 32 bytes

let mut slice = [0_u8; HASH_SIZE];

let tx_hex = remove_prefix(query);
hex::decode_to_slice(&tx_hex, &mut slice)?;

Ok(TxHash::from_slice(&slice).unwrap())
}
3 changes: 0 additions & 3 deletions core/bin/zksync_api/src/api_server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
//! `mod rpc_server` - JSON rpc via HTTP (for request reply functions)
//! `mod rpc_subscriptions` - JSON rpc via WebSocket (for request reply functions and subscriptions)
// Public uses
pub use rest::v1;

// External uses
use futures::channel::mpsc;
// Workspace uses
Expand Down
Loading

0 comments on commit 5af42fe

Please sign in to comment.