Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🥅 fuzzer error handling #118

Merged
merged 8 commits into from
Feb 16, 2024
Merged

🥅 fuzzer error handling #118

merged 8 commits into from
Feb 16, 2024

Conversation

lukacan
Copy link
Collaborator

@lukacan lukacan commented Feb 5, 2024

Currently, marked as draft as branch is WIP:

I would like to open a discussion to get feedback on whether the error handling is implemented correctly. Feel free to also point out some ideas or suggestions.

@lukacan lukacan requested a review from Ikrk February 5, 2024 20:24
@lukacan
Copy link
Collaborator Author

lukacan commented Feb 7, 2024

I will wait with this branch at least till we merge #115. So I can also update the accounts_snapshots.rs errors.

@lukacan lukacan force-pushed the feat/fuzzer-error-handling branch 2 times, most recently from efde295 to 40d4895 Compare February 14, 2024 21:20
@lukacan lukacan marked this pull request as ready for review February 15, 2024 18:57
@lukacan
Copy link
Collaborator Author

lukacan commented Feb 15, 2024

This PR should improve error handling throughout the entire fuzzing process.

Two types of errors can occur:

FuzzClientError
FuzzingError

Additionally, there is more information appended to the mentioned errors:

Context:
Pre - Pre-instruction
Post - Post-instruction

Origin:
Instruction (instruction name)
Account (PubKey)

These are then wrapped into FuzzClientErrorWithOrigin or FuzzingErrorWithOrigin (wrapped together with the error message). FuzzingErrorWithOrigin and FuzzClientErrorWithOrigin are propagated to the FuzzTestExecutor, where further steps can be evaluated based on the returned error.

@lukacan lukacan changed the title 🥅 WIP: error handling 🥅 error handling Feb 15, 2024
@lukacan lukacan changed the title 🥅 error handling 🥅 fuzzer error handling Feb 15, 2024
Copy link
Contributor

@Ikrk Ikrk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, it looks much better now.

.map_err(|e| e.with_origin(Origin::Instruction(self.to_string())));


match snapshot.capture_after(client) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you use match here (and also later on)? It should be the same as calling .unwrap()...

.ok_or(FuzzingError::AccountNotFound)?
.map_err(|_| FuzzingError::CannotDeserializeAccount)?;
.ok_or(FuzzingError::AccountNotFound(#name_str.to_string()))?
// TODO It would be helpful to do something like line below.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried to resolve it but without success. It really looks like some issue due to reexporting the type and having different anchor versions. Not sure. For now it is not critical. I will try to look at it once we update to anchor 0.29.0....

@Ikrk Ikrk merged commit 3e2c8da into develop Feb 16, 2024
7 checks passed
@Ikrk Ikrk deleted the feat/fuzzer-error-handling branch February 16, 2024 13:19
lukacan added a commit that referenced this pull request May 20, 2024
* 🥅 WIP: error handling

* 🔥 update FuzzTestExecutor to the default state

* 🚑️ box banksclient and minor error updates

* 🎨 fmt

* 🚀 update snapshot generator

* ✅ update tests

* ✅ update fuzz_example3

* 🎨 Cosmetic non-functional changes.

---------

Co-authored-by: lukacan <andrej@DESKTOP-UME2160.localdomain>
Co-authored-by: Ikrk <ikrk@centrum.cz>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants