From b5c7951891f9fef7c2dfa5f643787ae6a1d487b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 14 Jan 2020 14:14:20 +0100 Subject: [PATCH 1/3] Add warning if offchain workers version is not supported. --- client/offchain/src/lib.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/client/offchain/src/lib.rs b/client/offchain/src/lib.rs index e25072d42d603..5b5f40341c33a 100644 --- a/client/offchain/src/lib.rs +++ b/client/offchain/src/lib.rs @@ -139,6 +139,8 @@ impl OffchainWorkers< }); futures::future::Either::Left(runner.process()) } else { + let help = "Consider turning off offchain workers if they are not part of your runtime."; + warn!("Unsupported Offchain Worker API version: {}. {}", version, help); futures::future::Either::Right(futures::future::ready(())) } } From cb1a6b92dba9a72b1d1f35668b37eb73bde98c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 14 Jan 2020 14:27:05 +0100 Subject: [PATCH 2/3] Support only v2. --- client/offchain/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/offchain/src/lib.rs b/client/offchain/src/lib.rs index 5b5f40341c33a..038419e5c8132 100644 --- a/client/offchain/src/lib.rs +++ b/client/offchain/src/lib.rs @@ -101,13 +101,14 @@ impl OffchainWorkers< let has_api_v1 = runtime.has_api_with::, _>( &at, |v| v == 1 ); - let has_api_v2 = runtime.has_api::>(&at); + let has_api_v2 = runtime.has_api_with::, _>( + &at, |v| v == 2 + ); let version = match (has_api_v1, has_api_v2) { (_, Ok(true)) => 2, (Ok(true), _) => 1, _ => 0, }; - debug!("Checking offchain workers at {:?}: version:{}", at, version); if version > 0 { let (api, runner) = api::AsyncApi::new( From 63fe7af7f0411bdc9e6271457f510c5356c7b314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomasz=20Drwi=C4=99ga?= Date: Tue, 14 Jan 2020 14:45:13 +0100 Subject: [PATCH 3/3] Make it a warning. --- client/offchain/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/offchain/src/lib.rs b/client/offchain/src/lib.rs index 038419e5c8132..78760fb011c1c 100644 --- a/client/offchain/src/lib.rs +++ b/client/offchain/src/lib.rs @@ -141,7 +141,7 @@ impl OffchainWorkers< futures::future::Either::Left(runner.process()) } else { let help = "Consider turning off offchain workers if they are not part of your runtime."; - warn!("Unsupported Offchain Worker API version: {}. {}", version, help); + log::error!("Unsupported Offchain Worker API version: {}. {}", version, help); futures::future::Either::Right(futures::future::ready(())) } }