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
Implement ext_dispatch_call
#124
Conversation
9f13807
to
5dfe4b4
Compare
# Conflicts: # core/src/env/srml/srml_only/impls.rs # core/src/env/srml/types.rs # core/src/env/test_env.rs # core/src/env/traits.rs
# Conflicts: # examples/core/incrementer/Cargo.toml # examples/core/noop/Cargo.toml # examples/core/subpeep/Cargo.toml # examples/model/incrementer/Cargo.toml
core/src/env/srml/types.rs
Outdated
impl Decode for Call { | ||
fn decode<I: Input>(_value: &mut I) -> Option<Self> { | ||
impl parity_codec::Decode for Call { | ||
fn decode<I: parity_codec::Input>(_value: &mut I) -> Option<Self> { |
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.
Then better put it behind test-env
feature instead of std
feature and also provide a rational (comment) why it is there.
examples/lang/calls/Cargo.toml
Outdated
name = "calls" | ||
crate-type = ["cdylib"] | ||
|
||
[features] |
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.
Still needs adjustment
examples/lang/calls/rust-toolchain
Outdated
@@ -0,0 +1 @@ | |||
nightly-2019-05-21 |
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.
Please delete rust-toolchain
file.
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 🌠
* [core] Add AccountId to EnvTypes * [core] Add calls mod, plus WIP tests * [core] Balance transfer call roundtrip works * [core] Add ext_dispatch_call * [core] Implement ext_dispatch_call * [examples] Add example lang contract for ext_dispatch_call * [examples] WIP: implement example lang contract for ext_dispatch_call * [examples] complete basic implementation of dispatching Balances Call * srml-contracts -> srml-contract * [core] remove unsafe from dispatch_call api fn * [core] Add docs to dispatch_call * [core] Add missing trait bound to account index * [core] Some todos * [core] Rename dispatch_call to dispatch_raw_call on Env trait * [lang] Add AccountIndex type alias * [model] add strongly type dispatch call to EnvHandler * [*] specify latest parity-codec version, same as substrate * [core] fix call roundtrip tests * [lang] fix tests * [core] fix wasm build * [core] fix std build * [core] move call type serialization tests * [core] test Call serialization roundtrip * [core] use node_runtime for Call serialization roundtrip * [core] remove unused dependencies * [core] remove unused substrate dependencies * [core] change default Balance to u128, matching substrate * [core] introduce Address type for balance calls * [core] fix Balances transfer serialization test * [core] add Address serialization tests * [ci] install wasm-gc for building substrate dev deps * [ci] move wasm-gc installation after wasm target added * [examples] get the calls example compiling * [CI] add temporary check for debugging ci build * [CI] restore wasm-gc to install section and remove temp version check * [CI] temporarily depend on substrate branch to test build fix * [CI] remove temp substrate branch, build issue fixed * [core] use std feature instead of test-env for EnvTypes * [core] remove Call types, moved to ink-types-node-runtime * [core] remove AccountIndex from EnvTypes * [core] remove AccountIndex from lang codegen * [core] fix unused for std * [CI] remove wasm-gc from travis build * [CI] remove AccountIndex type alias from codegen * parity-codec version 4.1.1 -> 4.1 * [core] ext_dispatch_call docs * [core] describe in comment what will happen if decoding fails * [model] implement suggestion of Into<Call> * rustfmt * rustfmt again * rustfmt again again * [examples] deleted calls example - moved to ink_types_node_runtime * [core] use into in api::dispatch_call * [core] make Call empty enum and use test-env feature for EnvTypes * [core] remove unused Call enum * [core] add comments explaining rationale for test-env * [core] missing period * [core] add comments * [core] add space in comment * [core] add comment to Call decode impl * [core] make dispatched_calls a DoubleEndedIterator * [core] add missing doc comment * [core] add comment explaining Decode requirement * [core] doc comment and DoubleEndedIterator
Resolves #42.
dispatch_call
functionEnvType
Call
which must implementEncode
Introduces pre-baked. edit: this part has been moved to InitialCall
types for srml modulesCall
implementation paritytech/ink-types-node-runtime#3Here is an example of dispatching a
Balances::transfer
from a contract:The pre-baked
Call
types are "copies" of the srml moduleCall
enums e.g. Balances. Importing the actual types from substrate is possible but it results in a very large wasm blob size. To ensure compatibility with the equivalent substrate types, tests are required for eachCall
which encode the local type and decode as the substrate type.Note: This PR only includes a single predefined
Call
type forBalances
. I think we should consider which additional calls/modules we should add in a follow up PR.The final piece is the definition of the top level
Call
enum to compose the modules to match the substrate runtime. This can be user defined for custom runtimes by defining theCall
type inEnvTypes
e.g.Because of how
parity-scale-codec
encodes enums, chain authors can define only the srml module calls they want to support, so long as theindex
matches up with the the relevantCall
variant in the target chain's substrate runtime declaration.