Skip to content

Commit

Permalink
Merge branch 'dev' into breaking
Browse files Browse the repository at this point in the history
  • Loading branch information
vladbochok authored Mar 16, 2021
2 parents ba5d9f7 + 1e3e060 commit 9c538a7
Show file tree
Hide file tree
Showing 70 changed files with 1,234 additions and 1,200 deletions.
18 changes: 2 additions & 16 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -1,19 +1,5 @@
# about codeowners:
# https://help.github.com/articles/about-codeowners/

# notify about changes in codeowners file
/.github/ @dvush @pozpxc

# notify about any circuit, prover and server changes
/core/circuit/ @alexander-movchan
/core @dvush @popzxc

# dev tools
/bin @dvush @popzxc
/Makefile @dvush @popzxc

# js
/infrastructure/ @dvush @popzxc

# notify dvush about contracts changes
/contracts/ @dvush @popzxc
# Changes in smart contracts
/contracts/contracts @dvush @popzxc
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "sdk/binaryen"]
path = sdk/binaryen
url = [email protected]:WebAssembly/binaryen.git
11 changes: 11 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 @@ -30,6 +30,7 @@ members = [
"core/lib/contracts",
"core/lib/api_client",
"core/lib/notifier",
"core/lib/balancer",

# Test infrastructure
"core/tests/test_account",
Expand Down
7 changes: 1 addition & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,7 @@ To learn how to use zkSync, please refer to the [zkSync SDK documentation](https

## Development Documentation

The following guides for developers are available:

- Installing development dependencies: [docs/setup-dev.md](docs/setup-dev.md).
- Launching zkSync locally: [docs/launch.md](docs/launch.md).
- Development guide: [docs/development.md](docs/development.md).
- Repository architecture overview: [docs/architecture.md](docs/architecture.md).
The repository architecture overview is available: [docs/architecture.md](docs/architecture.md).

## Projects

Expand Down
9 changes: 9 additions & 0 deletions changelog/core.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ All notable changes to the core components will be documented in this file.

- (`loadtest`): `zksync_fee` has been moved to `[main_wallet]` section from the `[network]` section.
- (`EthWatcher`): added processing of events about adding new tokens to the contract.
- A special balancer for FeeTicker was replaced with a generic balancer.
- (`eth_client`): `web3` field was made private in `ETHDirectClient`. `testkit` and `loadtest` don't use it directly
now.
- (`api_server`): Make `submit_txs_batch` send only one signature request.

### Added

Expand All @@ -19,9 +23,14 @@ All notable changes to the core components will be documented in this file.
- (`TokenHandler`): Module for automatically adding a token to the database based on the received Ethereum event
(`NewTokenEvent`).
- (`Notifier`): Module for sending notifications to third-party services.
- (`eth_client`): Added `get_tx`, `create_contract` methods to `EthereumGateway`, `get_web3_transport` method to
ETHDirectClient.
- (`api_server`): Support for accounts that don't have to pay fees (e.g. network service accounts) was added.

### Fixed

- Fix wrong block info cache behavior in the `api_server`.

## Release 2021-02-19

### Removed
Expand Down
1 change: 1 addition & 0 deletions changelog/infrastructure.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ components, the logs will have the following format:

- (`read-variable`): tool for read private and public variables from contracts.
- (`reading-tool`): tool for reading test config.
- (`explorer`): column "Can be used to pay fees" for tokens.

### Fixed

Expand Down
19 changes: 19 additions & 0 deletions changelog/js-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,29 @@ All notable changes to `zksync.js` will be documented in this file.

### Added

### Changed

### Deprecated

### Fixed

## Version 0.10.6 (16.03.2021)

### Added

- (`BatchBuilder`) Make it possible to add signed `ChangePubKey` transaction to the batch.

## Version 0.10.4 (08.03.2021)

### Added

- Method for calculation of transaction hash.
- Support for environments without WebAssembly.

### Changed

- Hardcode gas limit for `depositERC20` for each token.

### Deprecated

- `Signer.transferSignBytes` method
Expand Down
2 changes: 2 additions & 0 deletions changelog/rust-sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ All notable changes to `zksync_rs` will be documented in this file.

### Changed

- Hardcode gas limit for `depositERC20` for each token.

### Deprecated

### Fixed
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 @@ -26,6 +26,7 @@ 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_prometheus_exporter = { path = "../../lib/prometheus_exporter", version = "1.0" }
zksync_balancer = { path = "../../lib/balancer", version = "1.0" }

vlog = { path = "../../lib/vlog", version = "1.0" }

Expand Down
6 changes: 3 additions & 3 deletions core/bin/zksync_api/src/api_server/rest/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use zksync_types::H160;
use zksync_utils::panic_notify::ThreadPanicNotify;

use self::v01::api_decl::ApiV01;
use crate::{fee_ticker::TickerRequest, signature_checker::VerifyTxSignatureRequest};
use crate::{fee_ticker::TickerRequest, signature_checker::VerifySignatureRequest};

use super::tx_sender::TxSender;
use zksync_config::ZkSyncConfig;
Expand All @@ -20,7 +20,7 @@ pub mod v1;
async fn start_server(
api_v01: ApiV01,
fee_ticker: mpsc::Sender<TickerRequest>,
sign_verifier: mpsc::Sender<VerifyTxSignatureRequest>,
sign_verifier: mpsc::Sender<VerifySignatureRequest>,
bind_to: SocketAddr,
) {
HttpServer::new(move || {
Expand Down Expand Up @@ -63,7 +63,7 @@ pub(super) fn start_server_thread_detached(
contract_address: H160,
panic_notify: mpsc::Sender<bool>,
fee_ticker: mpsc::Sender<TickerRequest>,
sign_verifier: mpsc::Sender<VerifyTxSignatureRequest>,
sign_verifier: mpsc::Sender<VerifySignatureRequest>,
config: ZkSyncConfig,
) {
std::thread::Builder::new()
Expand Down
40 changes: 11 additions & 29 deletions core/bin/zksync_api/src/api_server/rest/v1/blocks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,29 @@ use actix_web::{

// Workspace uses
pub use zksync_api_client::rest::v1::{BlockInfo, TransactionInfo};
use zksync_config::ZkSyncConfig;
use zksync_crypto::{convert::FeConvert, Fr};
use zksync_storage::{chain::block::records, ConnectionPool, QueryResult};
use zksync_types::{tx::TxHash, BlockNumber};

// Local uses
use super::{Error as ApiError, JsonResult, Pagination, PaginationQuery};
use crate::{api_server::helpers::try_parse_tx_hash, utils::shared_lru_cache::AsyncLruCache};
use crate::{
api_server::helpers::try_parse_tx_hash, utils::block_details_cache::BlockDetailsCache,
};

/// Shared data between `api/v1/blocks` endpoints.
#[derive(Debug, Clone)]
struct ApiBlocksData {
pool: ConnectionPool,
/// Verified blocks cache.
verified_blocks: AsyncLruCache<BlockNumber, records::BlockDetails>,
verified_blocks: BlockDetailsCache,
}

impl ApiBlocksData {
fn new(pool: ConnectionPool, capacity: usize) -> Self {
fn new(pool: ConnectionPool, verified_blocks: BlockDetailsCache) -> Self {
Self {
pool,
verified_blocks: AsyncLruCache::new(capacity),
verified_blocks,
}
}

Expand All @@ -42,27 +43,7 @@ impl ApiBlocksData {
&self,
block_number: BlockNumber,
) -> QueryResult<Option<records::BlockDetails>> {
if let Some(block) = self.verified_blocks.get(&block_number).await {
return Ok(Some(block));
}

let blocks = self.blocks_range(Some(block_number), 1).await?;
if let Some(block) = blocks.into_iter().next() {
// Check if this is exactly the requested block.
if block.block_number != *block_number as i64 {
return Ok(None);
}

// It makes sense to store in cache only fully verified blocks.
if block.is_verified() {
self.verified_blocks
.insert(block_number, block.clone())
.await;
}
Ok(Some(block))
} else {
Ok(None)
}
self.verified_blocks.get(&self.pool, block_number).await
}

/// Returns the block range up to the given block number.
Expand Down Expand Up @@ -218,8 +199,8 @@ async fn blocks_range(
Ok(Json(range))
}

pub fn api_scope(config: &ZkSyncConfig, pool: ConnectionPool) -> Scope {
let data = ApiBlocksData::new(pool, config.api.common.caches_size);
pub fn api_scope(pool: ConnectionPool, cache: BlockDetailsCache) -> Scope {
let data = ApiBlocksData::new(pool, cache);

web::scope("blocks")
.data(data)
Expand All @@ -241,7 +222,8 @@ mod tests {
let cfg = TestServerConfig::default();
cfg.fill_database().await?;

let (client, server) = cfg.start_server(|cfg| api_scope(&cfg.config, cfg.pool.clone()));
let (client, server) =
cfg.start_server(|cfg| api_scope(cfg.pool.clone(), BlockDetailsCache::new(10)));

// Block requests part
let blocks: Vec<BlockInfo> = {
Expand Down
5 changes: 4 additions & 1 deletion core/bin/zksync_api/src/api_server/rest/v1/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,10 @@ pub(crate) fn api_scope(tx_sender: TxSender, zk_config: &ZkSyncConfig) -> Scope
tx_sender.core_api_client.clone(),
))
.service(config::api_scope(&zk_config))
.service(blocks::api_scope(&zk_config, tx_sender.pool.clone()))
.service(blocks::api_scope(
tx_sender.pool.clone(),
tx_sender.blocks.clone(),
))
.service(transactions::api_scope(tx_sender.clone()))
.service(operations::api_scope(tx_sender.pool.clone()))
.service(search::api_scope(tx_sender.pool.clone()))
Expand Down
Loading

0 comments on commit 9c538a7

Please sign in to comment.