-
Notifications
You must be signed in to change notification settings - Fork 58
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
Chain extension #662
Chain extension #662
Conversation
…xtension # Conflicts: # pallets/snarcos/src/lib.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.
One more thing, confused the hell out of me
@@ -0,0 +1,33 @@ | |||
[package] | |||
name = "snarcos-extension" |
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.
I find it kinda weird this crate is under runtime
folder. contracts
would be much better place in my opinion
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.
I have to plead guilty here as I made @pmikolajczyk41 move it from /contracts
to here.
My reasoning was (and still is) that the chain extension is part of the core chain (you can see it being defined in runtime/src/lib.rs
) and not living in the client space like contracts. Now it lives closer to the place where it's actually used and defined - we wouldn't be adding a chain extension written by clients (/contracts
, even though now live in the node's repo, are not part of the core chain).
IMO this also lowers a congitive load on developers that will read the code. Since the chain extensions' functions are referred by an index (number) and not interface, having the caller's function index "closer" (in terms of code organization) to the actual index we will pattern match on should be it simpler to discover. For this particular case, consider the interface exposed to contracts (link) and the actual pattern matching in the chain extension that routes the calls (link).
We can still make it "publishable" and have contracts refer to it in their dependencies https://github.com/Cardinal-Cryptography/aleph-node/blob/liminal/chain-extension/contracts/snarcos-contract/Cargo.toml#L26 - making it all type-safe.
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.
I see both points and I really cannot decide. There is, lets say, some solution with using https://github.com/Supercolony-net/obce, but for now it would be an overkill.
I'll leave this as it is now, and in case we find it inconvenient, we'll move it somewhere else (I suppose/hope somebody will play with it more and thus have some experience-based feedback).
CCing @Yithis to make him aware of these doubts (since he'll be extending this extension (today?))
This PR includes:
pallet_contracts::ChainExtension
which exposes a single function for callingpallet_snarcos::bare_store_key
with mocked argumentsink::chain_extension
definition (reusable in any contract)Reading: