diff --git a/README.md b/README.md index 8a9396f..dab9734 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ async fn main() -> Result<(), Box> { let cfg = TestConfig::from_file("testfile.toml")?; let mut agents = AgentStore::new(); let rand_seed = RandSeed::new(); + let legacy = false; agents.add_random_agent( "agentName", 4, // number of random signers to create @@ -88,7 +89,8 @@ async fn main() -> Result<(), Box> { .iter() .map(|s| s.parse::<_>().unwrap()) .collect::>(), - agents + agents, + legacy, ); if db.get_named_tx("MyContract").is_err() { diff --git a/crates/cli/src/commands.rs b/crates/cli/src/commands.rs index 0687ded..2883ed4 100644 --- a/crates/cli/src/commands.rs +++ b/crates/cli/src/commands.rs @@ -90,6 +90,13 @@ May be specified multiple times." default_value = "1.0" )] min_balance: String, + + /// Whether to send legacy transactions. + #[arg( + long, + long_help = "If set, will send legacy Ethereum transactions instead of EIP-1559 transactions." + )] + legacy: bool, }, #[command( @@ -119,6 +126,13 @@ May be specified multiple times." default_value = "1.0" )] min_balance: String, + + /// Whether to send legacy transactions. + #[arg( + long, + long_help = "If set, will send legacy Ethereum transactions instead of EIP-1559 transactions." + )] + legacy: bool, }, #[command( diff --git a/crates/cli/src/main.rs b/crates/cli/src/main.rs index c898a92..3a989f0 100644 --- a/crates/cli/src/main.rs +++ b/crates/cli/src/main.rs @@ -46,6 +46,7 @@ async fn main() -> Result<(), Box> { rpc_url, private_keys, min_balance, + legacy, } => { let url = Url::parse(rpc_url.as_ref()).expect("Invalid RPC URL"); let rpc_client = ProviderBuilder::new() @@ -83,6 +84,7 @@ async fn main() -> Result<(), Box> { RandSeed::new(), &signers, Default::default(), + legacy, ) .await?; @@ -101,6 +103,7 @@ async fn main() -> Result<(), Box> { private_keys, disable_reports, min_balance, + legacy, } => { let testconfig = TestConfig::from_file(&testfile)?; let rand_seed = seed @@ -228,6 +231,7 @@ async fn main() -> Result<(), Box> { rand_seed, &user_signers, agents, + legacy, ) .await?; diff --git a/crates/core/src/spammer/blockwise.rs b/crates/core/src/spammer/blockwise.rs index e3a1b19..eccb064 100644 --- a/crates/core/src/spammer/blockwise.rs +++ b/crates/core/src/spammer/blockwise.rs @@ -74,6 +74,7 @@ mod tests { seed, get_test_signers().as_slice(), AgentStore::new(), + false, ) .await .unwrap(); diff --git a/crates/core/src/test_scenario.rs b/crates/core/src/test_scenario.rs index a41d679..2b0ddc5 100644 --- a/crates/core/src/test_scenario.rs +++ b/crates/core/src/test_scenario.rs @@ -45,6 +45,8 @@ where pub chain_id: u64, pub gas_limits: HashMap, u128>, pub msg_handle: Arc, + /// Whether to send legacy transactions instead of EIP-1559 transactions + pub legacy: bool, } impl TestScenario @@ -61,6 +63,7 @@ where rand_seed: S, signers: &[PrivateKeySigner], agent_store: AgentStore, + legacy: bool, ) -> Result { let rpc_client = Arc::new( ProviderBuilder::new() @@ -120,6 +123,7 @@ where nonces, gas_limits, msg_handle, + legacy, }) } @@ -320,10 +324,20 @@ where let full_tx = tx_req .to_owned() .with_nonce(nonce) - .with_max_fee_per_gas(gas_price + (gas_price / 5)) - .with_max_priority_fee_per_gas(gas_price) .with_chain_id(self.chain_id) - .with_gas_limit(gas_limit + (gas_limit / 6)); + .with_gas_limit(if self.legacy { + gas_limit + } else { + gas_limit + (gas_limit / 6) + }); + + let full_tx = if self.legacy { + full_tx.with_gas_price(gas_price) + } else { + full_tx + .with_max_fee_per_gas(gas_price + (gas_price / 5)) + .with_max_priority_fee_per_gas(gas_price) + }; Ok((full_tx, signer)) } @@ -721,6 +735,7 @@ pub mod tests { seed.to_owned(), signers, AgentStore::new(), + false, ) .await .unwrap() diff --git a/crates/testfile/src/lib.rs b/crates/testfile/src/lib.rs index efa56c4..de70ae8 100644 --- a/crates/testfile/src/lib.rs +++ b/crates/testfile/src/lib.rs @@ -381,6 +381,7 @@ pub mod tests { seed, &get_test_signers(), Default::default(), + false, ) .await .unwrap(); @@ -421,6 +422,7 @@ pub mod tests { seed.to_owned(), &signers, Default::default(), + false, ) .await .unwrap(); @@ -432,6 +434,7 @@ pub mod tests { seed, &signers, Default::default(), + false, ) .await .unwrap();