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

Debug-mode detailed output #125

Merged
merged 6 commits into from
Feb 20, 2024
Merged

Debug-mode detailed output #125

merged 6 commits into from
Feb 20, 2024

Conversation

lukacan
Copy link
Collaborator

@lukacan lukacan commented Feb 16, 2024

I would say currently the best possible option to debug the fuzzed instructions sequence is to use msg!() macro inside the solana program.

This PR makes it easier to examine data and accounts passed into instructions. Here are the improvements:

  • It defaults to deriving the Debug trait for Accounts and Data structs generated by the Fuzzer.
  • The DisplayIx macro is extended to also display struct contents.
  • In relation to the above points, the DisplayIx macro is further extended to derive a "to_context_string()" function. This is used to obtain the instruction name since the std::fmt::Display implementation now includes the struct contents, meaning to_string() would also fetch the contents - this method is further used within the FuzzTestExecutor to obtain Error Context.
  • (This may be overkill) A simple "show_account" macro is introduced, which implements pretty-print for the input account.
    • This may be used by the user for example within the check() function. The macro contains requirements inside rustdocs to derive the Debug trait for the Account Struct If the user wants to display the Account`s contents.

When we look at the data from instruction sequences, the amount of information in debug mode can be too noisy. I thought about using an additional conditional compilation to manage this. This means we could use the RUSTFLAGS environment variable to give extra instructions to the rustc compiler (used by the honggfuzz). But, doing this would mean that all the code that was compiled before would need to be compiled again, and this could take a lot of time. So, for now, I've decided to just use the fuzzing_debug flag, which is automatically turned on by the honggfuzz.

@lukacan lukacan requested a review from Ikrk February 16, 2024 21:23
@Ikrk Ikrk force-pushed the feat/fuzz-debug-display-instr branch from e8ee52f to eccb9d4 Compare February 19, 2024 16:25
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.

lgtm

@Ikrk Ikrk merged commit a8d2529 into develop Feb 20, 2024
7 checks passed
@Ikrk Ikrk deleted the feat/fuzz-debug-display-instr branch February 20, 2024 08:27
lukacan added a commit that referenced this pull request May 20, 2024
* 🚧 WIP: display deserialized instruction data within debug mode

* 🧑‍💻 show_account macro + docu

* 🧑‍💻 to_context_string() fn, debug output

* ♻️ Updated derive macros

* ♻️ Updated crash error message

* ♻️ pass tests, remove unnecessary macro

---------

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.

None yet

2 participants