Skip to content

Commit

Permalink
Add DOS test that sends large transactions (solana-labs#20624)
Browse files Browse the repository at this point in the history
Problem
We need a test that stress-tests the network using large transactions, including sending multiple large transactions that reference independent sets of accounts, so they can be executed in parallel.

Summary of Changes
Adds such a test. Also adds a version of the tuner program that runs for a configurable number of iterations.
  • Loading branch information
ryleung-solana authored Oct 29, 2021
1 parent 1453fce commit 4663b86
Show file tree
Hide file tree
Showing 6 changed files with 824 additions and 0 deletions.
26 changes: 26 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ members = [
"stake-accounts",
"sys-tuner",
"tokens",
"transaction-dos",
"transaction-status",
"account-decoder",
"upload-perf",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @brief Compute budget tuner program. Spins in a loop for the specified number of iterations
* (or for UINT64_MAX iterations if 0 is specified for the number of iterations), in order to consume
* a configurable amount of the budget.
*
* Care should be taken because the compiler might optimize out the mechanism
* you are trying to tune.
*/

#include <solana_sdk.h>

#define NUM_KA 1

extern uint64_t entrypoint(const uint8_t *input) {
SolAccountInfo ka[NUM_KA];
SolParameters params = (SolParameters){.ka = ka};
if (!sol_deserialize(input, &params, SOL_ARRAY_SIZE(ka))) {
return ERROR_INVALID_ARGUMENT;
}

size_t current = 1;

uint64_t iterations = params.data[0] * 18;
iterations = iterations == 0 ? UINT64_MAX : iterations;
size_t rand = params.data[1];
size_t account_index = rand % params.ka_num;
uint8_t *val = (uint8_t *)ka[account_index].data;
uint64_t memory_size = ka[account_index].data_len;

for (uint64_t i = 0; i < iterations; i++) {
{
*val ^= val[current % memory_size];
current = current * 76510171 + 47123;
}
}
return *val;
}
2 changes: 2 additions & 0 deletions transaction-dos/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target/
/farf/
36 changes: 36 additions & 0 deletions transaction-dos/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
[package]
authors = ["Solana Maintainers <[email protected]>"]
edition = "2018"
name = "solana-transaction-dos"
version = "1.9.0"
repository = "https://github.com/solana-labs/solana"
license = "Apache-2.0"
homepage = "https://solana.com/"
publish = false

[dependencies]
bincode = "1.3.3"
clap = "2.33.1"
log = "0.4.14"
rand = "0.7.0"
rayon = "1.5.1"
solana-cli = { path = "../cli", version = "=1.9.0" }
solana-clap-utils = { path = "../clap-utils", version = "=1.9.0" }
solana-client = { path = "../client", version = "=1.9.0" }
solana-core = { path = "../core", version = "=1.9.0" }
solana-faucet = { path = "../faucet", version = "=1.9.0" }
solana-gossip = { path = "../gossip", version = "=1.9.0" }
solana-logger = { path = "../logger", version = "=1.9.0" }
solana-measure = { path = "../measure", version = "=1.9.0" }
solana-net-utils = { path = "../net-utils", version = "=1.9.0" }
solana-runtime = { path = "../runtime", version = "=1.9.0" }
solana-sdk = { path = "../sdk", version = "=1.9.0" }
solana-streamer = { path = "../streamer", version = "=1.9.0" }
solana-transaction-status = { path = "../transaction-status", version = "=1.9.0" }
solana-version = { path = "../version", version = "=1.9.0" }

[dev-dependencies]
solana-local-cluster = { path = "../local-cluster", version = "=1.9.0" }

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Loading

0 comments on commit 4663b86

Please sign in to comment.