From 69bd5a18f7dd48e78e7253fdf5e76b713584244a Mon Sep 17 00:00:00 2001 From: lukacan Date: Mon, 13 Jan 2025 19:40:48 +0100 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Rename=20config=20to=20TridentConfi?= =?UTF-8?q?g=20as=20the=20old=20name=20was=20causing=20issues?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 1 + crates/client/src/commander/afl.rs | 6 +++--- crates/client/src/commander/honggfuzz.rs | 8 ++++---- .../tests/expected_source_codes/expected_test_fuzz.rs | 4 ++-- crates/config/src/lib.rs | 9 +++++---- crates/fuzz/derive/fuzz_test_executor/src/lib.rs | 2 +- crates/fuzz/src/fuzz_client.rs | 4 ++-- crates/fuzz/src/fuzz_client_impl.rs | 4 ++-- crates/fuzz/src/fuzz_data.rs | 4 ++-- crates/fuzz/src/fuzz_test_executor.rs | 4 ++-- crates/fuzz/src/lib.rs | 2 +- crates/fuzz/src/transaction_executor.rs | 4 ++-- crates/template/src/test_fuzz_generator.rs | 4 ++-- .../trident-tests/fuzz_0/test_fuzz.rs | 4 ++-- .../cpi/cpi-metaplex-7/trident-tests/fuzz_0/test_fuzz.rs | 4 ++-- .../cpi/simple-cpi-6/trident-tests/fuzz_0/test_fuzz.rs | 4 ++-- examples/hello_world/trident-tests/fuzz_0/test_fuzz.rs | 4 ++-- 17 files changed, 37 insertions(+), 35 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 06c3288f..9a87804e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,7 @@ incremented upon a breaking change and the patch version will be incremented for **Changed** +- renamed Config to TridentConfig ([246](https://github.com/Ackee-Blockchain/trident/pull/246)) - errors are simplified and transaction error contains only transaction error ([244](https://github.com/Ackee-Blockchain/trident/pull/244)) ## [0.8.1] - 2024-11-14 diff --git a/crates/client/src/commander/afl.rs b/crates/client/src/commander/afl.rs index 52bc3bc3..83fc7b99 100644 --- a/crates/client/src/commander/afl.rs +++ b/crates/client/src/commander/afl.rs @@ -6,7 +6,7 @@ use std::{fs::File, path::Path}; use tokio::{io::AsyncWriteExt, process::Command}; use trident_config::afl::AflSeed; -use trident_config::Config; +use trident_config::TridentConfig; use super::{Commander, Error}; use rand::RngCore; @@ -15,7 +15,7 @@ impl Commander { /// Runs fuzzer on the given target. #[throws] pub async fn run_afl(&self, target: String) { - let config = Config::new(); + let config = TridentConfig::new(); // build args without cargo target dir let build_args = config.get_afl_build_args(); @@ -77,7 +77,7 @@ impl Commander { /// Runs fuzzer on the given target. #[throws] pub async fn run_afl_debug(&self, target: String, crash_file: String) { - let config = Config::new(); + let config = TridentConfig::new(); let crash_file_path = Path::new(&crash_file); diff --git a/crates/client/src/commander/honggfuzz.rs b/crates/client/src/commander/honggfuzz.rs index 24e2f231..efb5c970 100644 --- a/crates/client/src/commander/honggfuzz.rs +++ b/crates/client/src/commander/honggfuzz.rs @@ -4,7 +4,7 @@ use std::process; use std::{os::unix::process::CommandExt, process::Stdio}; use tokio::process::Command; -use trident_config::Config; +use trident_config::TridentConfig; use crate::constants::*; @@ -14,7 +14,7 @@ impl Commander { /// Runs fuzzer on the given target with exit code option. #[throws] pub async fn run_honggfuzz_with_exit_code(&self, target: String) { - let config = Config::new(); + let config = TridentConfig::new(); // obtain hfuzz_run_args from env variable, this variable can contain multiple // arguments so we need to parse the variable content. @@ -86,7 +86,7 @@ impl Commander { /// Runs fuzzer on the given target. #[throws] pub async fn run_honggfuzz(&self, target: String) { - let config = Config::new(); + let config = TridentConfig::new(); let hfuzz_run_args = std::env::var("HFUZZ_RUN_ARGS").unwrap_or_default(); @@ -134,7 +134,7 @@ impl Commander { /// Runs fuzzer on the given target. #[throws] pub async fn run_hfuzz_debug(&self, target: String, crash_file_path: String) { - let config = Config::new(); + let config = TridentConfig::new(); let crash_file = Path::new(&crash_file_path); diff --git a/crates/client/tests/expected_source_codes/expected_test_fuzz.rs b/crates/client/tests/expected_source_codes/expected_test_fuzz.rs index 8043c30f..84b3338f 100644 --- a/crates/client/tests/expected_source_codes/expected_test_fuzz.rs +++ b/crates/client/tests/expected_source_codes/expected_test_fuzz.rs @@ -28,8 +28,8 @@ fn main() { None, processor!(entry_idl_test), ); - let config = Config::new(); + let config = TridentConfig::new(); let mut client = TridentSVM::new_client(&[program_additional_program, program_idl_test], &config); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : Config |); + fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : TridentConfig |); } diff --git a/crates/config/src/lib.rs b/crates/config/src/lib.rs index 9e8a5e5b..31a6d8e7 100644 --- a/crates/config/src/lib.rs +++ b/crates/config/src/lib.rs @@ -29,24 +29,25 @@ pub enum Error { } #[derive(Debug, Deserialize, Clone)] -pub struct Config { +pub struct TridentConfig { pub honggfuzz: Option, pub afl: Option, pub fuzz: Option, } -impl Default for Config { +impl Default for TridentConfig { fn default() -> Self { Self::new() } } -impl Config { +impl TridentConfig { pub fn new() -> Self { let root = discover_root().expect("failed to find the root folder"); let s = fs::read_to_string(root.join(TRIDENT_TOML).as_path()) .expect("failed to read the Trident config file"); - let _config: Config = toml::from_str(&s).expect("failed to parse the Trident config file"); + let _config: TridentConfig = + toml::from_str(&s).expect("failed to parse the Trident config file"); _config } diff --git a/crates/fuzz/derive/fuzz_test_executor/src/lib.rs b/crates/fuzz/derive/fuzz_test_executor/src/lib.rs index a1a5b861..5b32afd0 100644 --- a/crates/fuzz/derive/fuzz_test_executor/src/lib.rs +++ b/crates/fuzz/derive/fuzz_test_executor/src/lib.rs @@ -32,7 +32,7 @@ pub fn fuzz_test_executor(input: TokenStream) -> TokenStream { &self, accounts: &RefCell, client: &mut impl trident_fuzz::fuzzing::FuzzClient, - config: &trident_fuzz::fuzzing::Config, + config: &trident_fuzz::fuzzing::TridentConfig, ) -> core::result::Result<(), trident_fuzz::fuzzing::FuzzClientErrorWithOrigin> { match self { #(#display_match_arms)* diff --git a/crates/fuzz/src/fuzz_client.rs b/crates/fuzz/src/fuzz_client.rs index f668e451..54b84eed 100644 --- a/crates/fuzz/src/fuzz_client.rs +++ b/crates/fuzz/src/fuzz_client.rs @@ -8,12 +8,12 @@ use solana_sdk::signature::Keypair; use solana_sdk::sysvar::Sysvar; use solana_sdk::transaction::TransactionError; -use trident_config::Config; +use trident_config::TridentConfig; use trident_svm::utils::ProgramEntrypoint; /// A trait providing methods to read and write (manipulate) accounts pub trait FuzzClient { - fn new_client(programs: &[ProgramEntrypoint], config: &Config) -> Self; + fn new_client(programs: &[ProgramEntrypoint], config: &TridentConfig) -> Self; /// Get the cluster rent fn get_sysvar(&self) -> T; diff --git a/crates/fuzz/src/fuzz_client_impl.rs b/crates/fuzz/src/fuzz_client_impl.rs index 4a4be8a6..27578389 100644 --- a/crates/fuzz/src/fuzz_client_impl.rs +++ b/crates/fuzz/src/fuzz_client_impl.rs @@ -6,7 +6,7 @@ use solana_sdk::pubkey::Pubkey; use solana_sdk::signer::Signer; use solana_sdk::sysvar::Sysvar; -use trident_config::Config; +use trident_config::TridentConfig; use trident_svm::trident_svm::TridentSVM; use trident_svm::utils::ProgramEntrypoint; @@ -17,7 +17,7 @@ use crate::fuzz_client::FuzzClient; use solana_sdk::transaction::TransactionError; impl FuzzClient for TridentSVM<'_> { - fn new_client(programs: &[ProgramEntrypoint], config: &Config) -> Self { + fn new_client(programs: &[ProgramEntrypoint], config: &TridentConfig) -> Self { let sbf_programs = config .programs() diff --git a/crates/fuzz/src/fuzz_data.rs b/crates/fuzz/src/fuzz_data.rs index 06505767..87e3c36b 100644 --- a/crates/fuzz/src/fuzz_data.rs +++ b/crates/fuzz/src/fuzz_data.rs @@ -8,7 +8,7 @@ use std::fmt::Display; use crate::fuzz_client::FuzzClient; use crate::fuzz_test_executor::FuzzTestExecutor; -use trident_config::Config; +use trident_config::TridentConfig; pub struct FuzzData { pub pre_ixs: Vec, @@ -51,7 +51,7 @@ where pub fn run_with_runtime( &self, client: &mut impl FuzzClient, - config: &Config, + config: &TridentConfig, ) -> core::result::Result<(), Box> { // solana_logger::setup_with_default("off"); // #[cfg(fuzzing_debug)] diff --git a/crates/fuzz/src/fuzz_test_executor.rs b/crates/fuzz/src/fuzz_test_executor.rs index d4cf9caa..e10d020d 100644 --- a/crates/fuzz/src/fuzz_test_executor.rs +++ b/crates/fuzz/src/fuzz_test_executor.rs @@ -4,13 +4,13 @@ use std::cell::RefCell; use crate::error::FuzzClientErrorWithOrigin; use crate::fuzz_client::FuzzClient; -use trident_config::Config; +use trident_config::TridentConfig; pub trait FuzzTestExecutor { fn run_fuzzer( &self, accounts: &RefCell, client: &mut impl FuzzClient, - config: &Config, + config: &TridentConfig, ) -> core::result::Result<(), FuzzClientErrorWithOrigin>; } diff --git a/crates/fuzz/src/lib.rs b/crates/fuzz/src/lib.rs index e3cb2269..50da7ffd 100644 --- a/crates/fuzz/src/lib.rs +++ b/crates/fuzz/src/lib.rs @@ -49,7 +49,7 @@ pub mod fuzzing { /// trident methods pub use super::accounts_storage::*; - pub use trident_config::Config; + pub use trident_config::TridentConfig; pub use super::error::*; pub use super::fuzz_client::FuzzClient; diff --git a/crates/fuzz/src/transaction_executor.rs b/crates/fuzz/src/transaction_executor.rs index 7bf41348..ee6e40a6 100644 --- a/crates/fuzz/src/transaction_executor.rs +++ b/crates/fuzz/src/transaction_executor.rs @@ -10,7 +10,7 @@ use crate::fuzz_stats::FuzzingStatistics; use crate::ix_ops::IxOps; use crate::snapshot::Snapshot; -use trident_config::Config; +use trident_config::TridentConfig; pub struct TransactionExecutor; @@ -19,7 +19,7 @@ impl TransactionExecutor { instruction_name: &str, client: &mut impl FuzzClient, ix: &I, - config: &Config, + config: &TridentConfig, accounts: &RefCell, ) -> core::result::Result<(), FuzzClientErrorWithOrigin> where diff --git a/crates/template/src/test_fuzz_generator.rs b/crates/template/src/test_fuzz_generator.rs index f8a4e04d..24f631f9 100644 --- a/crates/template/src/test_fuzz_generator.rs +++ b/crates/template/src/test_fuzz_generator.rs @@ -46,11 +46,11 @@ pub fn generate_source_code(_idl_instructions: &[Idl], lib_names: &[String]) -> #(#programs)* - let config = Config::new(); + let config = TridentConfig::new(); let mut client = TridentSVM::new_client(&[ #(#input_array),* ], &config); fuzz_trident!( fuzz_ix: FuzzInstruction, - |fuzz_data: InstructionsSequence, client: TridentSVM, config: Config| + |fuzz_data: InstructionsSequence, client: TridentSVM, config: TridentConfig| ); } }; diff --git a/examples/common_issues/arbitrary-limit-inputs-5/trident-tests/fuzz_0/test_fuzz.rs b/examples/common_issues/arbitrary-limit-inputs-5/trident-tests/fuzz_0/test_fuzz.rs index e4373d22..0e290eea 100644 --- a/examples/common_issues/arbitrary-limit-inputs-5/trident-tests/fuzz_0/test_fuzz.rs +++ b/examples/common_issues/arbitrary-limit-inputs-5/trident-tests/fuzz_0/test_fuzz.rs @@ -26,7 +26,7 @@ fn main() { None, processor!(entry), ); - let config = Config::new(); + let config = TridentConfig::new(); let mut client = TridentSVM::new_client(&[program], &config); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : Config |); + fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : TridentConfig |); } diff --git a/examples/cpi/cpi-metaplex-7/trident-tests/fuzz_0/test_fuzz.rs b/examples/cpi/cpi-metaplex-7/trident-tests/fuzz_0/test_fuzz.rs index dd2f717c..e45a1139 100644 --- a/examples/cpi/cpi-metaplex-7/trident-tests/fuzz_0/test_fuzz.rs +++ b/examples/cpi/cpi-metaplex-7/trident-tests/fuzz_0/test_fuzz.rs @@ -27,7 +27,7 @@ fn main() { processor!(entry), ); - let config = Config::new(); + let config = TridentConfig::new(); let mut client = TridentSVM::new_client(&[program], &config); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : Config |); + fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : TridentConfig |); } diff --git a/examples/cpi/simple-cpi-6/trident-tests/fuzz_0/test_fuzz.rs b/examples/cpi/simple-cpi-6/trident-tests/fuzz_0/test_fuzz.rs index 98ed5b3b..670b55f7 100644 --- a/examples/cpi/simple-cpi-6/trident-tests/fuzz_0/test_fuzz.rs +++ b/examples/cpi/simple-cpi-6/trident-tests/fuzz_0/test_fuzz.rs @@ -33,7 +33,7 @@ fn main() { None, processor!(entry_caller), ); - let config = Config::new(); + let config = TridentConfig::new(); let mut client = TridentSVM::new_client(&[program_callee, program_caller], &config); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : Config |); + fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : TridentConfig |); } diff --git a/examples/hello_world/trident-tests/fuzz_0/test_fuzz.rs b/examples/hello_world/trident-tests/fuzz_0/test_fuzz.rs index 2879638b..94db656b 100644 --- a/examples/hello_world/trident-tests/fuzz_0/test_fuzz.rs +++ b/examples/hello_world/trident-tests/fuzz_0/test_fuzz.rs @@ -26,7 +26,7 @@ fn main() { None, processor!(entry_hello_world), ); - let config = Config::new(); + let config = TridentConfig::new(); let mut client = TridentSVM::new_client(&[program_hello_world], &config); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : Config |); + fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : InstructionsSequence , client : TridentSVM , config : TridentConfig |); }