Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

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

17 changes: 17 additions & 0 deletions configs/max.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
inherits = "aggressive.toml"

[rate_limiting]
initial_ratelimit = 500
ratelimit_thresholds = [
[2_500, 1_000],
[5_000, 2_500],
[25_000, 500_000],
]

[network_worker]
total_connections = 20_000
tx_queue_empty_sleep_ms = 5

[workers]
tx_gen_worker_percentage = 0.3
network_worker_percentage = 0.7
3 changes: 2 additions & 1 deletion crescendo/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,5 @@ rand = "0.9.1"
ratelimit = "0.10"
clap = { version = "4.5", features = ["derive", "env"] }
toml = "0.8"
parking_lot = "0.12.4"
parking_lot = "0.12.4"
dashmap = "6.1"
15 changes: 7 additions & 8 deletions crescendo/src/workers/tx_gen.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
use std::collections::HashMap;
use std::sync::LazyLock;
use std::time::Instant;

Expand All @@ -9,20 +8,20 @@ use alloy::sol_types::SolCall;
use alloy_consensus::{SignableTransaction, TxLegacy};
use alloy_signer_local::coins_bip39::English;
use alloy_signer_local::{MnemonicBuilder, PrivateKeySigner};
use parking_lot::Mutex;
use dashmap::DashMap;
use rand::Rng;
use rayon::prelude::*;
use thousands::Separable;

use crate::config;
use crate::tx_queue::TX_QUEUE;

static NONCE_MAP: LazyLock<Mutex<HashMap<u32, u64>>> = LazyLock::new(|| {
let mut map = HashMap::with_capacity(config::get().tx_gen_worker.num_accounts as usize);
static NONCE_MAP: LazyLock<DashMap<u32, u64>> = LazyLock::new(|| {
let map = DashMap::with_capacity(config::get().tx_gen_worker.num_accounts as usize);
for i in 0..config::get().tx_gen_worker.num_accounts {
map.insert(i, 0);
}
Mutex::new(map)
map
});

static SIGNER_LIST: LazyLock<Vec<PrivateKeySigner>> = LazyLock::new(|| {
Expand Down Expand Up @@ -54,9 +53,9 @@ pub fn tx_gen_worker(_worker_id: u32) {

// Get and increment nonce atomically.
let nonce = {
let mut nonce_map = NONCE_MAP.lock();
let current_nonce = *nonce_map.get(&account_index).unwrap();
nonce_map.insert(account_index, current_nonce + 1);
let mut entry = NONCE_MAP.get_mut(&account_index).unwrap();
let current_nonce = *entry;
*entry = current_nonce + 1;
current_nonce
};

Expand Down
2 changes: 1 addition & 1 deletion testserver/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ static CONCURRENT_REQUESTS: CachePadded<AtomicU64> = CachePadded::new(AtomicU64:

async fn handler() -> Json<serde_json::Value> {
CONCURRENT_REQUESTS.fetch_add(1, Ordering::Relaxed);
tokio::time::sleep(Duration::from_millis(500)).await; // Simulate processing time.
tokio::time::sleep(Duration::from_millis(1)).await; // Simulate processing time.
CONCURRENT_REQUESTS.fetch_sub(1, Ordering::Relaxed);
TOTAL_REQUESTS.fetch_add(1, Ordering::Relaxed);
Json(json!({
Expand Down