Skip to content

Commit

Permalink
rename traits, types, fix some imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Artemka374 committed Mar 8, 2024
1 parent 2996367 commit e291ebc
Show file tree
Hide file tree
Showing 87 changed files with 331 additions and 305 deletions.
3 changes: 3 additions & 0 deletions Cargo.lock

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

6 changes: 3 additions & 3 deletions core/bin/contract-verifier/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use lazy_static::lazy_static;
use regex::Regex;
use tokio::time;
use zksync_config::ContractVerifierConfig;
use zksync_dal::{ConnectionPool, StorageProcessor};
use zksync_dal::{BasicStorageProcessor, ConnectionPool};
use zksync_env_config::FromEnv;
use zksync_queued_job_processor::{async_trait, JobProcessor};
use zksync_types::{
Expand Down Expand Up @@ -54,7 +54,7 @@ impl ContractVerifier {
}

async fn verify(
storage: &mut StorageProcessor<'_>,
storage: &mut BasicStorageProcessor<'_>,
mut request: VerificationRequest,
config: ContractVerifierConfig,
) -> Result<VerificationInfo, ContractVerifierError> {
Expand Down Expand Up @@ -429,7 +429,7 @@ impl ContractVerifier {
}

async fn process_result(
storage: &mut StorageProcessor<'_>,
storage: &mut BasicStorageProcessor<'_>,
request_id: usize,
verification_result: Result<VerificationInfo, ContractVerifierError>,
) {
Expand Down
6 changes: 3 additions & 3 deletions core/bin/snapshots_creator/src/creator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::sync::Arc;
use anyhow::Context as _;
use tokio::sync::Semaphore;
use zksync_config::SnapshotsCreatorConfig;
use zksync_dal::{ConnectionPool, StorageProcessor};
use zksync_dal::{BasicStorageProcessor, ConnectionPool};
use zksync_object_store::ObjectStore;
use zksync_types::{
snapshots::{
Expand Down Expand Up @@ -67,7 +67,7 @@ pub(crate) struct SnapshotCreator {
}

impl SnapshotCreator {
async fn connect_to_replica(&self) -> anyhow::Result<StorageProcessor<'_>> {
async fn connect_to_replica(&self) -> anyhow::Result<BasicStorageProcessor<'_>> {
self.replica_pool
.access_storage_tagged("snapshots_creator")
.await
Expand Down Expand Up @@ -192,7 +192,7 @@ impl SnapshotCreator {
config: &SnapshotsCreatorConfig,
min_chunk_count: u64,
latest_snapshot: Option<&SnapshotMetadata>,
conn: &mut StorageProcessor<'_>,
conn: &mut BasicStorageProcessor<'_>,
) -> anyhow::Result<Option<SnapshotProgress>> {
// We subtract 1 so that after restore, EN node has at least one L1 batch to fetch
let sealed_l1_batch_number = conn.blocks_dal().get_sealed_l1_batch_number().await?;
Expand Down
8 changes: 4 additions & 4 deletions core/bin/snapshots_creator/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use std::{
};

use rand::{thread_rng, Rng};
use zksync_dal::StorageProcessor;
use zksync_dal::BasicStorageProcessor;
use zksync_object_store::ObjectStore;
use zksync_types::{
block::{L1BatchHeader, MiniblockHeader},
Expand Down Expand Up @@ -132,7 +132,7 @@ struct ExpectedOutputs {
}

async fn create_miniblock(
conn: &mut StorageProcessor<'_>,
conn: &mut BasicStorageProcessor<'_>,
miniblock_number: MiniblockNumber,
block_logs: Vec<StorageLog>,
) {
Expand Down Expand Up @@ -162,7 +162,7 @@ async fn create_miniblock(
}

async fn create_l1_batch(
conn: &mut StorageProcessor<'_>,
conn: &mut BasicStorageProcessor<'_>,
l1_batch_number: L1BatchNumber,
logs_for_initial_writes: &[StorageLog],
) {
Expand All @@ -186,7 +186,7 @@ async fn create_l1_batch(

async fn prepare_postgres(
rng: &mut impl Rng,
conn: &mut StorageProcessor<'_>,
conn: &mut BasicStorageProcessor<'_>,
block_count: u32,
) -> ExpectedOutputs {
conn.protocol_versions_dal()
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/blocks_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::{
use anyhow::Context as _;
use bigdecimal::{BigDecimal, FromPrimitive, ToPrimitive};
use zksync_db_connection::{
instrument::InstrumentExt, match_query_as, processor::StorageInteraction,
instrument::InstrumentExt, match_query_as, processor::StorageProcessor,
};
use zksync_types::{
aggregated_operations::AggregatedActionType,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/blocks_web3_dal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use zksync_db_connection::{
instrument::InstrumentExt, match_query_as, processor::StorageInteraction,
instrument::InstrumentExt, match_query_as, processor::StorageProcessor,
};
use zksync_system_constants::EMPTY_UNCLES_HASH;
use zksync_types::{
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/consensus_dal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Context as _;
use zksync_consensus_roles::validator;
use zksync_consensus_storage::ReplicaState;
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::MiniblockNumber;

pub use crate::models::consensus::Payload;
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 @@ -5,7 +5,7 @@ use std::{

use anyhow::Context as _;
use sqlx::postgres::types::PgInterval;
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::{
contract_verification_api::{
DeployContractCalldata, VerificationIncomingRequest, VerificationInfo, VerificationRequest,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/eth_sender_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::{convert::TryFrom, str::FromStr};

use anyhow::Context as _;
use sqlx::types::chrono::{DateTime, Utc};
use zksync_db_connection::{match_query_as, processor::StorageInteraction};
use zksync_db_connection::{match_query_as, processor::StorageProcessor};
use zksync_types::{
aggregated_operations::AggregatedActionType,
eth_sender::{EthTx, EthTxBlobSidecar, TxHistory, TxHistoryToSend},
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/events_dal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::HashMap, fmt};

use sqlx::types::chrono::Utc;
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_system_constants::L1_MESSENGER_ADDRESS;
use zksync_types::{
api,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/events_web3_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use sqlx::{
query::{Query, QueryAs},
Postgres, Row,
};
use zksync_db_connection::instrument::InstrumentExt;
use zksync_db_connection::{instrument::InstrumentExt, processor::StorageProcessor};
use zksync_types::{
api::{GetLogsFilter, Log},
Address, MiniblockNumber, H256,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/factory_deps_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::collections::{HashMap, HashSet};

use anyhow::Context as _;
use zksync_contracts::{BaseSystemContracts, SystemContractCode};
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::{MiniblockNumber, H256, U256};
use zksync_utils::{bytes_to_be_words, bytes_to_chunks};

Expand Down
11 changes: 4 additions & 7 deletions core/lib/dal/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
//! Data access layer (DAL) for zkSync Era.
use std::time::Instant;

use sqlx::{pool::PoolConnection, PgConnection, Postgres};
pub use sqlx::{types::BigDecimal, Error as SqlxError};
pub use zksync_db_connection::connection::ConnectionPool;
use zksync_db_connection::processor::{
StorageInteraction, StorageKind, StorageProcessor, StorageProcessorTags, TracedConnections,
BasicStorageProcessor, StorageKind, StorageProcessor, StorageProcessorTags, TracedConnections,
};

use crate::{
Expand All @@ -33,7 +31,6 @@ pub mod eth_sender_dal;
pub mod events_dal;
pub mod events_web3_dal;
pub mod factory_deps_dal;
mod metrics;
mod models;
pub mod proof_generation_dal;
pub mod protocol_versions_dal;
Expand All @@ -58,13 +55,13 @@ mod tests;

pub struct Server(());

pub struct ServerProcessor<'a>(StorageProcessor<'a>);
pub struct ServerProcessor<'a>(BasicStorageProcessor<'a>);

impl StorageKind for Server {
type Processor<'a> = ServerProcessor<'a>;
}

impl<'a> StorageInteraction for ServerProcessor<'a> {
impl<'a> StorageProcessor for ServerProcessor<'a> {
async fn start_transaction(&mut self) -> sqlx::Result<ServerProcessor<'_>> {
self.0.start_transaction()
}
Expand All @@ -83,7 +80,7 @@ impl<'a> StorageInteraction for ServerProcessor<'a> {
tags: Option<StorageProcessorTags>,
traced_connections: Option<&'a TracedConnections>,
) -> Self {
Self(StorageProcessor::from_pool(
Self(BasicStorageProcessor::from_pool(
connection,
tags,
traced_connections,
Expand Down
52 changes: 0 additions & 52 deletions core/lib/dal/src/metrics.rs

This file was deleted.

2 changes: 1 addition & 1 deletion core/lib/dal/src/proof_generation_dal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

use strum::{Display, EnumString};
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::L1BatchNumber;

use crate::{time_utils::pg_interval_from_duration, ServerProcessor, SqlxError};
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/protocol_versions_dal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::convert::TryInto;

use anyhow::Context as _;
use zksync_contracts::{BaseSystemContracts, BaseSystemContractsHashes};
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::{
protocol_version::{L1VerifierConfig, ProtocolUpgradeTx, ProtocolVersion, VerifierParams},
Address, ProtocolVersionId, H256,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/protocol_versions_web3_dal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::api::ProtocolVersion;

use crate::{models::storage_protocol_version::StorageProtocolVersion, ServerProcessor};
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/snapshot_recovery_dal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::{
snapshots::SnapshotRecoveryStatus, L1BatchNumber, MiniblockNumber, ProtocolVersionId, H256,
};
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/snapshots_dal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use zksync_db_connection::{instrument::InstrumentExt, processor::StorageInteraction};
use zksync_db_connection::{instrument::InstrumentExt, processor::StorageProcessor};
use zksync_types::{
snapshots::{AllSnapshots, SnapshotMetadata},
L1BatchNumber,
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
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use itertools::Itertools;
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::{StorageKey, StorageLog, StorageValue, H256};

use crate::ServerProcessor;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/storage_logs_dal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::{collections::HashMap, ops, time::Instant};

use sqlx::{types::chrono::Utc, Row};
use zksync_db_connection::{instrument::InstrumentExt, processor::StorageInteraction};
use zksync_db_connection::{instrument::InstrumentExt, processor::StorageProcessor};
use zksync_types::{
get_code_key, snapshots::SnapshotStorageLog, AccountTreeId, Address, L1BatchNumber,
MiniblockNumber, StorageKey, StorageLog, FAILED_CONTRACT_DEPLOYMENT_BYTECODE_HASH, H160, H256,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/storage_logs_dedup_dal.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashSet;

use sqlx::types::chrono::Utc;
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::{
snapshots::SnapshotStorageLog, zk_evm_types::LogQuery, AccountTreeId, Address, L1BatchNumber,
StorageKey, H256,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/storage_web3_dal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{collections::HashMap, ops};

use zksync_db_connection::{instrument::InstrumentExt, processor::StorageInteraction};
use zksync_db_connection::{instrument::InstrumentExt, processor::StorageProcessor};
use zksync_types::{
get_code_key, get_nonce_key,
utils::{decompose_full_nonce, storage_key_for_standard_token_balance},
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/tokens_dal.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use sqlx::types::chrono::Utc;
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::{tokens::TokenInfo, Address, MiniblockNumber};

use crate::ServerProcessor;
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/tokens_web3_dal.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use zksync_db_connection::processor::StorageInteraction;
use zksync_db_connection::processor::StorageProcessor;
use zksync_types::{
tokens::{TokenInfo, TokenMetadata},
Address, MiniblockNumber,
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 @@ -4,7 +4,7 @@ use anyhow::Context as _;
use bigdecimal::BigDecimal;
use itertools::Itertools;
use sqlx::{error, types::chrono::NaiveDateTime};
use zksync_db_connection::{instrument::InstrumentExt, processor::StorageInteraction};
use zksync_db_connection::{instrument::InstrumentExt, processor::StorageProcessor};
use zksync_types::{
block::MiniblockExecutionData,
fee::TransactionExecutionMetrics,
Expand Down
2 changes: 1 addition & 1 deletion core/lib/dal/src/transactions_web3_dal.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use sqlx::types::chrono::NaiveDateTime;
use zksync_db_connection::{
instrument::InstrumentExt, match_query_as, processor::StorageInteraction,
instrument::InstrumentExt, match_query_as, processor::StorageProcessor,
};
use zksync_types::{
api, api::TransactionReceipt, Address, L2ChainId, MiniblockNumber, Transaction,
Expand Down
3 changes: 3 additions & 0 deletions core/lib/db_connection/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ categories = ["cryptography"]

[dependencies]
zksync_health_check = { path = "../health_check" }
zksync_types = { path = "../types" }

serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
sqlx = { version = "0.7.3", default-features = false, features = [
"runtime-tokio",
"tls-native-tls",
Expand Down
Loading

0 comments on commit e291ebc

Please sign in to comment.