-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
377 additions
and
230 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# Debug | ||
|
||
To debug your program with values from a crash file: | ||
|
||
```bash | ||
# fuzzer will run the <TARGET_NAME> with the specified <CRASH_FILE_PATH> | ||
trident fuzz run-debug <TARGET_NAME> <CRASH_FILE_PATH> | ||
# for example: | ||
trident fuzz run-debug fuzz_0 trident-tests/fuzz_tests/fuzzing/fuzz_0/cr1.fuzz | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Fuzzing statistics | ||
|
||
!!! tip | ||
|
||
In order to show statistics of fuzzing session (statistics are displayed after the fuzzing session ended), set `fuzzing_with_stats` within the Trident.toml to `true`. | ||
|
||
```toml | ||
[fuzz] | ||
# ... | ||
fuzzing_with_stats = true | ||
# ... | ||
``` | ||
|
||
|
||
Currently exported statistics from the Fuzzing Session | ||
|
||
#### Simple | ||
|
||
- Number of invocations of each instruction during the fuzzing session. | ||
- Number of successful invocations of each instruction during the fuzzing session. | ||
- Number of failed invariants checks for each instruction during the fuzzing session. | ||
|
||
??? note | ||
|
||
Keep in mind that the number of fuzz iterations does not directly correspond to the total number of invocations. In one fuzz iteration, the fuzzer might be unable to deserialize fuzz data into instructions, causing the entire iteration to be skipped. |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...entation/docs/fuzzing/fuzzing-examples.md → documentation/docs/fuzzing/extra/examples.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
documentation/docs/fuzzing/first-steps/writing-fuzz-test.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# Writing Fuzz Test | ||
|
||
!!! tip | ||
|
||
At the current development stage, there are some manual steps required to start the Fuzzing Session. In principle: | ||
|
||
**Prerequisites:** | ||
|
||
- Add dependencies specific to your program to `trident-tests/fuzz_tests/Cargo.toml` (such as anchor-spl etc.). | ||
- Add necessary `use` statements into `trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/accounts_snapshots.rs` to import missing types. | ||
|
||
**Writing Fuzz Tests** | ||
|
||
1. Specify pseudo-random accounts to re-use [Accounts to re-use](./accounts.md). | ||
2. Specify instruction data [Instruction Data](./instruction-data.md). | ||
3. Specify instruction accounts [Instruction Accounts](./instruction-accounts.md). | ||
|
||
**Run and Debug** | ||
|
||
1. Execute desired fuzz test [Run](../execute/run.md) | ||
2. See the found crash with more details [Debug](../execute/debug.md) | ||
|
||
!!! note | ||
|
||
For better fuzzing results and experience you can also manually adjust the following: | ||
|
||
1. Define Invariants checks [Invariants Checks](../writing-fuzz-test-extra/invariants-checks.md). | ||
2. Specify instruction sequences[Instruction sequences](../writing-fuzz-test-extra/instruction-sequences.md). | ||
3. Specify custom data types[Custom Data types](../writing-fuzz-test-extra/custom-data-types.md). | ||
4. Well structured data[Arbitrary](../writing-fuzz-test-extra/arbitrary.md). |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
documentation/docs/fuzzing/initialization/fuzzing-initialization-all.md
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
documentation/docs/fuzzing/initialization/fuzzing-initialization-fuzz-add.md
This file was deleted.
Oops, something went wrong.
3 changes: 3 additions & 0 deletions
3
documentation/docs/fuzzing/writing-fuzz-test-extra/accounts-snapshots.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# AccountsSnapshots | ||
|
||
TBD |
2 changes: 1 addition & 1 deletion
2
...on/docs/fuzzing/howto/fuzzing-howto-p7.md → ...zing/writing-fuzz-test-extra/arbitrary.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...on/docs/fuzzing/howto/fuzzing-howto-p6.md → ...ting-fuzz-test-extra/custom-data-types.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...on/docs/fuzzing/howto/fuzzing-howto-p5.md → ...-fuzz-test-extra/instruction-sequences.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 4 additions & 2 deletions
6
...on/docs/fuzzing/howto/fuzzing-howto-p4.md → ...ting-fuzz-test-extra/invariants-checks.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Accounts to reuse | ||
|
||
{{ config.site_name }} helps you to generate only a limited amount of pseudo-random accounts and reuse them in the instructions. | ||
|
||
??? note | ||
|
||
**Details:** | ||
|
||
Always generating only random accounts would **in most cases lead to a situation where the fuzzer would be stuck because the accounts would be almost every time rejected by your Anchor program**. Therefore it is necessary to specify, what accounts should be used and also limit the number of newly created accounts to reduce the space complexity. | ||
|
||
|
||
!!! tip | ||
|
||
Go to the `trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/fuzz_instructions.rs` file and complete the pre-generated `FuzzAccounts` structure. It contains all accounts used in your program. You have to determine if the account is a: | ||
|
||
- Signer | ||
- PDA | ||
- Token Account | ||
- Program account | ||
|
||
Then use the corresponding AccountsStorage. | ||
|
||
|
||
```rust | ||
pub struct FuzzAccounts { | ||
signer: AccountsStorage<Keypair>, | ||
some_pda: AccountsStorage<PdaStore>, | ||
token_vault: AccountsStorage<TokenStore>, | ||
mint: AccountsStorage<MintStore>, | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
documentation/docs/fuzzing/writing-fuzz-test/instruction-data.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Instruction data | ||
|
||
{{ config.site_name }} generates random instruction data for you. | ||
|
||
!!! tip | ||
|
||
Currently, it is however required, that you manually assign the random fuzzer data to the instruction data. It is done using the `IxOps` trait and its method `get_data`. | ||
|
||
- Go to the `trident-tests/fuzz_tests/<FUZZ_TEST_NAME>/fuzz_instructions.rs` file and complete the pre-generated `get_data` methods for each instruction. | ||
|
||
```rust | ||
fn get_data( | ||
&self, | ||
_client: &mut impl FuzzClient, | ||
_fuzz_accounts: &mut FuzzAccounts, | ||
) -> Result<Self::IxData, FuzzingError> { | ||
let data = fuzz_example1::instruction::Invest { | ||
amount: self.data.amount, | ||
}; | ||
Ok(data) | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Include Programs | ||
|
||
TBD |
Oops, something went wrong.