Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into gprusak-dal-protobuf
Browse files Browse the repository at this point in the history
  • Loading branch information
pompon0 committed Dec 1, 2023
2 parents 2368bdf + e05d955 commit 98052a3
Show file tree
Hide file tree
Showing 191 changed files with 3,742 additions and 1,784 deletions.
10 changes: 8 additions & 2 deletions .githooks/pre-push
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/sh
#!/bin/bash
#
# Pre-push hook verifying that inappropriate code will not be pushed.

Expand All @@ -8,7 +8,13 @@ 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 -e "${RED}Push error!${NC}"
echo "Please format the code via 'zk fmt', cannot push unformatted code"
exit 1
fi

if ! zk db check-sqlx-data; then
echo -e "${RED}Push error!${NC}"
echo "Please update sqlx-data.json via 'zk db setup', cannot push invalid sqlx-data.json file"
exit 1
fi
1 change: 1 addition & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@
- [ ] Tests for the changes have been added / updated.
- [ ] Documentation comments have been added / updated.
- [ ] Code has been formatted via `zk fmt` and `zk lint`.
- [ ] Spellcheck has been run via `cargo spellcheck --cfg=./spellcheck/era.cfg --code 1`.
2 changes: 1 addition & 1 deletion .github/workflows/build-core-template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
COMPONENT: ${{ matrix.component }}
run: |
ci_run rustup default nightly-2023-08-21
ci_run zk docker $DOCKER_ACTION $COMPONENT -- --public
ci_run zk docker $DOCKER_ACTION $COMPONENT
- name: Show sccache stats
if: always()
run: |
Expand Down
24 changes: 24 additions & 0 deletions .github/workflows/check-spelling.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Check Spelling

on:
push:
branches:
- main
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
spellcheck:
runs-on: ubuntu-latest
steps:
- name: Install cargo-spellcheck
uses: taiki-e/install-action@v2
with:
tool: cargo-spellcheck

- uses: actions/checkout@3df4ab11eba7bda6032a0b82a6bb43b11571feac # v4

- name: Run cargo-spellcheck
run: cargo spellcheck --cfg=./spellcheck/era.cfg --code 1
2 changes: 1 addition & 1 deletion core/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@
* **prover-fri:** added picked-by column in prover fri related tables ([#2600](https://github.com/matter-labs/zksync-2-dev/issues/2600)) ([9e604ab](https://github.com/matter-labs/zksync-2-dev/commit/9e604abf3bae11b6f583f2abd39c07a85dc20f0a))
* update verification keys, protocol version 15 ([#2602](https://github.com/matter-labs/zksync-2-dev/issues/2602)) ([2fff59b](https://github.com/matter-labs/zksync-2-dev/commit/2fff59bab00849996864b68e932739135337ebd7))
* **vlog:** Rework the observability configuration subsystem ([#2608](https://github.com/matter-labs/zksync-2-dev/issues/2608)) ([377f0c5](https://github.com/matter-labs/zksync-2-dev/commit/377f0c5f734c979bc990b429dff0971466872e71))
* **vm:** Multivm tracer support ([#2601](https://github.com/matter-labs/zksync-2-dev/issues/2601)) ([4a7467b](https://github.com/matter-labs/zksync-2-dev/commit/4a7467b1b1556bfd795792dbe280bcf28c93a58f))
* **vm:** MultiVM tracer support ([#2601](https://github.com/matter-labs/zksync-2-dev/issues/2601)) ([4a7467b](https://github.com/matter-labs/zksync-2-dev/commit/4a7467b1b1556bfd795792dbe280bcf28c93a58f))

## [8.7.0](https://github.com/matter-labs/zksync-2-dev/compare/core-v8.6.0...core-v8.7.0) (2023-09-19)

Expand Down
2 changes: 1 addition & 1 deletion core/bin/block_reverter/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ enum Command {
/// L1 batch number used to rollback to.
#[arg(long)]
l1_batch_number: u32,
/// Priority fee used for rollback ethereum transaction.
/// Priority fee used for rollback Ethereum transaction.
// We operate only by priority fee because we want to use base fee from ethereum
// and send transaction as soon as possible without any resend logic
#[arg(long)]
Expand Down
2 changes: 1 addition & 1 deletion core/bin/external_node/src/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub struct OptionalENConfig {
/// Max possible size of an ABI encoded tx (in bytes).
#[serde(default = "OptionalENConfig::default_max_tx_size")]
pub max_tx_size: usize,
/// Max number of cache misses during one VM execution. If the number of cache misses exceeds this value, the api server panics.
/// Max number of cache misses during one VM execution. If the number of cache misses exceeds this value, the API server panics.
/// This is a temporary solution to mitigate API request resulting in thousands of DB queries.
pub vm_execution_cache_misses_limit: Option<usize>,
/// Inbound transaction limit used for throttling.
Expand Down
2 changes: 1 addition & 1 deletion core/lib/basic_types/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl TryFrom<U256> for AccountTreeId {
}
}

/// ChainId in the ZkSync network.
/// ChainId in the zkSync network.
#[derive(Copy, Clone, Debug, Serialize, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct L2ChainId(u64);

Expand Down
2 changes: 1 addition & 1 deletion core/lib/config/src/configs/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ pub struct Web3JsonRpcConfig {
pub estimate_gas_acceptable_overestimation: u32,
/// Max possible size of an ABI encoded tx (in bytes).
pub max_tx_size: usize,
/// Max number of cache misses during one VM execution. If the number of cache misses exceeds this value, the api server panics.
/// Max number of cache misses during one VM execution. If the number of cache misses exceeds this value, the API server panics.
/// This is a temporary solution to mitigate API request resulting in thousands of DB queries.
pub vm_execution_cache_misses_limit: Option<usize>,
/// Max number of VM instances to be concurrently spawned by the API server.
Expand Down
2 changes: 1 addition & 1 deletion core/lib/config/src/configs/chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ pub struct StateKeeperConfig {
pub close_block_at_geometry_percentage: f64,
/// Denotes the percentage of L1 params used in L2 block that triggers L2 block seal.
pub close_block_at_eth_params_percentage: f64,
/// Denotes the percentage of L1 gas used in l2 block that triggers L2 block seal.
/// Denotes the percentage of L1 gas used in L2 block that triggers L2 block seal.
pub close_block_at_gas_percentage: f64,

pub fee_account_addr: Address,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/constants/src/crypto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub const MAX_NEW_FACTORY_DEPS: usize = 32;
pub const PAD_MSG_BEFORE_HASH_BITS_LEN: usize = 736;

/// The size of the bootloader memory in bytes which is used by the protocol.
/// While the maximal possible size is a lot higher, we restric ourselves to a certain limit to reduce
/// While the maximal possible size is a lot higher, we restrict ourselves to a certain limit to reduce
/// the requirements on RAM.
pub const USED_BOOTLOADER_MEMORY_BYTES: usize = 1 << 24;
pub const USED_BOOTLOADER_MEMORY_WORDS: usize = USED_BOOTLOADER_MEMORY_BYTES / 32;
2 changes: 1 addition & 1 deletion core/lib/constants/src/ethereum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub const GUARANTEED_PUBDATA_PER_L1_BATCH: u64 = 4000;

/// The maximum number of pubdata per L1 batch. This limit is due to the fact that the Ethereum
/// nodes do not accept transactions that have more than 128kb of pubdata.
/// The 18kb margin is left in case of any inpreciseness of the pubdata calculation.
/// The 18kb margin is left in case of any impreciseness of the pubdata calculation.
pub const MAX_PUBDATA_PER_L1_BATCH: u64 = 110000;

// TODO: import from zkevm_opcode_defs once VM1.3 is supported
Expand Down
6 changes: 3 additions & 3 deletions core/lib/contracts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ pub struct SystemContractsRepo {
}

impl SystemContractsRepo {
/// Returns the default system contracts repo with directory based on the ZKSYNC_HOME environment variable.
/// Returns the default system contracts repository with directory based on the ZKSYNC_HOME environment variable.
pub fn from_env() -> Self {
let zksync_home = std::env::var("ZKSYNC_HOME").unwrap_or_else(|_| ".".into());
let zksync_home = PathBuf::from(zksync_home);
Expand Down Expand Up @@ -336,7 +336,7 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

/// BaseSystemContracts with playground bootloader - used for handling 'eth_calls'.
/// BaseSystemContracts with playground bootloader - used for handling eth_calls.
pub fn playground() -> Self {
let bootloader_bytecode = read_playground_batch_bootloader_bytecode();
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
Expand Down Expand Up @@ -364,7 +364,7 @@ impl BaseSystemContracts {
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
}

/// BaseSystemContracts with playground bootloader - used for handling 'eth_calls'.
/// BaseSystemContracts with playground bootloader - used for handling eth_calls.
pub fn estimate_gas() -> Self {
let bootloader_bytecode = read_bootloader_code("fee_estimate");
BaseSystemContracts::load_with_bootloader(bootloader_bytecode)
Expand Down
30 changes: 15 additions & 15 deletions core/lib/dal/sqlx-data.json
Original file line number Diff line number Diff line change
Expand Up @@ -7470,21 +7470,6 @@
},
"query": "SELECT number, timestamp, is_finished, l1_tx_count, l2_tx_count, fee_account_address, bloom, priority_ops_onchain_data, hash, parent_hash, commitment, compressed_write_logs, compressed_contracts, eth_prove_tx_id, eth_commit_tx_id, eth_execute_tx_id, merkle_root_hash, l2_to_l1_logs, l2_to_l1_messages, used_contract_hashes, compressed_initial_writes, compressed_repeated_writes, l2_l1_compressed_messages, l2_l1_merkle_root, l1_gas_price, l2_fair_gas_price, rollup_last_leaf_index, zkporter_is_available, bootloader_code_hash, default_aa_code_hash, base_fee_per_gas, aux_data_hash, pass_through_data_hash, meta_parameters_hash, protocol_version, compressed_state_diffs, system_logs, events_queue_commitment, bootloader_initial_content_commitment FROM l1_batches LEFT JOIN commitments ON commitments.l1_batch_number = l1_batches.number WHERE eth_prove_tx_id IS NOT NULL AND eth_execute_tx_id IS NULL ORDER BY number LIMIT $1"
},
"8ff9d76b4791af1177231661847b6c8879ad625fd11c15de51a16c81d8712129": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Int8",
"Bytea",
"Text",
"Int4"
]
}
},
"query": "INSERT INTO witness_inputs(l1_batch_number, merkle_tree_paths, merkel_tree_paths_blob_url, status, protocol_version, created_at, updated_at) VALUES ($1, $2, $3, 'waiting_for_artifacts', $4, now(), now()) ON CONFLICT (l1_batch_number) DO NOTHING"
},
"9051cc1a715e152afdd0c19739c76666b1a9b134e17601ef9fdf3dec5d2fc561": {
"describe": {
"columns": [
Expand Down Expand Up @@ -11182,6 +11167,21 @@
},
"query": "UPDATE l1_batches SET predicted_commit_gas_cost = $2, updated_at = now() WHERE number = $1"
},
"ec35fc5128cf59d19e6d65ed6d84fcc50fedce921405c4ce700dd2e08c990642": {
"describe": {
"columns": [],
"nullable": [],
"parameters": {
"Left": [
"Int8",
"Bytea",
"Text",
"Int4"
]
}
},
"query": "INSERT INTO witness_inputs(l1_batch_number, merkle_tree_paths, merkel_tree_paths_blob_url, status, protocol_version, created_at, updated_at) VALUES ($1, $2, $3, 'queued', $4, now(), now()) ON CONFLICT (l1_batch_number) DO NOTHING"
},
"ed50c609371b4588964e29f8757c41973706710090a80eb025ec263ce3d019b4": {
"describe": {
"columns": [],
Expand Down
8 changes: 4 additions & 4 deletions core/lib/dal/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,13 +72,13 @@ impl<'a> ConnectionPoolBuilder<'a> {
}
}

/// Constructucts a new temporary database (with a randomized name)
/// Constructs a new temporary database (with a randomized name)
/// by cloning the database template pointed by TEST_DATABASE_URL env var.
/// The template is expected to have all migrations from dal/migrations applied.
/// For efficiency, the postgres container of TEST_DATABASE_URL should be
/// For efficiency, the Postgres container of TEST_DATABASE_URL should be
/// configured with option "fsync=off" - it disables waiting for disk synchronization
/// whenever you write to the DBs, therefore making it as fast as an inmem postgres instance.
/// The database is not cleaned up automatically, but rather the whole postgres
/// whenever you write to the DBs, therefore making it as fast as an in-memory Postgres instance.
/// The database is not cleaned up automatically, but rather the whole Postgres
/// container is recreated whenever you call "zk test rust".
pub(super) async fn create_test_db() -> anyhow::Result<url::Url> {
use rand::Rng as _;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/contract_verification_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl ContractVerificationDal<'_, '_> {
/// Returns the next verification request for processing.
/// Considering the situation where processing of some request
/// can be interrupted (panic, pod restart, etc..),
/// `processing_timeout` parameter is added to avoid stucking of requests.
/// `processing_timeout` parameter is added to avoid stuck requests.
pub async fn get_next_queued_verification_request(
&mut self,
processing_timeout: Duration,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ mod tests;

/// Storage processor is the main storage interaction point.
/// It holds down the connection (either direct or pooled) to the database
/// and provide methods to obtain different storage schemas.
/// and provide methods to obtain different storage schema.
#[derive(Debug)]
pub struct StorageProcessor<'a> {
conn: ConnectionHolder<'a>,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/storage_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl StorageDal<'_, '_> {
.unwrap();
}

/// Returns bytecode for a factory dep with the specified bytecode `hash`.
/// Returns bytecode for a factory dependency with the specified bytecode `hash`.
pub async fn get_factory_dep(&mut self, hash: H256) -> Option<Vec<u8>> {
sqlx::query!(
"SELECT bytecode FROM factory_deps WHERE bytecode_hash = $1",
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/transactions_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ impl TransactionsDal<'_, '_> {
}
}

/// Returns miniblocks with their transactions that state_keeper needs to reexecute on restart.
/// Returns miniblocks with their transactions that state_keeper needs to re-execute on restart.
/// These are the transactions that are included to some miniblock,
/// but not included to L1 batch. The order of the transactions is the same as it was
/// during the previous execution.
Expand Down
4 changes: 2 additions & 2 deletions core/lib/dal/src/witness_generator_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ impl WitnessGeneratorDal<'_, '_> {
/// Saves artifacts in node_aggregation_job
/// and advances it to `waiting_for_proofs` status
/// it will be advanced to `queued` by the prover when all the dependency proofs are computed.
/// If the node aggregation job was already `queued` in case of connrecunt run of same leaf aggregation job
/// If the node aggregation job was already `queued` in case of connector run of same leaf aggregation job
/// we keep the status as is to prevent data race.
pub async fn save_leaf_aggregation_artifacts(
&mut self,
Expand Down Expand Up @@ -728,7 +728,7 @@ impl WitnessGeneratorDal<'_, '_> {
{
sqlx::query!(
"INSERT INTO witness_inputs(l1_batch_number, merkle_tree_paths, merkel_tree_paths_blob_url, status, protocol_version, created_at, updated_at) \
VALUES ($1, $2, $3, 'waiting_for_artifacts', $4, now(), now()) \
VALUES ($1, $2, $3, 'queued', $4, now(), now()) \
ON CONFLICT (l1_batch_number) DO NOTHING",
block_number.0 as i64,
// TODO(SMA-1476): remove the below column once blob is migrated to GCS.
Expand Down
16 changes: 3 additions & 13 deletions core/lib/eth_client/src/clients/http/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@ use zksync_types::web3::{
Contract, Options,
},
ethabi,
helpers::CallFuture,
transports::Http,
types::{
Address, Block, BlockId, BlockNumber, Bytes, Filter, Log, Transaction, TransactionId,
TransactionReceipt, H256, U256, U64,
},
Transport, Web3,
Web3,
};

/// An "anonymous" Ethereum client that can invoke read-only methods that aren't
Expand Down Expand Up @@ -286,23 +285,14 @@ impl EthInterface for QueryClient {
Ok(logs)
}

// TODO (PLA-333): at the moment the latest version of `web3` crate doesn't have `Finalized` variant in `BlockNumber`.
// However, it's already added in github repo and probably will be included in the next released version.
// Scope of PLA-333 includes forking/using crate directly from github, after that we will be able to change
// type of `block_id` from `String` to `BlockId` and use `self.web3.eth().block(block_id)`.
async fn block(
&self,
block_id: String,
block_id: BlockId,
component: &'static str,
) -> Result<Option<Block<H256>>, Error> {
COUNTERS.call[&(Method::Block, component)].inc();
let latency = LATENCIES.direct[&Method::Block].start();
let block = CallFuture::new(
self.web3
.transport()
.execute("eth_getBlockByNumber", vec![block_id.into(), false.into()]),
)
.await?;
let block = self.web3.eth().block(block_id).await?;
latency.observe();
Ok(block)
}
Expand Down
2 changes: 1 addition & 1 deletion core/lib/eth_client/src/clients/http/signing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl<S: EthereumSigner> EthInterface for SigningClient<S> {

async fn block(
&self,
block_id: String,
block_id: BlockId,
component: &'static str,
) -> Result<Option<Block<H256>>, Error> {
self.query_client.block(block_id, component).await
Expand Down
4 changes: 2 additions & 2 deletions core/lib/eth_client/src/clients/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ impl EthInterface for MockEthereum {

async fn block(
&self,
_block_id: String,
_block_id: BlockId,
_component: &'static str,
) -> Result<Option<Block<H256>>, Error> {
unimplemented!("Not needed right now")
Expand Down Expand Up @@ -524,7 +524,7 @@ impl<T: AsRef<MockEthereum> + Send + Sync> EthInterface for T {

async fn block(
&self,
block_id: String,
block_id: BlockId,
component: &'static str,
) -> Result<Option<Block<H256>>, Error> {
self.as_ref().block(block_id, component).await
Expand Down
12 changes: 6 additions & 6 deletions core/lib/eth_client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use zksync_types::{
};

/// Common Web3 interface, as seen by the core applications.
/// Encapsulates the raw Web3 interction, providing a high-level interface.
/// Encapsulates the raw Web3 interaction, providing a high-level interface.
///
/// ## Trait contents
///
Expand All @@ -34,7 +34,7 @@ use zksync_types::{
///
/// Most of the trait methods support the `component` parameter. This parameter is used to
/// describe the caller of the method. It may be useful to find the component that makes an
/// unnecessary high amount of Web3 calls. Implementations are advices to count invocations
/// unnecessary high amount of Web3 calls. Implementations are advice to count invocations
/// per component and expose them to Prometheus.
#[async_trait]
pub trait EthInterface: Sync + Send {
Expand Down Expand Up @@ -131,15 +131,15 @@ pub trait EthInterface: Sync + Send {
/// Returns the block header for the specified block number or hash.
async fn block(
&self,
block_id: String,
block_id: BlockId,
component: &'static str,
) -> Result<Option<Block<H256>>, Error>;
}

/// An extension of `EthInterface` trait, which is used to perform queries that are bound to
/// a certain contract and account.
///
/// THe example use cases for this trait would be:
/// The example use cases for this trait would be:
/// - An operator that sends transactions and interacts with zkSync contract.
/// - A wallet implementation in the SDK that is tied to a user's account.
///
Expand All @@ -149,10 +149,10 @@ pub trait EthInterface: Sync + Send {
/// implementation that invokes `contract` / `contract_addr` / `sender_account` methods.
#[async_trait]
pub trait BoundEthInterface: EthInterface {
/// ABI of the contract that is used by the implementor.
/// ABI of the contract that is used by the implementer.
fn contract(&self) -> &ethabi::Contract;

/// Address of the contract that is used by the implementor.
/// Address of the contract that is used by the implementer.
fn contract_addr(&self) -> H160;

/// Chain ID of the L1 network the client is *configured* to connected to.
Expand Down
Loading

0 comments on commit 98052a3

Please sign in to comment.