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
40 changes: 20 additions & 20 deletions Cargo.lock

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

34 changes: 19 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ use contender_core::{
db::DbOps,
generator::RandSeed,
spammer::{BlockwiseSpammer, TimedSpammer, NilCallback, LogCallback},
test_scenario::TestScenario,
test_scenario::{TestScenario, TestScenarioParams},
};
use contender_sqlite::SqliteDb;
use contender_testfile::TestConfig;
Expand All @@ -195,22 +195,26 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
4, // number of random signers to create
rand_seed
)
let scenario = TestScenario::new(
let mut scenario = TestScenario::new(
cfg,
db.to_owned().into(),
"http://localhost:8545".parse::<_>()?,
None,
db.clone().into(),
rand_seed,
&[
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
"0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a",
]
.iter()
.map(|s| s.parse::<_>().unwrap())
.collect::<Vec<_>>(),
agents
);
TestScenarioParams {
rpc_url: "http://localhost:8545".parse::<_>()?,
builder_rpc_url: None,
signers: [
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80",
"0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d",
"0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a",
]
.iter()
.map(|s| s.parse::<_>().unwrap())
.collect::<Vec<_>>(),
agent_store: agents,
tx_type: alloy::consensus::TxType::Legacy,
},
)
.await?;

if db.get_named_tx("MyContract").is_err() {
scenario.deploy_contracts().await?;
Expand Down
31 changes: 31 additions & 0 deletions crates/cli/src/commands/contender_subcommand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ use clap::Subcommand;
use std::path::PathBuf;

use crate::default_scenarios::BuiltinScenario;
use crate::util::TxTypeCli;

#[derive(Debug, Subcommand)]
pub enum ContenderSubcommand {
Expand Down Expand Up @@ -97,6 +98,16 @@ May be specified multiple times."
long_help = "Filename of the saved report. May be a fully-qualified path. If not provided, the report can be generated with the `report` subcommand. '.csv' extension is added automatically."
)]
gen_report: bool,

/// Transaction type
#[arg(
short = 't',
long,
long_help = "Transaction type for spam transactions.",
value_enum,
default_value_t = TxTypeCli::Eip1559,
)]
tx_type: TxTypeCli,
},

#[command(
Expand Down Expand Up @@ -130,6 +141,16 @@ May be specified multiple times."
/// The seed used to generate pool accounts.
#[arg(short, long, long_help = "The seed used to generate pool accounts.")]
seed: Option<String>,

/// Transaction type
#[arg(
short = 't',
long,
long_help = "Transaction type for setup transactions.",
value_enum,
default_value_t = TxTypeCli::Eip1559,
)]
tx_type: TxTypeCli,
},

#[command(
Expand Down Expand Up @@ -204,6 +225,16 @@ May be specified multiple times."
visible_aliases = &["sdp"]
)]
skip_deploy_prompt: bool,

/// Transaction type
#[arg(
short = 't',
long,
long_help = "Transaction type for all transactions.",
value_enum,
default_value_t = TxTypeCli::Eip1559,
)]
tx_type: TxTypeCli,
// TODO: DRY duplicate args
},
}
Expand Down
15 changes: 10 additions & 5 deletions crates/cli/src/commands/run.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::{env, str::FromStr, sync::Arc};

use alloy::{
consensus::TxType,
eips::BlockId,
network::AnyNetwork,
providers::{DynProvider, Provider, ProviderBuilder},
Expand All @@ -13,7 +14,7 @@ use contender_core::{
error::ContenderError,
generator::RandSeed,
spammer::{LogCallback, Spammer, TimedSpammer},
test_scenario::TestScenario,
test_scenario::{TestScenario, TestScenarioParams},
};
use contender_testfile::TestConfig;

Expand All @@ -30,6 +31,7 @@ pub struct RunCommandArgs {
pub duration: usize,
pub txs_per_duration: usize,
pub skip_deploy_prompt: bool,
pub tx_type: TxType,
}

pub async fn run(
Expand Down Expand Up @@ -71,11 +73,14 @@ pub async fn run(
let mut scenario = TestScenario::new(
testconfig,
db.clone().into(),
rpc_url.to_owned(),
None,
rand_seed,
&user_signers,
AgentStore::default(),
TestScenarioParams {
rpc_url: rpc_url.to_owned(),
builder_rpc_url: None,
signers: user_signers,
agent_store: AgentStore::default(),
tx_type: args.tx_type,
},
)
.await?;

Expand Down
16 changes: 11 additions & 5 deletions crates/cli/src/commands/setup.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use alloy::{
consensus::TxType,
network::AnyNetwork,
primitives::utils::{format_ether, parse_ether},
providers::{DynProvider, ProviderBuilder},
Expand All @@ -9,7 +10,7 @@ use contender_core::{
agent_controller::{AgentStore, SignerStore},
error::ContenderError,
generator::RandSeed,
test_scenario::TestScenario,
test_scenario::{TestScenario, TestScenarioParams},
};
use contender_testfile::TestConfig;
use std::str::FromStr;
Expand All @@ -26,6 +27,7 @@ pub async fn setup(
private_keys: Option<Vec<String>>,
min_balance: String,
seed: RandSeed,
tx_type: TxType,
) -> Result<(), Box<dyn std::error::Error>> {
let url = Url::parse(rpc_url.as_ref()).expect("Invalid RPC URL");
let rpc_client = DynProvider::new(
Expand Down Expand Up @@ -108,17 +110,21 @@ pub async fn setup(
&rpc_client,
&eth_client,
min_balance,
tx_type,
)
.await?;

let mut scenario = TestScenario::new(
testconfig.to_owned(),
db.clone().into(),
url,
None,
seed,
&user_signers_with_defaults,
agents,
TestScenarioParams {
rpc_url: url,
builder_rpc_url: None,
signers: user_signers_with_defaults,
agent_store: agents,
tx_type,
},
)
.await?;

Expand Down
19 changes: 13 additions & 6 deletions crates/cli/src/commands/spam.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::sync::Arc;

use alloy::{
consensus::TxType,
network::AnyNetwork,
primitives::{
utils::{format_ether, parse_ether},
Expand All @@ -15,7 +16,7 @@ use contender_core::{
error::ContenderError,
generator::{seeder::Seeder, types::AnyProvider, Generator, PlanType, RandSeed},
spammer::{BlockwiseSpammer, ExecutionPayload, Spammer, TimedSpammer},
test_scenario::TestScenario,
test_scenario::{TestScenario, TestScenarioParams},
};
use contender_testfile::TestConfig;

Expand All @@ -36,6 +37,7 @@ pub struct SpamCommandArgs {
pub private_keys: Option<Vec<String>>,
pub disable_reports: bool,
pub min_balance: String,
pub tx_type: TxType,
}

/// Runs spammer and returns run ID.
Expand Down Expand Up @@ -128,6 +130,7 @@ pub async fn spam(
&rpc_client,
&eth_client,
min_balance,
args.tx_type,
)
.await?;

Expand All @@ -136,12 +139,16 @@ pub async fn spam(
let mut scenario = TestScenario::new(
testconfig,
db.clone().into(),
url,
args.builder_url
.map(|url| Url::parse(&url).expect("Invalid builder URL")),
rand_seed,
&user_signers,
agents,
TestScenarioParams {
rpc_url: url,
builder_rpc_url: args
.builder_url
.map(|url| Url::parse(&url).expect("Invalid builder URL")),
signers: user_signers,
agent_store: agents,
tx_type: args.tx_type,
},
)
.await?;

Expand Down
Loading
Loading