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
9 changes: 6 additions & 3 deletions bench_config.template
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ private_key = "ac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80"
faucet_level = 10
# Wait duration in seconds between faucet distribution levels
# If you encounter 'insufficient funds' errors, try increasing this value
wait_duration_secs = 60
fauce_eth_balance = "100000000000000000000"
wait_duration_secs = 5
# Total ETH the faucet distributes to test accounts (in ETH units, not wei).
# After subtracting gas reserves, the remainder is split equally among all accounts.
# This is the total spendable ETH budget for the benchmark run.
faucet_eth_balance = "100.0"

# Load testing account configuration
[accounts]
Expand All @@ -39,4 +42,4 @@ max_pool_size = 100000
duration_secs = 60
# Sampling strategy: integer (transaction count) or "full" (check all pending)
# Default is 10
sampling = 20
sampling = 20
20 changes: 18 additions & 2 deletions src/config/bench_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ pub struct NodeConfig {
pub chain_id: u64,
}

/// Deserialize a string representing ETH (e.g. "100.0" or "0.5") into U256 wei.
/// The string is parsed as f64 and multiplied by 1e18.
#[allow(dead_code)]
fn from_str_to_u256<'de, D>(deserializer: D) -> Result<U256, D::Error>
where
D: Deserializer<'de>,
Expand All @@ -48,14 +51,27 @@ where
Ok(U256::from_str_radix(&s, 10).map_err(serde::de::Error::custom)?)
}

fn from_eth_str_to_u256<'de, D>(deserializer: D) -> Result<U256, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
let eth: f64 = s.parse().map_err(serde::de::Error::custom)?;
let wei = (eth * 1e18) as u128;
Ok(U256::from(wei))
}

/// Faucet and deployer account configuration
#[derive(Debug, Clone, Deserialize, Serialize)]
pub struct FaucetConfig {
pub private_key: String,
pub faucet_level: u32,
pub wait_duration_secs: u64,
#[serde(deserialize_with = "from_str_to_u256")]
pub fauce_eth_balance: U256,
/// Total ETH (in ETH units, not wei) the faucet distributes to test accounts.
/// After subtracting gas reserves, the remainder is split equally among all accounts.
/// This represents the total spendable ETH budget for the benchmark run.
#[serde(deserialize_with = "from_eth_str_to_u256")]
pub faucet_eth_balance: U256,
}

/// Load testing account configuration
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,7 @@ async fn start_bench() -> Result<()> {
let faucet_address =
PrivateKeySigner::from_str(&benchmark_config.faucet.private_key).unwrap().address();
let on_chain_nonce = eth_clients[0].get_pending_txn_count(faucet_address).await.unwrap();
// Clamp configured fauce_eth_balance to the actual on-chain balance to prevent
// Clamp configured faucet_eth_balance to the actual on-chain balance to prevent
// U256 underflow inside FaucetTreePlanBuilder::new when (gas_budget * total_txns)
// exceeds the configured amount. Underflow produces ~2^256 funding values that
// permanently strip ENOUGH_BALANCE in the txpool and silently deadlock cascade.
Expand All @@ -381,7 +381,7 @@ async fn start_bench() -> Result<()> {
.get_balance(&faucet_address)
.await
.expect("failed to query faucet on-chain balance");
let configured_faucet_eth = benchmark_config.faucet.fauce_eth_balance;
let configured_faucet_eth = benchmark_config.faucet.faucet_eth_balance;
// Pick an on-chain-aware faucet ceiling for the cascade math:
// - If on-chain balance < configured: clamp DOWN to on-chain reality so the
// cascade can't be sized for funds we don't have (avoids U256 underflow in
Expand All @@ -392,7 +392,7 @@ async fn start_bench() -> Result<()> {
// The FaucetTreePlanBuilder assert is the final backstop for absurd inputs.
let effective_faucet_eth = if on_chain_faucet_balance < configured_faucet_eth {
tracing::warn!(
"fauce_eth_balance ({}) exceeds on-chain balance ({}); clamping down.",
"faucet_eth_balance ({}) exceeds on-chain balance ({}); clamping down.",
configured_faucet_eth,
on_chain_faucet_balance
);
Expand Down
Loading