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
Trait implementation #1246
Trait implementation #1246
Conversation
# Conflicts: # src/vm/analysis/analysis_db.rs # src/vm/mod.rs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks again for all your work on this @lgalabru! I think we still need to get some clarity on whether or not the system needs to be strict on requiring a contract to impl-trait
, but I could be convinced. My only hesitation is from how it affects analysis and runtime cost. Maybe @kantai can comment?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great stuff, @lgalabru!
I left comments on the issues that I think need to be addressed. Otherwise, I think we should open an issue for moving the VM's trait check to be checked at the top-level contract-call execution (i.e. on transaction execution).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Thanks @lgalabru! Just a small typo fix and you're good to go on my end.
This PR is addressing #1168.
By doing so, we're introducing a mechanism for dynamically calling contracts while keeping our ability to run static analysis on contracts.
When a contract need to dispatch a call dynamically, it has to describe the behavior expected from the callee by defining a
trait
.Traits can be imported, aliased (for avoiding name collisions) and re-used:
Developers also have the option to explicitly declare that their contract is implementing a specific trait:
In this case, the static analysis will throw if the contract is violating the specifications defined by the trait.