diff --git a/bench_config.template b/bench_config.template index 7493f73..5bc1319 100644 --- a/bench_config.template +++ b/bench_config.template @@ -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] @@ -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 \ No newline at end of file +sampling = 20 diff --git a/src/config/bench_config.rs b/src/config/bench_config.rs index 35bfdb1..a85262d 100644 --- a/src/config/bench_config.rs +++ b/src/config/bench_config.rs @@ -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 where D: Deserializer<'de>, @@ -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 +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 diff --git a/src/main.rs b/src/main.rs index 85b48f1..885ba31 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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. @@ -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 @@ -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 );