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

Auto generate entrypoint method redirection based on method names / ABI #1094

Closed
lock9 opened this issue Sep 10, 2019 · 10 comments
Closed

Auto generate entrypoint method redirection based on method names / ABI #1094

lock9 opened this issue Sep 10, 2019 · 10 comments
Labels
compiler Module - Issues that are related or influence the behavior of our C# compiler discussion Initial issue state - proposed but not yet accepted enhancement Type - Changes that may affect performance, usability or add new features to existing modules.

Comments

@lock9
Copy link
Contributor

lock9 commented Sep 10, 2019

Summary
Today we have the ABI listing the methods available in a contract, however, it is not possible to know how to call these methods, because it depends on the implementation of the "switch statement", so the operation parameter doesn't have to match any method name in the ABI - but it should.

Do you have any solution you want to propose?
We should auto generate the entrypoint map to the methods, just like neo-one does.
If we can ensure that the operation matches the method names, we can automatically deserialize the results based on the ABI and allow users to explore and use smart contracts deployed in the network.

Where in the software does this update applies to?

  • Compiler
@lock9 lock9 added discussion Initial issue state - proposed but not yet accepted compiler Module - Issues that are related or influence the behavior of our C# compiler enhancement Type - Changes that may affect performance, usability or add new features to existing modules. labels Sep 10, 2019
@lock9
Copy link
Contributor Author

lock9 commented Sep 10, 2019

@shargon but how does it work? Is the compiler blocking an implementation of Main(operation, args)? It should if it is auto-generated

@shargon
Copy link
Member

shargon commented Sep 10, 2019

The compiler generate it, only if not exists

@lock9
Copy link
Contributor Author

lock9 commented Sep 10, 2019

@shargon I think we should block it completely, otherwise the ABI method names may not match the operation argument, and in my opinion, it should always match, after all, that is why the ABI is for

@shargon
Copy link
Member

shargon commented Sep 10, 2019

I don't think so, I think that should be created only if not exist, like now, maybe you need to add specific logic for verification, or maybe you don't want to create methods.

Now is more powerful. Acording to the abi, if a developer want to do by himself, what is wrong?

@lock9
Copy link
Contributor Author

lock9 commented Sep 10, 2019

@shargon the problem is that the ABI won't represent what it should: the contract interface. What is the sense of having an interface if it is not respected? 🤔
Why can't we have this auto-generated and have one specific method to be used in the verification? Like some kind of 'default' methods that users should override?
I have to enforce that it does not make sense to have an interface for a smart contract if it is not respected, and, it usually is not, because in C# we write methods in upper camel case, while we use the operation parameter with lower camel case.
We implement 'Transfer' method but use 'transfer' as operation.

@shargon
Copy link
Member

shargon commented Nov 18, 2019

If we avoid the Main method and we index the Offset in the ABI for all methods, we can avoid the initial switch too and start in the right place at the beginning.

What do you think @erikzhang @lightszero?

@erikzhang
Copy link
Member

This is an interesting proposal.

Usually we call a contract like this:

Call(hash, method, args)

Do you mean that we change to this:

Call(hash, offset, args)

This will indeed be faster. But I can think of some drawbacks, such as the inability to hide private methods.

@shargon
Copy link
Member

shargon commented Nov 19, 2019

exactly this

Call(hash, offset, args)

such as the inability to hide private methods.

If we allow only the offset if it is inside the ABI, we can hide them.

@erikzhang
Copy link
Member

Then we need to compare. I think it is the same as comparing the method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler Module - Issues that are related or influence the behavior of our C# compiler discussion Initial issue state - proposed but not yet accepted enhancement Type - Changes that may affect performance, usability or add new features to existing modules.
Projects
None yet
Development

No branches or pull requests

3 participants