Initial: Offchain Workers (#1942)

* Refactor state-machine stuff.

* Fix tests.

* WiP

* WiP2

* Service support for offchain workers.

* Service support for offchain workers.

* Testing offchain worker.

* Initial version working.

* Pass side effects in call.

* Pass OffchainExt in context.

* Submit extrinsics to the pool.

* Support inherents.

* Insert to inherents pool.

* Inserting to the pool asynchronously.

* Add test to offchain worker.

* Implement convenience syntax for modules.

* Dispatching offchain worker through executive.

* Fix offchain test.

* Remove offchain worker from timestamp.

* Update Cargo.lock.

* Address review comments.

* Use latest patch version for futures.

* Add CLI parameter for offchain worker.

* Fix compilation.

* Fix test.

* Fix extrinsics format for tests.

* Fix RPC test.

* Bump spec version.

* Fix executive.

* Fix support macro.

* Address grumbles.

* Bump runtime
This commit is contained in:
Tomasz Drwięga
2019-03-25 23:22:11 +01:00
committed by Gav Wood
parent 3ee0e69463
commit e2f5e40876
58 changed files with 1158 additions and 178 deletions
@@ -25,6 +25,7 @@ sudo = { package = "srml-sudo", path = "../../srml/sudo", default_features = fal
runtime-primitives = { package = "sr-primitives", path = "../../core/sr-primitives", default_features = false }
client = { package = "substrate-client", path = "../../core/client", default_features = false }
consensus-aura = { package = "substrate-consensus-aura-primitives", path = "../../core/consensus/aura/primitives", default_features = false }
offchain-primitives = { package = "substrate-offchain-primitives", path = "../../core/offchain/primitives", default-features = false }
[features]
default = ["std"]
@@ -48,4 +49,5 @@ std = [
"serde",
"safe-mix/std",
"consensus-aura/std",
"offchain-primitives/std",
]
+8 -2
View File
@@ -14,7 +14,7 @@ use primitives::bytes;
use primitives::{ed25519, OpaqueMetadata};
use runtime_primitives::{
ApplyResult, transaction_validity::TransactionValidity, generic, create_runtime_str,
traits::{self, BlakeTwo256, Block as BlockT, StaticLookup, Verify}
traits::{self, NumberFor, BlakeTwo256, Block as BlockT, StaticLookup, Verify}
};
use client::{
block_builder::api::{CheckInherentsResult, InherentData, self as block_builder_api},
@@ -182,7 +182,7 @@ impl sudo::Trait for Runtime {
}
/// Used for the module template in `./template.rs`
impl template::Trait for Runtime {
impl template::Trait for Runtime {
type Event = Event;
}
@@ -280,4 +280,10 @@ impl_runtime_apis! {
Aura::slot_duration()
}
}
impl offchain_primitives::OffchainWorkerApi<Block> for Runtime {
fn offchain_worker(n: NumberFor<Block>) {
Executive::offchain_worker(n)
}
}
}
+9
View File
@@ -1273,6 +1273,7 @@ dependencies = [
"srml-timestamp 0.1.0",
"substrate-client 0.1.0",
"substrate-consensus-aura-primitives 0.1.0",
"substrate-offchain-primitives 0.1.0",
"substrate-primitives 0.1.0",
]
@@ -2510,6 +2511,14 @@ dependencies = [
"substrate-primitives 0.1.0",
]
[[package]]
name = "substrate-offchain-primitives"
version = "0.1.0"
dependencies = [
"sr-primitives 0.1.0",
"substrate-client 0.1.0",
]
[[package]]
name = "substrate-panic-handler"
version = "0.1.0"