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

[Neo Plugin New feature] UnhandledExceptionPolicy on Plugin Unhandled Exception #3311

Merged

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jun 9, 2024

Description

This is a follow up work after #3309. This pr will stop a plugin if a plugin throws an unhandled exception, but we also allow user to specify plugins not to stop on exception (except store plugins.).

Every single plugin can specifiy their own policy when unhandled exception is throw out of the plugin:

  • StopNode. Exception will be throw directly and not handled, this will cause the node to stop working. And this is current logic.
  • StopPlugin. Exception will be handled by the core and the plugin will be stoped from running.
  • Ignore. Exception will be recorded, but node and plugin will keep running.

Fixes # follow #3309

Type of change

  • Optimization (the change is only an optimization)
  • Style (the change is only a code style for better maintenance or standard purpose)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

  • TestOnPluginStopOnException
  • TestOnPluginStopped
  • TestOnNodeStopOnPluginException

Test Configuration:

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

@Jim8y Jim8y marked this pull request as draft June 9, 2024 10:46
@Jim8y Jim8y marked this pull request as ready for review June 9, 2024 15:21
@Jim8y Jim8y added Blocked This issue can't be worked at the moment Waiting for Review labels Jun 9, 2024
@Jim8y Jim8y changed the title [Neo Plugin New feature] Stop plugins on Unhandled Exception [Neo Plugin New feature] UnhandledExceptionPolicy on Plugin Unhandled Exception Jun 9, 2024
cschuchardt88
cschuchardt88 previously approved these changes Jun 9, 2024
src/Neo/Plugins/PluginSettings.cs Outdated Show resolved Hide resolved
src/Neo/Ledger/Blockchain.cs Outdated Show resolved Hide resolved
@Jim8y Jim8y changed the base branch from master to plugin-unhandled-exception June 10, 2024 14:10
src/Neo/Plugins/PluginSettings.cs Outdated Show resolved Hide resolved
src/Plugins/TokensTracker/TokensTracker.cs Outdated Show resolved Hide resolved
Co-authored-by: Christopher Schuchardt <[email protected]>
@Jim8y Jim8y removed the Blocked This issue can't be worked at the moment label Jun 16, 2024
@superboyiii
Copy link
Member

superboyiii commented Jun 17, 2024

Maybe TokenTracker should be the same default settings as Applicationlogs, they're working in similar behaviours.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jun 17, 2024

Maybe TokenTracker should be the same default settings as Applicationlogs, they're working in similar behaviours.

will update.

@Jim8y
Copy link
Contributor Author

Jim8y commented Jun 18, 2024

Following the call of the TC, this pr will be halted for 3-6 months. Thus please don't merge this pr.

@cschuchardt88 cschuchardt88 added Wait Technical Committee Blocked This issue can't be worked at the moment and removed Waiting for Review labels Jun 18, 2024
@shargon
Copy link
Member

shargon commented Jun 18, 2024

Following the call of the TC, this pr will be halted for 3-6 months. Thus please don't merge this pr.

This is required if we merged the previous related one. I Didn't read it nothing related against this pr

#3309 (review)

@Jim8y
Copy link
Contributor Author

Jim8y commented Jun 18, 2024

Following the call of the TC, this pr will be halted for 3-6 months. Thus please don't merge this pr.

This is required if we merged the previous related one. I Didn't read it nothing related against this pr

#3309 (review)

sure. since coredev meeting is scheduled next week, i think it should still be fine to merge this one.

@Jim8y Jim8y merged commit c696cec into neo-project:plugin-unhandled-exception Jun 18, 2024
7 checks passed
@Jim8y
Copy link
Contributor Author

Jim8y commented Jun 18, 2024

@shargon can you please merge this branch to master?

@vncoelho
Copy link
Member

NGDAdmin added a commit that referenced this pull request Jun 21, 2024
* [Neo Core] Part 1. Isolate Plugins Exceptions from the Node. (#3309)

* catch plugin exceptions.

* add UT test

* udpate format

* make the test  more complete

* complete the ut test

* format

* complete UT tests with NonPlugin case

* async invoke

* Update src/Neo/Ledger/Blockchain.cs

Co-authored-by: Christopher Schuchardt <[email protected]>

---------

Co-authored-by: Christopher Schuchardt <[email protected]>

* [Neo Plugin New feature]  UnhandledExceptionPolicy on Plugin Unhandled Exception (#3311)

* catch plugin exceptions.

* add UT test

* udpate format

* make the test  more complete

* complete the ut test

* format

* complete UT tests with NonPlugin case

* async invoke

* stop plugin on exception

* remove watcher from blockchain if uint test is done to avoid cross test data pollution.

* add missing file

* 3 different policy on handling plugin exception

* add missing file

* fix null warning

* format

* Apply suggestions from code review

Clean

* Update src/Neo/Plugins/PluginSettings.cs

Co-authored-by: Shargon <[email protected]>

* Update src/Neo/Plugins/PluginSettings.cs

Co-authored-by: Christopher Schuchardt <[email protected]>

* Update src/Plugins/TokensTracker/TokensTracker.cs

Co-authored-by: Christopher Schuchardt <[email protected]>

* Update src/Plugins/TokensTracker/TokensTracker.json

---------

Co-authored-by: Shargon <[email protected]>
Co-authored-by: Christopher Schuchardt <[email protected]>

* make the exception message clear

---------

Co-authored-by: Christopher Schuchardt <[email protected]>
Co-authored-by: Shargon <[email protected]>
Co-authored-by: NGD Admin <[email protected]>
@Jim8y Jim8y deleted the stop-plugins-on-fault branch July 19, 2024 01:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Blocked This issue can't be worked at the moment Ready to Merge Wait Technical Committee
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants