Skip to content

Commit

Permalink
feat: Remove zksync-rs SDK (#1559)
Browse files Browse the repository at this point in the history
## What ❔

Moves `zksync-rs` SDK to `loadnext` as a module.


`zksync-rs` is deprecated and not really maintained. However, it's a
dependency for `loadnext`, and we don't have capacity to rewrite
`loadnext` to use newer SDK.
Here we simply move what was `zksync-rs` to a module within `loadnext`.

Also, it removes the `sdk` folder completely.

## Why ❔

One less public package to maintain at low cost.

## Checklist

<!-- Check your PR fulfills the following items. -->
<!-- For draft PRs check the boxes as you complete them. -->

- [ ] PR title corresponds to the body of PR (we generate changelog
entries from PRs).
- [ ] 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 `zk spellcheck`.
- [ ] Linkcheck has been run via `zk linkcheck`.
  • Loading branch information
popzxc committed Apr 3, 2024
1 parent 346a0a0 commit cc78e1d
Show file tree
Hide file tree
Showing 40 changed files with 40 additions and 1,583 deletions.
23 changes: 0 additions & 23 deletions Cargo.lock

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

2 changes: 0 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ members = [
"core/tests/loadnext",
"core/tests/vm-benchmark",
"core/tests/vm-benchmark/harness",
# SDK section
"sdk/zksync-rs",
]
resolver = "2"

Expand Down
2 changes: 0 additions & 2 deletions core/lib/l1_contract_interface/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ zksync_prover_interface.workspace = true

# Used to serialize proof data
crypto_codegen.workspace = true
# Used to calculate commitment for vk from the old L1 verifier contract (backward comatibility needs)
circuit_sequencer_api_1_3_3.workspace = true
# Used to calculate the kzg commitment and proofs
kzg.workspace = true

Expand Down
2 changes: 0 additions & 2 deletions core/lib/types/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ once_cell.workspace = true
rlp.workspace = true
serde.workspace = true
serde_json.workspace = true
serde_with = { workspace = true, features = ["base64"] }
strum = { workspace = true, features = ["derive"] }
thiserror.workspace = true
num_enum.workspace = true
Expand All @@ -40,7 +39,6 @@ blake2.workspace = true

[dev-dependencies]
tokio = { workspace = true, features = ["rt", "macros"] }
serde_with = { workspace = true, features = ["hex"] }

[build-dependencies]
zksync_protobuf_build.workspace = true
2 changes: 0 additions & 2 deletions core/lib/zksync_core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ zksync_dal.workspace = true
prover_dal.workspace = true
zksync_db_connection.workspace = true
zksync_config.workspace = true
zksync_env_config.workspace = true
zksync_protobuf_config.workspace = true
zksync_utils.workspace = true
zksync_contracts.workspace = true
zksync_system_constants.workspace = true
Expand Down
1 change: 0 additions & 1 deletion core/tests/loadnext/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ categories.workspace = true
publish = false

[dependencies]
zksync = { workspace = true, features = ["mint"] }
zksync_types.workspace = true
zksync_utils.workspace = true
zksync_eth_signer.workspace = true
Expand Down
10 changes: 5 additions & 5 deletions core/tests/loadnext/src/account/api_request_executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ use std::time::Instant;

use rand::seq::IteratorRandom;
use regex::Regex;
use zksync::{
error::{ClientError, RpcError},
types::FilterBuilder,
EthNamespaceClient,
};
use zksync_types::{api, ethabi::Contract, H256, U64};

use super::{Aborted, AccountLifespan};
Expand All @@ -16,6 +11,11 @@ use crate::{
constants::API_REQUEST_TIMEOUT,
report::{ApiActionType, ReportBuilder, ReportLabel},
rng::LoadtestRng,
sdk::{
error::{ClientError, RpcError},
types::FilterBuilder,
EthNamespaceClient,
},
};

impl AccountLifespan {
Expand Down
2 changes: 1 addition & 1 deletion core/tests/loadnext/src/account/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ use std::{

use futures::{channel::mpsc, SinkExt};
use tokio::sync::RwLock;
use zksync::{error::ClientError, operations::SyncTransactionHandle, HttpClient};
use zksync_contracts::test_contracts::LoadnextContractExecutionParams;
use zksync_types::{api::TransactionReceipt, Address, Nonce, H256, U256, U64};
use zksync_web3_decl::jsonrpsee::core::ClientError as CoreError;
Expand All @@ -18,6 +17,7 @@ use crate::{
config::{LoadtestConfig, RequestLimiters},
constants::{MAX_L1_TRANSACTIONS, POLLING_INTERVAL},
report::{Report, ReportBuilder, ReportLabel},
sdk::{error::ClientError, operations::SyncTransactionHandle, HttpClient},
utils::format_gwei,
};

Expand Down
2 changes: 1 addition & 1 deletion core/tests/loadnext/src/account/pubsub_executor.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use std::time::{Duration, Instant};

use futures::{stream, TryStreamExt};
use zksync::{error::ClientError, types::PubSubFilterBuilder};
use zksync_web3_decl::{
jsonrpsee::{
core::client::{Subscription, SubscriptionClientT},
Expand All @@ -17,6 +16,7 @@ use crate::{
config::RequestLimiters,
report::{ReportBuilder, ReportLabel},
rng::WeightedRandom,
sdk::{error::ClientError, types::PubSubFilterBuilder},
};

impl AccountLifespan {
Expand Down
18 changes: 9 additions & 9 deletions core/tests/loadnext/src/account/tx_command_executor.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,5 @@
use std::time::Instant;

use zksync::{
error::ClientError,
ethereum::PriorityOpHolder,
utils::{
get_approval_based_paymaster_input, get_approval_based_paymaster_input_for_estimation,
},
web3::ethabi,
EthNamespaceClient,
};
use zksync_eth_client::EthInterface;
use zksync_system_constants::MAX_L1_TRANSACTION_GAS_LIMIT;
use zksync_types::{
Expand All @@ -25,6 +16,15 @@ use crate::{
},
corrupted_tx::Corrupted,
report::ReportLabel,
sdk::{
error::ClientError,
ethereum::PriorityOpHolder,
utils::{
get_approval_based_paymaster_input, get_approval_based_paymaster_input_for_estimation,
},
web3::ethabi,
EthNamespaceClient,
},
utils::format_gwei,
};

Expand Down
2 changes: 1 addition & 1 deletion core/tests/loadnext/src/account_pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::{collections::VecDeque, convert::TryFrom, str::FromStr, sync::Arc, time
use once_cell::sync::OnceCell;
use rand::Rng;
use tokio::time::timeout;
use zksync::{signer::Signer, HttpClient, HttpClientBuilder, Wallet, ZksNamespaceClient};
use zksync_eth_signer::PrivateKeySigner;
use zksync_types::{tx::primitives::PackedEthSignature, Address, L2ChainId, H256};

Expand All @@ -12,6 +11,7 @@ use crate::{
corrupted_tx::CorruptedSigner,
fs_utils::{loadnext_contract, TestContract},
rng::{LoadtestRng, Random},
sdk::{signer::Signer, HttpClient, HttpClientBuilder, Wallet, ZksNamespaceClient},
};

/// An alias to [`zksync::Wallet`] with HTTP client. Wrapped in `Arc` since
Expand Down
2 changes: 1 addition & 1 deletion core/tests/loadnext/src/command/api.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use num::Integer;
use rand::RngCore;
use zksync::EthNamespaceClient;
use zksync_types::api;

use crate::{
account_pool::SyncWallet,
all::AllWeighted,
rng::{LoadtestRng, WeightedRandom},
sdk::EthNamespaceClient,
};

/// Helper enum for generating random block number.
Expand Down
3 changes: 1 addition & 2 deletions core/tests/loadnext/src/corrupted_tx.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
use async_trait::async_trait;
use zksync::signer::Signer;
use zksync_eth_signer::{
error::SignerError, raw_ethereum_tx::TransactionParameters, EthereumSigner,
};
use zksync_types::{
fee::Fee, l2::L2Tx, Address, EIP712TypedStructure, Eip712Domain, PackedEthSignature,
};

use crate::command::IncorrectnessModifier;
use crate::{command::IncorrectnessModifier, sdk::signer::Signer};

/// Trait that exists solely to extend the signed zkSync transaction interface, providing the ability
/// to modify transaction in a way that will make it invalid.
Expand Down
16 changes: 8 additions & 8 deletions core/tests/loadnext/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@ use std::sync::Arc;

use anyhow::anyhow;
use futures::{channel::mpsc, future, SinkExt};
use zksync::{
ethereum::{PriorityOpHolder, DEFAULT_PRIORITY_FEE},
utils::{
get_approval_based_paymaster_input, get_approval_based_paymaster_input_for_estimation,
},
web3::types::TransactionReceipt,
EthNamespaceClient, EthereumProvider, ZksNamespaceClient,
};
use zksync_eth_client::{BoundEthInterface, EthInterface, Options};
use zksync_eth_signer::PrivateKeySigner;
use zksync_system_constants::MAX_L1_TRANSACTION_GAS_LIMIT;
Expand All @@ -25,6 +17,14 @@ use crate::{
constants::*,
report::ReportBuilder,
report_collector::{LoadtestResult, ReportCollector},
sdk::{
ethereum::{PriorityOpHolder, DEFAULT_PRIORITY_FEE},
utils::{
get_approval_based_paymaster_input, get_approval_based_paymaster_input_for_estimation,
},
web3::types::TransactionReceipt,
EthNamespaceClient, EthereumProvider, ZksNamespaceClient,
},
utils::format_eth,
};

Expand Down
1 change: 1 addition & 0 deletions core/tests/loadnext/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ pub mod fs_utils;
pub mod report;
pub mod report_collector;
pub mod rng;
pub(crate) mod sdk;
pub mod utils;
3 changes: 1 addition & 2 deletions core/tests/loadnext/src/rng.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
use std::convert::TryInto;

use rand::{rngs::SmallRng, seq::SliceRandom, thread_rng, RngCore, SeedableRng};
use zksync::web3::signing::keccak256;
use zksync_types::H256;

use crate::all::AllWeighted;
use crate::{all::AllWeighted, sdk::web3::signing::keccak256};

// SmallRng seed type is [u8; 32].
const SEED_SIZE: usize = 32;
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use zksync_types::{
};
use zksync_web3_decl::namespaces::{EthNamespaceClient, ZksNamespaceClient};

use crate::{
use crate::sdk::{
error::ClientError,
operations::SyncTransactionHandle,
utils::{is_token_eth, load_contract},
Expand Down Expand Up @@ -309,7 +309,6 @@ impl<S: EthereumSigner> EthereumProvider<S> {
Ok(transaction_hash)
}

#[cfg(feature = "mint")]
pub async fn mint_erc20(
&self,
token_address: Address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub use zksync_web3_decl::{
types,
};

pub use crate::{ethereum::EthereumProvider, wallet::Wallet};
pub use crate::sdk::{ethereum::EthereumProvider, wallet::Wallet};

pub mod error;
pub mod ethereum;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use zksync_types::{
};
use zksync_utils::bytecode::hash_bytecode;

use crate::{
use crate::sdk::{
error::ClientError, operations::SyncTransactionHandle, wallet::Wallet, zksync_types::fee::Fee,
EthNamespaceClient, ZksNamespaceClient,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use zksync_types::{
fee::Fee, l2::L2Tx, transaction_request::PaymasterParams, Address, Nonce, U256,
};

use crate::{
use crate::sdk::{
error::ClientError, operations::SyncTransactionHandle, wallet::Wallet, EthNamespaceClient,
ZksNamespaceClient,
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ use std::time::{Duration, Instant};

use zksync_types::{
api::{BlockNumber, TransactionReceipt},
l2::L2Tx,
Bytes, L2ChainId, H256,
H256,
};

pub use self::{
Expand All @@ -14,21 +13,13 @@ pub use self::{
transfer::{create_transfer_calldata, TransferBuilder},
withdraw::WithdrawBuilder,
};
use crate::{error::ClientError, EthNamespaceClient};
use crate::sdk::{error::ClientError, EthNamespaceClient};

mod deploy_contract;
mod execute_contract;
mod transfer;
mod withdraw;

/// Encodes transaction into a bytes sequence in accordance
/// with the zkSync L2 protocol contract.
///
/// Used for estimating fees and submitting transactions.
pub fn encode_transaction(tx: &L2Tx, chain_id: L2ChainId) -> Result<Bytes, ClientError> {
Ok(tx.get_rlp_bytes(chain_id))
}

/// Handle for transaction, providing an interface to control its execution.
/// For obtained handle it's possible to set the polling interval, commit timeout
/// and verify timeout values.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use zksync_eth_signer::EthereumSigner;
use zksync_types::{fee::Fee, l2::L2Tx, Address, Nonce, L2_ETH_TOKEN_ADDRESS, U256};

use crate::{
use crate::sdk::{
error::ClientError,
ethereum::ierc20_contract,
operations::SyncTransactionHandle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use zksync_types::{
web3::ethabi, Address, Nonce, L2_ETH_TOKEN_ADDRESS, U256,
};

use crate::{
use crate::sdk::{
error::ClientError,
operations::{ExecuteContractBuilder, SyncTransactionHandle},
wallet::Wallet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use zksync_types::{
Nonce, PackedEthSignature, L2_ETH_TOKEN_ADDRESS, U256,
};

use crate::{operations::create_transfer_calldata, types::TransactionRequest};
use crate::sdk::{operations::create_transfer_calldata, types::TransactionRequest};

fn signing_failed_error(err: impl ToString) -> SignerError {
SignerError::SigningFailed(err.to_string())
Expand Down

0 comments on commit cc78e1d

Please sign in to comment.