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 Bug]fix 3296 #3299

Merged
merged 8 commits into from
Jun 11, 2024
Merged

[Neo Plugin Bug]fix 3296 #3299

merged 8 commits into from
Jun 11, 2024

Conversation

Jim8y
Copy link
Contributor

@Jim8y Jim8y commented Jun 7, 2024

Description

This pr solves the issue in #3296 that log only catch exception of specific type.

Fixes # #3296

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?

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
Copy link
Contributor Author

Jim8y commented Jun 7, 2024

@Jim8y Jim8y linked an issue Jun 7, 2024 that may be closed by this pull request
@Jim8y Jim8y added bug Used to tag confirmed bugs critical Issues (bugs) that need to be fixed ASAP waiting for review labels Jun 7, 2024
@Jim8y Jim8y requested a review from a team June 7, 2024 02:41
@Hecate2
Copy link
Contributor

Hecate2 commented Jun 7, 2024

It works on my private chain

{
_snapshot.Put(key, BinarySerializer.Serialize(StackItem.Null, ExecutionEngineLimits.Default with { MaxItemSize = (uint)Settings.Default.MaxStackSize }));
var detailedException = ex.Message;
if (detailedException.Length > 1024)
Copy link

Choose a reason for hiding this comment

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

Thanks @Jim8y. You've create a lot of PRs that makes exception messages much more clear than before. So as this one.

It would be better if we change the magic 1024 to some constant variable like Default.MaxStackSize/2 or something else.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@dusmart Thank you for the recognition, credits of this fix goes to @Hecate2. Need @dusmart your suggestion to decide that value, is Default.MaxStackSize/2 secure enough.

Copy link

Choose a reason for hiding this comment

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

I'm not sure what's the real value of Default.MaxStackSize. 1024 and 2048 or any number, they all seems good to me. Maybe @AnnaShaleva has more experience on this settings.

Copy link
Member

Choose a reason for hiding this comment

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

@dusmart, to be honest, I'd prefer not mix the real (even invalid) stackitem with some system-created one. See the #3299 (comment).

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure what's the real value of Default.MaxStackSize. 1024 and 2048 or any number, they all seems good to me. Maybe @AnnaShaleva has more experience on this settings.

Settings comes the config.json so it can be whatever you want.

cschuchardt88
cschuchardt88 previously approved these changes Jun 7, 2024
@superboyiii
Copy link
Member

Tested on testnet, it works.

Comment on lines 162 to 166
catch (NotSupportedException)
catch (Exception ex)
{
_snapshot.Put(key, BinarySerializer.Serialize(StackItem.Null, ExecutionEngineLimits.Default with { MaxItemSize = (uint)Settings.Default.MaxStackSize }));
var detailedException = ex.Message;
if (detailedException.Length > 1024)
Copy link
Member

Choose a reason for hiding this comment

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

Catching any exception is enough to solve the original problem. Why should we change the behavior and serialize exception message instead of Null stackitem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Null or exception both works. Using exception message to explicitly tell people there is an issue.

Copy link
Member

@AnnaShaleva AnnaShaleva Jun 7, 2024

Choose a reason for hiding this comment

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

We think that it's not quite correct to replace the original stackitem by either Null or ByteString because from the user side it's impossible to distinguish the "good" original stackitem from the result of invalid seialization.

Please, take a look at the way how this case is handled in NeoGo: https://github.com/nspcc-dev/neo-go/blob/cf4d4a2611209d8d085ccec6e1f1b8956006a577/pkg/vm/stackitem/serialization.go#L144. We use a special stackitem stub of InvalidT type which can't be produced by any means other than exception during serialisation. With this special type there's no doubts from the user side whether there was an exception during serialization or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We think that it's not quite correct to replace the original stackitem by either Null or ByteString because from the user side it's impossible to distinguish the "good" original stackitem from the result of invalid seialization.

i understand your concern, but issues has being there and this pr is not for that purpose, you can have another pr to fix it. for me, no one but hackers will ever see that information.

Copy link
Member

Choose a reason for hiding this comment

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

But if we're changing this code anyway, why not to make it work properly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

But if we're changing this code anyway, why not to make it work properly?

Cause its not the purpose of this pr, though its easy to update, but that is your idea and your property, and most importantly, its another issue.

Copy link
Member

@AnnaShaleva AnnaShaleva Jun 7, 2024

Choose a reason for hiding this comment

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

I agree with the fix itself. But then let's not to change this line:

_snapshot.Put(key, BinarySerializer.Serialize(StackItem.Null, ExecutionEngineLimits.Default with { MaxItemSize = (uint)Settings.Default.MaxStackSize }));

And create the proper issue to improve it.

Copy link
Member

Choose a reason for hiding this comment

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

Ref. #3303.

@Jim8y Jim8y requested a review from shargon June 7, 2024 07:09
shargon
shargon previously approved these changes Jun 7, 2024
@Jim8y Jim8y dismissed stale reviews from cschuchardt88 and shargon via 512d738 June 7, 2024 14:27
@Jim8y
Copy link
Contributor Author

Jim8y commented Jun 7, 2024

@AnnaShaleva updated

@Jim8y Jim8y added this to the v3.7.5 milestone Jun 11, 2024
@NGDAdmin NGDAdmin merged commit b68ad51 into neo-project:master Jun 11, 2024
7 checks passed
@Jim8y Jim8y deleted the fix-3296 branch June 11, 2024 03:16
superboyiii added a commit to neo-project/neo-modules that referenced this pull request Jun 11, 2024
superboyiii added a commit to neo-project/neo-modules that referenced this pull request Jun 12, 2024
* fix patch from:
neo-project/neo#3261
and
neo-project/neo#3299

* add neo-project/neo#3282

* add neo-project/neo#3263

* v3.7.5 hotfix

* readme
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to tag confirmed bugs critical Issues (bugs) that need to be fixed ASAP ready to merge waiting for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

some nodes on testnet stopped syncing maybe caused by some modules
8 participants