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

Fix Safe Assert #2784

Closed
wants to merge 1 commit into from
Closed

Fix Safe Assert #2784

wants to merge 1 commit into from

Conversation

shargon
Copy link
Member

@shargon shargon commented Jun 30, 2022

@shargon shargon requested a review from erikzhang June 30, 2022 13:25
@shargon shargon changed the title Fix safe log Fix Safe Assert Jun 30, 2022
@shargon
Copy link
Member Author

shargon commented Jun 30, 2022

@erikzhang @roman-khimov now Log (Safe Assert) will FAULT, but at least the exception will be saved. What do you think?


if (!CurrentContext.GetState<ExecutionContextState>().CallFlags.HasFlag(CallFlags.AllowNotify))
{
OnFault(new Exception(message));
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are we faulting on log if AllowNotify is enabled? Why would we assume that a call to Log must be a fault?

Copy link
Member Author

Choose a reason for hiding this comment

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

Because Log require Notify rights so if we don't have it, it will fault in the previous version, now the same but at least we have the message captured. That's my favorite version for solve the issue

Copy link
Member Author

Choose a reason for hiding this comment

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

Why are we faulting on log if AllowNotify is enabled? Why would we assume that a call to Log must be a fault?

If NOT

Copy link
Contributor

Choose a reason for hiding this comment

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

OK, I see the logic. Since this PR changes requiredCallFlags to None, RuntimeLog will only go down the fault path in cases where we would have thrown in ValidateCallFlags previously.

Why are we calling OnFault instead of throwing like ValidateCallFlags does?

Copy link
Member Author

@shargon shargon Jul 12, 2022

Choose a reason for hiding this comment

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

Because with OnFault we can set the Log error message, and we don't lose the assert message

Copy link
Contributor

@devhawk devhawk left a comment

Choose a reason for hiding this comment

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

NeoExpress, NeoDebugger and NeoTest all provide mechanisms to surface log messages. We can't automatically treat log calls as faults w/o breaking this.

Only faults in cases that would have faulted previously

@superboyiii
Copy link
Member

@roman-khimov @erikzhang Could you review this? I think throw error msg when fault is OK, at least we can make some logs.

@roman-khimov
Copy link
Contributor

I'd rather go with neo-project/neo-vm#491, as noted in #2782.

@shargon
Copy link
Member Author

shargon commented Nov 7, 2023

Closed by neo-project/neo-devpack-dotnet#758

@shargon shargon closed this Nov 7, 2023
@shargon shargon deleted the fix-safe-log branch November 7, 2023 16:56
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.

Assert and Safe methods
4 participants