feature: mpl-utils: Log assert failures for easier debugging#1163
feature: mpl-utils: Log assert failures for easier debugging#1163KartikSoneji wants to merge 4 commits intometaplex-foundation:masterfrom
mpl-utils: Log assert failures for easier debugging#1163Conversation
|
Thanks for this PR! It is indeed awful to debug any of these issues. The lack of logging of specific failures is unfortunately a necessity due to program size and compute constraints. However, ExtendProgram is scheduled to be enabled Monday so that will hopefully solve the size issue. |
|
Oh does calling |
|
It's the actual strings. I think we have more space now but we were a handful of bytes from the max a couple months ago. |
|
Ah I see. |
|
Hi, just a friendly ping on this. |
b73834d to
f15e902
Compare
|
Huzzah, we have space now! Can you just change these to use |
|
Done! |
core/rust/utils/src/assertions.rs
Outdated
| ) -> ProgramResult { | ||
| if account.owner != owner { | ||
| msg!( | ||
| "owner assertion failed for {key}: expected {expected}, got {actual}", |
There was a problem hiding this comment.
"invalid owner for {key} ({actual} != {expected})"
core/rust/utils/src/assertions.rs
Outdated
| let (key, bump) = Pubkey::find_program_address(path, program_id); | ||
| if key != *account.key { | ||
| msg!( | ||
| "derivation assertion failed for {actual_key}:\n |
There was a problem hiding this comment.
"invalid derivation {actual_key} != {key}"
There was a problem hiding this comment.
Looks like \n is not needed, I'll remove that.
febo
left a comment
There was a problem hiding this comment.
What do you think if we make the log messages a bit shorter so the log does not get cluttered?
|
Hmm I really think the log messages should provide as much information to debug as possible. |
I agree that log messages should be descriptive, but the observation here is because this is a library not a program. A program might handle an assert failure so it does not end up being a "fatal error". |
|
OK, I'll shorten the messages for |
At the moment, when an assertion fails, the program only throws an error about the type of assertion that has failed.
This there no indication to which account is the incorrect one, making it a nightmare to debug.
For example:
This PR adds logs that print the account that failed the assertion and some debug information about why the assertion failed.
They only trigger if the assertion fails, so shouldn't effect the compute unit budget during normal operation.