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 NEO callstates #3599

Open
wants to merge 21 commits into
base: HF_Echidna
Choose a base branch
from
Open

Fix NEO callstates #3599

wants to merge 21 commits into from

Conversation

shargon
Copy link
Member

@shargon shargon commented Nov 26, 2024

Description

Fixes #3596

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?

  • Manual

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

@shargon shargon marked this pull request as ready for review November 26, 2024 11:37
Copy link
Contributor

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

vote method requires this too.

src/Neo/SmartContract/Native/NativeContract.cs Outdated Show resolved Hide resolved
@shargon shargon added Bug Used to tag confirmed bugs Hardfork labels Nov 26, 2024
@shargon shargon changed the title Allow callstates to use HF Allow NEO callstates Nov 26, 2024
@shargon shargon changed the title Allow NEO callstates Fix NEO callstates Nov 26, 2024
Copy link
Contributor

@roman-khimov roman-khimov left a comment

Choose a reason for hiding this comment

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

Much better this way. Probably solving any other similar problems (like CpuFee updates). I'd try avoiding unnecessary changes, but that's nitpicking mostly.

src/Neo/ProtocolSettings.cs Outdated Show resolved Hide resolved
src/Neo/ProtocolSettings.cs Outdated Show resolved Hide resolved
src/Neo/SmartContract/Native/ContractMethodMetadata.cs Outdated Show resolved Hide resolved
Copy link
Member

@cschuchardt88 cschuchardt88 left a comment

Choose a reason for hiding this comment

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

Please fix these memory leaks

src/Neo/ProtocolSettings.cs Outdated Show resolved Hide resolved
src/Neo/ProtocolSettings.cs Show resolved Hide resolved
shargon and others added 2 commits November 26, 2024 23:46
Co-authored-by: Christopher Schuchardt <[email protected]>
Co-authored-by: Christopher Schuchardt <[email protected]>
@@ -131,7 +131,7 @@ public record ProtocolSettings
/// <returns>The loaded <see cref="ProtocolSettings"/>.</returns>
public static ProtocolSettings Load(Stream stream)
{
var config = new ConfigurationBuilder().AddJsonStream(stream).Build();
using var config = new ConfigurationBuilder().AddJsonStream(stream).Build();
Copy link
Member

@cschuchardt88 cschuchardt88 Nov 26, 2024

Choose a reason for hiding this comment

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

ConfigurationBuilder on build uses ConfigurationRoot may have to cast to it. either way needs to be fixed for memory leak.

or could do
((IDisposable)config).Dispose(); at of the method

https://github.com/dotnet/runtime/blob/9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationBuilder.cs#L53C24-L53C41

Copy link
Member Author

Choose a reason for hiding this comment

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

It was not a memory leak...

Copy link
Member

@cschuchardt88 cschuchardt88 Nov 27, 2024

Choose a reason for hiding this comment

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

ConfiguationRoot is the class that is created for inherits from IConfigurationRoot

How isn't it a memory leak, The memory for the providers are still allocated? Streams and all.
https://github.com/dotnet/runtime/blob/9d5a6a9aa463d6d10b0b0ba6d5982cc82f363dc3/src/libraries/Microsoft.Extensions.Configuration/src/ConfigurationRoot.cs#L99C9-L112C10

Just do (config as IDisposable)?.Dispose() what's the big deal?

@Jim8y Jim8y added this to the v3.8.0 milestone Nov 27, 2024
@Jim8y Jim8y mentioned this pull request Nov 27, 2024
9 tasks
@shargon
Copy link
Member Author

shargon commented Nov 27, 2024

Ready to review again

Copy link
Member

@AnnaShaleva AnnaShaleva left a comment

Choose a reason for hiding this comment

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

LGTM.

ContractMethodAttribute attribute = member.GetCustomAttribute<ContractMethodAttribute>();
if (attribute is null) continue;
listMethods.Add(new ContractMethodMetadata(member, attribute));
foreach (var attribute in member.GetCustomAttributes<ContractMethodAttribute>())
Copy link
Member

Choose a reason for hiding this comment

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

Previously there was a check for if (attribute is null), is it possible that attribute is nil with the current implementation? I think it's OK, but we'd better make sure.

Copy link
Member Author

Choose a reason for hiding this comment

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

No, now can't be null

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 Hardfork Waiting for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants