Skip to content

Commit

Permalink
differentiate seed using pool name, fix account index bug
Browse files Browse the repository at this point in the history
  • Loading branch information
zeroXbrock committed Nov 18, 2024
1 parent ae17ca1 commit 4a6d127
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
continue;
}

let agent = SignerStore::new_random(signers_per_block, &rand_seed);
let agent = SignerStore::new_random(signers_per_block, &rand_seed, &from_pool);
all_signers.extend_from_slice(&agent.signers);
agents.add_agent(from_pool, agent);
}
Expand Down
11 changes: 8 additions & 3 deletions crates/core/src/agent_controller.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::collections::HashMap;

use alloy::{
primitives::{Address, FixedBytes},
primitives::{Address, FixedBytes, U256},
signers::local::PrivateKeySigner,
};

Expand Down Expand Up @@ -50,7 +50,7 @@ impl AgentStore {
num_signers: usize,
rand_seeder: &RandSeed,
) {
let signers = SignerStore::new_random(num_signers, rand_seeder);
let signers = SignerStore::new_random(num_signers, rand_seeder, name.as_ref());
self.add_agent(name, signers);
}

Expand Down Expand Up @@ -91,7 +91,12 @@ impl SignerStore {
}
}

pub fn new_random(num_signers: usize, rand_seeder: &RandSeed) -> Self {
pub fn new_random(num_signers: usize, rand_seeder: &RandSeed, acct_seed: &str) -> Self {
// add numerical value of acct_seed to given seed
let new_seed = rand_seeder.as_u256() + U256::from_be_slice(acct_seed.as_bytes());
let rand_seeder = RandSeed::from_u256(new_seed);

// generate random private keys with new seed
let prv_keys = rand_seeder
.seed_values(num_signers, None, None)
.map(|sv| sv.as_bytes().to_vec())
Expand Down
4 changes: 2 additions & 2 deletions crates/core/src/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ where
}

for i in 0..(num_txs / num_steps) {
for (j, step) in spam_steps.iter().enumerate() {
for step in spam_steps.iter() {
// converts a FunctionCallDefinition to a NamedTxRequest (filling in fuzzable args),
// returns a callback handle and the processed tx request
let process_tx = |req| {
Expand All @@ -286,7 +286,7 @@ where

let tx = NamedTxRequest::new(
templater.template_function_call(
&self.make_strict_call(&req, j)?, // 'from' address injected here
&self.make_strict_call(&req, i)?, // 'from' address injected here
&placeholder_map,
)?,
None,
Expand Down
3 changes: 2 additions & 1 deletion crates/core/src/spammer/blockwise.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use super::tx_actor::TxActorHandle;
use super::OnTxSent;

/// Defines the number of blocks to target with a single bundle.
const BUNDLE_BLOCK_TOLERANCE: usize = 5;
const BUNDLE_BLOCK_TOLERANCE: usize = 4;

pub struct BlockwiseSpammer<F, D, S, P>
where
Expand Down Expand Up @@ -249,6 +249,7 @@ where
.await
.map_err(|e| ContenderError::with_err(e, "failed to prepare tx"))?;

println!("bundle tx from {:?}", tx_req.from);
// sign tx
let tx_envelope = tx_req.build(&signer).await.map_err(|e| {
ContenderError::with_err(e, "bad request: failed to build tx")
Expand Down
4 changes: 2 additions & 2 deletions scenarios/spamMe.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ signature = "transfer()"
[[spam.tx.fuzz]]
value = true
min = "10000000000000"
max = "1000000000000000"
max = "100000000000000"


# spam bundle
Expand All @@ -33,4 +33,4 @@ fuzz = [{ param = "gasAmount", min = "100000", max = "500000" }]
to = "{SpamMe}"
from_pool = "bluepool"
signature = "tipCoinbase()"
value = "10000000000000000"
value = "10000000000000000"

0 comments on commit 4a6d127

Please sign in to comment.