diff --git a/examples/fuzz-tests/arbitrary-custom-types-4/.gitignore b/examples/fuzz-tests/arbitrary-custom-types-4/.gitignore index 4d41eb4da..3e0467a9e 100644 --- a/examples/fuzz-tests/arbitrary-custom-types-4/.gitignore +++ b/examples/fuzz-tests/arbitrary-custom-types-4/.gitignore @@ -7,4 +7,3 @@ node_modules test-ledger .yarn trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target -trident-tests/fuzz_tests/fuzzing/afl/afl_target diff --git a/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.lock b/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.lock index 4e21eb6c0..43f766f47 100644 --- a/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.lock +++ b/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "afl" -version = "0.15.10" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21e10b6947189c5ff61343b5354e9ad1c1722bd47b69cd0a6b49e5fa7f7ecf6" +checksum = "80bb240a3b9ff18002142c1a736e98046461d51a694d687c3e7329b456ab0fe4" dependencies = [ "home", "libc", @@ -974,9 +974,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -2942,9 +2942,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" [[package]] name = "pbkdf2" @@ -5765,7 +5765,6 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "indexmap 1.9.3", "serde", ] @@ -5775,6 +5774,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -5888,28 +5888,22 @@ dependencies = [ "anyhow", "arbitrary", "bincode", - "borsh 0.10.4", "cargo_metadata", "convert_case", "fehler", "futures", "honggfuzz", - "indicatif", - "log", "pathdiff", - "proc-macro2", "quinn-proto", "quote", - "regex", "serde", "serde_json", "solana-program-test", "solana-sdk", - "syn 1.0.109", + "syn 2.0.79", "thiserror", "tokio", - "toml 0.5.11", - "trident-derive-accounts-snapshots", + "toml 0.8.19", "trident-derive-displayix", "trident-derive-fuzz-test-executor", "trident-fuzz", @@ -5954,7 +5948,6 @@ dependencies = [ "fehler", "prettytable", "rand 0.8.5", - "regex", "serde", "serde_json", "solana-banks-client", @@ -5964,7 +5957,7 @@ dependencies = [ "spl-token", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", ] [[package]] diff --git a/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.toml b/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.toml index 245186370..daa4c9e62 100644 --- a/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.toml +++ b/examples/fuzz-tests/arbitrary-custom-types-4/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["programs/*", "trident-tests/fuzz_tests"] + [profile.release] overflow-checks = true lto = "fat" diff --git a/examples/fuzz-tests/arbitrary-custom-types-4/Trident.toml b/examples/fuzz-tests/arbitrary-custom-types-4/Trident.toml index 524c2d903..b976b8222 100644 --- a/examples/fuzz-tests/arbitrary-custom-types-4/Trident.toml +++ b/examples/fuzz-tests/arbitrary-custom-types-4/Trident.toml @@ -29,42 +29,6 @@ max_file_size = 1048576 # Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) save_all = false -[afl] -# Target compilation directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"]). -# To not clash with cargo build's default target directory. -cargo_target_dir = "" -# AFL working input directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"]). -afl_workspace_in = "" -# AFL working output directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"]). -afl_workspace_out = "" -# fuzz for an approx. no. of total executions then terminate -# Note: not precise and can have several more executions. -# (default: 0 [no limit]). -execs = 0 -# fuzz for a specified time then terminate (fuzz time only!) -# (default: 0 [no limit]). -seconds = 0 - -[[afl.seeds]] -# Filename under which the test input is generated. -# The location of file is afl_workspace_in directory. -# (default: "" ["trident-seed"]). -file_name = "trident-seed" -# String used as seed. -# (default: "" ["0"]). -seed = "" -# If the file already exists at specific location, -# select if override. -# (default: false). -override_file = false -# Number of randomly generated bytes. -# (default: 0). -bytes_count = 20 - - [fuzz] # Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false) allow_duplicate_txs = false diff --git a/examples/fuzz-tests/arbitrary-custom-types-4/programs/arbitrary-custom-types-4/Cargo.toml b/examples/fuzz-tests/arbitrary-custom-types-4/programs/arbitrary-custom-types-4/Cargo.toml index 981f60fd5..1b7723837 100644 --- a/examples/fuzz-tests/arbitrary-custom-types-4/programs/arbitrary-custom-types-4/Cargo.toml +++ b/examples/fuzz-tests/arbitrary-custom-types-4/programs/arbitrary-custom-types-4/Cargo.toml @@ -18,6 +18,11 @@ idl-build = ["anchor-lang/idl-build"] trident-fuzzing = ["dep:trident-fuzz"] [dependencies] -trident-derive-accounts-snapshots = { path = "../../../../../crates/fuzz/derive/accounts_snapshots" } -trident-fuzz = { path = "../../../../../crates/fuzz", optional = true } anchor-lang = "0.30.1" + +[dependencies.trident-derive-accounts-snapshots] +path = "../../../../../crates/fuzz/derive/accounts_snapshots" + +[dependencies.trident-fuzz] +path = "../../../../../crates/fuzz" +optional = true diff --git a/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs b/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs index 09026b8b5..50e061c07 100644 --- a/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs +++ b/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs @@ -1,10 +1,13 @@ use solana_sdk::native_token::LAMPORTS_PER_SOL; use trident_client::fuzzing::*; - -use arbitrary_custom_types_4::trident_fuzz_initialize_snapshot::InitializeAlias; -use arbitrary_custom_types_4::trident_fuzz_update_snapshot::UpdateAlias; +/// Link the relevant Account Context Alias from the program. +/// Aliases are generated by the `AccountsSnapshots` macro. type InitializeSnapshot<'info> = InitializeAlias<'info>; type UpdateSnapshot<'info> = UpdateAlias<'info>; +use arbitrary_custom_types_4::trident_fuzz_initialize_snapshot::InitializeAlias; +use arbitrary_custom_types_4::trident_fuzz_update_snapshot::UpdateAlias; +/// FuzzInstruction contains all available Instructions. +/// Below, the instruction arguments (accounts and data) are defined. #[derive(Arbitrary, DisplayIx, FuzzTestExecutor)] pub enum FuzzInstruction { Initialize(Initialize), @@ -21,6 +24,11 @@ pub struct InitializeAccounts { pub user: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct InitializeData {} #[derive(Arbitrary, Debug)] @@ -33,18 +41,29 @@ pub struct UpdateAccounts { pub counter: AccountId, pub authority: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct UpdateData { - pub input: InputUpdatePrameters, - pub variant: InputUpdateVariant, + pub input: InputUpdatePrametersTrident, + pub variant: InputUpdateVariantTrident, } +///IxOps implementation for `Initialize` with all required functions. impl<'info> IxOps<'info> for Initialize { type IxData = arbitrary_custom_types_4::instruction::Initialize; type IxAccounts = FuzzAccounts; type IxSnapshot = InitializeSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { arbitrary_custom_types_4::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -53,6 +72,12 @@ impl<'info> IxOps<'info> for Initialize { let data = arbitrary_custom_types_4::instruction::Initialize {}; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -78,13 +103,19 @@ impl<'info> IxOps<'info> for Initialize { Ok((vec![user, counter], acc_meta)) } } +///IxOps implementation for `Update` with all required functions. impl<'info> IxOps<'info> for Update { type IxData = arbitrary_custom_types_4::instruction::Update; type IxAccounts = FuzzAccounts; type IxSnapshot = UpdateSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { arbitrary_custom_types_4::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -96,6 +127,12 @@ impl<'info> IxOps<'info> for Update { let data = arbitrary_custom_types_4::instruction::Update { input, variant }; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -120,8 +157,8 @@ impl<'info> IxOps<'info> for Update { Ok((vec![user], acc_meta)) } } -#[doc = r" Use AccountsStorage where T can be one of:"] -#[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] +/// Use AccountsStorage where T can be one of: +/// Keypair, PdaStore, TokenStore, MintStore, ProgramStore #[derive(Default)] pub struct FuzzAccounts { user: AccountsStorage, @@ -135,32 +172,36 @@ pub struct FuzzAccounts { // ------------------------------------------------------------------- // Use arbitrary section #[derive(Arbitrary, Debug, Clone, Copy)] -pub struct InputUpdatePrameters { +pub struct InputUpdatePrametersTrident { pub input1: u8, pub input2: u8, } #[derive(Arbitrary, Debug, Clone, Copy)] -pub enum InputUpdateVariant { +pub enum InputUpdateVariantTrident { UpdateVariant1, UpdateVariant2, } -impl std::convert::From for arbitrary_custom_types_4::InputUpdatePrameters { - fn from(val: InputUpdatePrameters) -> Self { +impl std::convert::From + for arbitrary_custom_types_4::InputUpdatePrameters +{ + fn from(val: InputUpdatePrametersTrident) -> Self { arbitrary_custom_types_4::InputUpdatePrameters { input1: val.input1, input2: val.input2, } } } -impl std::convert::From for arbitrary_custom_types_4::InputUpdateVariant { - fn from(val: InputUpdateVariant) -> Self { +impl std::convert::From + for arbitrary_custom_types_4::InputUpdateVariant +{ + fn from(val: InputUpdateVariantTrident) -> Self { match val { - InputUpdateVariant::UpdateVariant1 => { + InputUpdateVariantTrident::UpdateVariant1 => { arbitrary_custom_types_4::InputUpdateVariant::UpdateVariant1 } - InputUpdateVariant::UpdateVariant2 => { + InputUpdateVariantTrident::UpdateVariant2 => { arbitrary_custom_types_4::InputUpdateVariant::UpdateVariant2 } } diff --git a/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index db072d0b3..dff433797 100644 --- a/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/arbitrary-custom-types-4/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -2,15 +2,22 @@ use fuzz_instructions::Initialize; use fuzz_instructions::Update; use trident_client::fuzzing::*; mod fuzz_instructions; - use arbitrary_custom_types_4::entry as entry_arbitrary_custom_types_4; use arbitrary_custom_types_4::ID as PROGRAM_ID_ARBITRARY_CUSTOM_TYPES_4; use fuzz_instructions::FuzzInstruction; - const PROGRAM_NAME_ARBITRARY_CUSTOM_TYPES_4: &str = "arbitrary_custom_types_4"; - struct MyFuzzData; - +/// Define instruction sequences for invocation. +/// `pre_ixs` runs at the start, `ixs` in the middle, and `post_ixs` at the end. +/// For example, to call `InitializeFn` at the start of each fuzzing iteration: +/// ``` +/// fn pre_ixs(u: &mut arbitrary::Unstructured) -> +/// arbitrary::Result> { +/// let init = FuzzInstruction::InitializeFn(InitializeFn::arbitrary(u)?); +/// Ok(vec![init]) +/// } +/// ``` +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences impl FuzzDataBuilder for MyFuzzData { fn pre_ixs(u: &mut arbitrary::Unstructured) -> arbitrary::Result> { let init = FuzzInstruction::Initialize(Initialize::arbitrary(u)?); @@ -18,7 +25,8 @@ impl FuzzDataBuilder for MyFuzzData { Ok(vec![init, update]) } } - +/// `fn fuzz_iteration` runs during every fuzzing iteration. +/// Modification is not required. fn fuzz_iteration + std::fmt::Display, U>( fuzz_data: FuzzData, config: &Config, @@ -28,16 +36,12 @@ fn fuzz_iteration + std::fmt::Display, U>( &PROGRAM_ID_ARBITRARY_CUSTOM_TYPES_4, processor!(convert_entry!(entry_arbitrary_custom_types_4)), ); - let mut client = ProgramTestClientBlocking::new(&[fuzzing_program_arbitrary_custom_types_4], config) .unwrap(); - let _ = fuzz_data.run_with_runtime(&mut client, config); } - fn main() { let config = Config::new(); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : MyFuzzData | { fuzz_iteration (fuzz_data , & config) ; }); } diff --git a/examples/fuzz-tests/arbitrary-limit-inputs-5/.gitignore b/examples/fuzz-tests/arbitrary-limit-inputs-5/.gitignore index edc161d20..31f8853b5 100644 --- a/examples/fuzz-tests/arbitrary-limit-inputs-5/.gitignore +++ b/examples/fuzz-tests/arbitrary-limit-inputs-5/.gitignore @@ -6,4 +6,3 @@ node_modules test-ledger .yarn trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target -trident-tests/fuzz_tests/fuzzing/afl/afl_target diff --git a/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.lock b/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.lock index 37ebdbd3d..692d75789 100644 --- a/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.lock +++ b/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "afl" -version = "0.15.10" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21e10b6947189c5ff61343b5354e9ad1c1722bd47b69cd0a6b49e5fa7f7ecf6" +checksum = "80bb240a3b9ff18002142c1a736e98046461d51a694d687c3e7329b456ab0fe4" dependencies = [ "home", "libc", @@ -990,9 +990,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -2959,9 +2959,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" [[package]] name = "pbkdf2" @@ -5965,7 +5965,6 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "indexmap 1.9.3", "serde", ] @@ -5975,6 +5974,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -6088,27 +6088,22 @@ dependencies = [ "anyhow", "arbitrary", "bincode", - "borsh 0.10.4", "cargo_metadata", "convert_case", "fehler", "futures", "honggfuzz", - "indicatif", - "log", "pathdiff", - "proc-macro2", "quinn-proto", "quote", - "regex", "serde", "serde_json", "solana-program-test", "solana-sdk", - "syn 1.0.109", + "syn 2.0.79", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", "trident-derive-displayix", "trident-derive-fuzz-test-executor", "trident-fuzz", @@ -6153,7 +6148,6 @@ dependencies = [ "fehler", "prettytable", "rand 0.8.5", - "regex", "serde", "serde_json", "solana-banks-client", @@ -6163,7 +6157,7 @@ dependencies = [ "spl-token", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", ] [[package]] diff --git a/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.toml b/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.toml index 9783b3f09..97d1d6397 100644 --- a/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.toml +++ b/examples/fuzz-tests/arbitrary-limit-inputs-5/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = ["programs/*", "trident-tests/fuzz_tests"] resolver = "2" + [profile.release] overflow-checks = true lto = "fat" diff --git a/examples/fuzz-tests/arbitrary-limit-inputs-5/Trident.toml b/examples/fuzz-tests/arbitrary-limit-inputs-5/Trident.toml index de42d4676..6de0eb954 100644 --- a/examples/fuzz-tests/arbitrary-limit-inputs-5/Trident.toml +++ b/examples/fuzz-tests/arbitrary-limit-inputs-5/Trident.toml @@ -29,42 +29,6 @@ max_file_size = 1048576 # Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) save_all = false -[afl] -# Target compilation directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"]). -# To not clash with cargo build's default target directory. -cargo_target_dir = "" -# AFL working input directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"]). -afl_workspace_in = "" -# AFL working output directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"]). -afl_workspace_out = "" -# fuzz for an approx. no. of total executions then terminate -# Note: not precise and can have several more executions. -# (default: 0 [no limit]). -execs = 100 -# fuzz for a specified time then terminate (fuzz time only!) -# (default: 0 [no limit]). -seconds = 5 - -[[afl.seeds]] -# Filename under which the test input is generated. -# The location of file is afl_workspace_in directory. -# (default: "" ["trident-seed"]). -file_name = "trident-seed" -# String used as seed. -# (default: "" ["0"]). -seed = "" -# If the file already exists at specific location, -# select if override. -# (default: false). -override_file = false -# Number of randomly generated bytes. -# (default: 0). -bytes_count = 20 - - [fuzz] # Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false) allow_duplicate_txs = false diff --git a/examples/fuzz-tests/arbitrary-limit-inputs-5/programs/arbitrary-limit-inputs-5/Cargo.toml b/examples/fuzz-tests/arbitrary-limit-inputs-5/programs/arbitrary-limit-inputs-5/Cargo.toml index 2e68ebba0..84b90a2f2 100644 --- a/examples/fuzz-tests/arbitrary-limit-inputs-5/programs/arbitrary-limit-inputs-5/Cargo.toml +++ b/examples/fuzz-tests/arbitrary-limit-inputs-5/programs/arbitrary-limit-inputs-5/Cargo.toml @@ -18,7 +18,12 @@ idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"] trident-fuzzing = ["dep:trident-fuzz"] [dependencies] -trident-derive-accounts-snapshots = { path = "../../../../../crates/fuzz/derive/accounts_snapshots" } -trident-fuzz = { path = "../../../../../crates/fuzz", optional = true } anchor-lang = "0.30.1" anchor-spl = "0.30.1" + +[dependencies.trident-derive-accounts-snapshots] +path = "../../../../../crates/fuzz/derive/accounts_snapshots" + +[dependencies.trident-fuzz] +path = "../../../../../crates/fuzz" +optional = true diff --git a/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs b/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs index 3447f6ea8..6d355267b 100644 --- a/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs +++ b/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs @@ -1,11 +1,13 @@ use solana_sdk::native_token::LAMPORTS_PER_SOL; use trident_client::fuzzing::*; - -use arbitrary_limit_inputs_5::trident_fuzz_init_vesting_context_snapshot::InitVestingContextAlias; -use arbitrary_limit_inputs_5::trident_fuzz_withdraw_unlocked_snapshot::WithdrawUnlockedAlias; - +/// Link the relevant Account Context Alias from the program. +/// Aliases are generated by the `AccountsSnapshots` macro. type InitVestingSnapshot<'info> = InitVestingContextAlias<'info>; type WithdrawUnlockedSnapshot<'info> = WithdrawUnlockedAlias<'info>; +use arbitrary_limit_inputs_5::trident_fuzz_init_vesting_context_snapshot::InitVestingContextAlias; +use arbitrary_limit_inputs_5::trident_fuzz_withdraw_unlocked_snapshot::WithdrawUnlockedAlias; +/// FuzzInstruction contains all available Instructions. +/// Below, the instruction arguments (accounts and data) are defined. #[derive(Arbitrary, DisplayIx, FuzzTestExecutor)] pub enum FuzzInstruction { InitVesting(InitVesting), @@ -26,6 +28,11 @@ pub struct InitVestingAccounts { pub _token_program: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Debug)] pub struct InitVestingData { pub recipient: AccountId, @@ -40,7 +47,6 @@ pub struct InitVestingData { // #[arbitrary(with = |u: &mut arbitrary::Unstructured| u.int_in_range(1..=1000))] pub interval: u64, } - // ------------------------------------------------------------------- // ------------------------------------------------------------------- // Implement Arbitrary @@ -91,7 +97,6 @@ impl<'a> Arbitrary<'a> for InitVestingData { // ------------------------------------------------------------------- // ------------------------------------------------------------------- } - #[derive(Arbitrary, Debug)] pub struct WithdrawUnlocked { pub accounts: WithdrawUnlockedAccounts, @@ -108,15 +113,26 @@ pub struct WithdrawUnlockedAccounts { pub _token_program: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct WithdrawUnlockedData {} +///IxOps implementation for `InitVesting` with all required functions. impl<'info> IxOps<'info> for InitVesting { type IxData = arbitrary_limit_inputs_5::instruction::InitVesting; type IxAccounts = FuzzAccounts; type IxSnapshot = InitVestingSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { arbitrary_limit_inputs_5::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, client: &mut impl FuzzClient, @@ -136,6 +152,12 @@ impl<'info> IxOps<'info> for InitVesting { }; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -211,13 +233,19 @@ impl<'info> IxOps<'info> for InitVesting { Ok((vec![sender], acc_meta)) } } +///IxOps implementation for `WithdrawUnlocked` with all required functions. impl<'info> IxOps<'info> for WithdrawUnlocked { type IxData = arbitrary_limit_inputs_5::instruction::WithdrawUnlocked; type IxAccounts = FuzzAccounts; type IxSnapshot = WithdrawUnlockedSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { arbitrary_limit_inputs_5::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -226,6 +254,12 @@ impl<'info> IxOps<'info> for WithdrawUnlocked { let data = arbitrary_limit_inputs_5::instruction::WithdrawUnlocked {}; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -337,8 +371,8 @@ impl<'info> IxOps<'info> for WithdrawUnlocked { Ok(()) } } -#[doc = r" Use AccountsStorage where T can be one of:"] -#[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] +/// Use AccountsStorage where T can be one of: +/// Keypair, PdaStore, TokenStore, MintStore, ProgramStore #[derive(Default)] pub struct FuzzAccounts { // No need to fuzz Token Program diff --git a/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index dcbfc10b0..da70edad3 100644 --- a/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/arbitrary-limit-inputs-5/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -2,15 +2,22 @@ use fuzz_instructions::InitVesting; use fuzz_instructions::WithdrawUnlocked; use trident_client::fuzzing::*; mod fuzz_instructions; - use arbitrary_limit_inputs_5::entry as entry_arbitrary_limit_inputs_5; use arbitrary_limit_inputs_5::ID as PROGRAM_ID_ARBITRARY_LIMIT_INPUTS_5; use fuzz_instructions::FuzzInstruction; - const PROGRAM_NAME_ARBITRARY_LIMIT_INPUTS_5: &str = "arbitrary_limit_inputs_5"; - struct MyFuzzData; - +/// Define instruction sequences for invocation. +/// `pre_ixs` runs at the start, `ixs` in the middle, and `post_ixs` at the end. +/// For example, to call `InitializeFn` at the start of each fuzzing iteration: +/// ``` +/// fn pre_ixs(u: &mut arbitrary::Unstructured) -> +/// arbitrary::Result> { +/// let init = FuzzInstruction::InitializeFn(InitializeFn::arbitrary(u)?); +/// Ok(vec![init]) +/// } +/// ``` +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences impl FuzzDataBuilder for MyFuzzData { fn pre_ixs(u: &mut arbitrary::Unstructured) -> arbitrary::Result> { let init_ix = FuzzInstruction::InitVesting(InitVesting::arbitrary(u)?); @@ -25,7 +32,8 @@ impl FuzzDataBuilder for MyFuzzData { Ok(vec![]) } } - +/// `fn fuzz_iteration` runs during every fuzzing iteration. +/// Modification is not required. fn fuzz_iteration + std::fmt::Display, U>( fuzz_data: FuzzData, config: &Config, @@ -35,16 +43,12 @@ fn fuzz_iteration + std::fmt::Display, U>( &PROGRAM_ID_ARBITRARY_LIMIT_INPUTS_5, processor!(convert_entry!(entry_arbitrary_limit_inputs_5)), ); - let mut client = ProgramTestClientBlocking::new(&[fuzzing_program_arbitrary_limit_inputs_5], config) .unwrap(); - let _ = fuzz_data.run_with_runtime(&mut client, config); } - fn main() { let config = Config::new(); - - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : MyFuzzData | { fuzz_iteration (fuzz_data , &config) ; }); + fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : MyFuzzData | { fuzz_iteration (fuzz_data , & config) ; }); } diff --git a/examples/fuzz-tests/cpi-metaplex-7/.gitignore b/examples/fuzz-tests/cpi-metaplex-7/.gitignore index edc161d20..31f8853b5 100644 --- a/examples/fuzz-tests/cpi-metaplex-7/.gitignore +++ b/examples/fuzz-tests/cpi-metaplex-7/.gitignore @@ -6,4 +6,3 @@ node_modules test-ledger .yarn trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target -trident-tests/fuzz_tests/fuzzing/afl/afl_target diff --git a/examples/fuzz-tests/cpi-metaplex-7/Cargo.lock b/examples/fuzz-tests/cpi-metaplex-7/Cargo.lock index d55b8e82f..f15592be3 100644 --- a/examples/fuzz-tests/cpi-metaplex-7/Cargo.lock +++ b/examples/fuzz-tests/cpi-metaplex-7/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "afl" -version = "0.15.10" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21e10b6947189c5ff61343b5354e9ad1c1722bd47b69cd0a6b49e5fa7f7ecf6" +checksum = "80bb240a3b9ff18002142c1a736e98046461d51a694d687c3e7329b456ab0fe4" dependencies = [ "home", "libc", @@ -980,9 +980,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -2974,9 +2974,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" [[package]] name = "pbkdf2" @@ -5980,7 +5980,6 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "indexmap 1.9.3", "serde", ] @@ -5990,6 +5989,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -6103,28 +6103,22 @@ dependencies = [ "anyhow", "arbitrary", "bincode", - "borsh 0.10.4", "cargo_metadata", "convert_case", "fehler", "futures", "honggfuzz", - "indicatif", - "log", "pathdiff", - "proc-macro2", "quinn-proto", "quote", - "regex", "serde", "serde_json", "solana-program-test", "solana-sdk", - "syn 1.0.109", + "syn 2.0.79", "thiserror", "tokio", - "toml 0.5.11", - "trident-derive-accounts-snapshots", + "toml 0.8.19", "trident-derive-displayix", "trident-derive-fuzz-test-executor", "trident-fuzz", @@ -6169,7 +6163,6 @@ dependencies = [ "fehler", "prettytable", "rand 0.8.5", - "regex", "serde", "serde_json", "solana-banks-client", @@ -6179,7 +6172,7 @@ dependencies = [ "spl-token", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", ] [[package]] diff --git a/examples/fuzz-tests/cpi-metaplex-7/Cargo.toml b/examples/fuzz-tests/cpi-metaplex-7/Cargo.toml index 9783b3f09..97d1d6397 100644 --- a/examples/fuzz-tests/cpi-metaplex-7/Cargo.toml +++ b/examples/fuzz-tests/cpi-metaplex-7/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = ["programs/*", "trident-tests/fuzz_tests"] resolver = "2" + [profile.release] overflow-checks = true lto = "fat" diff --git a/examples/fuzz-tests/cpi-metaplex-7/Trident.toml b/examples/fuzz-tests/cpi-metaplex-7/Trident.toml index d7d33f864..e4ed7982e 100644 --- a/examples/fuzz-tests/cpi-metaplex-7/Trident.toml +++ b/examples/fuzz-tests/cpi-metaplex-7/Trident.toml @@ -29,42 +29,6 @@ max_file_size = 1048576 # Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) save_all = false -[afl] -# Target compilation directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"]). -# To not clash with cargo build's default target directory. -cargo_target_dir = "" -# AFL working input directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"]). -afl_workspace_in = "" -# AFL working output directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"]). -afl_workspace_out = "" -# fuzz for an approx. no. of total executions then terminate -# Note: not precise and can have several more executions. -# (default: 0 [no limit]). -execs = 10 -# fuzz for a specified time then terminate (fuzz time only!) -# (default: 0 [no limit]). -seconds = 0 - -[[afl.seeds]] -# Filename under which the test input is generated. -# The location of file is afl_workspace_in directory. -# (default: "" ["trident-seed"]). -file_name = "trident-seed" -# String used as seed. -# (default: "" ["0"]). -seed = "" -# If the file already exists at specific location, -# select if override. -# (default: false). -override_file = false -# Number of randomly generated bytes. -# (default: 0). -bytes_count = 20 - - [fuzz] # Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false) allow_duplicate_txs = false diff --git a/examples/fuzz-tests/cpi-metaplex-7/programs/cpi-metaplex-7/Cargo.toml b/examples/fuzz-tests/cpi-metaplex-7/programs/cpi-metaplex-7/Cargo.toml index ad878cfa9..219209980 100644 --- a/examples/fuzz-tests/cpi-metaplex-7/programs/cpi-metaplex-7/Cargo.toml +++ b/examples/fuzz-tests/cpi-metaplex-7/programs/cpi-metaplex-7/Cargo.toml @@ -17,10 +17,14 @@ no-log-ix-name = [] idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"] trident-fuzzing = ["dep:trident-fuzz"] - [dependencies] anchor-lang = "0.30.1" anchor-spl = "0.30.1" mpl-token-metadata = "4.1.2" -trident-derive-accounts-snapshots = { path = "../../../../../crates/fuzz/derive/accounts_snapshots" } -trident-fuzz = { path = "../../../../../crates/fuzz", optional = true } + +[dependencies.trident-derive-accounts-snapshots] +path = "../../../../../crates/fuzz/derive/accounts_snapshots" + +[dependencies.trident-fuzz] +path = "../../../../../crates/fuzz" +optional = true diff --git a/examples/fuzz-tests/cpi-metaplex-7/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs b/examples/fuzz-tests/cpi-metaplex-7/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs index 0b54df8fd..ac5bd3995 100644 --- a/examples/fuzz-tests/cpi-metaplex-7/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs +++ b/examples/fuzz-tests/cpi-metaplex-7/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs @@ -1,9 +1,11 @@ use solana_sdk::native_token::LAMPORTS_PER_SOL; use trident_client::fuzzing::*; - -use cpi_metaplex_7::trident_fuzz_initialize_snapshot::InitializeAlias; - +/// Link the relevant Account Context Alias from the program. +/// Aliases are generated by the `AccountsSnapshots` macro. type InitializeSnapshot<'info> = InitializeAlias<'info>; +use cpi_metaplex_7::trident_fuzz_initialize_snapshot::InitializeAlias; +/// FuzzInstruction contains all available Instructions. +/// Below, the instruction arguments (accounts and data) are defined. #[derive(Arbitrary, DisplayIx, FuzzTestExecutor)] pub enum FuzzInstruction { Initialize(Initialize), @@ -22,6 +24,11 @@ pub struct InitializeAccounts { pub _system_program: AccountId, pub _token_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct InitializeData { pub input: u8, @@ -29,13 +36,19 @@ pub struct InitializeData { pub symbol: String, pub uri: String, } +///IxOps implementation for `Initialize` with all required functions. impl<'info> IxOps<'info> for Initialize { type IxData = cpi_metaplex_7::instruction::Initialize; type IxAccounts = FuzzAccounts; type IxSnapshot = InitializeSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { cpi_metaplex_7::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -49,6 +62,12 @@ impl<'info> IxOps<'info> for Initialize { }; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -81,8 +100,8 @@ impl<'info> IxOps<'info> for Initialize { Ok((signers, acc_meta)) } } -#[doc = r" Use AccountsStorage where T can be one of:"] -#[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] +/// Use AccountsStorage where T can be one of: +/// Keypair, PdaStore, TokenStore, MintStore, ProgramStore #[derive(Default)] pub struct FuzzAccounts { _metadata_account: AccountsStorage, diff --git a/examples/fuzz-tests/cpi-metaplex-7/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/cpi-metaplex-7/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index b1841345a..a1d7f2cc8 100644 --- a/examples/fuzz-tests/cpi-metaplex-7/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/cpi-metaplex-7/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -1,16 +1,22 @@ use fuzz_instructions::Initialize; use trident_client::fuzzing::*; - mod fuzz_instructions; - use cpi_metaplex_7::entry as entry_cpi_metaplex_7; use cpi_metaplex_7::ID as PROGRAM_ID_CPI_METAPLEX_7; use fuzz_instructions::FuzzInstruction; - const PROGRAM_NAME_CPI_METAPLEX_7: &str = "cpi_metaplex_7"; - struct MyFuzzData; - +/// Define instruction sequences for invocation. +/// `pre_ixs` runs at the start, `ixs` in the middle, and `post_ixs` at the end. +/// For example, to call `InitializeFn` at the start of each fuzzing iteration: +/// ``` +/// fn pre_ixs(u: &mut arbitrary::Unstructured) -> +/// arbitrary::Result> { +/// let init = FuzzInstruction::InitializeFn(InitializeFn::arbitrary(u)?); +/// Ok(vec![init]) +/// } +/// ``` +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences impl FuzzDataBuilder for MyFuzzData { fn pre_ixs(u: &mut arbitrary::Unstructured) -> arbitrary::Result> { let init = FuzzInstruction::Initialize(Initialize::arbitrary(u)?); @@ -23,7 +29,8 @@ impl FuzzDataBuilder for MyFuzzData { Ok(vec![]) } } - +/// `fn fuzz_iteration` runs during every fuzzing iteration. +/// Modification is not required. fn fuzz_iteration + std::fmt::Display, U>( fuzz_data: FuzzData, config: &Config, @@ -33,15 +40,11 @@ fn fuzz_iteration + std::fmt::Display, U>( &PROGRAM_ID_CPI_METAPLEX_7, processor!(convert_entry!(entry_cpi_metaplex_7)), ); - let mut client = ProgramTestClientBlocking::new(&[fuzzing_program_cpi_metaplex_7], config).unwrap(); - let _ = fuzz_data.run_with_runtime(&mut client, config); } - fn main() { let config = Config::new(); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : MyFuzzData | { fuzz_iteration (fuzz_data , & config) ; }); } diff --git a/examples/fuzz-tests/hello_world/.gitignore b/examples/fuzz-tests/hello_world/.gitignore index 4d41eb4da..3e0467a9e 100644 --- a/examples/fuzz-tests/hello_world/.gitignore +++ b/examples/fuzz-tests/hello_world/.gitignore @@ -7,4 +7,3 @@ node_modules test-ledger .yarn trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target -trident-tests/fuzz_tests/fuzzing/afl/afl_target diff --git a/examples/fuzz-tests/hello_world/Cargo.lock b/examples/fuzz-tests/hello_world/Cargo.lock index 60f9702b1..65a3145ad 100644 --- a/examples/fuzz-tests/hello_world/Cargo.lock +++ b/examples/fuzz-tests/hello_world/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "afl" -version = "0.15.10" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21e10b6947189c5ff61343b5354e9ad1c1722bd47b69cd0a6b49e5fa7f7ecf6" +checksum = "80bb240a3b9ff18002142c1a736e98046461d51a694d687c3e7329b456ab0fe4" dependencies = [ "home", "libc", @@ -965,9 +965,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -5768,7 +5768,6 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "indexmap 1.9.3", "serde", ] @@ -5778,6 +5777,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -5891,27 +5891,22 @@ dependencies = [ "anyhow", "arbitrary", "bincode", - "borsh 0.10.4", "cargo_metadata", "convert_case", "fehler", "futures", "honggfuzz", - "indicatif", - "log", "pathdiff", - "proc-macro2", "quinn-proto", "quote", - "regex", "serde", "serde_json", "solana-program-test", "solana-sdk", - "syn 1.0.109", + "syn 2.0.79", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", "trident-derive-displayix", "trident-derive-fuzz-test-executor", "trident-fuzz", @@ -5956,7 +5951,6 @@ dependencies = [ "fehler", "prettytable", "rand 0.8.5", - "regex", "serde", "serde_json", "solana-banks-client", @@ -5966,7 +5960,7 @@ dependencies = [ "spl-token", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", ] [[package]] diff --git a/examples/fuzz-tests/hello_world/Trident.toml b/examples/fuzz-tests/hello_world/Trident.toml index 524c2d903..b976b8222 100644 --- a/examples/fuzz-tests/hello_world/Trident.toml +++ b/examples/fuzz-tests/hello_world/Trident.toml @@ -29,42 +29,6 @@ max_file_size = 1048576 # Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) save_all = false -[afl] -# Target compilation directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"]). -# To not clash with cargo build's default target directory. -cargo_target_dir = "" -# AFL working input directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"]). -afl_workspace_in = "" -# AFL working output directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"]). -afl_workspace_out = "" -# fuzz for an approx. no. of total executions then terminate -# Note: not precise and can have several more executions. -# (default: 0 [no limit]). -execs = 0 -# fuzz for a specified time then terminate (fuzz time only!) -# (default: 0 [no limit]). -seconds = 0 - -[[afl.seeds]] -# Filename under which the test input is generated. -# The location of file is afl_workspace_in directory. -# (default: "" ["trident-seed"]). -file_name = "trident-seed" -# String used as seed. -# (default: "" ["0"]). -seed = "" -# If the file already exists at specific location, -# select if override. -# (default: false). -override_file = false -# Number of randomly generated bytes. -# (default: 0). -bytes_count = 20 - - [fuzz] # Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false) allow_duplicate_txs = false diff --git a/examples/fuzz-tests/hello_world/programs/hello_world/Cargo.toml b/examples/fuzz-tests/hello_world/programs/hello_world/Cargo.toml index d44efce39..fe31e5c5d 100644 --- a/examples/fuzz-tests/hello_world/programs/hello_world/Cargo.toml +++ b/examples/fuzz-tests/hello_world/programs/hello_world/Cargo.toml @@ -18,6 +18,11 @@ idl-build = ["anchor-lang/idl-build"] trident-fuzzing = ["dep:trident-fuzz"] [dependencies] -trident-derive-accounts-snapshots = { path = "../../../../../crates/fuzz/derive/accounts_snapshots" } -trident-fuzz = { path = "../../../../../crates/fuzz", optional = true } anchor-lang = "0.30.1" + +[dependencies.trident-derive-accounts-snapshots] +path = "../../../../../crates/fuzz/derive/accounts_snapshots" + +[dependencies.trident-fuzz] +path = "../../../../../crates/fuzz" +optional = true diff --git a/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs b/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs index e9e74ac1c..4c5d1fa18 100644 --- a/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs +++ b/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs @@ -1,9 +1,11 @@ use solana_sdk::native_token::LAMPORTS_PER_SOL; use trident_client::fuzzing::*; - -use hello_world::trident_fuzz_initialize_context_snapshot::InitializeContextAlias; - +/// Link the relevant Account Context Alias from the program. +/// Aliases are generated by the `AccountsSnapshots` macro. type InitializeFnSnapshot<'info> = InitializeContextAlias<'info>; +use hello_world::trident_fuzz_initialize_context_snapshot::InitializeContextAlias; +/// FuzzInstruction contains all available Instructions. +/// Below, the instruction arguments (accounts and data) are defined. #[derive(Arbitrary, DisplayIx, FuzzTestExecutor)] pub enum FuzzInstruction { InitializeFn(InitializeFn), @@ -19,17 +21,28 @@ pub struct InitializeFnAccounts { pub hello_world_account: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct InitializeFnData { pub input: u8, } +///IxOps implementation for `InitializeFn` with all required functions. impl<'info> IxOps<'info> for InitializeFn { type IxData = hello_world::instruction::InitializeFn; type IxAccounts = FuzzAccounts; type IxSnapshot = InitializeFnSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { hello_world::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -40,6 +53,12 @@ impl<'info> IxOps<'info> for InitializeFn { }; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -82,8 +101,8 @@ impl<'info> IxOps<'info> for InitializeFn { Ok(()) } } -#[doc = r" Use AccountsStorage where T can be one of:"] -#[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] +/// Use AccountsStorage where T can be one of: +/// Keypair, PdaStore, TokenStore, MintStore, ProgramStore #[derive(Default)] pub struct FuzzAccounts { author: AccountsStorage, diff --git a/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index 15c07bbfa..9df4c363e 100644 --- a/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/hello_world/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -1,16 +1,22 @@ use fuzz_instructions::InitializeFn; use trident_client::fuzzing::*; - mod fuzz_instructions; - use fuzz_instructions::FuzzInstruction; use hello_world::entry as entry_hello_world; use hello_world::ID as PROGRAM_ID_HELLO_WORLD; - const PROGRAM_NAME_HELLO_WORLD: &str = "hello_world"; - struct MyFuzzData; - +/// Define instruction sequences for invocation. +/// `pre_ixs` runs at the start, `ixs` in the middle, and `post_ixs` at the end. +/// For example, to call `InitializeFn` at the start of each fuzzing iteration: +/// ``` +/// fn pre_ixs(u: &mut arbitrary::Unstructured) -> +/// arbitrary::Result> { +/// let init = FuzzInstruction::InitializeFn(InitializeFn::arbitrary(u)?); +/// Ok(vec![init]) +/// } +/// ``` +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences impl FuzzDataBuilder for MyFuzzData { fn pre_ixs(u: &mut arbitrary::Unstructured) -> arbitrary::Result> { let init = FuzzInstruction::InitializeFn(InitializeFn::arbitrary(u)?); @@ -23,7 +29,8 @@ impl FuzzDataBuilder for MyFuzzData { Ok(vec![]) } } - +/// `fn fuzz_iteration` runs during every fuzzing iteration. +/// Modification is not required. fn fuzz_iteration + std::fmt::Display, U>( fuzz_data: FuzzData, config: &Config, @@ -33,15 +40,11 @@ fn fuzz_iteration + std::fmt::Display, U>( &PROGRAM_ID_HELLO_WORLD, processor!(convert_entry!(entry_hello_world)), ); - let mut client = ProgramTestClientBlocking::new(&[fuzzing_program_hello_world], config).unwrap(); - let _ = fuzz_data.run_with_runtime(&mut client, config); } - fn main() { let config = Config::new(); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : MyFuzzData | { fuzz_iteration (fuzz_data , & config) ; }); } diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/.gitignore b/examples/fuzz-tests/incorrect-integer-arithmetic-3/.gitignore index 4d41eb4da..3e0467a9e 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/.gitignore +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/.gitignore @@ -7,4 +7,3 @@ node_modules test-ledger .yarn trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target -trident-tests/fuzz_tests/fuzzing/afl/afl_target diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.lock b/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.lock index 8f7e0b777..f772d3a27 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.lock +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "afl" -version = "0.15.10" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21e10b6947189c5ff61343b5354e9ad1c1722bd47b69cd0a6b49e5fa7f7ecf6" +checksum = "80bb240a3b9ff18002142c1a736e98046461d51a694d687c3e7329b456ab0fe4" dependencies = [ "home", "libc", @@ -980,9 +980,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -2959,9 +2959,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" [[package]] name = "pbkdf2" @@ -5965,7 +5965,6 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "indexmap 1.9.3", "serde", ] @@ -5975,6 +5974,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -6088,28 +6088,22 @@ dependencies = [ "anyhow", "arbitrary", "bincode", - "borsh 0.10.4", "cargo_metadata", "convert_case", "fehler", "futures", "honggfuzz", - "indicatif", - "log", "pathdiff", - "proc-macro2", "quinn-proto", "quote", - "regex", "serde", "serde_json", "solana-program-test", "solana-sdk", - "syn 1.0.109", + "syn 2.0.79", "thiserror", "tokio", - "toml 0.5.11", - "trident-derive-accounts-snapshots", + "toml 0.8.19", "trident-derive-displayix", "trident-derive-fuzz-test-executor", "trident-fuzz", @@ -6154,7 +6148,6 @@ dependencies = [ "fehler", "prettytable", "rand 0.8.5", - "regex", "serde", "serde_json", "solana-banks-client", @@ -6164,7 +6157,7 @@ dependencies = [ "spl-token", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", ] [[package]] diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.toml b/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.toml index 245186370..daa4c9e62 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.toml +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["programs/*", "trident-tests/fuzz_tests"] + [profile.release] overflow-checks = true lto = "fat" diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/Trident.toml b/examples/fuzz-tests/incorrect-integer-arithmetic-3/Trident.toml index 524c2d903..b976b8222 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/Trident.toml +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/Trident.toml @@ -29,42 +29,6 @@ max_file_size = 1048576 # Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) save_all = false -[afl] -# Target compilation directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"]). -# To not clash with cargo build's default target directory. -cargo_target_dir = "" -# AFL working input directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"]). -afl_workspace_in = "" -# AFL working output directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"]). -afl_workspace_out = "" -# fuzz for an approx. no. of total executions then terminate -# Note: not precise and can have several more executions. -# (default: 0 [no limit]). -execs = 0 -# fuzz for a specified time then terminate (fuzz time only!) -# (default: 0 [no limit]). -seconds = 0 - -[[afl.seeds]] -# Filename under which the test input is generated. -# The location of file is afl_workspace_in directory. -# (default: "" ["trident-seed"]). -file_name = "trident-seed" -# String used as seed. -# (default: "" ["0"]). -seed = "" -# If the file already exists at specific location, -# select if override. -# (default: false). -override_file = false -# Number of randomly generated bytes. -# (default: 0). -bytes_count = 20 - - [fuzz] # Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false) allow_duplicate_txs = false diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/programs/incorrect-integer-arithmetic-3/Cargo.toml b/examples/fuzz-tests/incorrect-integer-arithmetic-3/programs/incorrect-integer-arithmetic-3/Cargo.toml index 5218a3e81..a13f69157 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/programs/incorrect-integer-arithmetic-3/Cargo.toml +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/programs/incorrect-integer-arithmetic-3/Cargo.toml @@ -18,7 +18,12 @@ idl-build = ["anchor-lang/idl-build", "anchor-spl/idl-build"] trident-fuzzing = ["dep:trident-fuzz"] [dependencies] -trident-derive-accounts-snapshots = { path = "../../../../../crates/fuzz/derive/accounts_snapshots" } -trident-fuzz = { path = "../../../../../crates/fuzz", optional = true } anchor-lang = "0.30.1" anchor-spl = "0.30.1" + +[dependencies.trident-derive-accounts-snapshots] +path = "../../../../../crates/fuzz/derive/accounts_snapshots" + +[dependencies.trident-fuzz] +path = "../../../../../crates/fuzz" +optional = true diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/Cargo.toml b/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/Cargo.toml index 8b32b2da1..65f8709d8 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/Cargo.toml +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/Cargo.toml @@ -16,7 +16,6 @@ anchor-spl = "0.30.1" [dependencies.trident-client] path = "../../../../../crates/client" - [dependencies.incorrect-integer-arithmetic-3] path = "../../programs/incorrect-integer-arithmetic-3" features = ["trident-fuzzing"] diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs b/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs index ca2d59394..59a0951fe 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs @@ -1,11 +1,13 @@ use solana_sdk::native_token::LAMPORTS_PER_SOL; use trident_client::fuzzing::*; - -use incorrect_integer_arithmetic_3::trident_fuzz_init_vesting_snapshot::InitVestingAlias; -use incorrect_integer_arithmetic_3::trident_fuzz_withdraw_unlocked_snapshot::WithdrawUnlockedAlias; - +/// Link the relevant Account Context Alias from the program. +/// Aliases are generated by the `AccountsSnapshots` macro. type InitVestingSnapshot<'info> = InitVestingAlias<'info>; type WithdrawUnlockedSnapshot<'info> = WithdrawUnlockedAlias<'info>; +use incorrect_integer_arithmetic_3::trident_fuzz_init_vesting_snapshot::InitVestingAlias; +use incorrect_integer_arithmetic_3::trident_fuzz_withdraw_unlocked_snapshot::WithdrawUnlockedAlias; +/// FuzzInstruction contains all available Instructions. +/// Below, the instruction arguments (accounts and data) are defined. #[derive(Arbitrary, DisplayIx, FuzzTestExecutor)] pub enum FuzzInstruction { InitVesting(InitVesting), @@ -26,6 +28,11 @@ pub struct InitVestingAccounts { pub _token_program: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct InitVestingData { pub recipient: AccountId, @@ -56,15 +63,26 @@ pub struct WithdrawUnlockedAccounts { pub _token_program: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct WithdrawUnlockedData {} +///IxOps implementation for `InitVesting` with all required functions. impl<'info> IxOps<'info> for InitVesting { type IxData = incorrect_integer_arithmetic_3::instruction::InitVesting; type IxAccounts = FuzzAccounts; type IxSnapshot = InitVestingSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { incorrect_integer_arithmetic_3::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, client: &mut impl FuzzClient, @@ -75,7 +93,6 @@ impl<'info> IxOps<'info> for InitVesting { client, 10 * LAMPORTS_PER_SOL, ); - let data = incorrect_integer_arithmetic_3::instruction::InitVesting { recipient: recipient.pubkey(), amount: self.data.amount, @@ -85,6 +102,12 @@ impl<'info> IxOps<'info> for InitVesting { }; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -160,13 +183,19 @@ impl<'info> IxOps<'info> for InitVesting { Ok((vec![sender], acc_meta)) } } +///IxOps implementation for `WithdrawUnlocked` with all required functions. impl<'info> IxOps<'info> for WithdrawUnlocked { type IxData = incorrect_integer_arithmetic_3::instruction::WithdrawUnlocked; type IxAccounts = FuzzAccounts; type IxSnapshot = WithdrawUnlockedSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { incorrect_integer_arithmetic_3::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -175,6 +204,12 @@ impl<'info> IxOps<'info> for WithdrawUnlocked { let data = incorrect_integer_arithmetic_3::instruction::WithdrawUnlocked {}; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -286,8 +321,8 @@ impl<'info> IxOps<'info> for WithdrawUnlocked { Ok(()) } } -#[doc = r" Use AccountsStorage where T can be one of:"] -#[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] +/// Use AccountsStorage where T can be one of: +/// Keypair, PdaStore, TokenStore, MintStore, ProgramStore #[derive(Default)] pub struct FuzzAccounts { // No need to fuzz Token Program diff --git a/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index 52a24491b..68d6410a9 100644 --- a/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/incorrect-integer-arithmetic-3/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -1,16 +1,22 @@ use fuzz_instructions::InitVesting; use trident_client::fuzzing::*; - mod fuzz_instructions; - use fuzz_instructions::FuzzInstruction; use incorrect_integer_arithmetic_3::entry as entry_incorrect_integer_arithmetic_3; use incorrect_integer_arithmetic_3::ID as PROGRAM_ID_INCORRECT_INTEGER_ARITHMETIC_3; - const PROGRAM_NAME_INCORRECT_INTEGER_ARITHMETIC_3: &str = "incorrect_integer_arithmetic_3"; - struct MyFuzzData; - +/// Define instruction sequences for invocation. +/// `pre_ixs` runs at the start, `ixs` in the middle, and `post_ixs` at the end. +/// For example, to call `InitializeFn` at the start of each fuzzing iteration: +/// ``` +/// fn pre_ixs(u: &mut arbitrary::Unstructured) -> +/// arbitrary::Result> { +/// let init = FuzzInstruction::InitializeFn(InitializeFn::arbitrary(u)?); +/// Ok(vec![init]) +/// } +/// ``` +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences impl FuzzDataBuilder for MyFuzzData { fn pre_ixs(u: &mut arbitrary::Unstructured) -> arbitrary::Result> { let init_ix = FuzzInstruction::InitVesting(InitVesting::arbitrary(u)?); @@ -18,7 +24,8 @@ impl FuzzDataBuilder for MyFuzzData { Ok(vec![init_ix]) } } - +/// `fn fuzz_iteration` runs during every fuzzing iteration. +/// Modification is not required. fn fuzz_iteration + std::fmt::Display, U>( fuzz_data: FuzzData, config: &Config, @@ -28,16 +35,12 @@ fn fuzz_iteration + std::fmt::Display, U>( &PROGRAM_ID_INCORRECT_INTEGER_ARITHMETIC_3, processor!(convert_entry!(entry_incorrect_integer_arithmetic_3)), ); - let mut client = ProgramTestClientBlocking::new(&[fuzzing_program_incorrect_integer_arithmetic_3], config) .unwrap(); - let _ = fuzz_data.run_with_runtime(&mut client, config); } - fn main() { let config = Config::new(); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : MyFuzzData | { fuzz_iteration (fuzz_data , & config) ; }); } diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/.gitignore b/examples/fuzz-tests/incorrect-ix-sequence-1/.gitignore index 4d41eb4da..3e0467a9e 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/.gitignore +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/.gitignore @@ -7,4 +7,3 @@ node_modules test-ledger .yarn trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target -trident-tests/fuzz_tests/fuzzing/afl/afl_target diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.lock b/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.lock index 8384782e2..ed03d9ef2 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.lock +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.lock @@ -14,19 +14,13 @@ dependencies = [ [[package]] name = "addr2line" -version = "0.22.0" +version = "0.24.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e4503c46a5c0c7844e948c9a4d6acd9f50cccb4de1c48eb9e291ea17470c678" +checksum = "dfbe277e56a376000877090da837660b4427aad530e3028d44e0bffe4f89a1c1" dependencies = [ "gimli", ] -[[package]] -name = "adler" -version = "1.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" - [[package]] name = "adler2" version = "2.0.0" @@ -71,9 +65,9 @@ dependencies = [ [[package]] name = "afl" -version = "0.15.10" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21e10b6947189c5ff61343b5354e9ad1c1722bd47b69cd0a6b49e5fa7f7ecf6" +checksum = "80bb240a3b9ff18002142c1a736e98046461d51a694d687c3e7329b456ab0fe4" dependencies = [ "home", "libc", @@ -562,9 +556,9 @@ dependencies = [ [[package]] name = "async-compression" -version = "0.4.12" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fec134f64e2bc57411226dfc4e52dec859ddfc7e711fc5e07b612584f000e4aa" +checksum = "0cb8f1d480b0ea3783ab015936d2a55c87e219676f0c0b7dec61494043f21857" dependencies = [ "brotli", "flate2", @@ -585,9 +579,9 @@ dependencies = [ [[package]] name = "async-trait" -version = "0.1.81" +version = "0.1.83" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6e0c28dcc82d7c8ead5cb13beb15405b57b8546e93215673ff8ca0349a028107" +checksum = "721cae7de5c34fbb2acd27e21e6d2cf7b886dce0c27388d46c4e6c47ea4318dd" dependencies = [ "proc-macro2", "quote", @@ -613,17 +607,17 @@ checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" [[package]] name = "backtrace" -version = "0.3.73" +version = "0.3.74" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5cc23269a4f8976d0a4d2e7109211a419fe30e8d88d677cd60b6bc79c5732e0a" +checksum = "8d82cb332cdfaed17ae235a638438ac4d4839913cc2af585c3c6746e8f8bee1a" dependencies = [ "addr2line", - "cc", "cfg-if", "libc", - "miniz_oxide 0.7.4", + "miniz_oxide", "object", "rustc-demangle", + "windows-targets 0.52.6", ] [[package]] @@ -838,9 +832,9 @@ dependencies = [ [[package]] name = "brotli" -version = "6.0.0" +version = "7.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "74f7971dbd9326d58187408ab83117d8ac1bb9c17b085fdacd1cf2f598719b6b" +checksum = "cc97b8f16f944bba54f0433f07e30be199b6dc2bd25937444bbad560bcea29bd" dependencies = [ "alloc-no-stdlib", "alloc-stdlib", @@ -916,9 +910,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.7.1" +version = "1.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8318a53db07bb3f8dca91a600466bdb3f2eaadeedfdbcf02e1accbad9271ba50" +checksum = "428d9aa8fbc0670b7b8d6030a7fadd0f86151cae55e4dbbece15f3780a3dfaf3" [[package]] name = "bzip2" @@ -971,9 +965,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -1720,12 +1714,12 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.33" +version = "1.0.34" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "324a1be68054ef05ad64b861cc9eaf1d623d2d8cb25b4bf2cb9cdd902b4bf253" +checksum = "a1b589b4dc103969ad3cf85c950899926ec64300a1a46d76c03a6072957036f0" dependencies = [ "crc32fast", - "miniz_oxide 0.8.0", + "miniz_oxide", ] [[package]] @@ -1760,9 +1754,9 @@ checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" [[package]] name = "futures" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "645c6916888f6cb6350d2550b80fb63e734897a8498abe35cfb732b6487804b0" +checksum = "65bc07b1a8bc7c85c5f2e110c476c7389b4554ba72af57d8445ea63a576b0876" dependencies = [ "futures-channel", "futures-core", @@ -1775,9 +1769,9 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "eac8f7d7865dcb88bd4373ab671c8cf4508703796caa2b1985a9ca867b3fcb78" +checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10" dependencies = [ "futures-core", "futures-sink", @@ -1785,15 +1779,15 @@ dependencies = [ [[package]] name = "futures-core" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dfc6580bb841c5a68e9ef15c77ccc837b40a7504914d52e47b8b0e9bbda25a1d" +checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e" [[package]] name = "futures-executor" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a576fc72ae164fca6b9db127eaa9a9dda0d61316034f33a0a0d4eda41f02b01d" +checksum = "1e28d1d997f585e54aebc3f97d39e72338912123a67330d723fdbb564d646c9f" dependencies = [ "futures-core", "futures-task", @@ -1802,15 +1796,15 @@ dependencies = [ [[package]] name = "futures-io" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a44623e20b9681a318efdd71c299b6b222ed6f231972bfe2f224ebad6311f0c1" +checksum = "9e5c1b78ca4aae1ac06c48a526a655760685149f0d465d21f37abfe57ce075c6" [[package]] name = "futures-macro" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87750cf4b7a4c0625b1529e4c543c2182106e4dedc60a2a6455e00d212c489ac" +checksum = "162ee34ebcb7c64a8abebc059ce0fee27c2262618d7b60ed8faf72fef13c3650" dependencies = [ "proc-macro2", "quote", @@ -1819,21 +1813,21 @@ dependencies = [ [[package]] name = "futures-sink" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9fb8e00e87438d937621c1c6269e53f536c14d3fbd6a042bb24879e57d474fb5" +checksum = "e575fab7d1e0dcb8d0c7bcf9a63ee213816ab51902e6d244a95819acacf1d4f7" [[package]] name = "futures-task" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38d84fa142264698cdce1a9f9172cf383a0c82de1bddcf3092901442c4097004" +checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988" [[package]] name = "futures-util" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d6401deb83407ab3da39eba7e33987a73c3df0c82b4bb5813ee871c19c41d48" +checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81" dependencies = [ "futures-channel", "futures-core", @@ -1906,9 +1900,9 @@ dependencies = [ [[package]] name = "gimli" -version = "0.29.0" +version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "40ecd4077b5ae9fd2e9e169b102c6c330d0605168eb0e8bf79952b256dbefffd" +checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" [[package]] name = "goblin" @@ -1936,7 +1930,7 @@ dependencies = [ "indexmap 2.4.0", "slab", "tokio", - "tokio-util 0.7.11", + "tokio-util 0.7.12", "tracing", ] @@ -2099,9 +2093,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.9.4" +version = "1.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fcc0b4a115bf80b728eb8ea024ad5bd707b615bfed49e0665b6e0f86fd082d9" +checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946" [[package]] name = "httpdate" @@ -2117,9 +2111,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.30" +version = "0.14.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a152ddd61dfaec7273fe8419ab357f33aee0d914c5f4efbf0d96fa749eea5ec9" +checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85" dependencies = [ "bytes", "futures-channel", @@ -2155,9 +2149,9 @@ dependencies = [ [[package]] name = "iana-time-zone" -version = "0.1.60" +version = "0.1.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7ffbb5a1b541ea2561f8c41c087286cc091e21e556a4f09a8f6cbf17b69b141" +checksum = "235e081f3925a06703c2d0117ea8b91f042756fd6e7a6e5d901e8ca1a996b220" dependencies = [ "android_system_properties", "core-foundation-sys", @@ -2286,9 +2280,9 @@ dependencies = [ [[package]] name = "ipnet" -version = "2.9.0" +version = "2.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f518f335dce6725a761382244631d86cf0ccb2863413590b31338feb467f9c3" +checksum = "ddc24109865250148c2e0f3d25d4f0f479571723792d3802153c60922a4fb708" [[package]] name = "is-terminal" @@ -2474,19 +2468,18 @@ dependencies = [ [[package]] name = "lz4" -version = "1.26.0" +version = "1.28.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "958b4caa893816eea05507c20cfe47574a43d9a697138a7872990bba8a0ece68" +checksum = "4d1febb2b4a79ddd1980eede06a8f7902197960aa0383ffcfdd62fe723036725" dependencies = [ - "libc", "lz4-sys", ] [[package]] name = "lz4-sys" -version = "1.10.0" +version = "1.11.1+lz4-1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "109de74d5d2353660401699a4174a4ff23fcc649caf553df71933c7fb45ad868" +checksum = "6bd8c0d6c6ed0cd30b3652886bb8711dc4bb01d637a68105a3d5158039b418e6" dependencies = [ "cc", "libc", @@ -2558,15 +2551,6 @@ version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" -[[package]] -name = "miniz_oxide" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b8a240ddb74feaf34a79a7add65a741f3167852fba007066dcac1ca548d89c08" -dependencies = [ - "adler", -] - [[package]] name = "miniz_oxide" version = "0.8.0" @@ -2839,9 +2823,9 @@ checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] name = "object" -version = "0.36.3" +version = "0.36.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "27b64972346851a39438c60b341ebc01bba47464ae329e55cf343eb93964efd9" +checksum = "aedf0a2d09c573ed1d8d85b30c119153926a2b36dce0ab28322c09a117a4683e" dependencies = [ "memchr", ] @@ -2952,9 +2936,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" [[package]] name = "pbkdf2" @@ -3000,18 +2984,18 @@ dependencies = [ [[package]] name = "pin-project" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6bf43b791c5b9e34c3d182969b4abb522f9343702850a2e57f460d00d09b4b3" +checksum = "baf123a161dde1e524adf36f90bc5d8d3462824a9c43553ad07a8183161189ec" dependencies = [ "pin-project-internal", ] [[package]] name = "pin-project-internal" -version = "1.1.5" +version = "1.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2f38a4412a78282e09a2cf38d195ea5420d15ba0602cb375210efbc877243965" +checksum = "a4502d8515ca9f32f1fb543d987f63d95a14934883db45bdb48060b6b69257f8" dependencies = [ "proc-macro2", "quote", @@ -3043,9 +3027,9 @@ dependencies = [ [[package]] name = "pkg-config" -version = "0.3.30" +version = "0.3.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" [[package]] name = "plain" @@ -3067,9 +3051,9 @@ dependencies = [ [[package]] name = "portable-atomic" -version = "1.7.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "da544ee218f0d287a911e9c99a39a8c9bc8fcad3cb8db5959940044ecfc67265" +checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2" [[package]] name = "powerfmt" @@ -3463,7 +3447,7 @@ dependencies = [ "system-configuration", "tokio", "tokio-rustls", - "tokio-util 0.7.11", + "tokio-util 0.7.12", "tower-service", "url", "wasm-bindgen", @@ -3556,9 +3540,9 @@ dependencies = [ [[package]] name = "rustix" -version = "0.38.35" +version = "0.38.37" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a85d50532239da68e9addb745ba38ff4612a242c1c7ceea689c4bc7c2f43c36f" +checksum = "8acb788b847c24f28525660c4d7758620a7210875711f79e7f663cc152726811" dependencies = [ "bitflags 2.6.0", "errno", @@ -3633,11 +3617,11 @@ dependencies = [ [[package]] name = "schannel" -version = "0.1.23" +version = "0.1.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbc91545643bcf3a0bbb6569265615222618bdf33ce4ffbbd13c4bbd4c093534" +checksum = "01227be5826fa0690321a2ba6c5cd57a19cf3f6a09e76973b58e61de6ab9d1c1" dependencies = [ - "windows-sys 0.52.0", + "windows-sys 0.59.0", ] [[package]] @@ -3691,9 +3675,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.11.1" +version = "2.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "75da29fe9b9b08fe9d6b22b5b4bcbc75d8db3aa31e639aa56bb62e9d46bfceaf" +checksum = "ea4a292869320c0272d7bc55a5a6aafaff59b4f63404a003887b679a2e05b4b6" dependencies = [ "core-foundation-sys", "libc", @@ -3937,9 +3921,9 @@ dependencies = [ [[package]] name = "solana-account-decoder" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b4185d569c062983fc2a618ae4ee6fe1a139b36bce7a25045647c49bf0020a53" +checksum = "b109fd3a106e079005167e5b0e6f6d2c88bbedec32530837b584791a8b5abf36" dependencies = [ "Inflector", "base64 0.21.7", @@ -3962,9 +3946,9 @@ dependencies = [ [[package]] name = "solana-accounts-db" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7c156ddd42a2746e14fe267f85a2f802567dfa7c1702836b0ce69ea3be15a3c3" +checksum = "ec9829d10d521f3ed5e50c12d2b62784e2901aa484a92c2aa3924151da046139" dependencies = [ "arrayref", "bincode", @@ -4023,9 +4007,9 @@ dependencies = [ [[package]] name = "solana-address-lookup-table-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7f5967c234aa8281f36999ded250403ddacb77863e2a1e157a3203884a13cfa" +checksum = "f3527a26138b5deb126f13c27743f3d95ac533abee5979e4113f6d59ef919cc6" dependencies = [ "bincode", "bytemuck", @@ -4044,9 +4028,9 @@ dependencies = [ [[package]] name = "solana-banks-client" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d78204433cdb1945ef3622905f806423f5536cc91205dc8e325efe521394d3ca" +checksum = "e58fa66e1e240097665e7f87b267aa8e976ea3fcbd86918c8fd218c875395ada" dependencies = [ "borsh 1.5.1", "futures", @@ -4061,9 +4045,9 @@ dependencies = [ [[package]] name = "solana-banks-interface" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f959539e11afaa554c0ae445bb3c726ad658aa33d8b577b76ab7e0ad6e313405" +checksum = "f54d0a4334c153eadaa0326296a47a92d110c1cc975075fd6e1a7b67067f9812" dependencies = [ "serde", "solana-sdk", @@ -4072,9 +4056,9 @@ dependencies = [ [[package]] name = "solana-banks-server" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5224477dc90857c98bec8ff746926facf525e0216fdfbde51e28d92d5b11b236" +checksum = "8cbe287a0f859362de9b155fabd44e479eba26d5d80e07a7d021297b7b06ecba" dependencies = [ "bincode", "crossbeam-channel", @@ -4092,9 +4076,9 @@ dependencies = [ [[package]] name = "solana-bpf-loader-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bfab3aa028e4feac760f28e7fb24760813d451e7cff5a13584509ddab4a94311" +checksum = "a8cc27ceda9a22804d73902f5d718ff1331aa53990c2665c90535f6b182db259" dependencies = [ "bincode", "byteorder", @@ -4111,9 +4095,9 @@ dependencies = [ [[package]] name = "solana-bucket-map" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "06f781213cf76d8840e688d52fbc3876ae8522d2ac594c1c11ab9b982d7f0336" +checksum = "ca55ec9b8d01d2e3bba9fad77b27c9a8fd51fe12475549b93a853d921b653139" dependencies = [ "bv", "bytemuck", @@ -4129,9 +4113,9 @@ dependencies = [ [[package]] name = "solana-clap-utils" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c817832e71886dbea877d1aa911c9ce2e984a39081bb56ee30d4c835567827a6" +checksum = "074ef478856a45d5627270fbc6b331f91de9aae7128242d9e423931013fb8a2a" dependencies = [ "chrono", "clap 2.34.0", @@ -4146,9 +4130,9 @@ dependencies = [ [[package]] name = "solana-client" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fa9cc6e8e59adf70acbf5cac21342ae8b5e41cbf05519fe5f6287e84ab40f63" +checksum = "24a9f32c42402c4b9484d5868ac74b7e0a746e3905d8bfd756e1203e50cbb87e" dependencies = [ "async-trait", "bincode", @@ -4179,9 +4163,9 @@ dependencies = [ [[package]] name = "solana-compute-budget-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b176bad40620d1c443365daf24e19fbfccafe8daff60eb3ddd6cbd9cf0fbec58" +checksum = "6af050a6e0b402e322aa21f5441c7e27cdd52624a2d659f455b68afd7cda218c" dependencies = [ "solana-program-runtime", "solana-sdk", @@ -4189,9 +4173,9 @@ dependencies = [ [[package]] name = "solana-config-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d02fb29934427f1487d2149fe8bcb405306729b2f22a2ad616bb8ffd024cee7b" +checksum = "9d75b803860c0098e021a26f0624129007c15badd5b0bc2fbd9f0e1a73060d3b" dependencies = [ "bincode", "chrono", @@ -4203,9 +4187,9 @@ dependencies = [ [[package]] name = "solana-connection-cache" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d8e5a2e26448b3e04ce673794994ff27f3972ec8a806c224eccc02e09f751ca5" +checksum = "b9306ede13e8ceeab8a096bcf5fa7126731e44c201ca1721ea3c38d89bcd4111" dependencies = [ "async-trait", "bincode", @@ -4225,9 +4209,9 @@ dependencies = [ [[package]] name = "solana-cost-model" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8c4564996ef9f2983efeedb14a38315fa606d3d2cc0a2c8d899c507c5893fe79" +checksum = "c852790063f7646a1c5199234cc82e1304b55a3b3fb8055a0b5c8b0393565c1c" dependencies = [ "lazy_static", "log", @@ -4249,9 +4233,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20a6ef2db80dceb124b7bf81cca3300804bf427d2711973fc3df450ed7dfb26d" +checksum = "03ab2c30c15311b511c0d1151e4ab6bc9a3e080a37e7c6e7c2d96f5784cf9434" dependencies = [ "block-buffer 0.10.4", "bs58 0.4.0", @@ -4274,9 +4258,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70088de7d4067d19a7455609e2b393e6086bd847bb39c4d2bf234fc14827ef9e" +checksum = "c142f779c3633ac83c84d04ff06c70e1f558c876f13358bed77ba629c7417932" dependencies = [ "proc-macro2", "quote", @@ -4286,9 +4270,9 @@ dependencies = [ [[package]] name = "solana-loader-v4-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3fde1ab49eb031882f4803bf5a8008dca84356717e120ba9276d229ff24633c" +checksum = "78b58f70f5883b0f26a6011ed23f76c493a3f22df63aec46cfe8e1b9bf82b5cc" dependencies = [ "log", "solana-measure", @@ -4299,9 +4283,9 @@ dependencies = [ [[package]] name = "solana-logger" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b129da15193f26db62d62ae6bb9f72361f361bcdc36054be3ab8bc04cc7a4f31" +checksum = "121d36ffb3c6b958763312cbc697fbccba46ee837d3a0aa4fc0e90fcb3b884f3" dependencies = [ "env_logger", "lazy_static", @@ -4310,9 +4294,9 @@ dependencies = [ [[package]] name = "solana-measure" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6d195b73093a4964ba6b5943418054a5fcbba23eafdd0842fd973fcceac1a967" +checksum = "5c01a7f9cdc9d9d37a3d5651b2fe7ec9d433c2a3470b9f35897e373b421f0737" dependencies = [ "log", "solana-sdk", @@ -4320,9 +4304,9 @@ dependencies = [ [[package]] name = "solana-metrics" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe7b06860ffbf4cf4714182e1b7eb00eb3ff0bcc9cff615d05e01e488923883c" +checksum = "71e36052aff6be1536bdf6f737c6e69aca9dbb6a2f3f582e14ecb0ddc0cd66ce" dependencies = [ "crossbeam-channel", "gethostname", @@ -4335,9 +4319,9 @@ dependencies = [ [[package]] name = "solana-net-utils" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9400b50b8439868a99b5fa2d961d74e37b7a6c1d5865759d0b1c906c2ad6b2a9" +checksum = "2a1f5c6be9c5b272866673741e1ebc64b2ea2118e5c6301babbce526fdfb15f4" dependencies = [ "bincode", "clap 3.2.25", @@ -4363,9 +4347,9 @@ checksum = "8b8a731ed60e89177c8a7ab05fe0f1511cedd3e70e773f288f9de33a9cfdc21e" [[package]] name = "solana-perf" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b01a386e852df67031195094628851b8d239dd71fe17b721c3993277e68cb3ab" +checksum = "28acaf22477566a0fbddd67249ea5d859b39bacdb624aff3fadd3c5745e2643c" dependencies = [ "ahash 0.8.11", "bincode", @@ -4392,9 +4376,9 @@ dependencies = [ [[package]] name = "solana-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2b2c8babfae4cace1a25b6efa00418f3acd852cf55d7cecc0360d3c5050479" +checksum = "c10f4588cefd716b24a1a40dd32c278e43a560ab8ce4de6b5805c9d113afdfa1" dependencies = [ "ark-bn254", "ark-ec", @@ -4447,9 +4431,9 @@ dependencies = [ [[package]] name = "solana-program-runtime" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0444f9440f4459d377c41470b2eb48b527def81f3052b7a121f6aa8c7350cc52" +checksum = "fbf0c3eab2a80f514289af1f422c121defb030937643c43b117959d6f1932fb5" dependencies = [ "base64 0.21.7", "bincode", @@ -4475,9 +4459,9 @@ dependencies = [ [[package]] name = "solana-program-test" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c76274336971f37dbbd3508aaaa4c98ca0061abd31fb309ad1c6ad132f0c6c0e" +checksum = "c1382a5768ff738e283770ee331d0a4fa04aa1aceed8eb820a97094c93d53b72" dependencies = [ "assert_matches", "async-trait", @@ -4505,9 +4489,9 @@ dependencies = [ [[package]] name = "solana-pubsub-client" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ee4a39e41e789b6f100c97d9f40c1d08381bf6e3d0e351065e542091cddb039" +checksum = "b064e76909d33821b80fdd826e6757251934a52958220c92639f634bea90366d" dependencies = [ "crossbeam-channel", "futures-util", @@ -4530,9 +4514,9 @@ dependencies = [ [[package]] name = "solana-quic-client" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baad755c76ee0aab8890f0ef873e61b8b3012c523d33bfa5b062fe9be8cef370" +checksum = "5a90e40ee593f6e9ddd722d296df56743514ae804975a76d47e7afed4e3da244" dependencies = [ "async-mutex", "async-trait", @@ -4557,9 +4541,9 @@ dependencies = [ [[package]] name = "solana-rayon-threadlimit" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1c2a0ccb0be7ca79e8ff0d7c786bce586433a5687ffbea522453d0b41c4bf4a" +checksum = "66468f9c014992167de10cc68aad6ac8919a8c8ff428dc88c0d2b4da8c02b8b7" dependencies = [ "lazy_static", "num_cpus", @@ -4567,9 +4551,9 @@ dependencies = [ [[package]] name = "solana-remote-wallet" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3d042a812537e3507e1c163c7573fc04c96e12d3eba512e3fe74c7393229fa39" +checksum = "c191019f4d4f84281a6d0dd9a43181146b33019627fc394e42e08ade8976b431" dependencies = [ "console", "dialoguer", @@ -4586,9 +4570,9 @@ dependencies = [ [[package]] name = "solana-rpc-client" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c6f5560283bd0a6833d1bd816299785058a870fff51b0df399fdb3ce92c8484" +checksum = "36ed4628e338077c195ddbf790693d410123d17dec0a319b5accb4aaee3fb15c" dependencies = [ "async-trait", "base64 0.21.7", @@ -4612,9 +4596,9 @@ dependencies = [ [[package]] name = "solana-rpc-client-api" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e4ca77f89caa9071acadb1eed19c28a6691fd63d0563ed927c96bf734cf1c9c" +checksum = "83c913551faa4a1ae4bbfef6af19f3a5cf847285c05b4409e37c8993b3444229" dependencies = [ "base64 0.21.7", "bs58 0.4.0", @@ -4634,9 +4618,9 @@ dependencies = [ [[package]] name = "solana-rpc-client-nonce-utils" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42a6ea9ad81d63f18fb8b3a9b39643cc43eaf909199d67037e724562301d1df7" +checksum = "1a47b6bb1834e6141a799db62bbdcf80d17a7d58d7bc1684c614e01a7293d7cf" dependencies = [ "clap 2.34.0", "solana-clap-utils", @@ -4647,9 +4631,9 @@ dependencies = [ [[package]] name = "solana-runtime" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d7c4b50b29b6f5938d2c9b151e9187d4687ca9c26be2c6ebe53ba34826283441" +checksum = "73a12e1270121e1ca6a4e86d6d0f5c339f0811a8435161d9eee54cbb0a083859" dependencies = [ "aquamarine", "arrayref", @@ -4724,9 +4708,9 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b5e0f0def5c5af07f53d321cea7b104487b522cfff77c3cae3da361bfe956e9e" +checksum = "580ad66c2f7a4c3cb3244fe21440546bd500f5ecb955ad9826e92a78dded8009" dependencies = [ "assert_matches", "base64 0.21.7", @@ -4779,9 +4763,9 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c55c196c8050834c391a34b58e3c9fd86b15452ef1feeeafa1dbeb9d2291dfec" +checksum = "1b75d0f193a27719257af19144fdaebec0415d1c9e9226ae4bd29b791be5e9bd" dependencies = [ "bs58 0.4.0", "proc-macro2", @@ -4798,9 +4782,9 @@ checksum = "468aa43b7edb1f9b7b7b686d5c3aeb6630dc1708e86e31343499dd5c4d775183" [[package]] name = "solana-send-transaction-service" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f7c5fc9df712efd671a5a5b68e58a448dc13b70f59ef16bdd0e8d644813eb67a" +checksum = "3218f670f582126a3859c4fd152e922b93b3748a636bb143f970391925723577" dependencies = [ "crossbeam-channel", "log", @@ -4814,9 +4798,9 @@ dependencies = [ [[package]] name = "solana-stake-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "624f6d0c84c19a17bf882259303e99e1ed2562a0316c989f847a067aa99d4940" +checksum = "eeb3e0d2dc7080b9fa61b34699b176911684f5e04e8df4b565b2b6c962bb4321" dependencies = [ "bincode", "log", @@ -4829,9 +4813,9 @@ dependencies = [ [[package]] name = "solana-streamer" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "749720d82c5f31f7ec326da1e0baac098201de70f0874719172a55309433b449" +checksum = "f8476e41ad94fe492e8c06697ee35912cf3080aae0c9e9ac6430835256ccf056" dependencies = [ "async-channel", "bytes", @@ -4862,9 +4846,9 @@ dependencies = [ [[package]] name = "solana-system-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a449f40a516a8e83dcc2ce07643bb3feec4da690f170d438849af06c503cc28" +checksum = "26f31e04f5baad7cbc2281fea312c4e48277da42a93a0ba050b74edc5a74d63c" dependencies = [ "bincode", "log", @@ -4876,9 +4860,9 @@ dependencies = [ [[package]] name = "solana-thin-client" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "84535de1253afb6ccc4ae6852eb013ca734c439a902ec5e4684b90ed649a37c2" +checksum = "d8c02245d0d232430e79dc0d624aa42d50006097c3aec99ac82ac299eaa3a73f" dependencies = [ "bincode", "log", @@ -4891,9 +4875,9 @@ dependencies = [ [[package]] name = "solana-tpu-client" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3ff514462bb715aaea9bc5c0ee60f83ab3f91e04279337c6b07d054153b616dc" +checksum = "67251506ed03de15f1347b46636b45c47da6be75015b4a13f0620b21beb00566" dependencies = [ "async-trait", "bincode", @@ -4915,9 +4899,9 @@ dependencies = [ [[package]] name = "solana-transaction-status" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670e387049812d42bdc8fcc4ff75452ff3cb00657af979a90f55f6d37dba9dd9" +checksum = "2d3d36db1b2ab2801afd5482aad9fb15ed7959f774c81a77299fdd0ddcf839d4" dependencies = [ "Inflector", "base64 0.21.7", @@ -4940,9 +4924,9 @@ dependencies = [ [[package]] name = "solana-udp-client" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11183dae826f942ebd0401712c8a52367a4a6312f1cd325f304cd9551226fc8b" +checksum = "3a754a3c2265eb02e0c35aeaca96643951f03cee6b376afe12e0cf8860ffccd1" dependencies = [ "async-trait", "solana-connection-cache", @@ -4955,9 +4939,9 @@ dependencies = [ [[package]] name = "solana-version" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d518e61ce22c812df23d9c61ab9bcbef4df3e3d3dcaa74a999625f11bcf07" +checksum = "f44776bd685cc02e67ba264384acc12ef2931d01d1a9f851cb8cdbd3ce455b9e" dependencies = [ "log", "rustc_version", @@ -4971,9 +4955,9 @@ dependencies = [ [[package]] name = "solana-vote" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ae2a4908ac4df02a4adb78f09fe938b31c75f42ba64401b8ac88193eb446943" +checksum = "b5983370c95b615dc5f5d0e85414c499f05380393c578749bcd14c114c77c9bc" dependencies = [ "crossbeam-channel", "itertools", @@ -4990,9 +4974,9 @@ dependencies = [ [[package]] name = "solana-vote-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5743503143fb2259c41a973a78e9aeeb8e21f1b03543c3bb85449926ea692719" +checksum = "25810970c91feb579bd3f67dca215fce971522e42bfd59696af89c5dfebd997c" dependencies = [ "bincode", "log", @@ -5012,9 +4996,9 @@ dependencies = [ [[package]] name = "solana-zk-token-proof-program" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5813dc267bea898ff40d3bd662a0a7659170dd19ae5e7c46e8dc0a414a205868" +checksum = "1be1c15d4aace575e2de73ebeb9b37bac455e89bee9a8c3531f47ac5066b33e1" dependencies = [ "bytemuck", "num-derive 0.4.2", @@ -5026,9 +5010,9 @@ dependencies = [ [[package]] name = "solana-zk-token-sdk" -version = "1.18.22" +version = "1.18.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57ee07fa523b4cfcff68de774db7aa87d2da2c4357155a90bacd9a0a0af70a99" +checksum = "7cbdf4249b6dfcbba7d84e2b53313698043f60f8e22ce48286e6fbe8a17c8d16" dependencies = [ "aes-gcm-siv", "base64 0.21.7", @@ -5434,9 +5418,9 @@ dependencies = [ [[package]] name = "tar" -version = "0.4.41" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb797dad5fb5b76fcf519e702f4a589483b5ef06567f160c392832c1f5e44909" +checksum = "4ff6c40d3aedb5e06b57c6f669ad17ab063dd1e63d977c6a88e7f4dfa4f04020" dependencies = [ "filetime", "libc", @@ -5480,9 +5464,9 @@ dependencies = [ [[package]] name = "tempfile" -version = "3.12.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04cbcdd0c794ebb0d4cf35e88edd2f7d2c4c3e9a5a6dab322839b321c6a87a64" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", @@ -5662,9 +5646,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "tokio" -version = "1.39.3" +version = "1.40.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9babc99b9923bfa4804bd74722ff02c0381021eafa4db9949217e3be8e84fff5" +checksum = "e2b070231665d27ad9ec9b8df639893f46727666c6767db40317fbe920a5d998" dependencies = [ "backtrace", "bytes", @@ -5717,9 +5701,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.15" +version = "0.1.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "267ac89e0bec6e691e5813911606935d77c476ff49024f98abcea3e7b15e37af" +checksum = "4f4e6ce100d0eb49a2734f8c0812bcd324cf357d21810932c5df6b96ef2b86f1" dependencies = [ "futures-core", "pin-project-lite", @@ -5758,9 +5742,9 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.7.11" +version = "0.7.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9cf6b47b3771c49ac75ad09a6162f53ad4b8088b76ac60e8ec1455b31a189fe1" +checksum = "61e7c3654c13bcd040d4a03abee2c75b1d14a37b423cf5a813ceae1cc903ec6a" dependencies = [ "bytes", "futures-core", @@ -5775,7 +5759,6 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "indexmap 1.9.3", "serde", ] @@ -5785,6 +5768,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ + "indexmap 2.4.0", "serde", "serde_spanned", "toml_datetime", @@ -5898,28 +5882,22 @@ dependencies = [ "anyhow", "arbitrary", "bincode", - "borsh 0.10.3", "cargo_metadata", "convert_case", "fehler", "futures", "honggfuzz", - "indicatif", - "log", "pathdiff", - "proc-macro2", "quinn-proto", "quote", - "regex", "serde", "serde_json", "solana-program-test", "solana-sdk", - "syn 1.0.109", + "syn 2.0.76", "thiserror", "tokio", - "toml 0.5.11", - "trident-derive-accounts-snapshots", + "toml 0.8.19", "trident-derive-displayix", "trident-derive-fuzz-test-executor", "trident-fuzz", @@ -5964,7 +5942,6 @@ dependencies = [ "fehler", "prettytable", "rand 0.8.5", - "regex", "serde", "serde_json", "solana-banks-client", @@ -5974,7 +5951,7 @@ dependencies = [ "spl-token", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", ] [[package]] @@ -6012,9 +5989,9 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "unicode-bidi" -version = "0.3.15" +version = "0.3.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08f95100a766bf4f8f28f90d77e0a5461bbdb219042e7679bebe79004fed8d75" +checksum = "5ab17db44d7388991a428b2ee655ce0c212e862eff1768a455c58f9aad6e7893" [[package]] name = "unicode-ident" @@ -6039,15 +6016,15 @@ checksum = "d4c87d22b6e3f4a18d4d40ef354e97c90fcb14dd91d7dc0aa9d8a1172ebf7202" [[package]] name = "unicode-width" -version = "0.1.13" +version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" +checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" [[package]] name = "unicode-xid" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "229730647fbc343e3a80e463c1db7f78f3855d3f3739bee0dda773c9a037c90a" +checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "universal-hash" diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.toml b/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.toml index 245186370..daa4c9e62 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.toml +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["programs/*", "trident-tests/fuzz_tests"] + [profile.release] overflow-checks = true lto = "fat" diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/Trident.toml b/examples/fuzz-tests/incorrect-ix-sequence-1/Trident.toml index 524c2d903..b976b8222 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/Trident.toml +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/Trident.toml @@ -29,42 +29,6 @@ max_file_size = 1048576 # Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) save_all = false -[afl] -# Target compilation directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"]). -# To not clash with cargo build's default target directory. -cargo_target_dir = "" -# AFL working input directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"]). -afl_workspace_in = "" -# AFL working output directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"]). -afl_workspace_out = "" -# fuzz for an approx. no. of total executions then terminate -# Note: not precise and can have several more executions. -# (default: 0 [no limit]). -execs = 0 -# fuzz for a specified time then terminate (fuzz time only!) -# (default: 0 [no limit]). -seconds = 0 - -[[afl.seeds]] -# Filename under which the test input is generated. -# The location of file is afl_workspace_in directory. -# (default: "" ["trident-seed"]). -file_name = "trident-seed" -# String used as seed. -# (default: "" ["0"]). -seed = "" -# If the file already exists at specific location, -# select if override. -# (default: false). -override_file = false -# Number of randomly generated bytes. -# (default: 0). -bytes_count = 20 - - [fuzz] # Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false) allow_duplicate_txs = false diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/programs/incorrect-ix-sequence-1/Cargo.toml b/examples/fuzz-tests/incorrect-ix-sequence-1/programs/incorrect-ix-sequence-1/Cargo.toml index 651b2dcc0..8b30dd7f1 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/programs/incorrect-ix-sequence-1/Cargo.toml +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/programs/incorrect-ix-sequence-1/Cargo.toml @@ -18,6 +18,12 @@ idl-build = ["anchor-lang/idl-build"] trident-fuzzing = ["dep:trident-fuzz"] [dependencies] -trident-derive-accounts-snapshots = { path = "../../../../../crates/fuzz/derive/accounts_snapshots" } -trident-fuzz = { path = "../../../../../crates/fuzz", optional = true } anchor-lang = "0.30.1" + +[dependencies.trident-derive-accounts-snapshots] +path = "../../../../../crates/fuzz/derive/accounts_snapshots" + + +[dependencies.trident-fuzz] +path = "../../../../../crates/fuzz" +optional = true diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/Cargo.toml b/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/Cargo.toml index bca24fe6e..0ae727677 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/Cargo.toml +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/Cargo.toml @@ -15,7 +15,6 @@ assert_matches = "1.4.0" [dependencies.trident-client] path = "../../../../../crates/client" - [dependencies.incorrect-ix-sequence-1] path = "../../programs/incorrect-ix-sequence-1" features = ["trident-fuzzing"] diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs b/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs index 9d06c5dc8..9cee12e63 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs @@ -1,16 +1,18 @@ use incorrect_ix_sequence_1::{PROJECT_SEED, STATE_SEED}; use solana_sdk::native_token::LAMPORTS_PER_SOL; use trident_client::fuzzing::*; - -use incorrect_ix_sequence_1::trident_fuzz_end_registration_snapshot::EndRegistrationAlias; -use incorrect_ix_sequence_1::trident_fuzz_initialize_snapshot::InitializeAlias; -use incorrect_ix_sequence_1::trident_fuzz_invest_snapshot::InvestAlias; -use incorrect_ix_sequence_1::trident_fuzz_register_snapshot::RegisterAlias; - +/// Link the relevant Account Context Alias from the program. +/// Aliases are generated by the `AccountsSnapshots` macro. type EndRegistrationsSnapshot<'info> = EndRegistrationAlias<'info>; type InitializeSnapshot<'info> = InitializeAlias<'info>; type InvestSnapshot<'info> = InvestAlias<'info>; type RegisterSnapshot<'info> = RegisterAlias<'info>; +use incorrect_ix_sequence_1::trident_fuzz_end_registration_snapshot::EndRegistrationAlias; +use incorrect_ix_sequence_1::trident_fuzz_initialize_snapshot::InitializeAlias; +use incorrect_ix_sequence_1::trident_fuzz_invest_snapshot::InvestAlias; +use incorrect_ix_sequence_1::trident_fuzz_register_snapshot::RegisterAlias; +/// FuzzInstruction contains all available Instructions. +/// Below, the instruction arguments (accounts and data) are defined. #[derive(Arbitrary, DisplayIx, FuzzTestExecutor)] pub enum FuzzInstruction { EndRegistrations(EndRegistrations), @@ -28,6 +30,11 @@ pub struct EndRegistrationsAccounts { pub author: AccountId, pub state: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct EndRegistrationsData {} #[derive(Arbitrary, Debug)] @@ -41,6 +48,11 @@ pub struct InitializeAccounts { pub state: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct InitializeData {} #[derive(Arbitrary, Debug)] @@ -55,6 +67,11 @@ pub struct InvestAccounts { pub state: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct InvestData { pub amount: u64, @@ -71,15 +88,26 @@ pub struct RegisterAccounts { pub state: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct RegisterData {} +///IxOps implementation for `EndRegistrations` with all required functions. impl<'info> IxOps<'info> for EndRegistrations { type IxData = incorrect_ix_sequence_1::instruction::EndRegistrations; type IxAccounts = FuzzAccounts; type IxSnapshot = EndRegistrationsSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { incorrect_ix_sequence_1::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -88,6 +116,12 @@ impl<'info> IxOps<'info> for EndRegistrations { let data = incorrect_ix_sequence_1::instruction::EndRegistrations {}; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -116,13 +150,19 @@ impl<'info> IxOps<'info> for EndRegistrations { Ok((signers, acc_meta)) } } +///IxOps implementation for `Initialize` with all required functions. impl<'info> IxOps<'info> for Initialize { type IxData = incorrect_ix_sequence_1::instruction::Initialize; type IxAccounts = FuzzAccounts; type IxSnapshot = InitializeSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { incorrect_ix_sequence_1::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -131,6 +171,12 @@ impl<'info> IxOps<'info> for Initialize { let data = incorrect_ix_sequence_1::instruction::Initialize {}; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -161,13 +207,19 @@ impl<'info> IxOps<'info> for Initialize { Ok((signers, acc_meta)) } } +///IxOps implementation for `Invest` with all required functions. impl<'info> IxOps<'info> for Invest { type IxData = incorrect_ix_sequence_1::instruction::Invest; type IxAccounts = FuzzAccounts; type IxSnapshot = InvestSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { incorrect_ix_sequence_1::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -178,6 +230,12 @@ impl<'info> IxOps<'info> for Invest { }; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -228,13 +286,19 @@ impl<'info> IxOps<'info> for Invest { Ok((signers, acc_meta)) } } +///IxOps implementation for `Register` with all required functions. impl<'info> IxOps<'info> for Register { type IxData = incorrect_ix_sequence_1::instruction::Register; type IxAccounts = FuzzAccounts; type IxSnapshot = RegisterSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { incorrect_ix_sequence_1::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -243,6 +307,12 @@ impl<'info> IxOps<'info> for Register { let data = incorrect_ix_sequence_1::instruction::Register {}; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -305,8 +375,8 @@ impl<'info> IxOps<'info> for Register { Ok(()) } } -#[doc = r" Use AccountsStorage where T can be one of:"] -#[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] +/// Use AccountsStorage where T can be one of: +/// Keypair, PdaStore, TokenStore, MintStore, ProgramStore #[derive(Default)] pub struct FuzzAccounts { project_author: AccountsStorage, diff --git a/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index ce69f1a0c..8b0cbe10b 100644 --- a/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/incorrect-ix-sequence-1/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -1,23 +1,30 @@ use fuzz_instructions::Initialize; use trident_client::fuzzing::*; - mod fuzz_instructions; - use fuzz_instructions::FuzzInstruction; use incorrect_ix_sequence_1::entry as entry_incorrect_ix_sequence_1; use incorrect_ix_sequence_1::ID as PROGRAM_ID_INCORRECT_IX_SEQUENCE_1; - const PROGRAM_NAME_INCORRECT_IX_SEQUENCE_1: &str = "incorrect_ix_sequence_1"; - struct MyFuzzData; - +/// Define instruction sequences for invocation. +/// `pre_ixs` runs at the start, `ixs` in the middle, and `post_ixs` at the end. +/// For example, to call `InitializeFn` at the start of each fuzzing iteration: +/// ``` +/// fn pre_ixs(u: &mut arbitrary::Unstructured) -> +/// arbitrary::Result> { +/// let init = FuzzInstruction::InitializeFn(InitializeFn::arbitrary(u)?); +/// Ok(vec![init]) +/// } +/// ``` +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences impl FuzzDataBuilder for MyFuzzData { fn pre_ixs(u: &mut arbitrary::Unstructured) -> arbitrary::Result> { let init_ix = FuzzInstruction::Initialize(Initialize::arbitrary(u)?); Ok(vec![init_ix]) } } - +/// `fn fuzz_iteration` runs during every fuzzing iteration. +/// Modification is not required. fn fuzz_iteration + std::fmt::Display, U>( fuzz_data: FuzzData, config: &Config, @@ -27,15 +34,11 @@ fn fuzz_iteration + std::fmt::Display, U>( &PROGRAM_ID_INCORRECT_IX_SEQUENCE_1, processor!(convert_entry!(entry_incorrect_ix_sequence_1)), ); - let mut client = ProgramTestClientBlocking::new(&[fuzzing_program_incorrect_ix_sequence_1], config).unwrap(); - let _ = fuzz_data.run_with_runtime(&mut client, config); } - fn main() { let config = Config::new(); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : MyFuzzData | { fuzz_iteration (fuzz_data , & config) ; }); } diff --git a/examples/fuzz-tests/simple-cpi-6/.gitignore b/examples/fuzz-tests/simple-cpi-6/.gitignore index edc161d20..31f8853b5 100644 --- a/examples/fuzz-tests/simple-cpi-6/.gitignore +++ b/examples/fuzz-tests/simple-cpi-6/.gitignore @@ -6,4 +6,3 @@ node_modules test-ledger .yarn trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target -trident-tests/fuzz_tests/fuzzing/afl/afl_target diff --git a/examples/fuzz-tests/simple-cpi-6/Cargo.lock b/examples/fuzz-tests/simple-cpi-6/Cargo.lock index d47cf6eb1..f09db6fee 100644 --- a/examples/fuzz-tests/simple-cpi-6/Cargo.lock +++ b/examples/fuzz-tests/simple-cpi-6/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "afl" -version = "0.15.10" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21e10b6947189c5ff61343b5354e9ad1c1722bd47b69cd0a6b49e5fa7f7ecf6" +checksum = "80bb240a3b9ff18002142c1a736e98046461d51a694d687c3e7329b456ab0fe4" dependencies = [ "home", "libc", @@ -984,9 +984,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -2953,9 +2953,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" [[package]] name = "pbkdf2" @@ -5776,7 +5776,6 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "indexmap 1.9.3", "serde", ] @@ -5786,6 +5785,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -5899,28 +5899,22 @@ dependencies = [ "anyhow", "arbitrary", "bincode", - "borsh 0.10.4", "cargo_metadata", "convert_case", "fehler", "futures", "honggfuzz", - "indicatif", - "log", "pathdiff", - "proc-macro2", "quinn-proto", "quote", - "regex", "serde", "serde_json", "solana-program-test", "solana-sdk", - "syn 1.0.109", + "syn 2.0.79", "thiserror", "tokio", - "toml 0.5.11", - "trident-derive-accounts-snapshots", + "toml 0.8.19", "trident-derive-displayix", "trident-derive-fuzz-test-executor", "trident-fuzz", @@ -5965,7 +5959,6 @@ dependencies = [ "fehler", "prettytable", "rand 0.8.5", - "regex", "serde", "serde_json", "solana-banks-client", @@ -5975,7 +5968,7 @@ dependencies = [ "spl-token", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", ] [[package]] diff --git a/examples/fuzz-tests/simple-cpi-6/Cargo.toml b/examples/fuzz-tests/simple-cpi-6/Cargo.toml index 9783b3f09..97d1d6397 100644 --- a/examples/fuzz-tests/simple-cpi-6/Cargo.toml +++ b/examples/fuzz-tests/simple-cpi-6/Cargo.toml @@ -1,6 +1,7 @@ [workspace] members = ["programs/*", "trident-tests/fuzz_tests"] resolver = "2" + [profile.release] overflow-checks = true lto = "fat" diff --git a/examples/fuzz-tests/simple-cpi-6/Trident.toml b/examples/fuzz-tests/simple-cpi-6/Trident.toml index 75f467c96..6de0eb954 100644 --- a/examples/fuzz-tests/simple-cpi-6/Trident.toml +++ b/examples/fuzz-tests/simple-cpi-6/Trident.toml @@ -29,42 +29,6 @@ max_file_size = 1048576 # Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) save_all = false -[afl] -# Target compilation directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"]). -# To not clash with cargo build's default target directory. -cargo_target_dir = "" -# AFL working input directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"]). -afl_workspace_in = "" -# AFL working output directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"]). -afl_workspace_out = "" -# fuzz for an approx. no. of total executions then terminate -# Note: not precise and can have several more executions. -# (default: 0 [no limit]). -execs = 100 -# fuzz for a specified time then terminate (fuzz time only!) -# (default: 0 [no limit]). -seconds = 0 - -[[afl.seeds]] -# Filename under which the test input is generated. -# The location of file is afl_workspace_in directory. -# (default: "" ["trident-seed"]). -file_name = "trident-seed" -# String used as seed. -# (default: "" ["0"]). -seed = "" -# If the file already exists at specific location, -# select if override. -# (default: false). -override_file = false -# Number of randomly generated bytes. -# (default: 0). -bytes_count = 20 - - [fuzz] # Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false) allow_duplicate_txs = false diff --git a/examples/fuzz-tests/simple-cpi-6/programs/callee/Cargo.toml b/examples/fuzz-tests/simple-cpi-6/programs/callee/Cargo.toml index 28bd0fcda..b7bd54c3e 100644 --- a/examples/fuzz-tests/simple-cpi-6/programs/callee/Cargo.toml +++ b/examples/fuzz-tests/simple-cpi-6/programs/callee/Cargo.toml @@ -18,6 +18,11 @@ idl-build = ["anchor-lang/idl-build"] trident-fuzzing = ["dep:trident-fuzz"] [dependencies] -trident-derive-accounts-snapshots = { path = "../../../../../crates/fuzz/derive/accounts_snapshots" } -trident-fuzz = { path = "../../../../../crates/fuzz", optional = true } anchor-lang = "0.30.1" + +[dependencies.trident-derive-accounts-snapshots] +path = "../../../../../crates/fuzz/derive/accounts_snapshots" + +[dependencies.trident-fuzz] +path = "../../../../../crates/fuzz" +optional = true diff --git a/examples/fuzz-tests/simple-cpi-6/programs/caller/Cargo.toml b/examples/fuzz-tests/simple-cpi-6/programs/caller/Cargo.toml index b26d47dac..94186555a 100644 --- a/examples/fuzz-tests/simple-cpi-6/programs/caller/Cargo.toml +++ b/examples/fuzz-tests/simple-cpi-6/programs/caller/Cargo.toml @@ -18,7 +18,15 @@ idl-build = ["anchor-lang/idl-build"] trident-fuzzing = ["dep:trident-fuzz"] [dependencies] -trident-derive-accounts-snapshots = { path = "../../../../../crates/fuzz/derive/accounts_snapshots" } -trident-fuzz = { path = "../../../../../crates/fuzz", optional = true } anchor-lang = "0.30.1" -callee = { path = "../callee", features = ["cpi"] } + +[dependencies.trident-derive-accounts-snapshots] +path = "../../../../../crates/fuzz/derive/accounts_snapshots" + +[dependencies.trident-fuzz] +path = "../../../../../crates/fuzz" +optional = true + +[dependencies.callee] +path = "../callee" +features = ["cpi"] diff --git a/examples/fuzz-tests/simple-cpi-6/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs b/examples/fuzz-tests/simple-cpi-6/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs index 88ae8000d..0c9490699 100644 --- a/examples/fuzz-tests/simple-cpi-6/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs +++ b/examples/fuzz-tests/simple-cpi-6/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs @@ -1,13 +1,37 @@ use trident_client::fuzzing::*; - +/// Link the relevant Account Context Alias from the program. +/// Aliases are generated by the `AccountsSnapshots` macro. +type InitializeCalleeSnapshot<'info> = InitializeCalleeAlias<'info>; +type InitializeCallerSnapshot<'info> = InitializeCallerAlias<'info>; +use callee::trident_fuzz_initialize_callee_snapshot::InitializeCalleeAlias; use caller::trident_fuzz_initialize_caller_snapshot::InitializeCallerAlias; -type InitializeCallerSnapshot<'info> = InitializeCallerAlias<'info>; +/// FuzzInstruction contains all available Instructions. +/// Below, the instruction arguments (accounts and data) are defined. #[derive(Arbitrary, DisplayIx, FuzzTestExecutor)] pub enum FuzzInstruction { + InitializeCallee(InitializeCallee), InitializeCaller(InitializeCaller), } #[derive(Arbitrary, Debug)] +pub struct InitializeCallee { + pub _accounts: InitializeCalleeAccounts, + pub data: InitializeCalleeData, +} +#[derive(Arbitrary, Debug)] +pub struct InitializeCalleeAccounts { + pub _signer: AccountId, +} +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types +#[derive(Arbitrary, Debug)] +pub struct InitializeCalleeData { + pub input: u8, +} +#[derive(Arbitrary, Debug)] pub struct InitializeCaller { pub accounts: InitializeCallerAccounts, pub data: InitializeCallerData, @@ -17,17 +41,67 @@ pub struct InitializeCallerAccounts { pub signer: AccountId, pub _program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct InitializeCallerData { pub input: u8, } +///IxOps implementation for `InitializeCallee` with all required functions. +impl<'info> IxOps<'info> for InitializeCallee { + type IxData = callee::instruction::InitializeCallee; + type IxAccounts = FuzzAccounts; + type IxSnapshot = InitializeCalleeSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. + fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { + callee::ID + } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data + fn get_data( + &self, + _client: &mut impl FuzzClient, + _fuzz_accounts: &mut FuzzAccounts, + ) -> Result { + let data = callee::instruction::InitializeCallee { + input: self.data.input, + }; + Ok(data) + } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts + fn get_accounts( + &self, + _client: &mut impl FuzzClient, + _fuzz_accounts: &mut FuzzAccounts, + ) -> Result<(Vec, Vec), FuzzingError> { + let signers = vec![]; + let acc_meta = todo!(); + Ok((signers, acc_meta)) + } +} +///IxOps implementation for `InitializeCaller` with all required functions. impl<'info> IxOps<'info> for InitializeCaller { type IxData = caller::instruction::InitializeCaller; type IxAccounts = FuzzAccounts; type IxSnapshot = InitializeCallerSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { caller::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -38,6 +112,12 @@ impl<'info> IxOps<'info> for InitializeCaller { }; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -57,8 +137,8 @@ impl<'info> IxOps<'info> for InitializeCaller { Ok((signers, acc_meta)) } } -#[doc = r" Use AccountsStorage where T can be one of:"] -#[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] +/// Use AccountsStorage where T can be one of: +/// Keypair, PdaStore, TokenStore, MintStore, ProgramStore #[derive(Default)] pub struct FuzzAccounts { _program: AccountsStorage, diff --git a/examples/fuzz-tests/simple-cpi-6/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/simple-cpi-6/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index cf1b51446..4a860ade5 100644 --- a/examples/fuzz-tests/simple-cpi-6/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/simple-cpi-6/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -1,20 +1,25 @@ use fuzz_instructions::InitializeCaller; use trident_client::fuzzing::*; - mod fuzz_instructions; - use callee::entry as entry_callee; use callee::ID as PROGRAM_ID_CALLEE; use caller::entry as entry_caller; use caller::ID as PROGRAM_ID_CALLER; use fuzz_instructions::FuzzInstruction; - const PROGRAM_NAME_CALLEE: &str = "callee"; - const PROGRAM_NAME_CALLER: &str = "caller"; - struct MyFuzzData; - +/// Define instruction sequences for invocation. +/// `pre_ixs` runs at the start, `ixs` in the middle, and `post_ixs` at the end. +/// For example, to call `InitializeFn` at the start of each fuzzing iteration: +/// ``` +/// fn pre_ixs(u: &mut arbitrary::Unstructured) -> +/// arbitrary::Result> { +/// let init = FuzzInstruction::InitializeFn(InitializeFn::arbitrary(u)?); +/// Ok(vec![init]) +/// } +/// ``` +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences impl FuzzDataBuilder for MyFuzzData { fn pre_ixs(u: &mut arbitrary::Unstructured) -> arbitrary::Result> { let init_caller = FuzzInstruction::InitializeCaller(InitializeCaller::arbitrary(u)?); @@ -27,7 +32,8 @@ impl FuzzDataBuilder for MyFuzzData { Ok(vec![]) } } - +/// `fn fuzz_iteration` runs during every fuzzing iteration. +/// Modification is not required. fn fuzz_iteration + std::fmt::Display, U>( fuzz_data: FuzzData, config: &Config, @@ -37,22 +43,17 @@ fn fuzz_iteration + std::fmt::Display, U>( &PROGRAM_ID_CALLEE, processor!(convert_entry!(entry_callee)), ); - let fuzzing_program_caller = FuzzingProgram::new( PROGRAM_NAME_CALLER, &PROGRAM_ID_CALLER, processor!(convert_entry!(entry_caller)), ); - let mut client = ProgramTestClientBlocking::new(&[fuzzing_program_callee, fuzzing_program_caller], config) .unwrap(); - let _ = fuzz_data.run_with_runtime(&mut client, config); } - fn main() { let config = Config::new(); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : MyFuzzData | { fuzz_iteration (fuzz_data , & config) ; }); } diff --git a/examples/fuzz-tests/unauthorized-access-2/.gitignore b/examples/fuzz-tests/unauthorized-access-2/.gitignore index 4d41eb4da..3e0467a9e 100644 --- a/examples/fuzz-tests/unauthorized-access-2/.gitignore +++ b/examples/fuzz-tests/unauthorized-access-2/.gitignore @@ -7,4 +7,3 @@ node_modules test-ledger .yarn trident-tests/fuzz_tests/fuzzing/honggfuzz/hfuzz_target -trident-tests/fuzz_tests/fuzzing/afl/afl_target diff --git a/examples/fuzz-tests/unauthorized-access-2/Cargo.lock b/examples/fuzz-tests/unauthorized-access-2/Cargo.lock index 573a32079..562f28909 100644 --- a/examples/fuzz-tests/unauthorized-access-2/Cargo.lock +++ b/examples/fuzz-tests/unauthorized-access-2/Cargo.lock @@ -65,9 +65,9 @@ dependencies = [ [[package]] name = "afl" -version = "0.15.10" +version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c21e10b6947189c5ff61343b5354e9ad1c1722bd47b69cd0a6b49e5fa7f7ecf6" +checksum = "80bb240a3b9ff18002142c1a736e98046461d51a694d687c3e7329b456ab0fe4" dependencies = [ "home", "libc", @@ -965,9 +965,9 @@ dependencies = [ [[package]] name = "cargo_metadata" -version = "0.17.0" +version = "0.18.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e7daec1a2a2129eeba1644b220b4647ec537b0b5d4bfd6876fcc5a540056b592" +checksum = "2d886547e41f740c616ae73108f6eb70afe6d940c7bc697cb30f13daec073037" dependencies = [ "camino", "cargo-platform", @@ -2933,9 +2933,9 @@ checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" [[package]] name = "pathdiff" -version = "0.2.1" +version = "0.2.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8835116a5c179084a830efb3adc117ab007512b535bc1a21c991d3b32a6b44dd" +checksum = "d61c5ce1153ab5b689d0c074c4e7fc613e942dfb7dd9eea5ab202d2ad91fe361" [[package]] name = "pbkdf2" @@ -5756,7 +5756,6 @@ version = "0.5.11" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f4f7f0dd8d50a853a531c426359045b1998f04219d88799810762cd4ad314234" dependencies = [ - "indexmap 1.9.3", "serde", ] @@ -5766,6 +5765,7 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" dependencies = [ + "indexmap 2.6.0", "serde", "serde_spanned", "toml_datetime", @@ -5879,28 +5879,22 @@ dependencies = [ "anyhow", "arbitrary", "bincode", - "borsh 0.10.4", "cargo_metadata", "convert_case", "fehler", "futures", "honggfuzz", - "indicatif", - "log", "pathdiff", - "proc-macro2", "quinn-proto", "quote", - "regex", "serde", "serde_json", "solana-program-test", "solana-sdk", - "syn 1.0.109", + "syn 2.0.79", "thiserror", "tokio", - "toml 0.5.11", - "trident-derive-accounts-snapshots", + "toml 0.8.19", "trident-derive-displayix", "trident-derive-fuzz-test-executor", "trident-fuzz", @@ -5945,7 +5939,6 @@ dependencies = [ "fehler", "prettytable", "rand 0.8.5", - "regex", "serde", "serde_json", "solana-banks-client", @@ -5955,7 +5948,7 @@ dependencies = [ "spl-token", "thiserror", "tokio", - "toml 0.5.11", + "toml 0.8.19", ] [[package]] diff --git a/examples/fuzz-tests/unauthorized-access-2/Cargo.toml b/examples/fuzz-tests/unauthorized-access-2/Cargo.toml index 245186370..daa4c9e62 100644 --- a/examples/fuzz-tests/unauthorized-access-2/Cargo.toml +++ b/examples/fuzz-tests/unauthorized-access-2/Cargo.toml @@ -1,5 +1,6 @@ [workspace] members = ["programs/*", "trident-tests/fuzz_tests"] + [profile.release] overflow-checks = true lto = "fat" diff --git a/examples/fuzz-tests/unauthorized-access-2/Trident.toml b/examples/fuzz-tests/unauthorized-access-2/Trident.toml index 75f467c96..6de0eb954 100644 --- a/examples/fuzz-tests/unauthorized-access-2/Trident.toml +++ b/examples/fuzz-tests/unauthorized-access-2/Trident.toml @@ -29,42 +29,6 @@ max_file_size = 1048576 # Save all test-cases (not only the unique ones) by appending the current time-stamp to the filenames (default: false) save_all = false -[afl] -# Target compilation directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_target"]). -# To not clash with cargo build's default target directory. -cargo_target_dir = "" -# AFL working input directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/in"]). -afl_workspace_in = "" -# AFL working output directory, -# (default: "" ["trident-tests/fuzz_tests/fuzzing/afl/afl_workspace/out"]). -afl_workspace_out = "" -# fuzz for an approx. no. of total executions then terminate -# Note: not precise and can have several more executions. -# (default: 0 [no limit]). -execs = 100 -# fuzz for a specified time then terminate (fuzz time only!) -# (default: 0 [no limit]). -seconds = 0 - -[[afl.seeds]] -# Filename under which the test input is generated. -# The location of file is afl_workspace_in directory. -# (default: "" ["trident-seed"]). -file_name = "trident-seed" -# String used as seed. -# (default: "" ["0"]). -seed = "" -# If the file already exists at specific location, -# select if override. -# (default: false). -override_file = false -# Number of randomly generated bytes. -# (default: 0). -bytes_count = 20 - - [fuzz] # Allow processing of duplicate transactions. Setting to true might speed up fuzzing but can cause false positive crashes (default: false) allow_duplicate_txs = false diff --git a/examples/fuzz-tests/unauthorized-access-2/programs/unauthorized-access-2/Cargo.toml b/examples/fuzz-tests/unauthorized-access-2/programs/unauthorized-access-2/Cargo.toml index 3b31e36c9..401fba4e2 100644 --- a/examples/fuzz-tests/unauthorized-access-2/programs/unauthorized-access-2/Cargo.toml +++ b/examples/fuzz-tests/unauthorized-access-2/programs/unauthorized-access-2/Cargo.toml @@ -18,6 +18,12 @@ idl-build = ["anchor-lang/idl-build"] trident-fuzzing = ["dep:trident-fuzz"] [dependencies] -trident-derive-accounts-snapshots = { path = "../../../../../crates/fuzz/derive/accounts_snapshots" } -trident-fuzz = { path = "../../../../../crates/fuzz", optional = true } anchor-lang = "0.30.1" + +[dependencies.trident-derive-accounts-snapshots] +path = "../../../../../crates/fuzz/derive/accounts_snapshots" + + +[dependencies.trident-fuzz] +path = "../../../../../crates/fuzz" +optional = true diff --git a/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs b/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs index 5703361f0..c2a1cc76c 100644 --- a/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs +++ b/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/fuzz_instructions.rs @@ -1,12 +1,14 @@ use solana_sdk::native_token::LAMPORTS_PER_SOL; use trident_client::fuzzing::*; - -use unauthorized_access_2::trident_fuzz_initialize_snapshot::InitializeAlias; -use unauthorized_access_2::trident_fuzz_withdraw_snapshot::WithdrawAlias; use unauthorized_access_2::ESCROW_SEED; - +/// Link the relevant Account Context Alias from the program. +/// Aliases are generated by the `AccountsSnapshots` macro. type InitializeSnapshot<'info> = InitializeAlias<'info>; type WithdrawSnapshot<'info> = WithdrawAlias<'info>; +use unauthorized_access_2::trident_fuzz_initialize_snapshot::InitializeAlias; +use unauthorized_access_2::trident_fuzz_withdraw_snapshot::WithdrawAlias; +/// FuzzInstruction contains all available Instructions. +/// Below, the instruction arguments (accounts and data) are defined. #[derive(Arbitrary, DisplayIx, FuzzTestExecutor)] pub enum FuzzInstruction { Initialize(Initialize), @@ -23,6 +25,11 @@ pub struct InitializeAccounts { pub escrow: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct InitializeData { pub receiver: AccountId, @@ -39,15 +46,26 @@ pub struct WithdrawAccounts { pub escrow: AccountId, pub _system_program: AccountId, } +/// Custom data types must derive `Debug` and `Arbitrary`. +/// To do this, redefine the type in the fuzz test and implement the `From` +/// trait +/// to convert it into the type defined in the program. +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/arbitrary-data/#custom-data-types #[derive(Arbitrary, Debug)] pub struct WithdrawData {} +///IxOps implementation for `Initialize` with all required functions. impl<'info> IxOps<'info> for Initialize { type IxData = unauthorized_access_2::instruction::Initialize; type IxAccounts = FuzzAccounts; type IxSnapshot = InitializeSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { unauthorized_access_2::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, client: &mut impl FuzzClient, @@ -64,6 +82,12 @@ impl<'info> IxOps<'info> for Initialize { }; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -102,13 +126,19 @@ impl<'info> IxOps<'info> for Initialize { Ok((vec![author], acc_meta)) } } +///IxOps implementation for `Withdraw` with all required functions. impl<'info> IxOps<'info> for Withdraw { type IxData = unauthorized_access_2::instruction::Withdraw; type IxAccounts = FuzzAccounts; type IxSnapshot = WithdrawSnapshot<'info>; + /// Definition of the program ID that the Instruction is associated with. fn get_program_id(&self) -> solana_sdk::pubkey::Pubkey { unauthorized_access_2::ID } + /// Definition of the Instruction data. + /// Use randomly generated data from the fuzzer using `self.data.arg_name` + /// or customize the data as needed. + /// For more details, visit: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-data fn get_data( &self, _client: &mut impl FuzzClient, @@ -117,6 +147,12 @@ impl<'info> IxOps<'info> for Withdraw { let data = unauthorized_access_2::instruction::Withdraw {}; Ok(data) } + /// Definition of of the accounts required by the Instruction. + /// To utilize accounts stored in `FuzzAccounts`, use + /// `fuzz_accounts.account_name.get_or_create_account()`. + /// If no signers are required, leave the vector empty. + /// For AccountMetas use ::accounts:: + /// For more details, see: https://ackee.xyz/trident/docs/dev/features/fuzz-instructions/#get-accounts fn get_accounts( &self, client: &mut impl FuzzClient, @@ -172,8 +208,8 @@ impl<'info> IxOps<'info> for Withdraw { Ok(()) } } -#[doc = r" Use AccountsStorage where T can be one of:"] -#[doc = r" Keypair, PdaStore, TokenStore, MintStore, ProgramStore"] +/// Use AccountsStorage where T can be one of: +/// Keypair, PdaStore, TokenStore, MintStore, ProgramStore #[derive(Default)] pub struct FuzzAccounts { receiver: AccountsStorage, diff --git a/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs b/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs index b6643b998..b16376005 100644 --- a/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs +++ b/examples/fuzz-tests/unauthorized-access-2/trident-tests/fuzz_tests/fuzz_0/test_fuzz.rs @@ -1,16 +1,22 @@ use fuzz_instructions::Initialize; use trident_client::fuzzing::*; - mod fuzz_instructions; - use fuzz_instructions::FuzzInstruction; use unauthorized_access_2::entry as entry_unauthorized_access_2; use unauthorized_access_2::ID as PROGRAM_ID_UNAUTHORIZED_ACCESS_2; - const PROGRAM_NAME_UNAUTHORIZED_ACCESS_2: &str = "unauthorized_access_2"; - struct MyFuzzData; - +/// Define instruction sequences for invocation. +/// `pre_ixs` runs at the start, `ixs` in the middle, and `post_ixs` at the end. +/// For example, to call `InitializeFn` at the start of each fuzzing iteration: +/// ``` +/// fn pre_ixs(u: &mut arbitrary::Unstructured) -> +/// arbitrary::Result> { +/// let init = FuzzInstruction::InitializeFn(InitializeFn::arbitrary(u)?); +/// Ok(vec![init]) +/// } +/// ``` +/// For more details, see: https://ackee.xyz/trident/docs/dev/features/instructions-sequences/#instructions-sequences impl FuzzDataBuilder for MyFuzzData { fn pre_ixs(u: &mut arbitrary::Unstructured) -> arbitrary::Result> { let init_ix = FuzzInstruction::Initialize(Initialize::arbitrary(u)?); @@ -18,7 +24,8 @@ impl FuzzDataBuilder for MyFuzzData { Ok(vec![init_ix]) } } - +/// `fn fuzz_iteration` runs during every fuzzing iteration. +/// Modification is not required. fn fuzz_iteration + std::fmt::Display, U>( fuzz_data: FuzzData, config: &Config, @@ -28,15 +35,11 @@ fn fuzz_iteration + std::fmt::Display, U>( &PROGRAM_ID_UNAUTHORIZED_ACCESS_2, processor!(convert_entry!(entry_unauthorized_access_2)), ); - let mut client = ProgramTestClientBlocking::new(&[fuzzing_program_unauthorized_access_2], config).unwrap(); - let _ = fuzz_data.run_with_runtime(&mut client, config); } - fn main() { let config = Config::new(); - fuzz_trident ! (fuzz_ix : FuzzInstruction , | fuzz_data : MyFuzzData | { fuzz_iteration (fuzz_data , & config) ; }); }