forked from matter-labs/zksync
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1490: Loadnext r=popzxc a=popzxc Surprise! I had some spare time recently, thus I decided to work on the important task that nobody has free hands to work on. Meet `loadnext`: a new random-driven loadtest. It: - doesn't care whether the server is alive or not. At worst, it will just consider the test failed. No panics, no mindless unwraps, yay. - does a unique set of operations for each participating account. - sends transactions, batches, and priority operations. - sends incorrect transactions as well as correct ones and compares the outcome to the expected one. - has an easy-to-extend command system that allows adding new types of actions to the flow. - has an easy-to-extend report analysis system. - already found a bug in the server code. Flaws: - API commands are not implemented. I was not sure whether it makes sense to test v0.1 API, and likely it will be better to implement these commands for API v0.2 once it's ready. - Report analysis system is in a pretty primitive state. I think that it's weird to try to understand which kind of analysis we need until we have something actually running. The system is easy to extend, so I think we will integrate the loadtest first, and then improve the report system. I didn't write the code in a while, so it's time to get revenge for all my nitpicks Resolves ZKS-260 Co-authored-by: Igor Aleksanov <[email protected]>
- Loading branch information
Showing
37 changed files
with
3,356 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
[package] | ||
name = "loadnext" | ||
version = "0.1.0" | ||
edition = "2018" | ||
authors = ["The Matter Labs Team <[email protected]>"] | ||
homepage = "https://zksync.io/" | ||
repository = "https://github.com/matter-labs/zksync" | ||
license = "Apache-2.0" | ||
keywords = ["blockchain", "zksync"] | ||
categories = ["cryptography"] | ||
publish = false # We don't want to publish our tests. | ||
|
||
[dependencies] | ||
zksync = { path = "../../../sdk/zksync-rs", version = "0.3", features = ["mint"] } | ||
zksync_types = { path = "../../lib/types", version = "1.0" } | ||
zksync_eth_signer = { path = "../../lib/eth_signer", version = "1.0" } | ||
vlog = { path = "../../lib/vlog", version = "1.0" } | ||
|
||
serde = { version = "1.0", features = ["derive"] } | ||
num = { version = "0.3.1", features = ["serde"] } | ||
tokio = { version = "0.2", features = ["full"] } | ||
futures = "0.3" | ||
anyhow = "1.0" | ||
rand = { version = "0.7", features = ["small_rng"] } | ||
envy = "0.4" | ||
hex = "0.4" | ||
static_assertions = "1.1" | ||
|
||
[dev-dependencies] | ||
zksync_test_account = { path = "../test_account", version = "1.0" } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
# Loadnext: the next generation loadtest for zkSync | ||
|
||
Loadnext is an utility for random stress-testing the zkSync server. It is capable of simulating the behavior of many | ||
independent users of zkSync network, who are sending quasi-random requests to the server. | ||
|
||
It: | ||
|
||
- doesn't care whether the server is alive or not. At worst, it will just consider the test failed. No panics, no | ||
mindless unwraps, yay. | ||
- does a unique set of operations for each participating account. | ||
- sends transactions, batches, and priority operations. | ||
- sends incorrect transactions as well as correct ones and compares the outcome to the expected one. | ||
- has an easy-to-extend command system that allows adding new types of actions to the flow. | ||
- has an easy-to-extend report analysis system. | ||
|
||
Flaws: | ||
|
||
- It does not send API requests other than required to execute transactions. | ||
- So far it has pretty primitive report system. | ||
|
||
## Launch | ||
|
||
In order to launch the test in the development scenario, you must first run server and prover (it is recommended to use | ||
dummy prover), and then launch the test itself. | ||
|
||
```sh | ||
# First terminal | ||
zk server | ||
# Second terminal | ||
zk dummy-prover | ||
# Third terminal | ||
RUST_BACKTRACE=1 RUST_LOG=info cargo run --bin loadnext | ||
``` | ||
|
||
Without any configuration supplied, the test will fallback to the dev defaults: | ||
|
||
- Use one of the "rich" accounts in the private local Ethereum chain. | ||
- Use mintable "DAI" token. | ||
- Connect to the localhost zkSync node and use localhost web3 API. | ||
|
||
**Note:** when running the loadtest in the localhost scenario, you **must** adjust the supported block chunks sizes. | ||
Edit the `etc/env/dev/chain.toml` and set `block_chunk_sizes` to `[10,32,72,156,322,654]` and `aggregated_proof_sizes` | ||
to `[1,4,8,18]`. Do not forget to re-compile configs after that. | ||
|
||
This is required because the loadtest relies on batches, which will not fit into smaller block sizes. | ||
|
||
## Configuration | ||
|
||
For cases when loadtest is launched outside of the localhost environment, configuration is provided via environment | ||
variables. | ||
|
||
The following variables are required: | ||
|
||
```sh | ||
# Address of the zkSync node. | ||
ZKSYNC_RPC_ADDR | ||
# Address of the Ethereum web3 API. | ||
WEB3_URL | ||
# Used Ethereum network (e.g. `rinkeby` or `localhost`). | ||
ETH_NETWORK | ||
# Ethereum private key of the wallet that has funds to perform a test (without `0x` prefix). | ||
MASTER_WALLET_PK | ||
# Amount of accounts to be used in test. | ||
# This option configures the "width" of the test: | ||
# how many concurrent operation flows will be executed. | ||
ACCOUNTS_AMOUNT | ||
# Amount of operations per account. | ||
# This option configures the "length" of the test: | ||
# how many individual operations each account of the test will execute. | ||
OPERATIONS_PER_ACCOUNT | ||
# Symbolic representation of the ERC-20 token to be used in test. | ||
# | ||
# Token must satisfy two criteria: | ||
# - Be supported by zkSync. | ||
# - Have `mint` operation. | ||
# | ||
# Note that we use ERC-20 token since we can't easily mint a lot of ETH on | ||
# Rinkeby or Ropsten without caring about collecting it back. | ||
MAIN_TOKEN | ||
``` | ||
|
||
Optional parameters: | ||
|
||
```sh | ||
# Optional seed to be used in the test: normally you don't need to set the seed, | ||
# but you can re-use seed from previous run to reproduce the sequence of operations locally. | ||
# Seed must be represented as a hexadecimal string. | ||
SEED | ||
``` | ||
|
||
## Infrastructure relationship | ||
|
||
This crate is meant to be independent of the existing zkSync infrastructure. It is not integrated in `zk` and does not | ||
rely on `zksync_config` crate, and is not meant to be. | ||
|
||
The reason is that this application is meant to be used in CI, where any kind of configuration pre-requisites makes the | ||
tool harder to use: | ||
|
||
- Additional tools (e.g. `zk`) must be shipped together with the application, or included into the docker container. | ||
- Configuration that lies in files is harder to use in CI, due some sensitive data being stored in GITHUB_SECRETS. |
Oops, something went wrong.