-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #57 from flashbots/default-scenarios-2
builtin scenarios; fill block
- Loading branch information
Showing
13 changed files
with
469 additions
and
146 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
pub const SPAM_ME: &str = "0x6080604052348015600f57600080fd5b506105f98061001f6000396000f3fe60806040526004361061004a5760003560e01c806369f86ec81461004f5780639402c00414610066578063a329e8de14610086578063c5eeaf17146100a6578063fb0e722b146100ae575b600080fd5b34801561005b57600080fd5b506100646100d9565b005b34801561007257600080fd5b50610064610081366004610284565b6100e4565b34801561009257600080fd5b506100646100a136600461033d565b610119565b6100646101b1565b3480156100ba57600080fd5b506100c36101e0565b6040516100d0919061037a565b60405180910390f35b5b60325a116100da57565b6000816040516020016100f89291906103e7565b6040516020818303038152906040526000908161011591906104bb565b5050565b6000811161016d5760405162461bcd60e51b815260206004820152601a60248201527f476173206d7573742062652067726561746572207468616e2030000000000000604482015260640160405180910390fd5b6000609561017d610a288461057a565b61018791906105a1565b905080600003610195575060015b60005b818110156101ac5760008055600101610198565b505050565b60405141903480156108fc02916000818181858888f193505050501580156101dd573d6000803e3d6000fd5b50565b600080546101ed906103ad565b80601f0160208091040260200160405190810160405280929190818152602001828054610219906103ad565b80156102665780601f1061023b57610100808354040283529160200191610266565b820191906000526020600020905b81548152906001019060200180831161024957829003601f168201915b505050505081565b634e487b7160e01b600052604160045260246000fd5b60006020828403121561029657600080fd5b813567ffffffffffffffff8111156102ad57600080fd5b8201601f810184136102be57600080fd5b803567ffffffffffffffff8111156102d8576102d861026e565b604051601f8201601f19908116603f0116810167ffffffffffffffff811182821017156103075761030761026e565b60405281815282820160200186101561031f57600080fd5b81602084016020830137600091810160200191909152949350505050565b60006020828403121561034f57600080fd5b5035919050565b60005b83811015610371578181015183820152602001610359565b50506000910152565b6020815260008251806020840152610399816040850160208701610356565b601f01601f19169190910160400192915050565b600181811c908216806103c157607f821691505b6020821081036103e157634e487b7160e01b600052602260045260246000fd5b50919050565b60008084546103f5816103ad565b60018216801561040c576001811461042157610451565b60ff1983168652811515820286019350610451565b87600052602060002060005b838110156104495781548882015260019091019060200161042d565b505081860193505b5050508351610464818360208801610356565b01949350505050565b601f8211156101ac57806000526020600020601f840160051c810160208510156104945750805b601f840160051c820191505b818110156104b457600081556001016104a0565b5050505050565b815167ffffffffffffffff8111156104d5576104d561026e565b6104e9816104e384546103ad565b8461046d565b6020601f82116001811461051d57600083156105055750848201515b600019600385901b1c1916600184901b1784556104b4565b600084815260208120601f198516915b8281101561054d578785015182556020948501946001909201910161052d565b508482101561056b5786840151600019600387901b60f8161c191681555b50505050600190811b01905550565b8181038181111561059b57634e487b7160e01b600052601160045260246000fd5b92915050565b6000826105be57634e487b7160e01b600052601260045260246000fd5b50049056fea264697066735822122045a1a87948aab5d390113cacf93d9eb435038ea2c95e18140c4d0e3e2604afca64736f6c634300081b0033"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
mod bytecode; | ||
mod runconfig; | ||
|
||
pub use runconfig::{BuiltinScenario, BuiltinScenarioConfig}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
use alloy::primitives::Address; | ||
use contender_core::generator::types::{CreateDefinition, FunctionCallDefinition, SpamRequest}; | ||
use contender_testfile::TestConfig; | ||
use serde::{Deserialize, Serialize}; | ||
|
||
use super::bytecode; | ||
|
||
#[derive(Serialize, Deserialize, Debug, Clone, clap::ValueEnum)] | ||
pub enum BuiltinScenario { | ||
FillBlock, | ||
} | ||
|
||
pub enum BuiltinScenarioConfig { | ||
FillBlock { | ||
max_gas_per_block: u128, | ||
num_txs: u64, | ||
sender: Address, | ||
}, | ||
} | ||
|
||
impl BuiltinScenarioConfig { | ||
pub fn fill_block(max_gas_per_block: u128, num_txs: u64, sender: Address) -> Self { | ||
Self::FillBlock { | ||
max_gas_per_block, | ||
num_txs, | ||
sender, | ||
} | ||
} | ||
} | ||
|
||
impl From<BuiltinScenarioConfig> for TestConfig { | ||
fn from(scenario: BuiltinScenarioConfig) -> Self { | ||
match scenario { | ||
BuiltinScenarioConfig::FillBlock { | ||
max_gas_per_block, | ||
num_txs, | ||
sender, | ||
} => { | ||
let gas_per_tx = max_gas_per_block / num_txs as u128; | ||
let spam_txs = (0..num_txs) | ||
.map(|_| { | ||
SpamRequest::Tx(FunctionCallDefinition { | ||
to: "{SpamMe}".to_owned(), | ||
from: Some(sender.to_string()), | ||
signature: "consumeGas(uint256 gas)".to_owned(), | ||
from_pool: None, | ||
args: Some(vec![gas_per_tx.to_string()]), | ||
value: None, | ||
fuzz: None, | ||
kind: Some("fill-block".to_owned()), | ||
}) | ||
}) | ||
.collect::<Vec<_>>(); | ||
|
||
TestConfig { | ||
env: None, | ||
create: Some(vec![CreateDefinition { | ||
name: "SpamMe".to_owned(), | ||
bytecode: bytecode::SPAM_ME.to_owned(), | ||
from: sender.to_string(), | ||
}]), | ||
setup: None, | ||
spam: Some(spam_txs), | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.