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

Unnecessary argument when the smart contract class and its methods are non-static #1183

Open
Hecate2 opened this issue Sep 27, 2024 · 3 comments

Comments

@Hecate2
Copy link
Contributor

Hecate2 commented Sep 27, 2024

When a user does not define the compiled smart contract class and its methods as static, the compiler builds an unnecessary argument, and input it as arg 0 (this of the class object) for all the non-static methods. An example is the compilation results of neo-devpack-dotnet/tests/Neo.Compiler.CSharp.TestContracts/Contract_Abort.cs (manifest and dumpnef affliated). Maybe we can avoid generating this unnecessary arg 0 in the compiler.
If (in the future) we have a symbolic VM that analyzes reads and writes to storage evaluation stack, static fields, arguments and local varaiables, we may try to identify the unnecessary constructions and delete the codes in the optimizer.

Contract_Abort.nef.txt
Contract_Abort.manifest.json

@Jim8y
Copy link
Contributor

Jim8y commented Sep 27, 2024

are you going to process it?

@Hecate2
Copy link
Contributor Author

Hecate2 commented Sep 27, 2024

are you going to process it?

I'm not sure. I have not found the best way to handle it.

@Hecate2
Copy link
Contributor Author

Hecate2 commented Sep 30, 2024

This problem can be handled by #1185 in most cases. But in polymorphism tests, I did not remove the constructors in a derived smart contract class, because base may be called at any time.

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

No branches or pull requests

2 participants