Skip to content

Commit

Permalink
Remove old block revert
Browse files Browse the repository at this point in the history
Signed-off-by: deniallugo <[email protected]>
  • Loading branch information
Deniallugo committed Mar 16, 2022
1 parent dd7db44 commit fa2fd37
Show file tree
Hide file tree
Showing 18 changed files with 148 additions and 332 deletions.
30 changes: 30 additions & 0 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ members = [
# Test infrastructure
"core/tests/flamegraph_target",
"core/tests/test_account",
# "core/tests/testkit",
"core/tests/testkit",
"core/tests/loadnext",

# SDK section
Expand Down
3 changes: 2 additions & 1 deletion core/bin/zksync_api/src/api_server/rpc_server/error.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
// External uses
use jsonrpc_core::ErrorCode;
use zksync_types::tx::error::TxAddError;
// Workspace uses
// Local uses
use crate::{api_server::tx_sender::SubmitError, tx_error::TxAddError};
use crate::api_server::tx_sender::SubmitError;

#[derive(Debug, Clone, Copy)]
pub enum RpcErrorCodes {
Expand Down
3 changes: 2 additions & 1 deletion core/bin/zksync_api/src/api_server/tx_sender.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,12 @@ use crate::{
BatchRequest, OrderRequest, RequestData, Toggle2FARequest, TxRequest, VerifiedTx,
VerifySignatureRequest,
},
tx_error::{Toggle2FAError, TxAddError},
tx_error::Toggle2FAError,
utils::{block_details_cache::BlockDetailsCache, token_db_cache::TokenDBCache},
};
use zksync_config::configs::api::CommonApiConfig;
use zksync_mempool::MempoolTransactionRequest;
use zksync_types::tx::error::TxAddError;

use super::rpc_server::types::RequestMetadata;
use crate::fee_ticker::{FeeTicker, PriceError};
Expand Down
1 change: 0 additions & 1 deletion core/bin/zksync_api/src/bin/dev-liquidity-token-watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ async fn handle_graphql(
params: web::Json<GrqaphqlQuery>,
volume_storage: web::Data<VolumeStorage>,
) -> Result<HttpResponse> {
// TODO https://linear.app/matterlabs/issue/ZKS-413/support-full-version-of-graphql-for-tokenvalidator
let query_parser = Regex::new(r#"\{token\(id:\s"(?P<address>.*?)"\).*"#).expect("Right regexp");
let caps = query_parser.captures(&params.query).unwrap();
let address = &caps["address"].to_ascii_lowercase();
Expand Down
1 change: 0 additions & 1 deletion core/bin/zksync_api/src/fee_ticker/validator/watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl UniswapTokenWatcher {
}
async fn get_market_volume(&mut self, address: Address) -> anyhow::Result<BigDecimal> {
// Uniswap has graphql API, using full graphql client for one query is overkill for current task
// TODO https://linear.app/matterlabs/issue/ZKS-413/support-full-version-of-graphql-for-tokenvalidator
let start = Instant::now();

let query = format!("{{token(id: \"{:#x}\"){{untrackedVolumeUSD}}}}", address);
Expand Down
3 changes: 2 additions & 1 deletion core/bin/zksync_api/src/signature_checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,13 @@ use tokio::task::JoinHandle;

// Workspace uses
use zksync_eth_client::EthereumGateway;
use zksync_types::tx::error::TxAddError;
use zksync_types::{
tx::{EthBatchSignData, EthSignData, TxEthSignature},
Address, Order, SignedZkSyncTx, Token, ZkSyncTx,
};
// Local uses
use crate::{eth_checker::EthereumChecker, tx_error::TxAddError};
use crate::eth_checker::EthereumChecker;
use zksync_types::tx::TransactionError;

/// `TxVariant` is used to form a verify request. It is possible to wrap
Expand Down
69 changes: 0 additions & 69 deletions core/bin/zksync_api/src/tx_error.rs
Original file line number Diff line number Diff line change
@@ -1,74 +1,5 @@
use serde::{Deserialize, Serialize};
use std::str::FromStr;
use thiserror::Error;
use zksync_types::tx;

#[derive(Debug, Clone, Copy, Serialize, Deserialize, Error)]
pub enum TxAddError {
#[error("Tx nonce is too low.")]
NonceMismatch,

#[error("Tx is incorrect: {0}")]
IncorrectTx(#[from] tx::TransactionError),

#[error("Transaction fee is too low")]
TxFeeTooLow,

#[error("Transactions batch summary fee is too low")]
TxBatchFeeTooLow,

#[error("EIP1271 signature could not be verified")]
EIP1271SignatureVerificationFail,

#[error("MissingEthSignature")]
MissingEthSignature,

#[error("Eth signature is incorrect")]
IncorrectEthSignature,

#[error("Change pubkey tx is not authorized onchain")]
ChangePkNotAuthorized,

#[error("Internal error")]
Other,

#[error("Database unavailable")]
DbError,

#[error("Transaction batch is empty")]
EmptyBatch,

#[error("Batch will not fit in any of supported block sizes")]
BatchTooBig,

#[error("The number of withdrawals in the batch is too big")]
BatchWithdrawalsOverload,

#[error("Too many Ethereum signatures provided")]
EthSignaturesLimitExceeded,
}

impl From<zksync_mempool::TxAddError> for TxAddError {
fn from(error: zksync_mempool::TxAddError) -> Self {
// TODO
Self::NonceMismatch
// match error {
// zksync_mempool::TxAddError::NonceMismatch => Self::NonceMismatch,
// zksync_mempool::TxAddError::IncorrectTx => Self::IncorrectTx()
// zksync_mempool::TxAddError::TxFeeTooLow => {}
// zksync_mempool::TxAddError::TxBatchFeeTooLow => {}
// zksync_mempool::TxAddError::EIP1271SignatureVerificationFail => {}
// zksync_mempool::TxAddError::MissingEthSignature => {}
// zksync_mempool::TxAddError::IncorrectEthSignature => {}
// zksync_mempool::TxAddError::ChangePkNotAuthorized => {}
// zksync_mempool::TxAddError::Other => {}
// zksync_mempool::TxAddError::DbError => {}
// zksync_mempool::TxAddError::EmptyBatch => {}
// zksync_mempool::TxAddError::BatchTooBig => {}
// zksync_mempool::TxAddError::BatchWithdrawalsOverload => {}
// }
}
}

#[derive(Debug, Clone, Copy, Serialize, Deserialize, Error)]
pub enum Toggle2FAError {
Expand Down
Loading

0 comments on commit fa2fd37

Please sign in to comment.