Make runtime api generate version and identifier information (#1226)

* Make `decl_runtime_apis!` implement `RuntimeApiInfo` for all runtime
apis

* Make the runtime side generate the info constants as well

* Make `RuntimeApiInfo` implementation use the correct generics

* Adds a test for the runtime api info stuff

* Remove duplicated code by using block from `test-client`

* Adds `compile_fail` tests for `api_version`

* Adds documentation for `api_version`

* Make `impl_runtime_apis!` generate `RUNTIME_API_VERSIONS`

* Update documentation and tests for `RUNTIME_API_VERSIONS`

* Implement `has_api` by using the `RuntimeApiInfo`

* Make `impl_runtime_apis` check that trait identifiers are unique

* Prefix all runtime api function with the corresponding trait

So `execute_block` will be called `Core_execute_block`.
This makes it possible to have traits implement a function with the
same name.

* Rebase master

* Update after master rebase
This commit is contained in:
Bastian Köcher
2018-12-10 11:48:07 +01:00
committed by GitHub
parent a4a67ccbe7
commit 1f6719346f
25 changed files with 661 additions and 396 deletions
+6 -6
View File
@@ -91,7 +91,7 @@ mod tests {
Some(&InMemoryChangesTrieStorage::new()),
&mut overlay,
&executor(),
"initialise_block",
"Core_initialise_block",
&header.encode(),
ExecutionStrategy::NativeWhenPossible,
).unwrap();
@@ -102,7 +102,7 @@ mod tests {
Some(&InMemoryChangesTrieStorage::new()),
&mut overlay,
&executor(),
"apply_extrinsic",
"BlockBuilder_apply_extrinsic",
&tx.encode(),
ExecutionStrategy::NativeWhenPossible,
).unwrap();
@@ -113,7 +113,7 @@ mod tests {
Some(&InMemoryChangesTrieStorage::new()),
&mut overlay,
&executor(),
"finalise_block",
"BlockBuilder_finalise_block",
&[],
ExecutionStrategy::NativeWhenPossible,
).unwrap();
@@ -157,7 +157,7 @@ mod tests {
Some(&InMemoryChangesTrieStorage::new()),
&mut overlay,
&executor(),
"execute_block",
"Core_execute_block",
&b1data,
ExecutionStrategy::NativeWhenPossible,
).unwrap();
@@ -182,7 +182,7 @@ mod tests {
Some(&InMemoryChangesTrieStorage::new()),
&mut overlay,
&executor(),
"execute_block",
"Core_execute_block",
&b1data,
ExecutionStrategy::AlwaysWasm,
).unwrap();
@@ -208,7 +208,7 @@ mod tests {
Some(&InMemoryChangesTrieStorage::new()),
&mut overlay,
&Executor::new(),
"execute_block",
"Core_execute_block",
&b1data,
ExecutionStrategy::NativeWhenPossible,
).unwrap();