Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Substrate runtime interface 2.0 #4057

Merged
merged 90 commits into from
Nov 10, 2019
Merged
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
1b62f0c
Adds first version of traits for generating the host functions
bkchr Sep 17, 2019
63fd2ce
First steps of the procedural macro
bkchr Sep 19, 2019
aecba72
Implements generation of the host extern functions
bkchr Sep 19, 2019
f7fa0ab
Prefix ext host function with snake case trait name
bkchr Sep 20, 2019
a922101
Implement host functions implementation on the host
bkchr Sep 24, 2019
156d8a0
Change `HostFunctions` interface
bkchr Sep 24, 2019
936d029
Implement `HostFunctions` for tuples
bkchr Sep 25, 2019
dfe833a
Make `WasmExecutor` generic over the host functions
bkchr Sep 25, 2019
bd8ac35
Begin to add a test and make it compile
bkchr Sep 25, 2019
6bd6d99
Make the test succeed
bkchr Sep 25, 2019
1cf5310
Add test to ensure that host functions are not found
bkchr Sep 25, 2019
8aaf851
It's alive! Make the `set_storage` test work
bkchr Sep 26, 2019
8d88117
Add test for mutable references
bkchr Sep 26, 2019
d17cf4f
Code cleanup and documentation etc
bkchr Sep 26, 2019
fcb6498
Add marker trait for types that should be passed as SCALE encoded
bkchr Sep 26, 2019
7c20e34
Inherit the visibility from the trait and more improvements
bkchr Sep 26, 2019
5eecdb0
More impls and move them into their own file
bkchr Sep 27, 2019
7a55140
Code simplification by dropping one trait
bkchr Sep 27, 2019
53f8de2
Give it a better name
bkchr Sep 27, 2019
0807fd9
Implement traits for arrays
bkchr Sep 30, 2019
dbab580
Refactor code to support pass by codec/inner
bkchr Sep 30, 2019
69ffd26
Docs
bkchr Sep 30, 2019
f7c1e5e
Implement pass by inner for some crypto types and add a test
bkchr Sep 30, 2019
36ac4d3
Implement exchangeable function support
bkchr Oct 1, 2019
5eb2143
Rewrite sr-io with as runtime interface
bkchr Oct 2, 2019
4a83704
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Oct 2, 2019
5f11653
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Oct 9, 2019
9e8869b
Start reworking after master merge
bkchr Oct 9, 2019
ac8de56
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Oct 10, 2019
0402799
Adds `PassByCodec` derive
bkchr Oct 10, 2019
78a7092
Adds `PassByInner` derive
bkchr Oct 10, 2019
8a1987a
Fix compilation errors
bkchr Oct 14, 2019
450a9d7
More implementations
bkchr Oct 14, 2019
0e9167f
Implement runtime interface traits for `str`
bkchr Oct 14, 2019
c0d8132
Make `sr-io` compile again
bkchr Oct 15, 2019
323bf15
Fix more compilation errors
bkchr Oct 18, 2019
a27038e
More progress on getting stuff back to compile
bkchr Oct 22, 2019
f6af79e
Merge branch 'master' into bkchr-generate-host-functions
bkchr Oct 22, 2019
87eb710
More compilation fixes
bkchr Oct 25, 2019
cd7b9a9
Fix warnings
bkchr Oct 25, 2019
a2f9d31
Remove le conversions
bkchr Oct 25, 2019
2200ca1
Add support for `wasm_only` interfaces
bkchr Oct 25, 2019
a912730
Implement `Allocator` interface
bkchr Oct 25, 2019
0313975
Improve error message
bkchr Oct 25, 2019
f2c35bf
Move `WasmAllocator` to `sr-io` and more clean ups
bkchr Oct 25, 2019
e71f3e5
Use correct function signature for wasm functions
bkchr Oct 25, 2019
4e667eb
Store the host functions with the Wasm runtime
bkchr Oct 26, 2019
08d478c
Docs update
bkchr Oct 26, 2019
71e8006
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Oct 26, 2019
bcc04e6
Fix compilation after master merge
bkchr Oct 26, 2019
df8f9fc
Remove `sr-io/without_std`
bkchr Oct 27, 2019
1c818dd
Make `srml-support` tests run again
bkchr Oct 27, 2019
60b1fff
More compilation error fixes
bkchr Oct 27, 2019
a6c6791
Use correct doc syntax
bkchr Oct 28, 2019
2d6b05e
Fix test-runtime
bkchr Oct 28, 2019
9328a2d
Fix compilation
bkchr Oct 29, 2019
a805f2a
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Oct 29, 2019
57c4ed9
Catch native panics when executing the wasm runtime
bkchr Oct 29, 2019
c7b77c4
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Oct 30, 2019
3f2642b
Merge remote-tracking branch 'origin/bkchr-wasm-catch-panic' into bkc…
bkchr Oct 30, 2019
52fce3b
Fix compilation
bkchr Oct 30, 2019
0af7aaa
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Oct 30, 2019
33eb170
Don't panic in a panic
bkchr Oct 31, 2019
5a67f45
Move `sr-sandbox` to new runtime interface
bkchr Oct 31, 2019
1c68747
Fixes tests after sandbox changes
bkchr Oct 31, 2019
a546aab
Make sure we detect invalid utf8
bkchr Nov 1, 2019
184135f
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Nov 1, 2019
162c62b
Fixes after master merge
bkchr Nov 1, 2019
f0c7190
Adds pass by enum strategy
bkchr Nov 1, 2019
ac33c02
Fix wasmtime integration
bkchr Nov 3, 2019
959ae7d
Some macro structure clean up
bkchr Nov 4, 2019
f6da18e
Rework and test exchangebale host functions
bkchr Nov 4, 2019
573cec0
PassBy derive macros documentation
bkchr Nov 4, 2019
1e0f2eb
Docs for `runtime_interface` macro
bkchr Nov 6, 2019
987bb1b
Support wild card argument names
bkchr Nov 8, 2019
a5ff11b
Adds ui tests
bkchr Nov 8, 2019
dad538f
Make sure that we are backwards compatible to the old runtime interfaces
bkchr Nov 8, 2019
70149b6
Documentation
bkchr Nov 8, 2019
8238a14
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Nov 8, 2019
113d473
Fixes after latest master merge
bkchr Nov 8, 2019
e5faddf
Make `wasmtime` happy
bkchr Nov 8, 2019
059d80e
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Nov 9, 2019
c06174a
Make `full_crypto` work
bkchr Nov 9, 2019
4515c4d
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Nov 9, 2019
44333d2
Make the new interface versionable
bkchr Nov 9, 2019
652817b
Merge remote-tracking branch 'origin/master' into bkchr-generate-host…
bkchr Nov 10, 2019
cd2b226
Rename `Sanboxing` to `Sandbox`
bkchr Nov 10, 2019
4ce996c
Don't finalize in test while importing
bkchr Nov 10, 2019
d23587f
Fix Performance regression
bkchr Nov 10, 2019
696ed43
Fix test
bkchr Nov 10, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 80 additions & 15 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ members = [
"core/rpc",
"core/rpc/primitives",
"core/rpc-servers",
"core/runtime-interface",
"core/runtime-interface/proc-macro",
"core/runtime-interface/test-wasm",
"core/serializer",
"core/service",
"core/service/test",
Expand Down
15 changes: 8 additions & 7 deletions core/application-crypto/src/ed25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

use crate::{RuntimePublic, KeyTypeId};

use rstd::vec::Vec;

pub use primitives::ed25519::*;

mod app {
Expand All @@ -29,28 +31,27 @@ mod app {
}
}

pub use app::Public as AppPublic;
pub use app::Signature as AppSignature;
pub use app::{Public as AppPublic, Signature as AppSignature};
#[cfg(feature = "full_crypto")]
pub use app::Pair as AppPair;

impl RuntimePublic for Public {
type Signature = Signature;

fn all(key_type: KeyTypeId) -> crate::Vec<Self> {
runtime_io::ed25519_public_keys(key_type)
runtime_io::crypto::ed25519_public_keys(key_type)
}

fn generate_pair(key_type: KeyTypeId, seed: Option<&str>) -> Self {
runtime_io::ed25519_generate(key_type, seed)
fn generate_pair(key_type: KeyTypeId, seed: Option<Vec<u8>>) -> Self {
runtime_io::crypto::ed25519_generate(key_type, seed)
}

fn sign<M: AsRef<[u8]>>(&self, key_type: KeyTypeId, msg: &M) -> Option<Self::Signature> {
runtime_io::ed25519_sign(key_type, self, msg.as_ref())
runtime_io::crypto::ed25519_sign(key_type, self, msg.as_ref())
}

fn verify<M: AsRef<[u8]>>(&self, msg: &M, signature: &Self::Signature) -> bool {
runtime_io::ed25519_verify(&signature, msg.as_ref(), self)
runtime_io::crypto::ed25519_verify(&signature, msg.as_ref(), self)
}
}

Expand Down
2 changes: 1 addition & 1 deletion core/application-crypto/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ macro_rules! app_crypto_public_common {
<$public as $crate::RuntimePublic>::all($key_type).into_iter().map(Self).collect()
}

fn generate_pair(seed: Option<&str>) -> Self {
fn generate_pair(seed: Option<$crate::Vec<u8>>) -> Self {
Self(<$public as $crate::RuntimePublic>::generate_pair($key_type, seed))
}

Expand Down
15 changes: 8 additions & 7 deletions core/application-crypto/src/sr25519.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

use crate::{RuntimePublic, KeyTypeId};

use rstd::vec::Vec;

pub use primitives::sr25519::*;

mod app {
Expand All @@ -29,28 +31,27 @@ mod app {
}
}

pub use app::Public as AppPublic;
pub use app::Signature as AppSignature;
pub use app::{Public as AppPublic, Signature as AppSignature};
#[cfg(feature = "full_crypto")]
pub use app::Pair as AppPair;

impl RuntimePublic for Public {
type Signature = Signature;

fn all(key_type: KeyTypeId) -> crate::Vec<Self> {
runtime_io::sr25519_public_keys(key_type)
runtime_io::crypto::sr25519_public_keys(key_type)
}

fn generate_pair(key_type: KeyTypeId, seed: Option<&str>) -> Self {
runtime_io::sr25519_generate(key_type, seed)
fn generate_pair(key_type: KeyTypeId, seed: Option<Vec<u8>>) -> Self {
runtime_io::crypto::sr25519_generate(key_type, seed)
}

fn sign<M: AsRef<[u8]>>(&self, key_type: KeyTypeId, msg: &M) -> Option<Self::Signature> {
runtime_io::sr25519_sign(key_type, self, msg.as_ref())
runtime_io::crypto::sr25519_sign(key_type, self, msg.as_ref())
}

fn verify<M: AsRef<[u8]>>(&self, msg: &M, signature: &Self::Signature) -> bool {
runtime_io::sr25519_verify(&signature, msg.as_ref(), self)
runtime_io::crypto::sr25519_verify(&signature, msg.as_ref(), self)
}
}

Expand Down
Loading